babylon.module.d.ts 5.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts current color in rgb space to HSV values
  466. * @returns a new color3 representing the HSV values
  467. */
  468. toHSV(): Color3;
  469. /**
  470. * Converts current color in rgb space to HSV values
  471. * @param result defines the Color3 where to store the HSV values
  472. */
  473. toHSVToRef(result: Color3): void;
  474. /**
  475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the linear space version
  477. * @returns the unmodified Color3
  478. */
  479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  480. /**
  481. * Computes a new Color3 converted from the current one to gamma space
  482. * @returns a new Color3 object
  483. */
  484. toGammaSpace(): Color3;
  485. /**
  486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  487. * @param convertedColor defines the Color3 object where to store the gamma space version
  488. * @returns the unmodified Color3
  489. */
  490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  491. private static _BlackReadOnly;
  492. /**
  493. * Convert Hue, saturation and value to a Color3 (RGB)
  494. * @param hue defines the hue
  495. * @param saturation defines the saturation
  496. * @param value defines the value
  497. * @param result defines the Color3 where to store the RGB values
  498. */
  499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  500. /**
  501. * Creates a new Color3 from the string containing valid hexadecimal values
  502. * @param hex defines a string containing valid hexadecimal values
  503. * @returns a new Color3 object
  504. */
  505. static FromHexString(hex: string): Color3;
  506. /**
  507. * Creates a new Color3 from the starting index of the given array
  508. * @param array defines the source array
  509. * @param offset defines an offset in the source array
  510. * @returns a new Color3 object
  511. */
  512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  513. /**
  514. * Creates a new Color3 from integer values (< 256)
  515. * @param r defines the red component to read from (value between 0 and 255)
  516. * @param g defines the green component to read from (value between 0 and 255)
  517. * @param b defines the blue component to read from (value between 0 and 255)
  518. * @returns a new Color3 object
  519. */
  520. static FromInts(r: number, g: number, b: number): Color3;
  521. /**
  522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  523. * @param start defines the start Color3 value
  524. * @param end defines the end Color3 value
  525. * @param amount defines the gradient value between start and end
  526. * @returns a new Color3 object
  527. */
  528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  529. /**
  530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  531. * @param left defines the start value
  532. * @param right defines the end value
  533. * @param amount defines the gradient factor
  534. * @param result defines the Color3 object where to store the result
  535. */
  536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  537. /**
  538. * Returns a Color3 value containing a red color
  539. * @returns a new Color3 object
  540. */
  541. static Red(): Color3;
  542. /**
  543. * Returns a Color3 value containing a green color
  544. * @returns a new Color3 object
  545. */
  546. static Green(): Color3;
  547. /**
  548. * Returns a Color3 value containing a blue color
  549. * @returns a new Color3 object
  550. */
  551. static Blue(): Color3;
  552. /**
  553. * Returns a Color3 value containing a black color
  554. * @returns a new Color3 object
  555. */
  556. static Black(): Color3;
  557. /**
  558. * Gets a Color3 value containing a black color that must not be updated
  559. */
  560. static readonly BlackReadOnly: DeepImmutable<Color3>;
  561. /**
  562. * Returns a Color3 value containing a white color
  563. * @returns a new Color3 object
  564. */
  565. static White(): Color3;
  566. /**
  567. * Returns a Color3 value containing a purple color
  568. * @returns a new Color3 object
  569. */
  570. static Purple(): Color3;
  571. /**
  572. * Returns a Color3 value containing a magenta color
  573. * @returns a new Color3 object
  574. */
  575. static Magenta(): Color3;
  576. /**
  577. * Returns a Color3 value containing a yellow color
  578. * @returns a new Color3 object
  579. */
  580. static Yellow(): Color3;
  581. /**
  582. * Returns a Color3 value containing a gray color
  583. * @returns a new Color3 object
  584. */
  585. static Gray(): Color3;
  586. /**
  587. * Returns a Color3 value containing a teal color
  588. * @returns a new Color3 object
  589. */
  590. static Teal(): Color3;
  591. /**
  592. * Returns a Color3 value containing a random color
  593. * @returns a new Color3 object
  594. */
  595. static Random(): Color3;
  596. }
  597. /**
  598. * Class used to hold a RBGA color
  599. */
  600. export class Color4 {
  601. /**
  602. * Defines the red component (between 0 and 1, default is 0)
  603. */
  604. r: number;
  605. /**
  606. * Defines the green component (between 0 and 1, default is 0)
  607. */
  608. g: number;
  609. /**
  610. * Defines the blue component (between 0 and 1, default is 0)
  611. */
  612. b: number;
  613. /**
  614. * Defines the alpha component (between 0 and 1, default is 1)
  615. */
  616. a: number;
  617. /**
  618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  619. * @param r defines the red component (between 0 and 1, default is 0)
  620. * @param g defines the green component (between 0 and 1, default is 0)
  621. * @param b defines the blue component (between 0 and 1, default is 0)
  622. * @param a defines the alpha component (between 0 and 1, default is 1)
  623. */
  624. constructor(
  625. /**
  626. * Defines the red component (between 0 and 1, default is 0)
  627. */
  628. r?: number,
  629. /**
  630. * Defines the green component (between 0 and 1, default is 0)
  631. */
  632. g?: number,
  633. /**
  634. * Defines the blue component (between 0 and 1, default is 0)
  635. */
  636. b?: number,
  637. /**
  638. * Defines the alpha component (between 0 and 1, default is 1)
  639. */
  640. a?: number);
  641. /**
  642. * Adds in place the given Color4 values to the current Color4 object
  643. * @param right defines the second operand
  644. * @returns the current updated Color4 object
  645. */
  646. addInPlace(right: DeepImmutable<Color4>): Color4;
  647. /**
  648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  649. * @returns the new array
  650. */
  651. asArray(): number[];
  652. /**
  653. * Stores from the starting index in the given array the Color4 successive values
  654. * @param array defines the array where to store the r,g,b components
  655. * @param index defines an optional index in the target array to define where to start storing values
  656. * @returns the current Color4 object
  657. */
  658. toArray(array: number[], index?: number): Color4;
  659. /**
  660. * Determines equality between Color4 objects
  661. * @param otherColor defines the second operand
  662. * @returns true if the rgba values are equal to the given ones
  663. */
  664. equals(otherColor: DeepImmutable<Color4>): boolean;
  665. /**
  666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  667. * @param right defines the second operand
  668. * @returns a new Color4 object
  669. */
  670. add(right: DeepImmutable<Color4>): Color4;
  671. /**
  672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  673. * @param right defines the second operand
  674. * @returns a new Color4 object
  675. */
  676. subtract(right: DeepImmutable<Color4>): Color4;
  677. /**
  678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  679. * @param right defines the second operand
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the current Color4 object
  682. */
  683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  684. /**
  685. * Creates a new Color4 with the current Color4 values multiplied by scale
  686. * @param scale defines the scaling factor to apply
  687. * @returns a new Color4 object
  688. */
  689. scale(scale: number): Color4;
  690. /**
  691. * Multiplies the current Color4 values by scale and stores the result in "result"
  692. * @param scale defines the scaling factor to apply
  693. * @param result defines the Color4 object where to store the result
  694. * @returns the current unmodified Color4
  695. */
  696. scaleToRef(scale: number, result: Color4): Color4;
  697. /**
  698. * Scale the current Color4 values by a factor and add the result to a given Color4
  699. * @param scale defines the scale factor
  700. * @param result defines the Color4 object where to store the result
  701. * @returns the unmodified current Color4
  702. */
  703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  704. /**
  705. * Clamps the rgb values by the min and max values and stores the result into "result"
  706. * @param min defines minimum clamping value (default is 0)
  707. * @param max defines maximum clamping value (default is 1)
  708. * @param result defines color to store the result into.
  709. * @returns the cuurent Color4
  710. */
  711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  712. /**
  713. * Multipy an Color4 value by another and return a new Color4 object
  714. * @param color defines the Color4 value to multiply by
  715. * @returns a new Color4 object
  716. */
  717. multiply(color: Color4): Color4;
  718. /**
  719. * Multipy a Color4 value by another and push the result in a reference value
  720. * @param color defines the Color4 value to multiply by
  721. * @param result defines the Color4 to fill the result in
  722. * @returns the result Color4
  723. */
  724. multiplyToRef(color: Color4, result: Color4): Color4;
  725. /**
  726. * Creates a string with the Color4 current values
  727. * @returns the string representation of the Color4 object
  728. */
  729. toString(): string;
  730. /**
  731. * Returns the string "Color4"
  732. * @returns "Color4"
  733. */
  734. getClassName(): string;
  735. /**
  736. * Compute the Color4 hash code
  737. * @returns an unique number that can be used to hash Color4 objects
  738. */
  739. getHashCode(): number;
  740. /**
  741. * Creates a new Color4 copied from the current one
  742. * @returns a new Color4 object
  743. */
  744. clone(): Color4;
  745. /**
  746. * Copies the given Color4 values into the current one
  747. * @param source defines the source Color4 object
  748. * @returns the current updated Color4 object
  749. */
  750. copyFrom(source: Color4): Color4;
  751. /**
  752. * Copies the given float values into the current one
  753. * @param r defines the red component to read from
  754. * @param g defines the green component to read from
  755. * @param b defines the blue component to read from
  756. * @param a defines the alpha component to read from
  757. * @returns the current updated Color4 object
  758. */
  759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  760. /**
  761. * Copies the given float values into the current one
  762. * @param r defines the red component to read from
  763. * @param g defines the green component to read from
  764. * @param b defines the blue component to read from
  765. * @param a defines the alpha component to read from
  766. * @returns the current updated Color4 object
  767. */
  768. set(r: number, g: number, b: number, a: number): Color4;
  769. /**
  770. * Compute the Color4 hexadecimal code as a string
  771. * @returns a string containing the hexadecimal representation of the Color4 object
  772. */
  773. toHexString(): string;
  774. /**
  775. * Computes a new Color4 converted from the current one to linear space
  776. * @returns a new Color4 object
  777. */
  778. toLinearSpace(): Color4;
  779. /**
  780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  781. * @param convertedColor defines the Color4 object where to store the linear space version
  782. * @returns the unmodified Color4
  783. */
  784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  785. /**
  786. * Computes a new Color4 converted from the current one to gamma space
  787. * @returns a new Color4 object
  788. */
  789. toGammaSpace(): Color4;
  790. /**
  791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  792. * @param convertedColor defines the Color4 object where to store the gamma space version
  793. * @returns the unmodified Color4
  794. */
  795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  796. /**
  797. * Creates a new Color4 from the string containing valid hexadecimal values
  798. * @param hex defines a string containing valid hexadecimal values
  799. * @returns a new Color4 object
  800. */
  801. static FromHexString(hex: string): Color4;
  802. /**
  803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  804. * @param left defines the start value
  805. * @param right defines the end value
  806. * @param amount defines the gradient factor
  807. * @returns a new Color4 object
  808. */
  809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  810. /**
  811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  812. * @param left defines the start value
  813. * @param right defines the end value
  814. * @param amount defines the gradient factor
  815. * @param result defines the Color4 object where to store data
  816. */
  817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  818. /**
  819. * Creates a new Color4 from a Color3 and an alpha value
  820. * @param color3 defines the source Color3 to read from
  821. * @param alpha defines the alpha component (1.0 by default)
  822. * @returns a new Color4 object
  823. */
  824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  825. /**
  826. * Creates a new Color4 from the starting index element of the given array
  827. * @param array defines the source array to read from
  828. * @param offset defines the offset in the source array
  829. * @returns a new Color4 object
  830. */
  831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  832. /**
  833. * Creates a new Color3 from integer values (< 256)
  834. * @param r defines the red component to read from (value between 0 and 255)
  835. * @param g defines the green component to read from (value between 0 and 255)
  836. * @param b defines the blue component to read from (value between 0 and 255)
  837. * @param a defines the alpha component to read from (value between 0 and 255)
  838. * @returns a new Color3 object
  839. */
  840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  841. /**
  842. * Check the content of a given array and convert it to an array containing RGBA data
  843. * If the original array was already containing count * 4 values then it is returned directly
  844. * @param colors defines the array to check
  845. * @param count defines the number of RGBA data to expect
  846. * @returns an array containing count * 4 values (RGBA)
  847. */
  848. static CheckColors4(colors: number[], count: number): number[];
  849. }
  850. /**
  851. * Class representing a vector containing 2 coordinates
  852. */
  853. export class Vector2 {
  854. /** defines the first coordinate */
  855. x: number;
  856. /** defines the second coordinate */
  857. y: number;
  858. /**
  859. * Creates a new Vector2 from the given x and y coordinates
  860. * @param x defines the first coordinate
  861. * @param y defines the second coordinate
  862. */
  863. constructor(
  864. /** defines the first coordinate */
  865. x?: number,
  866. /** defines the second coordinate */
  867. y?: number);
  868. /**
  869. * Gets a string with the Vector2 coordinates
  870. * @returns a string with the Vector2 coordinates
  871. */
  872. toString(): string;
  873. /**
  874. * Gets class name
  875. * @returns the string "Vector2"
  876. */
  877. getClassName(): string;
  878. /**
  879. * Gets current vector hash code
  880. * @returns the Vector2 hash code as a number
  881. */
  882. getHashCode(): number;
  883. /**
  884. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  885. * @param array defines the source array
  886. * @param index defines the offset in source array
  887. * @returns the current Vector2
  888. */
  889. toArray(array: FloatArray, index?: number): Vector2;
  890. /**
  891. * Copy the current vector to an array
  892. * @returns a new array with 2 elements: the Vector2 coordinates.
  893. */
  894. asArray(): number[];
  895. /**
  896. * Sets the Vector2 coordinates with the given Vector2 coordinates
  897. * @param source defines the source Vector2
  898. * @returns the current updated Vector2
  899. */
  900. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. copyFromFloats(x: number, y: number): Vector2;
  908. /**
  909. * Sets the Vector2 coordinates with the given floats
  910. * @param x defines the first coordinate
  911. * @param y defines the second coordinate
  912. * @returns the current updated Vector2
  913. */
  914. set(x: number, y: number): Vector2;
  915. /**
  916. * Add another vector with the current one
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  919. */
  920. add(otherVector: DeepImmutable<Vector2>): Vector2;
  921. /**
  922. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  923. * @param otherVector defines the other vector
  924. * @param result defines the target vector
  925. * @returns the unmodified current Vector2
  926. */
  927. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  928. /**
  929. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  930. * @param otherVector defines the other vector
  931. * @returns the current updated Vector2
  932. */
  933. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  934. /**
  935. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  936. * @param otherVector defines the other vector
  937. * @returns a new Vector2
  938. */
  939. addVector3(otherVector: Vector3): Vector2;
  940. /**
  941. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  942. * @param otherVector defines the other vector
  943. * @returns a new Vector2
  944. */
  945. subtract(otherVector: Vector2): Vector2;
  946. /**
  947. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  948. * @param otherVector defines the other vector
  949. * @param result defines the target vector
  950. * @returns the unmodified current Vector2
  951. */
  952. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  953. /**
  954. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @returns the current updated Vector2
  957. */
  958. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  959. /**
  960. * Multiplies in place the current Vector2 coordinates by the given ones
  961. * @param otherVector defines the other vector
  962. * @returns the current updated Vector2
  963. */
  964. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  971. /**
  972. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  980. * @param x defines the first coordinate
  981. * @param y defines the second coordinate
  982. * @returns a new Vector2
  983. */
  984. multiplyByFloats(x: number, y: number): Vector2;
  985. /**
  986. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  987. * @param otherVector defines the other vector
  988. * @returns a new Vector2
  989. */
  990. divide(otherVector: Vector2): Vector2;
  991. /**
  992. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  993. * @param otherVector defines the other vector
  994. * @param result defines the target vector
  995. * @returns the unmodified current Vector2
  996. */
  997. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  998. /**
  999. * Divides the current Vector2 coordinates by the given ones
  1000. * @param otherVector defines the other vector
  1001. * @returns the current updated Vector2
  1002. */
  1003. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1004. /**
  1005. * Gets a new Vector2 with current Vector2 negated coordinates
  1006. * @returns a new Vector2
  1007. */
  1008. negate(): Vector2;
  1009. /**
  1010. * Multiply the Vector2 coordinates by scale
  1011. * @param scale defines the scaling factor
  1012. * @returns the current updated Vector2
  1013. */
  1014. scaleInPlace(scale: number): Vector2;
  1015. /**
  1016. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1017. * @param scale defines the scaling factor
  1018. * @returns a new Vector2
  1019. */
  1020. scale(scale: number): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1030. * @param scale defines the scale factor
  1031. * @param result defines the Vector2 object where to store the result
  1032. * @returns the unmodified current Vector2
  1033. */
  1034. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1035. /**
  1036. * Gets a boolean if two vectors are equals
  1037. * @param otherVector defines the other vector
  1038. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1039. */
  1040. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1041. /**
  1042. * Gets a boolean if two vectors are equals (using an epsilon value)
  1043. * @param otherVector defines the other vector
  1044. * @param epsilon defines the minimal distance to consider equality
  1045. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1046. */
  1047. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1048. /**
  1049. * Gets a new Vector2 from current Vector2 floored values
  1050. * @returns a new Vector2
  1051. */
  1052. floor(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 from current Vector2 floored values
  1055. * @returns a new Vector2
  1056. */
  1057. fract(): Vector2;
  1058. /**
  1059. * Gets the length of the vector
  1060. * @returns the vector length (float)
  1061. */
  1062. length(): number;
  1063. /**
  1064. * Gets the vector squared length
  1065. * @returns the vector squared length (float)
  1066. */
  1067. lengthSquared(): number;
  1068. /**
  1069. * Normalize the vector
  1070. * @returns the current updated Vector2
  1071. */
  1072. normalize(): Vector2;
  1073. /**
  1074. * Gets a new Vector2 copied from the Vector2
  1075. * @returns a new Vector2
  1076. */
  1077. clone(): Vector2;
  1078. /**
  1079. * Gets a new Vector2(0, 0)
  1080. * @returns a new Vector2
  1081. */
  1082. static Zero(): Vector2;
  1083. /**
  1084. * Gets a new Vector2(1, 1)
  1085. * @returns a new Vector2
  1086. */
  1087. static One(): Vector2;
  1088. /**
  1089. * Gets a new Vector2 set from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @returns a new Vector2
  1093. */
  1094. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1095. /**
  1096. * Sets "result" from the given index element of the given array
  1097. * @param array defines the data source
  1098. * @param offset defines the offset in the data source
  1099. * @param result defines the target vector
  1100. */
  1101. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1102. /**
  1103. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1104. * @param value1 defines 1st point of control
  1105. * @param value2 defines 2nd point of control
  1106. * @param value3 defines 3rd point of control
  1107. * @param value4 defines 4th point of control
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1114. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1115. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1116. * @param value defines the value to clamp
  1117. * @param min defines the lower limit
  1118. * @param max defines the upper limit
  1119. * @returns a new Vector2
  1120. */
  1121. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1122. /**
  1123. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1124. * @param value1 defines the 1st control point
  1125. * @param tangent1 defines the outgoing tangent
  1126. * @param value2 defines the 2nd control point
  1127. * @param tangent2 defines the incoming tangent
  1128. * @param amount defines the interpolation factor
  1129. * @returns a new Vector2
  1130. */
  1131. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1132. /**
  1133. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1134. * @param start defines the start vector
  1135. * @param end defines the end vector
  1136. * @param amount defines the interpolation factor
  1137. * @returns a new Vector2
  1138. */
  1139. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1140. /**
  1141. * Gets the dot product of the vector "left" and the vector "right"
  1142. * @param left defines first vector
  1143. * @param right defines second vector
  1144. * @returns the dot product (float)
  1145. */
  1146. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1147. /**
  1148. * Returns a new Vector2 equal to the normalized given vector
  1149. * @param vector defines the vector to normalize
  1150. * @returns a new Vector2
  1151. */
  1152. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1162. * @param left defines 1st vector
  1163. * @param right defines 2nd vector
  1164. * @returns a new Vector2
  1165. */
  1166. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1167. /**
  1168. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @returns a new Vector2
  1172. */
  1173. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1174. /**
  1175. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1176. * @param vector defines the vector to transform
  1177. * @param transformation defines the matrix to apply
  1178. * @param result defines the target vector
  1179. */
  1180. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1181. /**
  1182. * Determines if a given vector is included in a triangle
  1183. * @param p defines the vector to test
  1184. * @param p0 defines 1st triangle point
  1185. * @param p1 defines 2nd triangle point
  1186. * @param p2 defines 3rd triangle point
  1187. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1188. */
  1189. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1190. /**
  1191. * Gets the distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the distance between vectors
  1195. */
  1196. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Returns the squared distance between the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns the squared distance between vectors
  1202. */
  1203. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1204. /**
  1205. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1206. * @param value1 defines first vector
  1207. * @param value2 defines second vector
  1208. * @returns a new Vector2
  1209. */
  1210. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1211. /**
  1212. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1213. * @param p defines the middle point
  1214. * @param segA defines one point of the segment
  1215. * @param segB defines the other point of the segment
  1216. * @returns the shortest distance
  1217. */
  1218. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1219. }
  1220. /**
  1221. * Classed used to store (x,y,z) vector representation
  1222. * A Vector3 is the main object used in 3D geometry
  1223. * It can represent etiher the coordinates of a point the space, either a direction
  1224. * Reminder: js uses a left handed forward facing system
  1225. */
  1226. export class Vector3 {
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x: number;
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y: number;
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z: number;
  1239. private static _UpReadOnly;
  1240. private static _ZeroReadOnly;
  1241. /**
  1242. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1243. * @param x defines the first coordinates (on X axis)
  1244. * @param y defines the second coordinates (on Y axis)
  1245. * @param z defines the third coordinates (on Z axis)
  1246. */
  1247. constructor(
  1248. /**
  1249. * Defines the first coordinates (on X axis)
  1250. */
  1251. x?: number,
  1252. /**
  1253. * Defines the second coordinates (on Y axis)
  1254. */
  1255. y?: number,
  1256. /**
  1257. * Defines the third coordinates (on Z axis)
  1258. */
  1259. z?: number);
  1260. /**
  1261. * Creates a string representation of the Vector3
  1262. * @returns a string with the Vector3 coordinates.
  1263. */
  1264. toString(): string;
  1265. /**
  1266. * Gets the class name
  1267. * @returns the string "Vector3"
  1268. */
  1269. getClassName(): string;
  1270. /**
  1271. * Creates the Vector3 hash code
  1272. * @returns a number which tends to be unique between Vector3 instances
  1273. */
  1274. getHashCode(): number;
  1275. /**
  1276. * Creates an array containing three elements : the coordinates of the Vector3
  1277. * @returns a new array of numbers
  1278. */
  1279. asArray(): number[];
  1280. /**
  1281. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1282. * @param array defines the destination array
  1283. * @param index defines the offset in the destination array
  1284. * @returns the current Vector3
  1285. */
  1286. toArray(array: FloatArray, index?: number): Vector3;
  1287. /**
  1288. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1289. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1290. */
  1291. toQuaternion(): Quaternion;
  1292. /**
  1293. * Adds the given vector to the current Vector3
  1294. * @param otherVector defines the second operand
  1295. * @returns the current updated Vector3
  1296. */
  1297. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the given coordinates to the current Vector3
  1300. * @param x defines the x coordinate of the operand
  1301. * @param y defines the y coordinate of the operand
  1302. * @param z defines the z coordinate of the operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1306. /**
  1307. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Subtract the given vector from the current Vector3
  1321. * @param otherVector defines the second operand
  1322. * @returns the current updated Vector3
  1323. */
  1324. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1325. /**
  1326. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1327. * @param otherVector defines the second operand
  1328. * @returns the resulting Vector3
  1329. */
  1330. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1331. /**
  1332. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1333. * @param otherVector defines the second operand
  1334. * @param result defines the Vector3 object where to store the result
  1335. * @returns the current Vector3
  1336. */
  1337. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1338. /**
  1339. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1340. * @param x defines the x coordinate of the operand
  1341. * @param y defines the y coordinate of the operand
  1342. * @param z defines the z coordinate of the operand
  1343. * @returns the resulting Vector3
  1344. */
  1345. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1346. /**
  1347. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1348. * @param x defines the x coordinate of the operand
  1349. * @param y defines the y coordinate of the operand
  1350. * @param z defines the z coordinate of the operand
  1351. * @param result defines the Vector3 object where to store the result
  1352. * @returns the current Vector3
  1353. */
  1354. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1355. /**
  1356. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1357. * @returns a new Vector3
  1358. */
  1359. negate(): Vector3;
  1360. /**
  1361. * Multiplies the Vector3 coordinates by the float "scale"
  1362. * @param scale defines the multiplier factor
  1363. * @returns the current updated Vector3
  1364. */
  1365. scaleInPlace(scale: number): Vector3;
  1366. /**
  1367. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1368. * @param scale defines the multiplier factor
  1369. * @returns a new Vector3
  1370. */
  1371. scale(scale: number): Vector3;
  1372. /**
  1373. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1374. * @param scale defines the multiplier factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the current Vector3
  1377. */
  1378. scaleToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1381. * @param scale defines the scale factor
  1382. * @param result defines the Vector3 object where to store the result
  1383. * @returns the unmodified current Vector3
  1384. */
  1385. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1386. /**
  1387. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1388. * @param otherVector defines the second operand
  1389. * @returns true if both vectors are equals
  1390. */
  1391. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1394. * @param otherVector defines the second operand
  1395. * @param epsilon defines the minimal distance to define values as equals
  1396. * @returns true if both vectors are distant less than epsilon
  1397. */
  1398. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1399. /**
  1400. * Returns true if the current Vector3 coordinates equals the given floats
  1401. * @param x defines the x coordinate of the operand
  1402. * @param y defines the y coordinate of the operand
  1403. * @param z defines the z coordinate of the operand
  1404. * @returns true if both vectors are equals
  1405. */
  1406. equalsToFloats(x: number, y: number, z: number): boolean;
  1407. /**
  1408. * Multiplies the current Vector3 coordinates by the given ones
  1409. * @param otherVector defines the second operand
  1410. * @returns the current updated Vector3
  1411. */
  1412. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1413. /**
  1414. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1428. * @param x defines the x coordinate of the operand
  1429. * @param y defines the y coordinate of the operand
  1430. * @param z defines the z coordinate of the operand
  1431. * @returns the new Vector3
  1432. */
  1433. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1434. /**
  1435. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1436. * @param otherVector defines the second operand
  1437. * @returns the new Vector3
  1438. */
  1439. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1442. * @param otherVector defines the second operand
  1443. * @param result defines the Vector3 object where to store the result
  1444. * @returns the current Vector3
  1445. */
  1446. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1447. /**
  1448. * Divides the current Vector3 coordinates by the given ones.
  1449. * @param otherVector defines the second operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. divideInPlace(otherVector: Vector3): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1455. * @param other defines the second operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1461. * @param other defines the second operand
  1462. * @returns the current updated Vector3
  1463. */
  1464. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1465. /**
  1466. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1467. * @param x defines the x coordinate of the operand
  1468. * @param y defines the y coordinate of the operand
  1469. * @param z defines the z coordinate of the operand
  1470. * @returns the current updated Vector3
  1471. */
  1472. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1473. /**
  1474. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1475. * @param x defines the x coordinate of the operand
  1476. * @param y defines the y coordinate of the operand
  1477. * @param z defines the z coordinate of the operand
  1478. * @returns the current updated Vector3
  1479. */
  1480. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1481. /**
  1482. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1483. * Check if is non uniform within a certain amount of decimal places to account for this
  1484. * @param epsilon the amount the values can differ
  1485. * @returns if the the vector is non uniform to a certain number of decimal places
  1486. */
  1487. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1488. /**
  1489. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1490. */
  1491. readonly isNonUniform: boolean;
  1492. /**
  1493. * Gets a new Vector3 from current Vector3 floored values
  1494. * @returns a new Vector3
  1495. */
  1496. floor(): Vector3;
  1497. /**
  1498. * Gets a new Vector3 from current Vector3 floored values
  1499. * @returns a new Vector3
  1500. */
  1501. fract(): Vector3;
  1502. /**
  1503. * Gets the length of the Vector3
  1504. * @returns the length of the Vector3
  1505. */
  1506. length(): number;
  1507. /**
  1508. * Gets the squared length of the Vector3
  1509. * @returns squared length of the Vector3
  1510. */
  1511. lengthSquared(): number;
  1512. /**
  1513. * Normalize the current Vector3.
  1514. * Please note that this is an in place operation.
  1515. * @returns the current updated Vector3
  1516. */
  1517. normalize(): Vector3;
  1518. /**
  1519. * Reorders the x y z properties of the vector in place
  1520. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1521. * @returns the current updated vector
  1522. */
  1523. reorderInPlace(order: string): this;
  1524. /**
  1525. * Rotates the vector around 0,0,0 by a quaternion
  1526. * @param quaternion the rotation quaternion
  1527. * @param result vector to store the result
  1528. * @returns the resulting vector
  1529. */
  1530. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1531. /**
  1532. * Rotates a vector around a given point
  1533. * @param quaternion the rotation quaternion
  1534. * @param point the point to rotate around
  1535. * @param result vector to store the result
  1536. * @returns the resulting vector
  1537. */
  1538. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Interface for the size containing width and height
  2363. */
  2364. export interface ISize {
  2365. /**
  2366. * Width
  2367. */
  2368. width: number;
  2369. /**
  2370. * Heighht
  2371. */
  2372. height: number;
  2373. }
  2374. /**
  2375. * Size containing widht and height
  2376. */
  2377. export class Size implements ISize {
  2378. /**
  2379. * Width
  2380. */
  2381. width: number;
  2382. /**
  2383. * Height
  2384. */
  2385. height: number;
  2386. /**
  2387. * Creates a Size object from the given width and height (floats).
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. */
  2391. constructor(width: number, height: number);
  2392. /**
  2393. * Returns a string with the Size width and height
  2394. * @returns a string with the Size width and height
  2395. */
  2396. toString(): string;
  2397. /**
  2398. * "Size"
  2399. * @returns the string "Size"
  2400. */
  2401. getClassName(): string;
  2402. /**
  2403. * Returns the Size hash code.
  2404. * @returns a hash code for a unique width and height
  2405. */
  2406. getHashCode(): number;
  2407. /**
  2408. * Updates the current size from the given one.
  2409. * @param src the given size
  2410. */
  2411. copyFrom(src: Size): void;
  2412. /**
  2413. * Updates in place the current Size from the given floats.
  2414. * @param width width of the new size
  2415. * @param height height of the new size
  2416. * @returns the updated Size.
  2417. */
  2418. copyFromFloats(width: number, height: number): Size;
  2419. /**
  2420. * Updates in place the current Size from the given floats.
  2421. * @param width width to set
  2422. * @param height height to set
  2423. * @returns the updated Size.
  2424. */
  2425. set(width: number, height: number): Size;
  2426. /**
  2427. * Multiplies the width and height by numbers
  2428. * @param w factor to multiple the width by
  2429. * @param h factor to multiple the height by
  2430. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2431. */
  2432. multiplyByFloats(w: number, h: number): Size;
  2433. /**
  2434. * Clones the size
  2435. * @returns a new Size copied from the given one.
  2436. */
  2437. clone(): Size;
  2438. /**
  2439. * True if the current Size and the given one width and height are strictly equal.
  2440. * @param other the other size to compare against
  2441. * @returns True if the current Size and the given one width and height are strictly equal.
  2442. */
  2443. equals(other: Size): boolean;
  2444. /**
  2445. * The surface of the Size : width * height (float).
  2446. */
  2447. readonly surface: number;
  2448. /**
  2449. * Create a new size of zero
  2450. * @returns a new Size set to (0.0, 0.0)
  2451. */
  2452. static Zero(): Size;
  2453. /**
  2454. * Sums the width and height of two sizes
  2455. * @param otherSize size to add to this size
  2456. * @returns a new Size set as the addition result of the current Size and the given one.
  2457. */
  2458. add(otherSize: Size): Size;
  2459. /**
  2460. * Subtracts the width and height of two
  2461. * @param otherSize size to subtract to this size
  2462. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2463. */
  2464. subtract(otherSize: Size): Size;
  2465. /**
  2466. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2467. * @param start starting size to lerp between
  2468. * @param end end size to lerp between
  2469. * @param amount amount to lerp between the start and end values
  2470. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2471. */
  2472. static Lerp(start: Size, end: Size, amount: number): Size;
  2473. }
  2474. /**
  2475. * Class used to store quaternion data
  2476. * @see https://en.wikipedia.org/wiki/Quaternion
  2477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2478. */
  2479. export class Quaternion {
  2480. /** defines the first component (0 by default) */
  2481. x: number;
  2482. /** defines the second component (0 by default) */
  2483. y: number;
  2484. /** defines the third component (0 by default) */
  2485. z: number;
  2486. /** defines the fourth component (1.0 by default) */
  2487. w: number;
  2488. /**
  2489. * Creates a new Quaternion from the given floats
  2490. * @param x defines the first component (0 by default)
  2491. * @param y defines the second component (0 by default)
  2492. * @param z defines the third component (0 by default)
  2493. * @param w defines the fourth component (1.0 by default)
  2494. */
  2495. constructor(
  2496. /** defines the first component (0 by default) */
  2497. x?: number,
  2498. /** defines the second component (0 by default) */
  2499. y?: number,
  2500. /** defines the third component (0 by default) */
  2501. z?: number,
  2502. /** defines the fourth component (1.0 by default) */
  2503. w?: number);
  2504. /**
  2505. * Gets a string representation for the current quaternion
  2506. * @returns a string with the Quaternion coordinates
  2507. */
  2508. toString(): string;
  2509. /**
  2510. * Gets the class name of the quaternion
  2511. * @returns the string "Quaternion"
  2512. */
  2513. getClassName(): string;
  2514. /**
  2515. * Gets a hash code for this quaternion
  2516. * @returns the quaternion hash code
  2517. */
  2518. getHashCode(): number;
  2519. /**
  2520. * Copy the quaternion to an array
  2521. * @returns a new array populated with 4 elements from the quaternion coordinates
  2522. */
  2523. asArray(): number[];
  2524. /**
  2525. * Check if two quaternions are equals
  2526. * @param otherQuaternion defines the second operand
  2527. * @return true if the current quaternion and the given one coordinates are strictly equals
  2528. */
  2529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2530. /**
  2531. * Clone the current quaternion
  2532. * @returns a new quaternion copied from the current one
  2533. */
  2534. clone(): Quaternion;
  2535. /**
  2536. * Copy a quaternion to the current one
  2537. * @param other defines the other quaternion
  2538. * @returns the updated current quaternion
  2539. */
  2540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Updates the current quaternion with the given float coordinates
  2543. * @param x defines the x coordinate
  2544. * @param y defines the y coordinate
  2545. * @param z defines the z coordinate
  2546. * @param w defines the w coordinate
  2547. * @returns the updated current quaternion
  2548. */
  2549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2550. /**
  2551. * Updates the current quaternion from the given float coordinates
  2552. * @param x defines the x coordinate
  2553. * @param y defines the y coordinate
  2554. * @param z defines the z coordinate
  2555. * @param w defines the w coordinate
  2556. * @returns the updated current quaternion
  2557. */
  2558. set(x: number, y: number, z: number, w: number): Quaternion;
  2559. /**
  2560. * Adds two quaternions
  2561. * @param other defines the second operand
  2562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2563. */
  2564. add(other: DeepImmutable<Quaternion>): Quaternion;
  2565. /**
  2566. * Add a quaternion to the current one
  2567. * @param other defines the quaternion to add
  2568. * @returns the current quaternion
  2569. */
  2570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2571. /**
  2572. * Subtract two quaternions
  2573. * @param other defines the second operand
  2574. * @returns a new quaternion as the subtraction result of the given one from the current one
  2575. */
  2576. subtract(other: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies the current quaternion by a scale factor
  2579. * @param value defines the scale factor
  2580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2581. */
  2582. scale(value: number): Quaternion;
  2583. /**
  2584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2585. * @param scale defines the scale factor
  2586. * @param result defines the Quaternion object where to store the result
  2587. * @returns the unmodified current quaternion
  2588. */
  2589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2590. /**
  2591. * Multiplies in place the current quaternion by a scale factor
  2592. * @param value defines the scale factor
  2593. * @returns the current modified quaternion
  2594. */
  2595. scaleInPlace(value: number): Quaternion;
  2596. /**
  2597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2598. * @param scale defines the scale factor
  2599. * @param result defines the Quaternion object where to store the result
  2600. * @returns the unmodified current quaternion
  2601. */
  2602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2603. /**
  2604. * Multiplies two quaternions
  2605. * @param q1 defines the second operand
  2606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2607. */
  2608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2609. /**
  2610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2611. * @param q1 defines the second operand
  2612. * @param result defines the target quaternion
  2613. * @returns the current quaternion
  2614. */
  2615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2616. /**
  2617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2618. * @param q1 defines the second operand
  2619. * @returns the currentupdated quaternion
  2620. */
  2621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2622. /**
  2623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2624. * @param ref defines the target quaternion
  2625. * @returns the current quaternion
  2626. */
  2627. conjugateToRef(ref: Quaternion): Quaternion;
  2628. /**
  2629. * Conjugates in place (1-q) the current quaternion
  2630. * @returns the current updated quaternion
  2631. */
  2632. conjugateInPlace(): Quaternion;
  2633. /**
  2634. * Conjugates in place (1-q) the current quaternion
  2635. * @returns a new quaternion
  2636. */
  2637. conjugate(): Quaternion;
  2638. /**
  2639. * Gets length of current quaternion
  2640. * @returns the quaternion length (float)
  2641. */
  2642. length(): number;
  2643. /**
  2644. * Normalize in place the current quaternion
  2645. * @returns the current updated quaternion
  2646. */
  2647. normalize(): Quaternion;
  2648. /**
  2649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2650. * @param order is a reserved parameter and is ignore for now
  2651. * @returns a new Vector3 containing the Euler angles
  2652. */
  2653. toEulerAngles(order?: string): Vector3;
  2654. /**
  2655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2656. * @param result defines the vector which will be filled with the Euler angles
  2657. * @param order is a reserved parameter and is ignore for now
  2658. * @returns the current unchanged quaternion
  2659. */
  2660. toEulerAnglesToRef(result: Vector3): Quaternion;
  2661. /**
  2662. * Updates the given rotation matrix with the current quaternion values
  2663. * @param result defines the target matrix
  2664. * @returns the current unchanged quaternion
  2665. */
  2666. toRotationMatrix(result: Matrix): Quaternion;
  2667. /**
  2668. * Updates the current quaternion from the given rotation matrix values
  2669. * @param matrix defines the source matrix
  2670. * @returns the current updated quaternion
  2671. */
  2672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2673. /**
  2674. * Creates a new quaternion from a rotation matrix
  2675. * @param matrix defines the source matrix
  2676. * @returns a new quaternion created from the given rotation matrix values
  2677. */
  2678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2679. /**
  2680. * Updates the given quaternion with the given rotation matrix values
  2681. * @param matrix defines the source matrix
  2682. * @param result defines the target quaternion
  2683. */
  2684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2685. /**
  2686. * Returns the dot product (float) between the quaternions "left" and "right"
  2687. * @param left defines the left operand
  2688. * @param right defines the right operand
  2689. * @returns the dot product
  2690. */
  2691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2692. /**
  2693. * Checks if the two quaternions are close to each other
  2694. * @param quat0 defines the first quaternion to check
  2695. * @param quat1 defines the second quaternion to check
  2696. * @returns true if the two quaternions are close to each other
  2697. */
  2698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2699. /**
  2700. * Creates an empty quaternion
  2701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2702. */
  2703. static Zero(): Quaternion;
  2704. /**
  2705. * Inverse a given quaternion
  2706. * @param q defines the source quaternion
  2707. * @returns a new quaternion as the inverted current quaternion
  2708. */
  2709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2710. /**
  2711. * Inverse a given quaternion
  2712. * @param q defines the source quaternion
  2713. * @param result the quaternion the result will be stored in
  2714. * @returns the result quaternion
  2715. */
  2716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates an identity quaternion
  2719. * @returns the identity quaternion
  2720. */
  2721. static Identity(): Quaternion;
  2722. /**
  2723. * Gets a boolean indicating if the given quaternion is identity
  2724. * @param quaternion defines the quaternion to check
  2725. * @returns true if the quaternion is identity
  2726. */
  2727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2728. /**
  2729. * Creates a quaternion from a rotation around an axis
  2730. * @param axis defines the axis to use
  2731. * @param angle defines the angle to use
  2732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2733. */
  2734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2735. /**
  2736. * Creates a rotation around an axis and stores it into the given quaternion
  2737. * @param axis defines the axis to use
  2738. * @param angle defines the angle to use
  2739. * @param result defines the target quaternion
  2740. * @returns the target quaternion
  2741. */
  2742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Creates a new quaternion from data stored into an array
  2745. * @param array defines the data source
  2746. * @param offset defines the offset in the source array where the data starts
  2747. * @returns a new quaternion
  2748. */
  2749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2750. /**
  2751. * Create a quaternion from Euler rotation angles
  2752. * @param x Pitch
  2753. * @param y Yaw
  2754. * @param z Roll
  2755. * @returns the new Quaternion
  2756. */
  2757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2758. /**
  2759. * Updates a quaternion from Euler rotation angles
  2760. * @param x Pitch
  2761. * @param y Yaw
  2762. * @param z Roll
  2763. * @param result the quaternion to store the result
  2764. * @returns the updated quaternion
  2765. */
  2766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2767. /**
  2768. * Create a quaternion from Euler rotation vector
  2769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2770. * @returns the new Quaternion
  2771. */
  2772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2773. /**
  2774. * Updates a quaternion from Euler rotation vector
  2775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2776. * @param result the quaternion to store the result
  2777. * @returns the updated quaternion
  2778. */
  2779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2782. * @param yaw defines the rotation around Y axis
  2783. * @param pitch defines the rotation around X axis
  2784. * @param roll defines the rotation around Z axis
  2785. * @returns the new quaternion
  2786. */
  2787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2788. /**
  2789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2790. * @param yaw defines the rotation around Y axis
  2791. * @param pitch defines the rotation around X axis
  2792. * @param roll defines the rotation around Z axis
  2793. * @param result defines the target quaternion
  2794. */
  2795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2796. /**
  2797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2798. * @param alpha defines the rotation around first axis
  2799. * @param beta defines the rotation around second axis
  2800. * @param gamma defines the rotation around third axis
  2801. * @returns the new quaternion
  2802. */
  2803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2804. /**
  2805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2806. * @param alpha defines the rotation around first axis
  2807. * @param beta defines the rotation around second axis
  2808. * @param gamma defines the rotation around third axis
  2809. * @param result defines the target quaternion
  2810. */
  2811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2812. /**
  2813. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2814. * @param axis1 defines the first axis
  2815. * @param axis2 defines the second axis
  2816. * @param axis3 defines the third axis
  2817. * @returns the new quaternion
  2818. */
  2819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2820. /**
  2821. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2822. * @param axis1 defines the first axis
  2823. * @param axis2 defines the second axis
  2824. * @param axis3 defines the third axis
  2825. * @param ref defines the target quaternion
  2826. */
  2827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2828. /**
  2829. * Interpolates between two quaternions
  2830. * @param left defines first quaternion
  2831. * @param right defines second quaternion
  2832. * @param amount defines the gradient to use
  2833. * @returns the new interpolated quaternion
  2834. */
  2835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2836. /**
  2837. * Interpolates between two quaternions and stores it into a target quaternion
  2838. * @param left defines first quaternion
  2839. * @param right defines second quaternion
  2840. * @param amount defines the gradient to use
  2841. * @param result defines the target quaternion
  2842. */
  2843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2844. /**
  2845. * Interpolate between two quaternions using Hermite interpolation
  2846. * @param value1 defines first quaternion
  2847. * @param tangent1 defines the incoming tangent
  2848. * @param value2 defines second quaternion
  2849. * @param tangent2 defines the outgoing tangent
  2850. * @param amount defines the target quaternion
  2851. * @returns the new interpolated quaternion
  2852. */
  2853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2854. }
  2855. /**
  2856. * Class used to store matrix data (4x4)
  2857. */
  2858. export class Matrix {
  2859. private static _updateFlagSeed;
  2860. private static _identityReadOnly;
  2861. private _isIdentity;
  2862. private _isIdentityDirty;
  2863. private _isIdentity3x2;
  2864. private _isIdentity3x2Dirty;
  2865. /**
  2866. * Gets the update flag of the matrix which is an unique number for the matrix.
  2867. * It will be incremented every time the matrix data change.
  2868. * You can use it to speed the comparison between two versions of the same matrix.
  2869. */
  2870. updateFlag: number;
  2871. private readonly _m;
  2872. /**
  2873. * Gets the internal data of the matrix
  2874. */
  2875. readonly m: DeepImmutable<Float32Array>;
  2876. /** @hidden */
  2877. _markAsUpdated(): void;
  2878. /** @hidden */
  2879. private _updateIdentityStatus;
  2880. /**
  2881. * Creates an empty matrix (filled with zeros)
  2882. */
  2883. constructor();
  2884. /**
  2885. * Check if the current matrix is identity
  2886. * @returns true is the matrix is the identity matrix
  2887. */
  2888. isIdentity(): boolean;
  2889. /**
  2890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2891. * @returns true is the matrix is the identity matrix
  2892. */
  2893. isIdentityAs3x2(): boolean;
  2894. /**
  2895. * Gets the determinant of the matrix
  2896. * @returns the matrix determinant
  2897. */
  2898. determinant(): number;
  2899. /**
  2900. * Returns the matrix as a Float32Array
  2901. * @returns the matrix underlying array
  2902. */
  2903. toArray(): DeepImmutable<Float32Array>;
  2904. /**
  2905. * Returns the matrix as a Float32Array
  2906. * @returns the matrix underlying array.
  2907. */
  2908. asArray(): DeepImmutable<Float32Array>;
  2909. /**
  2910. * Inverts the current matrix in place
  2911. * @returns the current inverted matrix
  2912. */
  2913. invert(): Matrix;
  2914. /**
  2915. * Sets all the matrix elements to zero
  2916. * @returns the current matrix
  2917. */
  2918. reset(): Matrix;
  2919. /**
  2920. * Adds the current matrix with a second one
  2921. * @param other defines the matrix to add
  2922. * @returns a new matrix as the addition of the current matrix and the given one
  2923. */
  2924. add(other: DeepImmutable<Matrix>): Matrix;
  2925. /**
  2926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2927. * @param other defines the matrix to add
  2928. * @param result defines the target matrix
  2929. * @returns the current matrix
  2930. */
  2931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2932. /**
  2933. * Adds in place the given matrix to the current matrix
  2934. * @param other defines the second operand
  2935. * @returns the current updated matrix
  2936. */
  2937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2938. /**
  2939. * Sets the given matrix to the current inverted Matrix
  2940. * @param other defines the target matrix
  2941. * @returns the unmodified current matrix
  2942. */
  2943. invertToRef(other: Matrix): Matrix;
  2944. /**
  2945. * add a value at the specified position in the current Matrix
  2946. * @param index the index of the value within the matrix. between 0 and 15.
  2947. * @param value the value to be added
  2948. * @returns the current updated matrix
  2949. */
  2950. addAtIndex(index: number, value: number): Matrix;
  2951. /**
  2952. * mutiply the specified position in the current Matrix by a value
  2953. * @param index the index of the value within the matrix. between 0 and 15.
  2954. * @param value the value to be added
  2955. * @returns the current updated matrix
  2956. */
  2957. multiplyAtIndex(index: number, value: number): Matrix;
  2958. /**
  2959. * Inserts the translation vector (using 3 floats) in the current matrix
  2960. * @param x defines the 1st component of the translation
  2961. * @param y defines the 2nd component of the translation
  2962. * @param z defines the 3rd component of the translation
  2963. * @returns the current updated matrix
  2964. */
  2965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2966. /**
  2967. * Adds the translation vector (using 3 floats) in the current matrix
  2968. * @param x defines the 1st component of the translation
  2969. * @param y defines the 2nd component of the translation
  2970. * @param z defines the 3rd component of the translation
  2971. * @returns the current updated matrix
  2972. */
  2973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2974. /**
  2975. * Inserts the translation vector in the current matrix
  2976. * @param vector3 defines the translation to insert
  2977. * @returns the current updated matrix
  2978. */
  2979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2980. /**
  2981. * Gets the translation value of the current matrix
  2982. * @returns a new Vector3 as the extracted translation from the matrix
  2983. */
  2984. getTranslation(): Vector3;
  2985. /**
  2986. * Fill a Vector3 with the extracted translation from the matrix
  2987. * @param result defines the Vector3 where to store the translation
  2988. * @returns the current matrix
  2989. */
  2990. getTranslationToRef(result: Vector3): Matrix;
  2991. /**
  2992. * Remove rotation and scaling part from the matrix
  2993. * @returns the updated matrix
  2994. */
  2995. removeRotationAndScaling(): Matrix;
  2996. /**
  2997. * Multiply two matrices
  2998. * @param other defines the second operand
  2999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3000. */
  3001. multiply(other: DeepImmutable<Matrix>): Matrix;
  3002. /**
  3003. * Copy the current matrix from the given one
  3004. * @param other defines the source matrix
  3005. * @returns the current updated matrix
  3006. */
  3007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3008. /**
  3009. * Populates the given array from the starting index with the current matrix values
  3010. * @param array defines the target array
  3011. * @param offset defines the offset in the target array where to start storing values
  3012. * @returns the current matrix
  3013. */
  3014. copyToArray(array: Float32Array, offset?: number): Matrix;
  3015. /**
  3016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3017. * @param other defines the second operand
  3018. * @param result defines the matrix where to store the multiplication
  3019. * @returns the current matrix
  3020. */
  3021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3022. /**
  3023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3024. * @param other defines the second operand
  3025. * @param result defines the array where to store the multiplication
  3026. * @param offset defines the offset in the target array where to start storing values
  3027. * @returns the current matrix
  3028. */
  3029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3030. /**
  3031. * Check equality between this matrix and a second one
  3032. * @param value defines the second matrix to compare
  3033. * @returns true is the current matrix and the given one values are strictly equal
  3034. */
  3035. equals(value: DeepImmutable<Matrix>): boolean;
  3036. /**
  3037. * Clone the current matrix
  3038. * @returns a new matrix from the current matrix
  3039. */
  3040. clone(): Matrix;
  3041. /**
  3042. * Returns the name of the current matrix class
  3043. * @returns the string "Matrix"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Gets the hash code of the current matrix
  3048. * @returns the hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Decomposes the current Matrix into a translation, rotation and scaling components
  3053. * @param scale defines the scale vector3 given as a reference to update
  3054. * @param rotation defines the rotation quaternion given as a reference to update
  3055. * @param translation defines the translation vector3 given as a reference to update
  3056. * @returns true if operation was successful
  3057. */
  3058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3059. /**
  3060. * Gets specific row of the matrix
  3061. * @param index defines the number of the row to get
  3062. * @returns the index-th row of the current matrix as a new Vector4
  3063. */
  3064. getRow(index: number): Nullable<Vector4>;
  3065. /**
  3066. * Sets the index-th row of the current matrix to the vector4 values
  3067. * @param index defines the number of the row to set
  3068. * @param row defines the target vector4
  3069. * @returns the updated current matrix
  3070. */
  3071. setRow(index: number, row: Vector4): Matrix;
  3072. /**
  3073. * Compute the transpose of the matrix
  3074. * @returns the new transposed matrix
  3075. */
  3076. transpose(): Matrix;
  3077. /**
  3078. * Compute the transpose of the matrix and store it in a given matrix
  3079. * @param result defines the target matrix
  3080. * @returns the current matrix
  3081. */
  3082. transposeToRef(result: Matrix): Matrix;
  3083. /**
  3084. * Sets the index-th row of the current matrix with the given 4 x float values
  3085. * @param index defines the row index
  3086. * @param x defines the x component to set
  3087. * @param y defines the y component to set
  3088. * @param z defines the z component to set
  3089. * @param w defines the w component to set
  3090. * @returns the updated current matrix
  3091. */
  3092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3093. /**
  3094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3095. * @param scale defines the scale factor
  3096. * @returns a new matrix
  3097. */
  3098. scale(scale: number): Matrix;
  3099. /**
  3100. * Scale the current matrix values by a factor to a given result matrix
  3101. * @param scale defines the scale factor
  3102. * @param result defines the matrix to store the result
  3103. * @returns the current matrix
  3104. */
  3105. scaleToRef(scale: number, result: Matrix): Matrix;
  3106. /**
  3107. * Scale the current matrix values by a factor and add the result to a given matrix
  3108. * @param scale defines the scale factor
  3109. * @param result defines the Matrix to store the result
  3110. * @returns the current matrix
  3111. */
  3112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3113. /**
  3114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3115. * @param ref matrix to store the result
  3116. */
  3117. toNormalMatrix(ref: Matrix): void;
  3118. /**
  3119. * Gets only rotation part of the current matrix
  3120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3121. */
  3122. getRotationMatrix(): Matrix;
  3123. /**
  3124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3125. * @param result defines the target matrix to store data to
  3126. * @returns the current matrix
  3127. */
  3128. getRotationMatrixToRef(result: Matrix): Matrix;
  3129. /**
  3130. * Toggles model matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleModelMatrixHandInPlace(): void;
  3133. /**
  3134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3135. */
  3136. toggleProjectionMatrixHandInPlace(): void;
  3137. /**
  3138. * Creates a matrix from an array
  3139. * @param array defines the source array
  3140. * @param offset defines an offset in the source array
  3141. * @returns a new Matrix set from the starting index of the given array
  3142. */
  3143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3144. /**
  3145. * Copy the content of an array into a given matrix
  3146. * @param array defines the source array
  3147. * @param offset defines an offset in the source array
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3151. /**
  3152. * Stores an array into a matrix after having multiplied each component by a given factor
  3153. * @param array defines the source array
  3154. * @param offset defines the offset in the source array
  3155. * @param scale defines the scaling factor
  3156. * @param result defines the target matrix
  3157. */
  3158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3159. /**
  3160. * Gets an identity matrix that must not be updated
  3161. */
  3162. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3163. /**
  3164. * Stores a list of values (16) inside a given matrix
  3165. * @param initialM11 defines 1st value of 1st row
  3166. * @param initialM12 defines 2nd value of 1st row
  3167. * @param initialM13 defines 3rd value of 1st row
  3168. * @param initialM14 defines 4th value of 1st row
  3169. * @param initialM21 defines 1st value of 2nd row
  3170. * @param initialM22 defines 2nd value of 2nd row
  3171. * @param initialM23 defines 3rd value of 2nd row
  3172. * @param initialM24 defines 4th value of 2nd row
  3173. * @param initialM31 defines 1st value of 3rd row
  3174. * @param initialM32 defines 2nd value of 3rd row
  3175. * @param initialM33 defines 3rd value of 3rd row
  3176. * @param initialM34 defines 4th value of 3rd row
  3177. * @param initialM41 defines 1st value of 4th row
  3178. * @param initialM42 defines 2nd value of 4th row
  3179. * @param initialM43 defines 3rd value of 4th row
  3180. * @param initialM44 defines 4th value of 4th row
  3181. * @param result defines the target matrix
  3182. */
  3183. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3184. /**
  3185. * Creates new matrix from a list of values (16)
  3186. * @param initialM11 defines 1st value of 1st row
  3187. * @param initialM12 defines 2nd value of 1st row
  3188. * @param initialM13 defines 3rd value of 1st row
  3189. * @param initialM14 defines 4th value of 1st row
  3190. * @param initialM21 defines 1st value of 2nd row
  3191. * @param initialM22 defines 2nd value of 2nd row
  3192. * @param initialM23 defines 3rd value of 2nd row
  3193. * @param initialM24 defines 4th value of 2nd row
  3194. * @param initialM31 defines 1st value of 3rd row
  3195. * @param initialM32 defines 2nd value of 3rd row
  3196. * @param initialM33 defines 3rd value of 3rd row
  3197. * @param initialM34 defines 4th value of 3rd row
  3198. * @param initialM41 defines 1st value of 4th row
  3199. * @param initialM42 defines 2nd value of 4th row
  3200. * @param initialM43 defines 3rd value of 4th row
  3201. * @param initialM44 defines 4th value of 4th row
  3202. * @returns the new matrix
  3203. */
  3204. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3205. /**
  3206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3207. * @param scale defines the scale vector3
  3208. * @param rotation defines the rotation quaternion
  3209. * @param translation defines the translation vector3
  3210. * @returns a new matrix
  3211. */
  3212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3213. /**
  3214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3215. * @param scale defines the scale vector3
  3216. * @param rotation defines the rotation quaternion
  3217. * @param translation defines the translation vector3
  3218. * @param result defines the target matrix
  3219. */
  3220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3221. /**
  3222. * Creates a new identity matrix
  3223. * @returns a new identity matrix
  3224. */
  3225. static Identity(): Matrix;
  3226. /**
  3227. * Creates a new identity matrix and stores the result in a given matrix
  3228. * @param result defines the target matrix
  3229. */
  3230. static IdentityToRef(result: Matrix): void;
  3231. /**
  3232. * Creates a new zero matrix
  3233. * @returns a new zero matrix
  3234. */
  3235. static Zero(): Matrix;
  3236. /**
  3237. * Creates a new rotation matrix for "angle" radians around the X axis
  3238. * @param angle defines the angle (in radians) to use
  3239. * @return the new matrix
  3240. */
  3241. static RotationX(angle: number): Matrix;
  3242. /**
  3243. * Creates a new matrix as the invert of a given matrix
  3244. * @param source defines the source matrix
  3245. * @returns the new matrix
  3246. */
  3247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3248. /**
  3249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3250. * @param angle defines the angle (in radians) to use
  3251. * @param result defines the target matrix
  3252. */
  3253. static RotationXToRef(angle: number, result: Matrix): void;
  3254. /**
  3255. * Creates a new rotation matrix for "angle" radians around the Y axis
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationY(angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3262. * @param angle defines the angle (in radians) to use
  3263. * @param result defines the target matrix
  3264. */
  3265. static RotationYToRef(angle: number, result: Matrix): void;
  3266. /**
  3267. * Creates a new rotation matrix for "angle" radians around the Z axis
  3268. * @param angle defines the angle (in radians) to use
  3269. * @return the new matrix
  3270. */
  3271. static RotationZ(angle: number): Matrix;
  3272. /**
  3273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3274. * @param angle defines the angle (in radians) to use
  3275. * @param result defines the target matrix
  3276. */
  3277. static RotationZToRef(angle: number, result: Matrix): void;
  3278. /**
  3279. * Creates a new rotation matrix for "angle" radians around the given axis
  3280. * @param axis defines the axis to use
  3281. * @param angle defines the angle (in radians) to use
  3282. * @return the new matrix
  3283. */
  3284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3285. /**
  3286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3287. * @param axis defines the axis to use
  3288. * @param angle defines the angle (in radians) to use
  3289. * @param result defines the target matrix
  3290. */
  3291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3292. /**
  3293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3295. * @param from defines the vector to align
  3296. * @param to defines the vector to align to
  3297. * @param result defines the target matrix
  3298. */
  3299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3300. /**
  3301. * Creates a rotation matrix
  3302. * @param yaw defines the yaw angle in radians (Y axis)
  3303. * @param pitch defines the pitch angle in radians (X axis)
  3304. * @param roll defines the roll angle in radians (X axis)
  3305. * @returns the new rotation matrix
  3306. */
  3307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3308. /**
  3309. * Creates a rotation matrix and stores it in a given matrix
  3310. * @param yaw defines the yaw angle in radians (Y axis)
  3311. * @param pitch defines the pitch angle in radians (X axis)
  3312. * @param roll defines the roll angle in radians (X axis)
  3313. * @param result defines the target matrix
  3314. */
  3315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3316. /**
  3317. * Creates a scaling matrix
  3318. * @param x defines the scale factor on X axis
  3319. * @param y defines the scale factor on Y axis
  3320. * @param z defines the scale factor on Z axis
  3321. * @returns the new matrix
  3322. */
  3323. static Scaling(x: number, y: number, z: number): Matrix;
  3324. /**
  3325. * Creates a scaling matrix and stores it in a given matrix
  3326. * @param x defines the scale factor on X axis
  3327. * @param y defines the scale factor on Y axis
  3328. * @param z defines the scale factor on Z axis
  3329. * @param result defines the target matrix
  3330. */
  3331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3332. /**
  3333. * Creates a translation matrix
  3334. * @param x defines the translation on X axis
  3335. * @param y defines the translation on Y axis
  3336. * @param z defines the translationon Z axis
  3337. * @returns the new matrix
  3338. */
  3339. static Translation(x: number, y: number, z: number): Matrix;
  3340. /**
  3341. * Creates a translation matrix and stores it in a given matrix
  3342. * @param x defines the translation on X axis
  3343. * @param y defines the translation on Y axis
  3344. * @param z defines the translationon Z axis
  3345. * @param result defines the target matrix
  3346. */
  3347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3348. /**
  3349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3350. * @param startValue defines the start value
  3351. * @param endValue defines the end value
  3352. * @param gradient defines the gradient factor
  3353. * @returns the new matrix
  3354. */
  3355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3356. /**
  3357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3358. * @param startValue defines the start value
  3359. * @param endValue defines the end value
  3360. * @param gradient defines the gradient factor
  3361. * @param result defines the Matrix object where to store data
  3362. */
  3363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3364. /**
  3365. * Builds a new matrix whose values are computed by:
  3366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3369. * @param startValue defines the first matrix
  3370. * @param endValue defines the second matrix
  3371. * @param gradient defines the gradient between the two matrices
  3372. * @returns the new matrix
  3373. */
  3374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3375. /**
  3376. * Update a matrix to values which are computed by:
  3377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3380. * @param startValue defines the first matrix
  3381. * @param endValue defines the second matrix
  3382. * @param gradient defines the gradient between the two matrices
  3383. * @param result defines the target matrix
  3384. */
  3385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3386. /**
  3387. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3388. * This function works in left handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @returns the new matrix
  3393. */
  3394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3395. /**
  3396. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3397. * This function works in left handed mode
  3398. * @param eye defines the final position of the entity
  3399. * @param target defines where the entity should look at
  3400. * @param up defines the up vector for the entity
  3401. * @param result defines the target matrix
  3402. */
  3403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3404. /**
  3405. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3406. * This function works in right handed mode
  3407. * @param eye defines the final position of the entity
  3408. * @param target defines where the entity should look at
  3409. * @param up defines the up vector for the entity
  3410. * @returns the new matrix
  3411. */
  3412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3413. /**
  3414. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3415. * This function works in right handed mode
  3416. * @param eye defines the final position of the entity
  3417. * @param target defines where the entity should look at
  3418. * @param up defines the up vector for the entity
  3419. * @param result defines the target matrix
  3420. */
  3421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3422. /**
  3423. * Create a left-handed orthographic projection matrix
  3424. * @param width defines the viewport width
  3425. * @param height defines the viewport height
  3426. * @param znear defines the near clip plane
  3427. * @param zfar defines the far clip plane
  3428. * @returns a new matrix as a left-handed orthographic projection matrix
  3429. */
  3430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3431. /**
  3432. * Store a left-handed orthographic projection to a given matrix
  3433. * @param width defines the viewport width
  3434. * @param height defines the viewport height
  3435. * @param znear defines the near clip plane
  3436. * @param zfar defines the far clip plane
  3437. * @param result defines the target matrix
  3438. */
  3439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3440. /**
  3441. * Create a left-handed orthographic projection matrix
  3442. * @param left defines the viewport left coordinate
  3443. * @param right defines the viewport right coordinate
  3444. * @param bottom defines the viewport bottom coordinate
  3445. * @param top defines the viewport top coordinate
  3446. * @param znear defines the near clip plane
  3447. * @param zfar defines the far clip plane
  3448. * @returns a new matrix as a left-handed orthographic projection matrix
  3449. */
  3450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3451. /**
  3452. * Stores a left-handed orthographic projection into a given matrix
  3453. * @param left defines the viewport left coordinate
  3454. * @param right defines the viewport right coordinate
  3455. * @param bottom defines the viewport bottom coordinate
  3456. * @param top defines the viewport top coordinate
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @param result defines the target matrix
  3460. */
  3461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3462. /**
  3463. * Creates a right-handed orthographic projection matrix
  3464. * @param left defines the viewport left coordinate
  3465. * @param right defines the viewport right coordinate
  3466. * @param bottom defines the viewport bottom coordinate
  3467. * @param top defines the viewport top coordinate
  3468. * @param znear defines the near clip plane
  3469. * @param zfar defines the far clip plane
  3470. * @returns a new matrix as a right-handed orthographic projection matrix
  3471. */
  3472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3473. /**
  3474. * Stores a right-handed orthographic projection into a given matrix
  3475. * @param left defines the viewport left coordinate
  3476. * @param right defines the viewport right coordinate
  3477. * @param bottom defines the viewport bottom coordinate
  3478. * @param top defines the viewport top coordinate
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. */
  3483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3484. /**
  3485. * Creates a left-handed perspective projection matrix
  3486. * @param width defines the viewport width
  3487. * @param height defines the viewport height
  3488. * @param znear defines the near clip plane
  3489. * @param zfar defines the far clip plane
  3490. * @returns a new matrix as a left-handed perspective projection matrix
  3491. */
  3492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3493. /**
  3494. * Creates a left-handed perspective projection matrix
  3495. * @param fov defines the horizontal field of view
  3496. * @param aspect defines the aspect ratio
  3497. * @param znear defines the near clip plane
  3498. * @param zfar defines the far clip plane
  3499. * @returns a new matrix as a left-handed perspective projection matrix
  3500. */
  3501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3502. /**
  3503. * Stores a left-handed perspective projection into a given matrix
  3504. * @param fov defines the horizontal field of view
  3505. * @param aspect defines the aspect ratio
  3506. * @param znear defines the near clip plane
  3507. * @param zfar defines the far clip plane
  3508. * @param result defines the target matrix
  3509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3510. */
  3511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3512. /**
  3513. * Creates a right-handed perspective projection matrix
  3514. * @param fov defines the horizontal field of view
  3515. * @param aspect defines the aspect ratio
  3516. * @param znear defines the near clip plane
  3517. * @param zfar defines the far clip plane
  3518. * @returns a new matrix as a right-handed perspective projection matrix
  3519. */
  3520. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3521. /**
  3522. * Stores a right-handed perspective projection into a given matrix
  3523. * @param fov defines the horizontal field of view
  3524. * @param aspect defines the aspect ratio
  3525. * @param znear defines the near clip plane
  3526. * @param zfar defines the far clip plane
  3527. * @param result defines the target matrix
  3528. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3529. */
  3530. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3531. /**
  3532. * Stores a perspective projection for WebVR info a given matrix
  3533. * @param fov defines the field of view
  3534. * @param znear defines the near clip plane
  3535. * @param zfar defines the far clip plane
  3536. * @param result defines the target matrix
  3537. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3538. */
  3539. static PerspectiveFovWebVRToRef(fov: {
  3540. upDegrees: number;
  3541. downDegrees: number;
  3542. leftDegrees: number;
  3543. rightDegrees: number;
  3544. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3545. /**
  3546. * Computes a complete transformation matrix
  3547. * @param viewport defines the viewport to use
  3548. * @param world defines the world matrix
  3549. * @param view defines the view matrix
  3550. * @param projection defines the projection matrix
  3551. * @param zmin defines the near clip plane
  3552. * @param zmax defines the far clip plane
  3553. * @returns the transformation matrix
  3554. */
  3555. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3556. /**
  3557. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3558. * @param matrix defines the matrix to use
  3559. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3560. */
  3561. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3562. /**
  3563. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3564. * @param matrix defines the matrix to use
  3565. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3566. */
  3567. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3568. /**
  3569. * Compute the transpose of a given matrix
  3570. * @param matrix defines the matrix to transpose
  3571. * @returns the new matrix
  3572. */
  3573. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3574. /**
  3575. * Compute the transpose of a matrix and store it in a target matrix
  3576. * @param matrix defines the matrix to transpose
  3577. * @param result defines the target matrix
  3578. */
  3579. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3580. /**
  3581. * Computes a reflection matrix from a plane
  3582. * @param plane defines the reflection plane
  3583. * @returns a new matrix
  3584. */
  3585. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3586. /**
  3587. * Computes a reflection matrix from a plane
  3588. * @param plane defines the reflection plane
  3589. * @param result defines the target matrix
  3590. */
  3591. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3592. /**
  3593. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3594. * @param xaxis defines the value of the 1st axis
  3595. * @param yaxis defines the value of the 2nd axis
  3596. * @param zaxis defines the value of the 3rd axis
  3597. * @param result defines the target matrix
  3598. */
  3599. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3600. /**
  3601. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3602. * @param quat defines the quaternion to use
  3603. * @param result defines the target matrix
  3604. */
  3605. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3606. }
  3607. /**
  3608. * Represens a plane by the equation ax + by + cz + d = 0
  3609. */
  3610. export class Plane {
  3611. /**
  3612. * Normal of the plane (a,b,c)
  3613. */
  3614. normal: Vector3;
  3615. /**
  3616. * d component of the plane
  3617. */
  3618. d: number;
  3619. /**
  3620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3621. * @param a a component of the plane
  3622. * @param b b component of the plane
  3623. * @param c c component of the plane
  3624. * @param d d component of the plane
  3625. */
  3626. constructor(a: number, b: number, c: number, d: number);
  3627. /**
  3628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3629. */
  3630. asArray(): number[];
  3631. /**
  3632. * @returns a new plane copied from the current Plane.
  3633. */
  3634. clone(): Plane;
  3635. /**
  3636. * @returns the string "Plane".
  3637. */
  3638. getClassName(): string;
  3639. /**
  3640. * @returns the Plane hash code.
  3641. */
  3642. getHashCode(): number;
  3643. /**
  3644. * Normalize the current Plane in place.
  3645. * @returns the updated Plane.
  3646. */
  3647. normalize(): Plane;
  3648. /**
  3649. * Applies a transformation the plane and returns the result
  3650. * @param transformation the transformation matrix to be applied to the plane
  3651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3652. */
  3653. transform(transformation: DeepImmutable<Matrix>): Plane;
  3654. /**
  3655. * Calcualtte the dot product between the point and the plane normal
  3656. * @param point point to calculate the dot product with
  3657. * @returns the dot product (float) of the point coordinates and the plane normal.
  3658. */
  3659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3660. /**
  3661. * Updates the current Plane from the plane defined by the three given points.
  3662. * @param point1 one of the points used to contruct the plane
  3663. * @param point2 one of the points used to contruct the plane
  3664. * @param point3 one of the points used to contruct the plane
  3665. * @returns the updated Plane.
  3666. */
  3667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Checks if the plane is facing a given direction
  3670. * @param direction the direction to check if the plane is facing
  3671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3672. * @returns True is the vector "direction" is the same side than the plane normal.
  3673. */
  3674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3675. /**
  3676. * Calculates the distance to a point
  3677. * @param point point to calculate distance to
  3678. * @returns the signed distance (float) from the given point to the Plane.
  3679. */
  3680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3681. /**
  3682. * Creates a plane from an array
  3683. * @param array the array to create a plane from
  3684. * @returns a new Plane from the given array.
  3685. */
  3686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3687. /**
  3688. * Creates a plane from three points
  3689. * @param point1 point used to create the plane
  3690. * @param point2 point used to create the plane
  3691. * @param point3 point used to create the plane
  3692. * @returns a new Plane defined by the three given points.
  3693. */
  3694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3695. /**
  3696. * Creates a plane from an origin point and a normal
  3697. * @param origin origin of the plane to be constructed
  3698. * @param normal normal of the plane to be constructed
  3699. * @returns a new Plane the normal vector to this plane at the given origin point.
  3700. * Note : the vector "normal" is updated because normalized.
  3701. */
  3702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3703. /**
  3704. * Calculates the distance from a plane and a point
  3705. * @param origin origin of the plane to be constructed
  3706. * @param normal normal of the plane to be constructed
  3707. * @param point point to calculate distance to
  3708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3709. */
  3710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3711. }
  3712. /**
  3713. * Class used to represent a viewport on screen
  3714. */
  3715. export class Viewport {
  3716. /** viewport left coordinate */
  3717. x: number;
  3718. /** viewport top coordinate */
  3719. y: number;
  3720. /**viewport width */
  3721. width: number;
  3722. /** viewport height */
  3723. height: number;
  3724. /**
  3725. * Creates a Viewport object located at (x, y) and sized (width, height)
  3726. * @param x defines viewport left coordinate
  3727. * @param y defines viewport top coordinate
  3728. * @param width defines the viewport width
  3729. * @param height defines the viewport height
  3730. */
  3731. constructor(
  3732. /** viewport left coordinate */
  3733. x: number,
  3734. /** viewport top coordinate */
  3735. y: number,
  3736. /**viewport width */
  3737. width: number,
  3738. /** viewport height */
  3739. height: number);
  3740. /**
  3741. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3742. * @param renderWidth defines the rendering width
  3743. * @param renderHeight defines the rendering height
  3744. * @returns a new Viewport
  3745. */
  3746. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3747. /**
  3748. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3749. * @param renderWidth defines the rendering width
  3750. * @param renderHeight defines the rendering height
  3751. * @param ref defines the target viewport
  3752. * @returns the current viewport
  3753. */
  3754. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3755. /**
  3756. * Returns a new Viewport copied from the current one
  3757. * @returns a new Viewport
  3758. */
  3759. clone(): Viewport;
  3760. }
  3761. /**
  3762. * Reprasents a camera frustum
  3763. */
  3764. export class Frustum {
  3765. /**
  3766. * Gets the planes representing the frustum
  3767. * @param transform matrix to be applied to the returned planes
  3768. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3769. */
  3770. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3771. /**
  3772. * Gets the near frustum plane transformed by the transform matrix
  3773. * @param transform transformation matrix to be applied to the resulting frustum plane
  3774. * @param frustumPlane the resuling frustum plane
  3775. */
  3776. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3777. /**
  3778. * Gets the far frustum plane transformed by the transform matrix
  3779. * @param transform transformation matrix to be applied to the resulting frustum plane
  3780. * @param frustumPlane the resuling frustum plane
  3781. */
  3782. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3783. /**
  3784. * Gets the left frustum plane transformed by the transform matrix
  3785. * @param transform transformation matrix to be applied to the resulting frustum plane
  3786. * @param frustumPlane the resuling frustum plane
  3787. */
  3788. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3789. /**
  3790. * Gets the right frustum plane transformed by the transform matrix
  3791. * @param transform transformation matrix to be applied to the resulting frustum plane
  3792. * @param frustumPlane the resuling frustum plane
  3793. */
  3794. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3795. /**
  3796. * Gets the top frustum plane transformed by the transform matrix
  3797. * @param transform transformation matrix to be applied to the resulting frustum plane
  3798. * @param frustumPlane the resuling frustum plane
  3799. */
  3800. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3801. /**
  3802. * Gets the bottom frustum plane transformed by the transform matrix
  3803. * @param transform transformation matrix to be applied to the resulting frustum plane
  3804. * @param frustumPlane the resuling frustum plane
  3805. */
  3806. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3807. /**
  3808. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3809. * @param transform transformation matrix to be applied to the resulting frustum planes
  3810. * @param frustumPlanes the resuling frustum planes
  3811. */
  3812. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3813. }
  3814. /** Defines supported spaces */
  3815. export enum Space {
  3816. /** Local (object) space */
  3817. LOCAL = 0,
  3818. /** World space */
  3819. WORLD = 1,
  3820. /** Bone space */
  3821. BONE = 2
  3822. }
  3823. /** Defines the 3 main axes */
  3824. export class Axis {
  3825. /** X axis */
  3826. static X: Vector3;
  3827. /** Y axis */
  3828. static Y: Vector3;
  3829. /** Z axis */
  3830. static Z: Vector3;
  3831. }
  3832. /** Class used to represent a Bezier curve */
  3833. export class BezierCurve {
  3834. /**
  3835. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3836. * @param t defines the time
  3837. * @param x1 defines the left coordinate on X axis
  3838. * @param y1 defines the left coordinate on Y axis
  3839. * @param x2 defines the right coordinate on X axis
  3840. * @param y2 defines the right coordinate on Y axis
  3841. * @returns the interpolated value
  3842. */
  3843. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3844. }
  3845. /**
  3846. * Defines potential orientation for back face culling
  3847. */
  3848. export enum Orientation {
  3849. /**
  3850. * Clockwise
  3851. */
  3852. CW = 0,
  3853. /** Counter clockwise */
  3854. CCW = 1
  3855. }
  3856. /**
  3857. * Defines angle representation
  3858. */
  3859. export class Angle {
  3860. private _radians;
  3861. /**
  3862. * Creates an Angle object of "radians" radians (float).
  3863. * @param radians the angle in radians
  3864. */
  3865. constructor(radians: number);
  3866. /**
  3867. * Get value in degrees
  3868. * @returns the Angle value in degrees (float)
  3869. */
  3870. degrees(): number;
  3871. /**
  3872. * Get value in radians
  3873. * @returns the Angle value in radians (float)
  3874. */
  3875. radians(): number;
  3876. /**
  3877. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3878. * @param a defines first vector
  3879. * @param b defines second vector
  3880. * @returns a new Angle
  3881. */
  3882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3883. /**
  3884. * Gets a new Angle object from the given float in radians
  3885. * @param radians defines the angle value in radians
  3886. * @returns a new Angle
  3887. */
  3888. static FromRadians(radians: number): Angle;
  3889. /**
  3890. * Gets a new Angle object from the given float in degrees
  3891. * @param degrees defines the angle value in degrees
  3892. * @returns a new Angle
  3893. */
  3894. static FromDegrees(degrees: number): Angle;
  3895. }
  3896. /**
  3897. * This represents an arc in a 2d space.
  3898. */
  3899. export class Arc2 {
  3900. /** Defines the start point of the arc */
  3901. startPoint: Vector2;
  3902. /** Defines the mid point of the arc */
  3903. midPoint: Vector2;
  3904. /** Defines the end point of the arc */
  3905. endPoint: Vector2;
  3906. /**
  3907. * Defines the center point of the arc.
  3908. */
  3909. centerPoint: Vector2;
  3910. /**
  3911. * Defines the radius of the arc.
  3912. */
  3913. radius: number;
  3914. /**
  3915. * Defines the angle of the arc (from mid point to end point).
  3916. */
  3917. angle: Angle;
  3918. /**
  3919. * Defines the start angle of the arc (from start point to middle point).
  3920. */
  3921. startAngle: Angle;
  3922. /**
  3923. * Defines the orientation of the arc (clock wise/counter clock wise).
  3924. */
  3925. orientation: Orientation;
  3926. /**
  3927. * Creates an Arc object from the three given points : start, middle and end.
  3928. * @param startPoint Defines the start point of the arc
  3929. * @param midPoint Defines the midlle point of the arc
  3930. * @param endPoint Defines the end point of the arc
  3931. */
  3932. constructor(
  3933. /** Defines the start point of the arc */
  3934. startPoint: Vector2,
  3935. /** Defines the mid point of the arc */
  3936. midPoint: Vector2,
  3937. /** Defines the end point of the arc */
  3938. endPoint: Vector2);
  3939. }
  3940. /**
  3941. * Represents a 2D path made up of multiple 2D points
  3942. */
  3943. export class Path2 {
  3944. private _points;
  3945. private _length;
  3946. /**
  3947. * If the path start and end point are the same
  3948. */
  3949. closed: boolean;
  3950. /**
  3951. * Creates a Path2 object from the starting 2D coordinates x and y.
  3952. * @param x the starting points x value
  3953. * @param y the starting points y value
  3954. */
  3955. constructor(x: number, y: number);
  3956. /**
  3957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3958. * @param x the added points x value
  3959. * @param y the added points y value
  3960. * @returns the updated Path2.
  3961. */
  3962. addLineTo(x: number, y: number): Path2;
  3963. /**
  3964. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3965. * @param midX middle point x value
  3966. * @param midY middle point y value
  3967. * @param endX end point x value
  3968. * @param endY end point y value
  3969. * @param numberOfSegments (default: 36)
  3970. * @returns the updated Path2.
  3971. */
  3972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3973. /**
  3974. * Closes the Path2.
  3975. * @returns the Path2.
  3976. */
  3977. close(): Path2;
  3978. /**
  3979. * Gets the sum of the distance between each sequential point in the path
  3980. * @returns the Path2 total length (float).
  3981. */
  3982. length(): number;
  3983. /**
  3984. * Gets the points which construct the path
  3985. * @returns the Path2 internal array of points.
  3986. */
  3987. getPoints(): Vector2[];
  3988. /**
  3989. * Retreives the point at the distance aways from the starting point
  3990. * @param normalizedLengthPosition the length along the path to retreive the point from
  3991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3992. */
  3993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3994. /**
  3995. * Creates a new path starting from an x and y position
  3996. * @param x starting x value
  3997. * @param y starting y value
  3998. * @returns a new Path2 starting at the coordinates (x, y).
  3999. */
  4000. static StartingAt(x: number, y: number): Path2;
  4001. }
  4002. /**
  4003. * Represents a 3D path made up of multiple 3D points
  4004. */
  4005. export class Path3D {
  4006. /**
  4007. * an array of Vector3, the curve axis of the Path3D
  4008. */
  4009. path: Vector3[];
  4010. private _curve;
  4011. private _distances;
  4012. private _tangents;
  4013. private _normals;
  4014. private _binormals;
  4015. private _raw;
  4016. /**
  4017. * new Path3D(path, normal, raw)
  4018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4020. * @param path an array of Vector3, the curve axis of the Path3D
  4021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4023. */
  4024. constructor(
  4025. /**
  4026. * an array of Vector3, the curve axis of the Path3D
  4027. */
  4028. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4029. /**
  4030. * Returns the Path3D array of successive Vector3 designing its curve.
  4031. * @returns the Path3D array of successive Vector3 designing its curve.
  4032. */
  4033. getCurve(): Vector3[];
  4034. /**
  4035. * Returns an array populated with tangent vectors on each Path3D curve point.
  4036. * @returns an array populated with tangent vectors on each Path3D curve point.
  4037. */
  4038. getTangents(): Vector3[];
  4039. /**
  4040. * Returns an array populated with normal vectors on each Path3D curve point.
  4041. * @returns an array populated with normal vectors on each Path3D curve point.
  4042. */
  4043. getNormals(): Vector3[];
  4044. /**
  4045. * Returns an array populated with binormal vectors on each Path3D curve point.
  4046. * @returns an array populated with binormal vectors on each Path3D curve point.
  4047. */
  4048. getBinormals(): Vector3[];
  4049. /**
  4050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4051. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4052. */
  4053. getDistances(): number[];
  4054. /**
  4055. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4056. * @param path path which all values are copied into the curves points
  4057. * @param firstNormal which should be projected onto the curve
  4058. * @returns the same object updated.
  4059. */
  4060. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4061. private _compute;
  4062. private _getFirstNonNullVector;
  4063. private _getLastNonNullVector;
  4064. private _normalVector;
  4065. }
  4066. /**
  4067. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4068. * A Curve3 is designed from a series of successive Vector3.
  4069. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4070. */
  4071. export class Curve3 {
  4072. private _points;
  4073. private _length;
  4074. /**
  4075. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4076. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4077. * @param v1 (Vector3) the control point
  4078. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4079. * @param nbPoints (integer) the wanted number of points in the curve
  4080. * @returns the created Curve3
  4081. */
  4082. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4083. /**
  4084. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4085. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4086. * @param v1 (Vector3) the first control point
  4087. * @param v2 (Vector3) the second control point
  4088. * @param v3 (Vector3) the end point of the Cubic Bezier
  4089. * @param nbPoints (integer) the wanted number of points in the curve
  4090. * @returns the created Curve3
  4091. */
  4092. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4093. /**
  4094. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4095. * @param p1 (Vector3) the origin point of the Hermite Spline
  4096. * @param t1 (Vector3) the tangent vector at the origin point
  4097. * @param p2 (Vector3) the end point of the Hermite Spline
  4098. * @param t2 (Vector3) the tangent vector at the end point
  4099. * @param nbPoints (integer) the wanted number of points in the curve
  4100. * @returns the created Curve3
  4101. */
  4102. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4103. /**
  4104. * Returns a Curve3 object along a CatmullRom Spline curve :
  4105. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4106. * @param nbPoints (integer) the wanted number of points between each curve control points
  4107. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4108. * @returns the created Curve3
  4109. */
  4110. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4111. /**
  4112. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4113. * A Curve3 is designed from a series of successive Vector3.
  4114. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4115. * @param points points which make up the curve
  4116. */
  4117. constructor(points: Vector3[]);
  4118. /**
  4119. * @returns the Curve3 stored array of successive Vector3
  4120. */
  4121. getPoints(): Vector3[];
  4122. /**
  4123. * @returns the computed length (float) of the curve.
  4124. */
  4125. length(): number;
  4126. /**
  4127. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4128. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4129. * curveA and curveB keep unchanged.
  4130. * @param curve the curve to continue from this curve
  4131. * @returns the newly constructed curve
  4132. */
  4133. continue(curve: DeepImmutable<Curve3>): Curve3;
  4134. private _computeLength;
  4135. }
  4136. /**
  4137. * Contains position and normal vectors for a vertex
  4138. */
  4139. export class PositionNormalVertex {
  4140. /** the position of the vertex (defaut: 0,0,0) */
  4141. position: Vector3;
  4142. /** the normal of the vertex (defaut: 0,1,0) */
  4143. normal: Vector3;
  4144. /**
  4145. * Creates a PositionNormalVertex
  4146. * @param position the position of the vertex (defaut: 0,0,0)
  4147. * @param normal the normal of the vertex (defaut: 0,1,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3);
  4154. /**
  4155. * Clones the PositionNormalVertex
  4156. * @returns the cloned PositionNormalVertex
  4157. */
  4158. clone(): PositionNormalVertex;
  4159. }
  4160. /**
  4161. * Contains position, normal and uv vectors for a vertex
  4162. */
  4163. export class PositionNormalTextureVertex {
  4164. /** the position of the vertex (defaut: 0,0,0) */
  4165. position: Vector3;
  4166. /** the normal of the vertex (defaut: 0,1,0) */
  4167. normal: Vector3;
  4168. /** the uv of the vertex (default: 0,0) */
  4169. uv: Vector2;
  4170. /**
  4171. * Creates a PositionNormalTextureVertex
  4172. * @param position the position of the vertex (defaut: 0,0,0)
  4173. * @param normal the normal of the vertex (defaut: 0,1,0)
  4174. * @param uv the uv of the vertex (default: 0,0)
  4175. */
  4176. constructor(
  4177. /** the position of the vertex (defaut: 0,0,0) */
  4178. position?: Vector3,
  4179. /** the normal of the vertex (defaut: 0,1,0) */
  4180. normal?: Vector3,
  4181. /** the uv of the vertex (default: 0,0) */
  4182. uv?: Vector2);
  4183. /**
  4184. * Clones the PositionNormalTextureVertex
  4185. * @returns the cloned PositionNormalTextureVertex
  4186. */
  4187. clone(): PositionNormalTextureVertex;
  4188. }
  4189. /**
  4190. * @hidden
  4191. */
  4192. export class Tmp {
  4193. static Color3: Color3[];
  4194. static Color4: Color4[];
  4195. static Vector2: Vector2[];
  4196. static Vector3: Vector3[];
  4197. static Vector4: Vector4[];
  4198. static Quaternion: Quaternion[];
  4199. static Matrix: Matrix[];
  4200. }
  4201. }
  4202. declare module "babylonjs/Offline/IOfflineProvider" {
  4203. /**
  4204. * Class used to enable access to offline support
  4205. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4206. */
  4207. export interface IOfflineProvider {
  4208. /**
  4209. * Gets a boolean indicating if scene must be saved in the database
  4210. */
  4211. enableSceneOffline: boolean;
  4212. /**
  4213. * Gets a boolean indicating if textures must be saved in the database
  4214. */
  4215. enableTexturesOffline: boolean;
  4216. /**
  4217. * Open the offline support and make it available
  4218. * @param successCallback defines the callback to call on success
  4219. * @param errorCallback defines the callback to call on error
  4220. */
  4221. open(successCallback: () => void, errorCallback: () => void): void;
  4222. /**
  4223. * Loads an image from the offline support
  4224. * @param url defines the url to load from
  4225. * @param image defines the target DOM image
  4226. */
  4227. loadImage(url: string, image: HTMLImageElement): void;
  4228. /**
  4229. * Loads a file from offline support
  4230. * @param url defines the URL to load from
  4231. * @param sceneLoaded defines a callback to call on success
  4232. * @param progressCallBack defines a callback to call when progress changed
  4233. * @param errorCallback defines a callback to call on error
  4234. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4235. */
  4236. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4237. }
  4238. }
  4239. declare module "babylonjs/Misc/observable" {
  4240. import { Nullable } from "babylonjs/types";
  4241. /**
  4242. * A class serves as a medium between the observable and its observers
  4243. */
  4244. export class EventState {
  4245. /**
  4246. * Create a new EventState
  4247. * @param mask defines the mask associated with this state
  4248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4249. * @param target defines the original target of the state
  4250. * @param currentTarget defines the current target of the state
  4251. */
  4252. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4253. /**
  4254. * Initialize the current event state
  4255. * @param mask defines the mask associated with this state
  4256. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4257. * @param target defines the original target of the state
  4258. * @param currentTarget defines the current target of the state
  4259. * @returns the current event state
  4260. */
  4261. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4262. /**
  4263. * An Observer can set this property to true to prevent subsequent observers of being notified
  4264. */
  4265. skipNextObservers: boolean;
  4266. /**
  4267. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4268. */
  4269. mask: number;
  4270. /**
  4271. * The object that originally notified the event
  4272. */
  4273. target?: any;
  4274. /**
  4275. * The current object in the bubbling phase
  4276. */
  4277. currentTarget?: any;
  4278. /**
  4279. * This will be populated with the return value of the last function that was executed.
  4280. * If it is the first function in the callback chain it will be the event data.
  4281. */
  4282. lastReturnValue?: any;
  4283. }
  4284. /**
  4285. * Represent an Observer registered to a given Observable object.
  4286. */
  4287. export class Observer<T> {
  4288. /**
  4289. * Defines the callback to call when the observer is notified
  4290. */
  4291. callback: (eventData: T, eventState: EventState) => void;
  4292. /**
  4293. * Defines the mask of the observer (used to filter notifications)
  4294. */
  4295. mask: number;
  4296. /**
  4297. * Defines the current scope used to restore the JS context
  4298. */
  4299. scope: any;
  4300. /** @hidden */
  4301. _willBeUnregistered: boolean;
  4302. /**
  4303. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4304. */
  4305. unregisterOnNextCall: boolean;
  4306. /**
  4307. * Creates a new observer
  4308. * @param callback defines the callback to call when the observer is notified
  4309. * @param mask defines the mask of the observer (used to filter notifications)
  4310. * @param scope defines the current scope used to restore the JS context
  4311. */
  4312. constructor(
  4313. /**
  4314. * Defines the callback to call when the observer is notified
  4315. */
  4316. callback: (eventData: T, eventState: EventState) => void,
  4317. /**
  4318. * Defines the mask of the observer (used to filter notifications)
  4319. */
  4320. mask: number,
  4321. /**
  4322. * Defines the current scope used to restore the JS context
  4323. */
  4324. scope?: any);
  4325. }
  4326. /**
  4327. * Represent a list of observers registered to multiple Observables object.
  4328. */
  4329. export class MultiObserver<T> {
  4330. private _observers;
  4331. private _observables;
  4332. /**
  4333. * Release associated resources
  4334. */
  4335. dispose(): void;
  4336. /**
  4337. * Raise a callback when one of the observable will notify
  4338. * @param observables defines a list of observables to watch
  4339. * @param callback defines the callback to call on notification
  4340. * @param mask defines the mask used to filter notifications
  4341. * @param scope defines the current scope used to restore the JS context
  4342. * @returns the new MultiObserver
  4343. */
  4344. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4345. }
  4346. /**
  4347. * The Observable class is a simple implementation of the Observable pattern.
  4348. *
  4349. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4350. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4351. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4352. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4353. */
  4354. export class Observable<T> {
  4355. private _observers;
  4356. private _eventState;
  4357. private _onObserverAdded;
  4358. /**
  4359. * Creates a new observable
  4360. * @param onObserverAdded defines a callback to call when a new observer is added
  4361. */
  4362. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4363. /**
  4364. * Create a new Observer with the specified callback
  4365. * @param callback the callback that will be executed for that Observer
  4366. * @param mask the mask used to filter observers
  4367. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4368. * @param scope optional scope for the callback to be called from
  4369. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4370. * @returns the new observer created for the callback
  4371. */
  4372. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4373. /**
  4374. * Create a new Observer with the specified callback and unregisters after the next notification
  4375. * @param callback the callback that will be executed for that Observer
  4376. * @returns the new observer created for the callback
  4377. */
  4378. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4379. /**
  4380. * Remove an Observer from the Observable object
  4381. * @param observer the instance of the Observer to remove
  4382. * @returns false if it doesn't belong to this Observable
  4383. */
  4384. remove(observer: Nullable<Observer<T>>): boolean;
  4385. /**
  4386. * Remove a callback from the Observable object
  4387. * @param callback the callback to remove
  4388. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4389. * @returns false if it doesn't belong to this Observable
  4390. */
  4391. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4392. private _deferUnregister;
  4393. private _remove;
  4394. /**
  4395. * Moves the observable to the top of the observer list making it get called first when notified
  4396. * @param observer the observer to move
  4397. */
  4398. makeObserverTopPriority(observer: Observer<T>): void;
  4399. /**
  4400. * Moves the observable to the bottom of the observer list making it get called last when notified
  4401. * @param observer the observer to move
  4402. */
  4403. makeObserverBottomPriority(observer: Observer<T>): void;
  4404. /**
  4405. * Notify all Observers by calling their respective callback with the given data
  4406. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4407. * @param eventData defines the data to send to all observers
  4408. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4409. * @param target defines the original target of the state
  4410. * @param currentTarget defines the current target of the state
  4411. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4412. */
  4413. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4414. /**
  4415. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4416. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4417. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4418. * and it is crucial that all callbacks will be executed.
  4419. * The order of the callbacks is kept, callbacks are not executed parallel.
  4420. *
  4421. * @param eventData The data to be sent to each callback
  4422. * @param mask is used to filter observers defaults to -1
  4423. * @param target defines the callback target (see EventState)
  4424. * @param currentTarget defines he current object in the bubbling phase
  4425. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4426. */
  4427. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4428. /**
  4429. * Notify a specific observer
  4430. * @param observer defines the observer to notify
  4431. * @param eventData defines the data to be sent to each callback
  4432. * @param mask is used to filter observers defaults to -1
  4433. */
  4434. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4435. /**
  4436. * Gets a boolean indicating if the observable has at least one observer
  4437. * @returns true is the Observable has at least one Observer registered
  4438. */
  4439. hasObservers(): boolean;
  4440. /**
  4441. * Clear the list of observers
  4442. */
  4443. clear(): void;
  4444. /**
  4445. * Clone the current observable
  4446. * @returns a new observable
  4447. */
  4448. clone(): Observable<T>;
  4449. /**
  4450. * Does this observable handles observer registered with a given mask
  4451. * @param mask defines the mask to be tested
  4452. * @return whether or not one observer registered with the given mask is handeled
  4453. **/
  4454. hasSpecificMask(mask?: number): boolean;
  4455. }
  4456. }
  4457. declare module "babylonjs/Misc/filesInputStore" {
  4458. /**
  4459. * Class used to help managing file picking and drag'n'drop
  4460. * File Storage
  4461. */
  4462. export class FilesInputStore {
  4463. /**
  4464. * List of files ready to be loaded
  4465. */
  4466. static FilesToLoad: {
  4467. [key: string]: File;
  4468. };
  4469. }
  4470. }
  4471. declare module "babylonjs/Engines/constants" {
  4472. /** Defines the cross module used constants to avoid circular dependncies */
  4473. export class Constants {
  4474. /** Defines that alpha blending is disabled */
  4475. static readonly ALPHA_DISABLE: number;
  4476. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4477. static readonly ALPHA_ADD: number;
  4478. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4479. static readonly ALPHA_COMBINE: number;
  4480. /** Defines that alpha blending to DEST - SRC * DEST */
  4481. static readonly ALPHA_SUBTRACT: number;
  4482. /** Defines that alpha blending to SRC * DEST */
  4483. static readonly ALPHA_MULTIPLY: number;
  4484. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4485. static readonly ALPHA_MAXIMIZED: number;
  4486. /** Defines that alpha blending to SRC + DEST */
  4487. static readonly ALPHA_ONEONE: number;
  4488. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4489. static readonly ALPHA_PREMULTIPLIED: number;
  4490. /**
  4491. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4492. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4493. */
  4494. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4495. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4496. static readonly ALPHA_INTERPOLATE: number;
  4497. /**
  4498. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4499. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4500. */
  4501. static readonly ALPHA_SCREENMODE: number;
  4502. /** Defines that the ressource is not delayed*/
  4503. static readonly DELAYLOADSTATE_NONE: number;
  4504. /** Defines that the ressource was successfully delay loaded */
  4505. static readonly DELAYLOADSTATE_LOADED: number;
  4506. /** Defines that the ressource is currently delay loading */
  4507. static readonly DELAYLOADSTATE_LOADING: number;
  4508. /** Defines that the ressource is delayed and has not started loading */
  4509. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4510. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4511. static readonly NEVER: number;
  4512. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4513. static readonly ALWAYS: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4515. static readonly LESS: number;
  4516. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4517. static readonly EQUAL: number;
  4518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4519. static readonly LEQUAL: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4521. static readonly GREATER: number;
  4522. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4523. static readonly GEQUAL: number;
  4524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4525. static readonly NOTEQUAL: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be kept */
  4527. static readonly KEEP: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4529. static readonly REPLACE: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4531. static readonly INCR: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4533. static readonly DECR: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4535. static readonly INVERT: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4537. static readonly INCR_WRAP: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4539. static readonly DECR_WRAP: number;
  4540. /** Texture is not repeating outside of 0..1 UVs */
  4541. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4542. /** Texture is repeating outside of 0..1 UVs */
  4543. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4544. /** Texture is repeating and mirrored */
  4545. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4546. /** ALPHA */
  4547. static readonly TEXTUREFORMAT_ALPHA: number;
  4548. /** LUMINANCE */
  4549. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4550. /** LUMINANCE_ALPHA */
  4551. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4552. /** RGB */
  4553. static readonly TEXTUREFORMAT_RGB: number;
  4554. /** RGBA */
  4555. static readonly TEXTUREFORMAT_RGBA: number;
  4556. /** RED */
  4557. static readonly TEXTUREFORMAT_RED: number;
  4558. /** RED (2nd reference) */
  4559. static readonly TEXTUREFORMAT_R: number;
  4560. /** RG */
  4561. static readonly TEXTUREFORMAT_RG: number;
  4562. /** RED_INTEGER */
  4563. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4564. /** RED_INTEGER (2nd reference) */
  4565. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4566. /** RG_INTEGER */
  4567. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4568. /** RGB_INTEGER */
  4569. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4570. /** RGBA_INTEGER */
  4571. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4572. /** UNSIGNED_BYTE */
  4573. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4574. /** UNSIGNED_BYTE (2nd reference) */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4576. /** FLOAT */
  4577. static readonly TEXTURETYPE_FLOAT: number;
  4578. /** HALF_FLOAT */
  4579. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4580. /** BYTE */
  4581. static readonly TEXTURETYPE_BYTE: number;
  4582. /** SHORT */
  4583. static readonly TEXTURETYPE_SHORT: number;
  4584. /** UNSIGNED_SHORT */
  4585. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4586. /** INT */
  4587. static readonly TEXTURETYPE_INT: number;
  4588. /** UNSIGNED_INT */
  4589. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4590. /** UNSIGNED_SHORT_4_4_4_4 */
  4591. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4592. /** UNSIGNED_SHORT_5_5_5_1 */
  4593. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4594. /** UNSIGNED_SHORT_5_6_5 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4596. /** UNSIGNED_INT_2_10_10_10_REV */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4598. /** UNSIGNED_INT_24_8 */
  4599. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4600. /** UNSIGNED_INT_10F_11F_11F_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4602. /** UNSIGNED_INT_5_9_9_9_REV */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4604. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4605. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4606. /** nearest is mag = nearest and min = nearest and mip = linear */
  4607. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4608. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4609. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4610. /** Trilinear is mag = linear and min = linear and mip = linear */
  4611. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4612. /** nearest is mag = nearest and min = nearest and mip = linear */
  4613. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4614. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4615. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4616. /** Trilinear is mag = linear and min = linear and mip = linear */
  4617. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4618. /** mag = nearest and min = nearest and mip = nearest */
  4619. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4620. /** mag = nearest and min = linear and mip = nearest */
  4621. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4622. /** mag = nearest and min = linear and mip = linear */
  4623. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4624. /** mag = nearest and min = linear and mip = none */
  4625. static readonly TEXTURE_NEAREST_LINEAR: number;
  4626. /** mag = nearest and min = nearest and mip = none */
  4627. static readonly TEXTURE_NEAREST_NEAREST: number;
  4628. /** mag = linear and min = nearest and mip = nearest */
  4629. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4630. /** mag = linear and min = nearest and mip = linear */
  4631. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4632. /** mag = linear and min = linear and mip = none */
  4633. static readonly TEXTURE_LINEAR_LINEAR: number;
  4634. /** mag = linear and min = nearest and mip = none */
  4635. static readonly TEXTURE_LINEAR_NEAREST: number;
  4636. /** Explicit coordinates mode */
  4637. static readonly TEXTURE_EXPLICIT_MODE: number;
  4638. /** Spherical coordinates mode */
  4639. static readonly TEXTURE_SPHERICAL_MODE: number;
  4640. /** Planar coordinates mode */
  4641. static readonly TEXTURE_PLANAR_MODE: number;
  4642. /** Cubic coordinates mode */
  4643. static readonly TEXTURE_CUBIC_MODE: number;
  4644. /** Projection coordinates mode */
  4645. static readonly TEXTURE_PROJECTION_MODE: number;
  4646. /** Skybox coordinates mode */
  4647. static readonly TEXTURE_SKYBOX_MODE: number;
  4648. /** Inverse Cubic coordinates mode */
  4649. static readonly TEXTURE_INVCUBIC_MODE: number;
  4650. /** Equirectangular coordinates mode */
  4651. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4652. /** Equirectangular Fixed coordinates mode */
  4653. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4654. /** Equirectangular Fixed Mirrored coordinates mode */
  4655. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4656. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4657. static readonly SCALEMODE_FLOOR: number;
  4658. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4659. static readonly SCALEMODE_NEAREST: number;
  4660. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4661. static readonly SCALEMODE_CEILING: number;
  4662. /**
  4663. * The dirty texture flag value
  4664. */
  4665. static readonly MATERIAL_TextureDirtyFlag: number;
  4666. /**
  4667. * The dirty light flag value
  4668. */
  4669. static readonly MATERIAL_LightDirtyFlag: number;
  4670. /**
  4671. * The dirty fresnel flag value
  4672. */
  4673. static readonly MATERIAL_FresnelDirtyFlag: number;
  4674. /**
  4675. * The dirty attribute flag value
  4676. */
  4677. static readonly MATERIAL_AttributesDirtyFlag: number;
  4678. /**
  4679. * The dirty misc flag value
  4680. */
  4681. static readonly MATERIAL_MiscDirtyFlag: number;
  4682. /**
  4683. * The all dirty flag value
  4684. */
  4685. static readonly MATERIAL_AllDirtyFlag: number;
  4686. /**
  4687. * Returns the triangle fill mode
  4688. */
  4689. static readonly MATERIAL_TriangleFillMode: number;
  4690. /**
  4691. * Returns the wireframe mode
  4692. */
  4693. static readonly MATERIAL_WireFrameFillMode: number;
  4694. /**
  4695. * Returns the point fill mode
  4696. */
  4697. static readonly MATERIAL_PointFillMode: number;
  4698. /**
  4699. * Returns the point list draw mode
  4700. */
  4701. static readonly MATERIAL_PointListDrawMode: number;
  4702. /**
  4703. * Returns the line list draw mode
  4704. */
  4705. static readonly MATERIAL_LineListDrawMode: number;
  4706. /**
  4707. * Returns the line loop draw mode
  4708. */
  4709. static readonly MATERIAL_LineLoopDrawMode: number;
  4710. /**
  4711. * Returns the line strip draw mode
  4712. */
  4713. static readonly MATERIAL_LineStripDrawMode: number;
  4714. /**
  4715. * Returns the triangle strip draw mode
  4716. */
  4717. static readonly MATERIAL_TriangleStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle fan draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleFanDrawMode: number;
  4722. /**
  4723. * Stores the clock-wise side orientation
  4724. */
  4725. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4726. /**
  4727. * Stores the counter clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4730. /**
  4731. * Nothing
  4732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4733. */
  4734. static readonly ACTION_NothingTrigger: number;
  4735. /**
  4736. * On pick
  4737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4738. */
  4739. static readonly ACTION_OnPickTrigger: number;
  4740. /**
  4741. * On left pick
  4742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4743. */
  4744. static readonly ACTION_OnLeftPickTrigger: number;
  4745. /**
  4746. * On right pick
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnRightPickTrigger: number;
  4750. /**
  4751. * On center pick
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnCenterPickTrigger: number;
  4755. /**
  4756. * On pick down
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPickDownTrigger: number;
  4760. /**
  4761. * On double pick
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnDoublePickTrigger: number;
  4765. /**
  4766. * On pick up
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnPickUpTrigger: number;
  4770. /**
  4771. * On pick out.
  4772. * This trigger will only be raised if you also declared a OnPickDown
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnPickOutTrigger: number;
  4776. /**
  4777. * On long press
  4778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4779. */
  4780. static readonly ACTION_OnLongPressTrigger: number;
  4781. /**
  4782. * On pointer over
  4783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4784. */
  4785. static readonly ACTION_OnPointerOverTrigger: number;
  4786. /**
  4787. * On pointer out
  4788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4789. */
  4790. static readonly ACTION_OnPointerOutTrigger: number;
  4791. /**
  4792. * On every frame
  4793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4794. */
  4795. static readonly ACTION_OnEveryFrameTrigger: number;
  4796. /**
  4797. * On intersection enter
  4798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4799. */
  4800. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4801. /**
  4802. * On intersection exit
  4803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4804. */
  4805. static readonly ACTION_OnIntersectionExitTrigger: number;
  4806. /**
  4807. * On key down
  4808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4809. */
  4810. static readonly ACTION_OnKeyDownTrigger: number;
  4811. /**
  4812. * On key up
  4813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4814. */
  4815. static readonly ACTION_OnKeyUpTrigger: number;
  4816. /**
  4817. * Billboard mode will only apply to Y axis
  4818. */
  4819. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4820. /**
  4821. * Billboard mode will apply to all axes
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4824. /**
  4825. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4828. /**
  4829. * Gets or sets base Assets URL
  4830. */
  4831. static PARTICLES_BaseAssetsUrl: string;
  4832. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4833. * Test order :
  4834. * Is the bounding sphere outside the frustum ?
  4835. * If not, are the bounding box vertices outside the frustum ?
  4836. * It not, then the cullable object is in the frustum.
  4837. */
  4838. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4839. /** Culling strategy : Bounding Sphere Only.
  4840. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4841. * It's also less accurate than the standard because some not visible objects can still be selected.
  4842. * Test : is the bounding sphere outside the frustum ?
  4843. * If not, then the cullable object is in the frustum.
  4844. */
  4845. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4846. /** Culling strategy : Optimistic Inclusion.
  4847. * This in an inclusion test first, then the standard exclusion test.
  4848. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4849. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4850. * Anyway, it's as accurate as the standard strategy.
  4851. * Test :
  4852. * Is the cullable object bounding sphere center in the frustum ?
  4853. * If not, apply the default culling strategy.
  4854. */
  4855. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4856. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4857. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4858. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4859. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4860. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4861. * Test :
  4862. * Is the cullable object bounding sphere center in the frustum ?
  4863. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4864. */
  4865. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4866. /**
  4867. * No logging while loading
  4868. */
  4869. static readonly SCENELOADER_NO_LOGGING: number;
  4870. /**
  4871. * Minimal logging while loading
  4872. */
  4873. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4874. /**
  4875. * Summary logging while loading
  4876. */
  4877. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4878. /**
  4879. * Detailled logging while loading
  4880. */
  4881. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4882. }
  4883. }
  4884. declare module "babylonjs/Misc/domManagement" {
  4885. /**
  4886. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4887. * Babylon.js
  4888. */
  4889. export class DomManagement {
  4890. /**
  4891. * Checks if the window object exists
  4892. * @returns true if the window object exists
  4893. */
  4894. static IsWindowObjectExist(): boolean;
  4895. /**
  4896. * Extracts text content from a DOM element hierarchy
  4897. * @param element defines the root element
  4898. * @returns a string
  4899. */
  4900. static GetDOMTextContent(element: HTMLElement): string;
  4901. }
  4902. }
  4903. declare module "babylonjs/Misc/logger" {
  4904. /**
  4905. * Logger used througouht the application to allow configuration of
  4906. * the log level required for the messages.
  4907. */
  4908. export class Logger {
  4909. /**
  4910. * No log
  4911. */
  4912. static readonly NoneLogLevel: number;
  4913. /**
  4914. * Only message logs
  4915. */
  4916. static readonly MessageLogLevel: number;
  4917. /**
  4918. * Only warning logs
  4919. */
  4920. static readonly WarningLogLevel: number;
  4921. /**
  4922. * Only error logs
  4923. */
  4924. static readonly ErrorLogLevel: number;
  4925. /**
  4926. * All logs
  4927. */
  4928. static readonly AllLogLevel: number;
  4929. private static _LogCache;
  4930. /**
  4931. * Gets a value indicating the number of loading errors
  4932. * @ignorenaming
  4933. */
  4934. static errorsCount: number;
  4935. /**
  4936. * Callback called when a new log is added
  4937. */
  4938. static OnNewCacheEntry: (entry: string) => void;
  4939. private static _AddLogEntry;
  4940. private static _FormatMessage;
  4941. private static _LogDisabled;
  4942. private static _LogEnabled;
  4943. private static _WarnDisabled;
  4944. private static _WarnEnabled;
  4945. private static _ErrorDisabled;
  4946. private static _ErrorEnabled;
  4947. /**
  4948. * Log a message to the console
  4949. */
  4950. static Log: (message: string) => void;
  4951. /**
  4952. * Write a warning message to the console
  4953. */
  4954. static Warn: (message: string) => void;
  4955. /**
  4956. * Write an error message to the console
  4957. */
  4958. static Error: (message: string) => void;
  4959. /**
  4960. * Gets current log cache (list of logs)
  4961. */
  4962. static readonly LogCache: string;
  4963. /**
  4964. * Clears the log cache
  4965. */
  4966. static ClearLogCache(): void;
  4967. /**
  4968. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4969. */
  4970. static LogLevels: number;
  4971. }
  4972. }
  4973. declare module "babylonjs/Misc/typeStore" {
  4974. /** @hidden */
  4975. export class _TypeStore {
  4976. /** @hidden */
  4977. static RegisteredTypes: {
  4978. [key: string]: Object;
  4979. };
  4980. /** @hidden */
  4981. static GetClass(fqdn: string): any;
  4982. }
  4983. }
  4984. declare module "babylonjs/Misc/deepCopier" {
  4985. /**
  4986. * Class containing a set of static utilities functions for deep copy.
  4987. */
  4988. export class DeepCopier {
  4989. /**
  4990. * Tries to copy an object by duplicating every property
  4991. * @param source defines the source object
  4992. * @param destination defines the target object
  4993. * @param doNotCopyList defines a list of properties to avoid
  4994. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4995. */
  4996. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4997. }
  4998. }
  4999. declare module "babylonjs/Misc/precisionDate" {
  5000. /**
  5001. * Class containing a set of static utilities functions for precision date
  5002. */
  5003. export class PrecisionDate {
  5004. /**
  5005. * Gets either window.performance.now() if supported or Date.now() else
  5006. */
  5007. static readonly Now: number;
  5008. }
  5009. }
  5010. declare module "babylonjs/Misc/devTools" {
  5011. /** @hidden */
  5012. export class _DevTools {
  5013. static WarnImport(name: string): string;
  5014. }
  5015. }
  5016. declare module "babylonjs/Misc/webRequest" {
  5017. /**
  5018. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5019. */
  5020. export class WebRequest {
  5021. private _xhr;
  5022. /**
  5023. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5024. * i.e. when loading files, where the server/service expects an Authorization header
  5025. */
  5026. static CustomRequestHeaders: {
  5027. [key: string]: string;
  5028. };
  5029. /**
  5030. * Add callback functions in this array to update all the requests before they get sent to the network
  5031. */
  5032. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5033. private _injectCustomRequestHeaders;
  5034. /**
  5035. * Gets or sets a function to be called when loading progress changes
  5036. */
  5037. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5038. /**
  5039. * Returns client's state
  5040. */
  5041. readonly readyState: number;
  5042. /**
  5043. * Returns client's status
  5044. */
  5045. readonly status: number;
  5046. /**
  5047. * Returns client's status as a text
  5048. */
  5049. readonly statusText: string;
  5050. /**
  5051. * Returns client's response
  5052. */
  5053. readonly response: any;
  5054. /**
  5055. * Returns client's response url
  5056. */
  5057. readonly responseURL: string;
  5058. /**
  5059. * Returns client's response as text
  5060. */
  5061. readonly responseText: string;
  5062. /**
  5063. * Gets or sets the expected response type
  5064. */
  5065. responseType: XMLHttpRequestResponseType;
  5066. /** @hidden */
  5067. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5068. /** @hidden */
  5069. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5070. /**
  5071. * Cancels any network activity
  5072. */
  5073. abort(): void;
  5074. /**
  5075. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5076. * @param body defines an optional request body
  5077. */
  5078. send(body?: Document | BodyInit | null): void;
  5079. /**
  5080. * Sets the request method, request URL
  5081. * @param method defines the method to use (GET, POST, etc..)
  5082. * @param url defines the url to connect with
  5083. */
  5084. open(method: string, url: string): void;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5088. /**
  5089. * Class used to evalaute queries containing `and` and `or` operators
  5090. */
  5091. export class AndOrNotEvaluator {
  5092. /**
  5093. * Evaluate a query
  5094. * @param query defines the query to evaluate
  5095. * @param evaluateCallback defines the callback used to filter result
  5096. * @returns true if the query matches
  5097. */
  5098. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5099. private static _HandleParenthesisContent;
  5100. private static _SimplifyNegation;
  5101. }
  5102. }
  5103. declare module "babylonjs/Misc/tags" {
  5104. /**
  5105. * Class used to store custom tags
  5106. */
  5107. export class Tags {
  5108. /**
  5109. * Adds support for tags on the given object
  5110. * @param obj defines the object to use
  5111. */
  5112. static EnableFor(obj: any): void;
  5113. /**
  5114. * Removes tags support
  5115. * @param obj defines the object to use
  5116. */
  5117. static DisableFor(obj: any): void;
  5118. /**
  5119. * Gets a boolean indicating if the given object has tags
  5120. * @param obj defines the object to use
  5121. * @returns a boolean
  5122. */
  5123. static HasTags(obj: any): boolean;
  5124. /**
  5125. * Gets the tags available on a given object
  5126. * @param obj defines the object to use
  5127. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5128. * @returns the tags
  5129. */
  5130. static GetTags(obj: any, asString?: boolean): any;
  5131. /**
  5132. * Adds tags to an object
  5133. * @param obj defines the object to use
  5134. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5135. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5136. */
  5137. static AddTagsTo(obj: any, tagsString: string): void;
  5138. /**
  5139. * @hidden
  5140. */
  5141. static _AddTagTo(obj: any, tag: string): void;
  5142. /**
  5143. * Removes specific tags from a specific object
  5144. * @param obj defines the object to use
  5145. * @param tagsString defines the tags to remove
  5146. */
  5147. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5148. /**
  5149. * @hidden
  5150. */
  5151. static _RemoveTagFrom(obj: any, tag: string): void;
  5152. /**
  5153. * Defines if tags hosted on an object match a given query
  5154. * @param obj defines the object to use
  5155. * @param tagsQuery defines the tag query
  5156. * @returns a boolean
  5157. */
  5158. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5159. }
  5160. }
  5161. declare module "babylonjs/Materials/materialDefines" {
  5162. /**
  5163. * Manages the defines for the Material
  5164. */
  5165. export class MaterialDefines {
  5166. /** @hidden */
  5167. protected _keys: string[];
  5168. private _isDirty;
  5169. /** @hidden */
  5170. _renderId: number;
  5171. /** @hidden */
  5172. _areLightsDirty: boolean;
  5173. /** @hidden */
  5174. _areAttributesDirty: boolean;
  5175. /** @hidden */
  5176. _areTexturesDirty: boolean;
  5177. /** @hidden */
  5178. _areFresnelDirty: boolean;
  5179. /** @hidden */
  5180. _areMiscDirty: boolean;
  5181. /** @hidden */
  5182. _areImageProcessingDirty: boolean;
  5183. /** @hidden */
  5184. _normals: boolean;
  5185. /** @hidden */
  5186. _uvs: boolean;
  5187. /** @hidden */
  5188. _needNormals: boolean;
  5189. /** @hidden */
  5190. _needUVs: boolean;
  5191. [id: string]: any;
  5192. /**
  5193. * Specifies if the material needs to be re-calculated
  5194. */
  5195. readonly isDirty: boolean;
  5196. /**
  5197. * Marks the material to indicate that it has been re-calculated
  5198. */
  5199. markAsProcessed(): void;
  5200. /**
  5201. * Marks the material to indicate that it needs to be re-calculated
  5202. */
  5203. markAsUnprocessed(): void;
  5204. /**
  5205. * Marks the material to indicate all of its defines need to be re-calculated
  5206. */
  5207. markAllAsDirty(): void;
  5208. /**
  5209. * Marks the material to indicate that image processing needs to be re-calculated
  5210. */
  5211. markAsImageProcessingDirty(): void;
  5212. /**
  5213. * Marks the material to indicate the lights need to be re-calculated
  5214. */
  5215. markAsLightDirty(): void;
  5216. /**
  5217. * Marks the attribute state as changed
  5218. */
  5219. markAsAttributesDirty(): void;
  5220. /**
  5221. * Marks the texture state as changed
  5222. */
  5223. markAsTexturesDirty(): void;
  5224. /**
  5225. * Marks the fresnel state as changed
  5226. */
  5227. markAsFresnelDirty(): void;
  5228. /**
  5229. * Marks the misc state as changed
  5230. */
  5231. markAsMiscDirty(): void;
  5232. /**
  5233. * Rebuilds the material defines
  5234. */
  5235. rebuild(): void;
  5236. /**
  5237. * Specifies if two material defines are equal
  5238. * @param other - A material define instance to compare to
  5239. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5240. */
  5241. isEqual(other: MaterialDefines): boolean;
  5242. /**
  5243. * Clones this instance's defines to another instance
  5244. * @param other - material defines to clone values to
  5245. */
  5246. cloneTo(other: MaterialDefines): void;
  5247. /**
  5248. * Resets the material define values
  5249. */
  5250. reset(): void;
  5251. /**
  5252. * Converts the material define values to a string
  5253. * @returns - String of material define information
  5254. */
  5255. toString(): string;
  5256. }
  5257. }
  5258. declare module "babylonjs/Engines/IPipelineContext" {
  5259. /**
  5260. * Class used to store and describe the pipeline context associated with an effect
  5261. */
  5262. export interface IPipelineContext {
  5263. /**
  5264. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5265. */
  5266. isAsync: boolean;
  5267. /**
  5268. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5269. */
  5270. isReady: boolean;
  5271. /** @hidden */
  5272. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5273. }
  5274. }
  5275. declare module "babylonjs/Meshes/dataBuffer" {
  5276. /**
  5277. * Class used to store gfx data (like WebGLBuffer)
  5278. */
  5279. export class DataBuffer {
  5280. /**
  5281. * Gets or sets the number of objects referencing this buffer
  5282. */
  5283. references: number;
  5284. /** Gets or sets the size of the underlying buffer */
  5285. capacity: number;
  5286. /**
  5287. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5288. */
  5289. is32Bits: boolean;
  5290. /**
  5291. * Gets the underlying buffer
  5292. */
  5293. readonly underlyingResource: any;
  5294. }
  5295. }
  5296. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  5297. /** @hidden */
  5298. export interface IShaderProcessor {
  5299. attributeProcessor?: (attribute: string) => string;
  5300. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5301. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5302. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5303. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5304. lineProcessor?: (line: string, isFragment: boolean) => string;
  5305. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5306. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5307. }
  5308. }
  5309. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  5310. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  5311. /** @hidden */
  5312. export interface ProcessingOptions {
  5313. defines: string[];
  5314. indexParameters: any;
  5315. isFragment: boolean;
  5316. shouldUseHighPrecisionShader: boolean;
  5317. supportsUniformBuffers: boolean;
  5318. shadersRepository: string;
  5319. includesShadersStore: {
  5320. [key: string]: string;
  5321. };
  5322. processor?: IShaderProcessor;
  5323. version: string;
  5324. platformName: string;
  5325. lookForClosingBracketForUniformBuffer?: boolean;
  5326. }
  5327. }
  5328. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5329. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5330. /** @hidden */
  5331. export class ShaderCodeNode {
  5332. line: string;
  5333. children: ShaderCodeNode[];
  5334. additionalDefineKey?: string;
  5335. additionalDefineValue?: string;
  5336. isValid(preprocessors: {
  5337. [key: string]: string;
  5338. }): boolean;
  5339. process(preprocessors: {
  5340. [key: string]: string;
  5341. }, options: ProcessingOptions): string;
  5342. }
  5343. }
  5344. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5345. /** @hidden */
  5346. export class ShaderCodeCursor {
  5347. private _lines;
  5348. lineIndex: number;
  5349. readonly currentLine: string;
  5350. readonly canRead: boolean;
  5351. lines: string[];
  5352. }
  5353. }
  5354. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5355. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5356. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5357. /** @hidden */
  5358. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5359. process(preprocessors: {
  5360. [key: string]: string;
  5361. }, options: ProcessingOptions): string;
  5362. }
  5363. }
  5364. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5365. /** @hidden */
  5366. export class ShaderDefineExpression {
  5367. isTrue(preprocessors: {
  5368. [key: string]: string;
  5369. }): boolean;
  5370. }
  5371. }
  5372. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5373. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5374. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5375. /** @hidden */
  5376. export class ShaderCodeTestNode extends ShaderCodeNode {
  5377. testExpression: ShaderDefineExpression;
  5378. isValid(preprocessors: {
  5379. [key: string]: string;
  5380. }): boolean;
  5381. }
  5382. }
  5383. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5384. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5385. /** @hidden */
  5386. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5387. define: string;
  5388. not: boolean;
  5389. constructor(define: string, not?: boolean);
  5390. isTrue(preprocessors: {
  5391. [key: string]: string;
  5392. }): boolean;
  5393. }
  5394. }
  5395. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5396. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5397. /** @hidden */
  5398. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5399. leftOperand: ShaderDefineExpression;
  5400. rightOperand: ShaderDefineExpression;
  5401. isTrue(preprocessors: {
  5402. [key: string]: string;
  5403. }): boolean;
  5404. }
  5405. }
  5406. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5407. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5408. /** @hidden */
  5409. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5410. leftOperand: ShaderDefineExpression;
  5411. rightOperand: ShaderDefineExpression;
  5412. isTrue(preprocessors: {
  5413. [key: string]: string;
  5414. }): boolean;
  5415. }
  5416. }
  5417. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5418. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5419. /** @hidden */
  5420. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5421. define: string;
  5422. operand: string;
  5423. testValue: string;
  5424. constructor(define: string, operand: string, testValue: string);
  5425. isTrue(preprocessors: {
  5426. [key: string]: string;
  5427. }): boolean;
  5428. }
  5429. }
  5430. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5431. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5432. /** @hidden */
  5433. export class ShaderProcessor {
  5434. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5435. private static _ProcessPrecision;
  5436. private static _ExtractOperation;
  5437. private static _BuildSubExpression;
  5438. private static _BuildExpression;
  5439. private static _MoveCursorWithinIf;
  5440. private static _MoveCursor;
  5441. private static _EvaluatePreProcessors;
  5442. private static _PreparePreProcessors;
  5443. private static _ProcessShaderConversion;
  5444. private static _ProcessIncludes;
  5445. }
  5446. }
  5447. declare module "babylonjs/Misc/performanceMonitor" {
  5448. /**
  5449. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5450. */
  5451. export class PerformanceMonitor {
  5452. private _enabled;
  5453. private _rollingFrameTime;
  5454. private _lastFrameTimeMs;
  5455. /**
  5456. * constructor
  5457. * @param frameSampleSize The number of samples required to saturate the sliding window
  5458. */
  5459. constructor(frameSampleSize?: number);
  5460. /**
  5461. * Samples current frame
  5462. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5463. */
  5464. sampleFrame(timeMs?: number): void;
  5465. /**
  5466. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5467. */
  5468. readonly averageFrameTime: number;
  5469. /**
  5470. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5471. */
  5472. readonly averageFrameTimeVariance: number;
  5473. /**
  5474. * Returns the frame time of the most recent frame
  5475. */
  5476. readonly instantaneousFrameTime: number;
  5477. /**
  5478. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5479. */
  5480. readonly averageFPS: number;
  5481. /**
  5482. * Returns the average framerate in frames per second using the most recent frame time
  5483. */
  5484. readonly instantaneousFPS: number;
  5485. /**
  5486. * Returns true if enough samples have been taken to completely fill the sliding window
  5487. */
  5488. readonly isSaturated: boolean;
  5489. /**
  5490. * Enables contributions to the sliding window sample set
  5491. */
  5492. enable(): void;
  5493. /**
  5494. * Disables contributions to the sliding window sample set
  5495. * Samples will not be interpolated over the disabled period
  5496. */
  5497. disable(): void;
  5498. /**
  5499. * Returns true if sampling is enabled
  5500. */
  5501. readonly isEnabled: boolean;
  5502. /**
  5503. * Resets performance monitor
  5504. */
  5505. reset(): void;
  5506. }
  5507. /**
  5508. * RollingAverage
  5509. *
  5510. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5511. */
  5512. export class RollingAverage {
  5513. /**
  5514. * Current average
  5515. */
  5516. average: number;
  5517. /**
  5518. * Current variance
  5519. */
  5520. variance: number;
  5521. protected _samples: Array<number>;
  5522. protected _sampleCount: number;
  5523. protected _pos: number;
  5524. protected _m2: number;
  5525. /**
  5526. * constructor
  5527. * @param length The number of samples required to saturate the sliding window
  5528. */
  5529. constructor(length: number);
  5530. /**
  5531. * Adds a sample to the sample set
  5532. * @param v The sample value
  5533. */
  5534. add(v: number): void;
  5535. /**
  5536. * Returns previously added values or null if outside of history or outside the sliding window domain
  5537. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5538. * @return Value previously recorded with add() or null if outside of range
  5539. */
  5540. history(i: number): number;
  5541. /**
  5542. * Returns true if enough samples have been taken to completely fill the sliding window
  5543. * @return true if sample-set saturated
  5544. */
  5545. isSaturated(): boolean;
  5546. /**
  5547. * Resets the rolling average (equivalent to 0 samples taken so far)
  5548. */
  5549. reset(): void;
  5550. /**
  5551. * Wraps a value around the sample range boundaries
  5552. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5553. * @return Wrapped position in sample range
  5554. */
  5555. protected _wrapPosition(i: number): number;
  5556. }
  5557. }
  5558. declare module "babylonjs/Misc/stringDictionary" {
  5559. import { Nullable } from "babylonjs/types";
  5560. /**
  5561. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5562. * The underlying implementation relies on an associative array to ensure the best performances.
  5563. * The value can be anything including 'null' but except 'undefined'
  5564. */
  5565. export class StringDictionary<T> {
  5566. /**
  5567. * This will clear this dictionary and copy the content from the 'source' one.
  5568. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5569. * @param source the dictionary to take the content from and copy to this dictionary
  5570. */
  5571. copyFrom(source: StringDictionary<T>): void;
  5572. /**
  5573. * Get a value based from its key
  5574. * @param key the given key to get the matching value from
  5575. * @return the value if found, otherwise undefined is returned
  5576. */
  5577. get(key: string): T | undefined;
  5578. /**
  5579. * Get a value from its key or add it if it doesn't exist.
  5580. * This method will ensure you that a given key/data will be present in the dictionary.
  5581. * @param key the given key to get the matching value from
  5582. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5583. * The factory will only be invoked if there's no data for the given key.
  5584. * @return the value corresponding to the key.
  5585. */
  5586. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5587. /**
  5588. * Get a value from its key if present in the dictionary otherwise add it
  5589. * @param key the key to get the value from
  5590. * @param val if there's no such key/value pair in the dictionary add it with this value
  5591. * @return the value corresponding to the key
  5592. */
  5593. getOrAdd(key: string, val: T): T;
  5594. /**
  5595. * Check if there's a given key in the dictionary
  5596. * @param key the key to check for
  5597. * @return true if the key is present, false otherwise
  5598. */
  5599. contains(key: string): boolean;
  5600. /**
  5601. * Add a new key and its corresponding value
  5602. * @param key the key to add
  5603. * @param value the value corresponding to the key
  5604. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5605. */
  5606. add(key: string, value: T): boolean;
  5607. /**
  5608. * Update a specific value associated to a key
  5609. * @param key defines the key to use
  5610. * @param value defines the value to store
  5611. * @returns true if the value was updated (or false if the key was not found)
  5612. */
  5613. set(key: string, value: T): boolean;
  5614. /**
  5615. * Get the element of the given key and remove it from the dictionary
  5616. * @param key defines the key to search
  5617. * @returns the value associated with the key or null if not found
  5618. */
  5619. getAndRemove(key: string): Nullable<T>;
  5620. /**
  5621. * Remove a key/value from the dictionary.
  5622. * @param key the key to remove
  5623. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5624. */
  5625. remove(key: string): boolean;
  5626. /**
  5627. * Clear the whole content of the dictionary
  5628. */
  5629. clear(): void;
  5630. /**
  5631. * Gets the current count
  5632. */
  5633. readonly count: number;
  5634. /**
  5635. * Execute a callback on each key/val of the dictionary.
  5636. * Note that you can remove any element in this dictionary in the callback implementation
  5637. * @param callback the callback to execute on a given key/value pair
  5638. */
  5639. forEach(callback: (key: string, val: T) => void): void;
  5640. /**
  5641. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5642. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5643. * Note that you can remove any element in this dictionary in the callback implementation
  5644. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5645. * @returns the first item
  5646. */
  5647. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5648. private _count;
  5649. private _data;
  5650. }
  5651. }
  5652. declare module "babylonjs/Misc/promise" {
  5653. /**
  5654. * Helper class that provides a small promise polyfill
  5655. */
  5656. export class PromisePolyfill {
  5657. /**
  5658. * Static function used to check if the polyfill is required
  5659. * If this is the case then the function will inject the polyfill to window.Promise
  5660. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5661. */
  5662. static Apply(force?: boolean): void;
  5663. }
  5664. }
  5665. declare module "babylonjs/Meshes/buffer" {
  5666. import { Nullable, DataArray } from "babylonjs/types";
  5667. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5668. /**
  5669. * Class used to store data that will be store in GPU memory
  5670. */
  5671. export class Buffer {
  5672. private _engine;
  5673. private _buffer;
  5674. /** @hidden */
  5675. _data: Nullable<DataArray>;
  5676. private _updatable;
  5677. private _instanced;
  5678. /**
  5679. * Gets the byte stride.
  5680. */
  5681. readonly byteStride: number;
  5682. /**
  5683. * Constructor
  5684. * @param engine the engine
  5685. * @param data the data to use for this buffer
  5686. * @param updatable whether the data is updatable
  5687. * @param stride the stride (optional)
  5688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5689. * @param instanced whether the buffer is instanced (optional)
  5690. * @param useBytes set to true if the stride in in bytes (optional)
  5691. */
  5692. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5693. /**
  5694. * Create a new VertexBuffer based on the current buffer
  5695. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5696. * @param offset defines offset in the buffer (0 by default)
  5697. * @param size defines the size in floats of attributes (position is 3 for instance)
  5698. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5699. * @param instanced defines if the vertex buffer contains indexed data
  5700. * @param useBytes defines if the offset and stride are in bytes
  5701. * @returns the new vertex buffer
  5702. */
  5703. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5704. /**
  5705. * Gets a boolean indicating if the Buffer is updatable?
  5706. * @returns true if the buffer is updatable
  5707. */
  5708. isUpdatable(): boolean;
  5709. /**
  5710. * Gets current buffer's data
  5711. * @returns a DataArray or null
  5712. */
  5713. getData(): Nullable<DataArray>;
  5714. /**
  5715. * Gets underlying native buffer
  5716. * @returns underlying native buffer
  5717. */
  5718. getBuffer(): Nullable<DataBuffer>;
  5719. /**
  5720. * Gets the stride in float32 units (i.e. byte stride / 4).
  5721. * May not be an integer if the byte stride is not divisible by 4.
  5722. * DEPRECATED. Use byteStride instead.
  5723. * @returns the stride in float32 units
  5724. */
  5725. getStrideSize(): number;
  5726. /**
  5727. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5728. * @param data defines the data to store
  5729. */
  5730. create(data?: Nullable<DataArray>): void;
  5731. /** @hidden */
  5732. _rebuild(): void;
  5733. /**
  5734. * Update current buffer data
  5735. * @param data defines the data to store
  5736. */
  5737. update(data: DataArray): void;
  5738. /**
  5739. * Updates the data directly.
  5740. * @param data the new data
  5741. * @param offset the new offset
  5742. * @param vertexCount the vertex count (optional)
  5743. * @param useBytes set to true if the offset is in bytes
  5744. */
  5745. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5746. /**
  5747. * Release all resources
  5748. */
  5749. dispose(): void;
  5750. }
  5751. /**
  5752. * Specialized buffer used to store vertex data
  5753. */
  5754. export class VertexBuffer {
  5755. /** @hidden */
  5756. _buffer: Buffer;
  5757. private _kind;
  5758. private _size;
  5759. private _ownsBuffer;
  5760. private _instanced;
  5761. private _instanceDivisor;
  5762. /**
  5763. * The byte type.
  5764. */
  5765. static readonly BYTE: number;
  5766. /**
  5767. * The unsigned byte type.
  5768. */
  5769. static readonly UNSIGNED_BYTE: number;
  5770. /**
  5771. * The short type.
  5772. */
  5773. static readonly SHORT: number;
  5774. /**
  5775. * The unsigned short type.
  5776. */
  5777. static readonly UNSIGNED_SHORT: number;
  5778. /**
  5779. * The integer type.
  5780. */
  5781. static readonly INT: number;
  5782. /**
  5783. * The unsigned integer type.
  5784. */
  5785. static readonly UNSIGNED_INT: number;
  5786. /**
  5787. * The float type.
  5788. */
  5789. static readonly FLOAT: number;
  5790. /**
  5791. * Gets or sets the instance divisor when in instanced mode
  5792. */
  5793. instanceDivisor: number;
  5794. /**
  5795. * Gets the byte stride.
  5796. */
  5797. readonly byteStride: number;
  5798. /**
  5799. * Gets the byte offset.
  5800. */
  5801. readonly byteOffset: number;
  5802. /**
  5803. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5804. */
  5805. readonly normalized: boolean;
  5806. /**
  5807. * Gets the data type of each component in the array.
  5808. */
  5809. readonly type: number;
  5810. /**
  5811. * Constructor
  5812. * @param engine the engine
  5813. * @param data the data to use for this vertex buffer
  5814. * @param kind the vertex buffer kind
  5815. * @param updatable whether the data is updatable
  5816. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5817. * @param stride the stride (optional)
  5818. * @param instanced whether the buffer is instanced (optional)
  5819. * @param offset the offset of the data (optional)
  5820. * @param size the number of components (optional)
  5821. * @param type the type of the component (optional)
  5822. * @param normalized whether the data contains normalized data (optional)
  5823. * @param useBytes set to true if stride and offset are in bytes (optional)
  5824. */
  5825. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5826. /** @hidden */
  5827. _rebuild(): void;
  5828. /**
  5829. * Returns the kind of the VertexBuffer (string)
  5830. * @returns a string
  5831. */
  5832. getKind(): string;
  5833. /**
  5834. * Gets a boolean indicating if the VertexBuffer is updatable?
  5835. * @returns true if the buffer is updatable
  5836. */
  5837. isUpdatable(): boolean;
  5838. /**
  5839. * Gets current buffer's data
  5840. * @returns a DataArray or null
  5841. */
  5842. getData(): Nullable<DataArray>;
  5843. /**
  5844. * Gets underlying native buffer
  5845. * @returns underlying native buffer
  5846. */
  5847. getBuffer(): Nullable<DataBuffer>;
  5848. /**
  5849. * Gets the stride in float32 units (i.e. byte stride / 4).
  5850. * May not be an integer if the byte stride is not divisible by 4.
  5851. * DEPRECATED. Use byteStride instead.
  5852. * @returns the stride in float32 units
  5853. */
  5854. getStrideSize(): number;
  5855. /**
  5856. * Returns the offset as a multiple of the type byte length.
  5857. * DEPRECATED. Use byteOffset instead.
  5858. * @returns the offset in bytes
  5859. */
  5860. getOffset(): number;
  5861. /**
  5862. * Returns the number of components per vertex attribute (integer)
  5863. * @returns the size in float
  5864. */
  5865. getSize(): number;
  5866. /**
  5867. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5868. * @returns true if this buffer is instanced
  5869. */
  5870. getIsInstanced(): boolean;
  5871. /**
  5872. * Returns the instancing divisor, zero for non-instanced (integer).
  5873. * @returns a number
  5874. */
  5875. getInstanceDivisor(): number;
  5876. /**
  5877. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5878. * @param data defines the data to store
  5879. */
  5880. create(data?: DataArray): void;
  5881. /**
  5882. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5883. * This function will create a new buffer if the current one is not updatable
  5884. * @param data defines the data to store
  5885. */
  5886. update(data: DataArray): void;
  5887. /**
  5888. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5889. * Returns the directly updated WebGLBuffer.
  5890. * @param data the new data
  5891. * @param offset the new offset
  5892. * @param useBytes set to true if the offset is in bytes
  5893. */
  5894. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5895. /**
  5896. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5897. */
  5898. dispose(): void;
  5899. /**
  5900. * Enumerates each value of this vertex buffer as numbers.
  5901. * @param count the number of values to enumerate
  5902. * @param callback the callback function called for each value
  5903. */
  5904. forEach(count: number, callback: (value: number, index: number) => void): void;
  5905. /**
  5906. * Positions
  5907. */
  5908. static readonly PositionKind: string;
  5909. /**
  5910. * Normals
  5911. */
  5912. static readonly NormalKind: string;
  5913. /**
  5914. * Tangents
  5915. */
  5916. static readonly TangentKind: string;
  5917. /**
  5918. * Texture coordinates
  5919. */
  5920. static readonly UVKind: string;
  5921. /**
  5922. * Texture coordinates 2
  5923. */
  5924. static readonly UV2Kind: string;
  5925. /**
  5926. * Texture coordinates 3
  5927. */
  5928. static readonly UV3Kind: string;
  5929. /**
  5930. * Texture coordinates 4
  5931. */
  5932. static readonly UV4Kind: string;
  5933. /**
  5934. * Texture coordinates 5
  5935. */
  5936. static readonly UV5Kind: string;
  5937. /**
  5938. * Texture coordinates 6
  5939. */
  5940. static readonly UV6Kind: string;
  5941. /**
  5942. * Colors
  5943. */
  5944. static readonly ColorKind: string;
  5945. /**
  5946. * Matrix indices (for bones)
  5947. */
  5948. static readonly MatricesIndicesKind: string;
  5949. /**
  5950. * Matrix weights (for bones)
  5951. */
  5952. static readonly MatricesWeightsKind: string;
  5953. /**
  5954. * Additional matrix indices (for bones)
  5955. */
  5956. static readonly MatricesIndicesExtraKind: string;
  5957. /**
  5958. * Additional matrix weights (for bones)
  5959. */
  5960. static readonly MatricesWeightsExtraKind: string;
  5961. /**
  5962. * Deduces the stride given a kind.
  5963. * @param kind The kind string to deduce
  5964. * @returns The deduced stride
  5965. */
  5966. static DeduceStride(kind: string): number;
  5967. /**
  5968. * Gets the byte length of the given type.
  5969. * @param type the type
  5970. * @returns the number of bytes
  5971. */
  5972. static GetTypeByteLength(type: number): number;
  5973. /**
  5974. * Enumerates each value of the given parameters as numbers.
  5975. * @param data the data to enumerate
  5976. * @param byteOffset the byte offset of the data
  5977. * @param byteStride the byte stride of the data
  5978. * @param componentCount the number of components per element
  5979. * @param componentType the type of the component
  5980. * @param count the number of values to enumerate
  5981. * @param normalized whether the data is normalized
  5982. * @param callback the callback function called for each value
  5983. */
  5984. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5985. private static _GetFloatValue;
  5986. }
  5987. }
  5988. declare module "babylonjs/Maths/sphericalPolynomial" {
  5989. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5990. /**
  5991. * Class representing spherical harmonics coefficients to the 3rd degree
  5992. */
  5993. export class SphericalHarmonics {
  5994. /**
  5995. * Defines whether or not the harmonics have been prescaled for rendering.
  5996. */
  5997. preScaled: boolean;
  5998. /**
  5999. * The l0,0 coefficients of the spherical harmonics
  6000. */
  6001. l00: Vector3;
  6002. /**
  6003. * The l1,-1 coefficients of the spherical harmonics
  6004. */
  6005. l1_1: Vector3;
  6006. /**
  6007. * The l1,0 coefficients of the spherical harmonics
  6008. */
  6009. l10: Vector3;
  6010. /**
  6011. * The l1,1 coefficients of the spherical harmonics
  6012. */
  6013. l11: Vector3;
  6014. /**
  6015. * The l2,-2 coefficients of the spherical harmonics
  6016. */
  6017. l2_2: Vector3;
  6018. /**
  6019. * The l2,-1 coefficients of the spherical harmonics
  6020. */
  6021. l2_1: Vector3;
  6022. /**
  6023. * The l2,0 coefficients of the spherical harmonics
  6024. */
  6025. l20: Vector3;
  6026. /**
  6027. * The l2,1 coefficients of the spherical harmonics
  6028. */
  6029. l21: Vector3;
  6030. /**
  6031. * The l2,2 coefficients of the spherical harmonics
  6032. */
  6033. l22: Vector3;
  6034. /**
  6035. * Adds a light to the spherical harmonics
  6036. * @param direction the direction of the light
  6037. * @param color the color of the light
  6038. * @param deltaSolidAngle the delta solid angle of the light
  6039. */
  6040. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6041. /**
  6042. * Scales the spherical harmonics by the given amount
  6043. * @param scale the amount to scale
  6044. */
  6045. scaleInPlace(scale: number): void;
  6046. /**
  6047. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6048. *
  6049. * ```
  6050. * E_lm = A_l * L_lm
  6051. * ```
  6052. *
  6053. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6054. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6055. * the scaling factors are given in equation 9.
  6056. */
  6057. convertIncidentRadianceToIrradiance(): void;
  6058. /**
  6059. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6060. *
  6061. * ```
  6062. * L = (1/pi) * E * rho
  6063. * ```
  6064. *
  6065. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6066. */
  6067. convertIrradianceToLambertianRadiance(): void;
  6068. /**
  6069. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6070. * required operations at run time.
  6071. *
  6072. * This is simply done by scaling back the SH with Ylm constants parameter.
  6073. * The trigonometric part being applied by the shader at run time.
  6074. */
  6075. preScaleForRendering(): void;
  6076. /**
  6077. * Constructs a spherical harmonics from an array.
  6078. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6079. * @returns the spherical harmonics
  6080. */
  6081. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6082. /**
  6083. * Gets the spherical harmonics from polynomial
  6084. * @param polynomial the spherical polynomial
  6085. * @returns the spherical harmonics
  6086. */
  6087. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6088. }
  6089. /**
  6090. * Class representing spherical polynomial coefficients to the 3rd degree
  6091. */
  6092. export class SphericalPolynomial {
  6093. private _harmonics;
  6094. /**
  6095. * The spherical harmonics used to create the polynomials.
  6096. */
  6097. readonly preScaledHarmonics: SphericalHarmonics;
  6098. /**
  6099. * The x coefficients of the spherical polynomial
  6100. */
  6101. x: Vector3;
  6102. /**
  6103. * The y coefficients of the spherical polynomial
  6104. */
  6105. y: Vector3;
  6106. /**
  6107. * The z coefficients of the spherical polynomial
  6108. */
  6109. z: Vector3;
  6110. /**
  6111. * The xx coefficients of the spherical polynomial
  6112. */
  6113. xx: Vector3;
  6114. /**
  6115. * The yy coefficients of the spherical polynomial
  6116. */
  6117. yy: Vector3;
  6118. /**
  6119. * The zz coefficients of the spherical polynomial
  6120. */
  6121. zz: Vector3;
  6122. /**
  6123. * The xy coefficients of the spherical polynomial
  6124. */
  6125. xy: Vector3;
  6126. /**
  6127. * The yz coefficients of the spherical polynomial
  6128. */
  6129. yz: Vector3;
  6130. /**
  6131. * The zx coefficients of the spherical polynomial
  6132. */
  6133. zx: Vector3;
  6134. /**
  6135. * Adds an ambient color to the spherical polynomial
  6136. * @param color the color to add
  6137. */
  6138. addAmbient(color: Color3): void;
  6139. /**
  6140. * Scales the spherical polynomial by the given amount
  6141. * @param scale the amount to scale
  6142. */
  6143. scaleInPlace(scale: number): void;
  6144. /**
  6145. * Gets the spherical polynomial from harmonics
  6146. * @param harmonics the spherical harmonics
  6147. * @returns the spherical polynomial
  6148. */
  6149. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6150. /**
  6151. * Constructs a spherical polynomial from an array.
  6152. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6153. * @returns the spherical polynomial
  6154. */
  6155. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6156. }
  6157. }
  6158. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6159. import { Nullable } from "babylonjs/types";
  6160. /**
  6161. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6162. */
  6163. export interface CubeMapInfo {
  6164. /**
  6165. * The pixel array for the front face.
  6166. * This is stored in format, left to right, up to down format.
  6167. */
  6168. front: Nullable<ArrayBufferView>;
  6169. /**
  6170. * The pixel array for the back face.
  6171. * This is stored in format, left to right, up to down format.
  6172. */
  6173. back: Nullable<ArrayBufferView>;
  6174. /**
  6175. * The pixel array for the left face.
  6176. * This is stored in format, left to right, up to down format.
  6177. */
  6178. left: Nullable<ArrayBufferView>;
  6179. /**
  6180. * The pixel array for the right face.
  6181. * This is stored in format, left to right, up to down format.
  6182. */
  6183. right: Nullable<ArrayBufferView>;
  6184. /**
  6185. * The pixel array for the up face.
  6186. * This is stored in format, left to right, up to down format.
  6187. */
  6188. up: Nullable<ArrayBufferView>;
  6189. /**
  6190. * The pixel array for the down face.
  6191. * This is stored in format, left to right, up to down format.
  6192. */
  6193. down: Nullable<ArrayBufferView>;
  6194. /**
  6195. * The size of the cubemap stored.
  6196. *
  6197. * Each faces will be size * size pixels.
  6198. */
  6199. size: number;
  6200. /**
  6201. * The format of the texture.
  6202. *
  6203. * RGBA, RGB.
  6204. */
  6205. format: number;
  6206. /**
  6207. * The type of the texture data.
  6208. *
  6209. * UNSIGNED_INT, FLOAT.
  6210. */
  6211. type: number;
  6212. /**
  6213. * Specifies whether the texture is in gamma space.
  6214. */
  6215. gammaSpace: boolean;
  6216. }
  6217. /**
  6218. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6219. */
  6220. export class PanoramaToCubeMapTools {
  6221. private static FACE_FRONT;
  6222. private static FACE_BACK;
  6223. private static FACE_RIGHT;
  6224. private static FACE_LEFT;
  6225. private static FACE_DOWN;
  6226. private static FACE_UP;
  6227. /**
  6228. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6229. *
  6230. * @param float32Array The source data.
  6231. * @param inputWidth The width of the input panorama.
  6232. * @param inputHeight The height of the input panorama.
  6233. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6234. * @return The cubemap data
  6235. */
  6236. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6237. private static CreateCubemapTexture;
  6238. private static CalcProjectionSpherical;
  6239. }
  6240. }
  6241. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6242. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6244. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6245. /**
  6246. * Helper class dealing with the extraction of spherical polynomial dataArray
  6247. * from a cube map.
  6248. */
  6249. export class CubeMapToSphericalPolynomialTools {
  6250. private static FileFaces;
  6251. /**
  6252. * Converts a texture to the according Spherical Polynomial data.
  6253. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6254. *
  6255. * @param texture The texture to extract the information from.
  6256. * @return The Spherical Polynomial data.
  6257. */
  6258. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6259. /**
  6260. * Converts a cubemap to the according Spherical Polynomial data.
  6261. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6262. *
  6263. * @param cubeInfo The Cube map to extract the information from.
  6264. * @return The Spherical Polynomial data.
  6265. */
  6266. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6267. }
  6268. }
  6269. declare module "babylonjs/Engines/engineStore" {
  6270. import { Nullable } from "babylonjs/types";
  6271. import { Engine } from "babylonjs/Engines/engine";
  6272. import { Scene } from "babylonjs/scene";
  6273. /**
  6274. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6275. * during the life time of the application.
  6276. */
  6277. export class EngineStore {
  6278. /** Gets the list of created engines */
  6279. static Instances: import("babylonjs/Engines/engine").Engine[];
  6280. /** @hidden */
  6281. static _LastCreatedScene: Nullable<Scene>;
  6282. /**
  6283. * Gets the latest created engine
  6284. */
  6285. static readonly LastCreatedEngine: Nullable<Engine>;
  6286. /**
  6287. * Gets the latest created scene
  6288. */
  6289. static readonly LastCreatedScene: Nullable<Scene>;
  6290. }
  6291. }
  6292. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6293. /**
  6294. * Define options used to create a render target texture
  6295. */
  6296. export class RenderTargetCreationOptions {
  6297. /**
  6298. * Specifies is mipmaps must be generated
  6299. */
  6300. generateMipMaps?: boolean;
  6301. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6302. generateDepthBuffer?: boolean;
  6303. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6304. generateStencilBuffer?: boolean;
  6305. /** Defines texture type (int by default) */
  6306. type?: number;
  6307. /** Defines sampling mode (trilinear by default) */
  6308. samplingMode?: number;
  6309. /** Defines format (RGBA by default) */
  6310. format?: number;
  6311. }
  6312. }
  6313. declare module "babylonjs/States/alphaCullingState" {
  6314. /**
  6315. * @hidden
  6316. **/
  6317. export class _AlphaState {
  6318. private _isAlphaBlendDirty;
  6319. private _isBlendFunctionParametersDirty;
  6320. private _isBlendEquationParametersDirty;
  6321. private _isBlendConstantsDirty;
  6322. private _alphaBlend;
  6323. private _blendFunctionParameters;
  6324. private _blendEquationParameters;
  6325. private _blendConstants;
  6326. /**
  6327. * Initializes the state.
  6328. */
  6329. constructor();
  6330. readonly isDirty: boolean;
  6331. alphaBlend: boolean;
  6332. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6333. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6334. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6335. reset(): void;
  6336. apply(gl: WebGLRenderingContext): void;
  6337. }
  6338. }
  6339. declare module "babylonjs/States/depthCullingState" {
  6340. import { Nullable } from "babylonjs/types";
  6341. /**
  6342. * @hidden
  6343. **/
  6344. export class _DepthCullingState {
  6345. private _isDepthTestDirty;
  6346. private _isDepthMaskDirty;
  6347. private _isDepthFuncDirty;
  6348. private _isCullFaceDirty;
  6349. private _isCullDirty;
  6350. private _isZOffsetDirty;
  6351. private _isFrontFaceDirty;
  6352. private _depthTest;
  6353. private _depthMask;
  6354. private _depthFunc;
  6355. private _cull;
  6356. private _cullFace;
  6357. private _zOffset;
  6358. private _frontFace;
  6359. /**
  6360. * Initializes the state.
  6361. */
  6362. constructor();
  6363. readonly isDirty: boolean;
  6364. zOffset: number;
  6365. cullFace: Nullable<number>;
  6366. cull: Nullable<boolean>;
  6367. depthFunc: Nullable<number>;
  6368. depthMask: boolean;
  6369. depthTest: boolean;
  6370. frontFace: Nullable<number>;
  6371. reset(): void;
  6372. apply(gl: WebGLRenderingContext): void;
  6373. }
  6374. }
  6375. declare module "babylonjs/States/stencilState" {
  6376. /**
  6377. * @hidden
  6378. **/
  6379. export class _StencilState {
  6380. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6381. static readonly ALWAYS: number;
  6382. /** Passed to stencilOperation to specify that stencil value must be kept */
  6383. static readonly KEEP: number;
  6384. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6385. static readonly REPLACE: number;
  6386. private _isStencilTestDirty;
  6387. private _isStencilMaskDirty;
  6388. private _isStencilFuncDirty;
  6389. private _isStencilOpDirty;
  6390. private _stencilTest;
  6391. private _stencilMask;
  6392. private _stencilFunc;
  6393. private _stencilFuncRef;
  6394. private _stencilFuncMask;
  6395. private _stencilOpStencilFail;
  6396. private _stencilOpDepthFail;
  6397. private _stencilOpStencilDepthPass;
  6398. readonly isDirty: boolean;
  6399. stencilFunc: number;
  6400. stencilFuncRef: number;
  6401. stencilFuncMask: number;
  6402. stencilOpStencilFail: number;
  6403. stencilOpDepthFail: number;
  6404. stencilOpStencilDepthPass: number;
  6405. stencilMask: number;
  6406. stencilTest: boolean;
  6407. constructor();
  6408. reset(): void;
  6409. apply(gl: WebGLRenderingContext): void;
  6410. }
  6411. }
  6412. declare module "babylonjs/States/index" {
  6413. export * from "babylonjs/States/alphaCullingState";
  6414. export * from "babylonjs/States/depthCullingState";
  6415. export * from "babylonjs/States/stencilState";
  6416. }
  6417. declare module "babylonjs/Instrumentation/timeToken" {
  6418. import { Nullable } from "babylonjs/types";
  6419. /**
  6420. * @hidden
  6421. **/
  6422. export class _TimeToken {
  6423. _startTimeQuery: Nullable<WebGLQuery>;
  6424. _endTimeQuery: Nullable<WebGLQuery>;
  6425. _timeElapsedQuery: Nullable<WebGLQuery>;
  6426. _timeElapsedQueryEnded: boolean;
  6427. }
  6428. }
  6429. declare module "babylonjs/Materials/Textures/internalTexture" {
  6430. import { Observable } from "babylonjs/Misc/observable";
  6431. import { Nullable, int } from "babylonjs/types";
  6432. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6433. import { Engine } from "babylonjs/Engines/engine";
  6434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6435. /**
  6436. * Class used to store data associated with WebGL texture data for the engine
  6437. * This class should not be used directly
  6438. */
  6439. export class InternalTexture {
  6440. /** @hidden */
  6441. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6442. /**
  6443. * The source of the texture data is unknown
  6444. */
  6445. static DATASOURCE_UNKNOWN: number;
  6446. /**
  6447. * Texture data comes from an URL
  6448. */
  6449. static DATASOURCE_URL: number;
  6450. /**
  6451. * Texture data is only used for temporary storage
  6452. */
  6453. static DATASOURCE_TEMP: number;
  6454. /**
  6455. * Texture data comes from raw data (ArrayBuffer)
  6456. */
  6457. static DATASOURCE_RAW: number;
  6458. /**
  6459. * Texture content is dynamic (video or dynamic texture)
  6460. */
  6461. static DATASOURCE_DYNAMIC: number;
  6462. /**
  6463. * Texture content is generated by rendering to it
  6464. */
  6465. static DATASOURCE_RENDERTARGET: number;
  6466. /**
  6467. * Texture content is part of a multi render target process
  6468. */
  6469. static DATASOURCE_MULTIRENDERTARGET: number;
  6470. /**
  6471. * Texture data comes from a cube data file
  6472. */
  6473. static DATASOURCE_CUBE: number;
  6474. /**
  6475. * Texture data comes from a raw cube data
  6476. */
  6477. static DATASOURCE_CUBERAW: number;
  6478. /**
  6479. * Texture data come from a prefiltered cube data file
  6480. */
  6481. static DATASOURCE_CUBEPREFILTERED: number;
  6482. /**
  6483. * Texture content is raw 3D data
  6484. */
  6485. static DATASOURCE_RAW3D: number;
  6486. /**
  6487. * Texture content is a depth texture
  6488. */
  6489. static DATASOURCE_DEPTHTEXTURE: number;
  6490. /**
  6491. * Texture data comes from a raw cube data encoded with RGBD
  6492. */
  6493. static DATASOURCE_CUBERAW_RGBD: number;
  6494. /**
  6495. * Defines if the texture is ready
  6496. */
  6497. isReady: boolean;
  6498. /**
  6499. * Defines if the texture is a cube texture
  6500. */
  6501. isCube: boolean;
  6502. /**
  6503. * Defines if the texture contains 3D data
  6504. */
  6505. is3D: boolean;
  6506. /**
  6507. * Defines if the texture contains multiview data
  6508. */
  6509. isMultiview: boolean;
  6510. /**
  6511. * Gets the URL used to load this texture
  6512. */
  6513. url: string;
  6514. /**
  6515. * Gets the sampling mode of the texture
  6516. */
  6517. samplingMode: number;
  6518. /**
  6519. * Gets a boolean indicating if the texture needs mipmaps generation
  6520. */
  6521. generateMipMaps: boolean;
  6522. /**
  6523. * Gets the number of samples used by the texture (WebGL2+ only)
  6524. */
  6525. samples: number;
  6526. /**
  6527. * Gets the type of the texture (int, float...)
  6528. */
  6529. type: number;
  6530. /**
  6531. * Gets the format of the texture (RGB, RGBA...)
  6532. */
  6533. format: number;
  6534. /**
  6535. * Observable called when the texture is loaded
  6536. */
  6537. onLoadedObservable: Observable<InternalTexture>;
  6538. /**
  6539. * Gets the width of the texture
  6540. */
  6541. width: number;
  6542. /**
  6543. * Gets the height of the texture
  6544. */
  6545. height: number;
  6546. /**
  6547. * Gets the depth of the texture
  6548. */
  6549. depth: number;
  6550. /**
  6551. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6552. */
  6553. baseWidth: number;
  6554. /**
  6555. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6556. */
  6557. baseHeight: number;
  6558. /**
  6559. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6560. */
  6561. baseDepth: number;
  6562. /**
  6563. * Gets a boolean indicating if the texture is inverted on Y axis
  6564. */
  6565. invertY: boolean;
  6566. /** @hidden */
  6567. _invertVScale: boolean;
  6568. /** @hidden */
  6569. _associatedChannel: number;
  6570. /** @hidden */
  6571. _dataSource: number;
  6572. /** @hidden */
  6573. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6574. /** @hidden */
  6575. _bufferView: Nullable<ArrayBufferView>;
  6576. /** @hidden */
  6577. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6578. /** @hidden */
  6579. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6580. /** @hidden */
  6581. _size: number;
  6582. /** @hidden */
  6583. _extension: string;
  6584. /** @hidden */
  6585. _files: Nullable<string[]>;
  6586. /** @hidden */
  6587. _workingCanvas: Nullable<HTMLCanvasElement>;
  6588. /** @hidden */
  6589. _workingContext: Nullable<CanvasRenderingContext2D>;
  6590. /** @hidden */
  6591. _framebuffer: Nullable<WebGLFramebuffer>;
  6592. /** @hidden */
  6593. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6594. /** @hidden */
  6595. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6596. /** @hidden */
  6597. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6598. /** @hidden */
  6599. _attachments: Nullable<number[]>;
  6600. /** @hidden */
  6601. _cachedCoordinatesMode: Nullable<number>;
  6602. /** @hidden */
  6603. _cachedWrapU: Nullable<number>;
  6604. /** @hidden */
  6605. _cachedWrapV: Nullable<number>;
  6606. /** @hidden */
  6607. _cachedWrapR: Nullable<number>;
  6608. /** @hidden */
  6609. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6610. /** @hidden */
  6611. _isDisabled: boolean;
  6612. /** @hidden */
  6613. _compression: Nullable<string>;
  6614. /** @hidden */
  6615. _generateStencilBuffer: boolean;
  6616. /** @hidden */
  6617. _generateDepthBuffer: boolean;
  6618. /** @hidden */
  6619. _comparisonFunction: number;
  6620. /** @hidden */
  6621. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6622. /** @hidden */
  6623. _lodGenerationScale: number;
  6624. /** @hidden */
  6625. _lodGenerationOffset: number;
  6626. /** @hidden */
  6627. _colorTextureArray: Nullable<WebGLTexture>;
  6628. /** @hidden */
  6629. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6630. /** @hidden */
  6631. _lodTextureHigh: Nullable<BaseTexture>;
  6632. /** @hidden */
  6633. _lodTextureMid: Nullable<BaseTexture>;
  6634. /** @hidden */
  6635. _lodTextureLow: Nullable<BaseTexture>;
  6636. /** @hidden */
  6637. _isRGBD: boolean;
  6638. /** @hidden */
  6639. _linearSpecularLOD: boolean;
  6640. /** @hidden */
  6641. _irradianceTexture: Nullable<BaseTexture>;
  6642. /** @hidden */
  6643. _webGLTexture: Nullable<WebGLTexture>;
  6644. /** @hidden */
  6645. _references: number;
  6646. private _engine;
  6647. /**
  6648. * Gets the Engine the texture belongs to.
  6649. * @returns The babylon engine
  6650. */
  6651. getEngine(): Engine;
  6652. /**
  6653. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6654. */
  6655. readonly dataSource: number;
  6656. /**
  6657. * Creates a new InternalTexture
  6658. * @param engine defines the engine to use
  6659. * @param dataSource defines the type of data that will be used
  6660. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6661. */
  6662. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6663. /**
  6664. * Increments the number of references (ie. the number of Texture that point to it)
  6665. */
  6666. incrementReferences(): void;
  6667. /**
  6668. * Change the size of the texture (not the size of the content)
  6669. * @param width defines the new width
  6670. * @param height defines the new height
  6671. * @param depth defines the new depth (1 by default)
  6672. */
  6673. updateSize(width: int, height: int, depth?: int): void;
  6674. /** @hidden */
  6675. _rebuild(): void;
  6676. /** @hidden */
  6677. _swapAndDie(target: InternalTexture): void;
  6678. /**
  6679. * Dispose the current allocated resources
  6680. */
  6681. dispose(): void;
  6682. }
  6683. }
  6684. declare module "babylonjs/Animations/easing" {
  6685. /**
  6686. * This represents the main contract an easing function should follow.
  6687. * Easing functions are used throughout the animation system.
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export interface IEasingFunction {
  6691. /**
  6692. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6693. * of the easing function.
  6694. * The link below provides some of the most common examples of easing functions.
  6695. * @see https://easings.net/
  6696. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6697. * @returns the corresponding value on the curve defined by the easing function
  6698. */
  6699. ease(gradient: number): number;
  6700. }
  6701. /**
  6702. * Base class used for every default easing function.
  6703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6704. */
  6705. export class EasingFunction implements IEasingFunction {
  6706. /**
  6707. * Interpolation follows the mathematical formula associated with the easing function.
  6708. */
  6709. static readonly EASINGMODE_EASEIN: number;
  6710. /**
  6711. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6712. */
  6713. static readonly EASINGMODE_EASEOUT: number;
  6714. /**
  6715. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6716. */
  6717. static readonly EASINGMODE_EASEINOUT: number;
  6718. private _easingMode;
  6719. /**
  6720. * Sets the easing mode of the current function.
  6721. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6722. */
  6723. setEasingMode(easingMode: number): void;
  6724. /**
  6725. * Gets the current easing mode.
  6726. * @returns the easing mode
  6727. */
  6728. getEasingMode(): number;
  6729. /**
  6730. * @hidden
  6731. */
  6732. easeInCore(gradient: number): number;
  6733. /**
  6734. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6735. * of the easing function.
  6736. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6737. * @returns the corresponding value on the curve defined by the easing function
  6738. */
  6739. ease(gradient: number): number;
  6740. }
  6741. /**
  6742. * Easing function with a circle shape (see link below).
  6743. * @see https://easings.net/#easeInCirc
  6744. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6745. */
  6746. export class CircleEase extends EasingFunction implements IEasingFunction {
  6747. /** @hidden */
  6748. easeInCore(gradient: number): number;
  6749. }
  6750. /**
  6751. * Easing function with a ease back shape (see link below).
  6752. * @see https://easings.net/#easeInBack
  6753. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6754. */
  6755. export class BackEase extends EasingFunction implements IEasingFunction {
  6756. /** Defines the amplitude of the function */
  6757. amplitude: number;
  6758. /**
  6759. * Instantiates a back ease easing
  6760. * @see https://easings.net/#easeInBack
  6761. * @param amplitude Defines the amplitude of the function
  6762. */
  6763. constructor(
  6764. /** Defines the amplitude of the function */
  6765. amplitude?: number);
  6766. /** @hidden */
  6767. easeInCore(gradient: number): number;
  6768. }
  6769. /**
  6770. * Easing function with a bouncing shape (see link below).
  6771. * @see https://easings.net/#easeInBounce
  6772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6773. */
  6774. export class BounceEase extends EasingFunction implements IEasingFunction {
  6775. /** Defines the number of bounces */
  6776. bounces: number;
  6777. /** Defines the amplitude of the bounce */
  6778. bounciness: number;
  6779. /**
  6780. * Instantiates a bounce easing
  6781. * @see https://easings.net/#easeInBounce
  6782. * @param bounces Defines the number of bounces
  6783. * @param bounciness Defines the amplitude of the bounce
  6784. */
  6785. constructor(
  6786. /** Defines the number of bounces */
  6787. bounces?: number,
  6788. /** Defines the amplitude of the bounce */
  6789. bounciness?: number);
  6790. /** @hidden */
  6791. easeInCore(gradient: number): number;
  6792. }
  6793. /**
  6794. * Easing function with a power of 3 shape (see link below).
  6795. * @see https://easings.net/#easeInCubic
  6796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6797. */
  6798. export class CubicEase extends EasingFunction implements IEasingFunction {
  6799. /** @hidden */
  6800. easeInCore(gradient: number): number;
  6801. }
  6802. /**
  6803. * Easing function with an elastic shape (see link below).
  6804. * @see https://easings.net/#easeInElastic
  6805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6806. */
  6807. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6808. /** Defines the number of oscillations*/
  6809. oscillations: number;
  6810. /** Defines the amplitude of the oscillations*/
  6811. springiness: number;
  6812. /**
  6813. * Instantiates an elastic easing function
  6814. * @see https://easings.net/#easeInElastic
  6815. * @param oscillations Defines the number of oscillations
  6816. * @param springiness Defines the amplitude of the oscillations
  6817. */
  6818. constructor(
  6819. /** Defines the number of oscillations*/
  6820. oscillations?: number,
  6821. /** Defines the amplitude of the oscillations*/
  6822. springiness?: number);
  6823. /** @hidden */
  6824. easeInCore(gradient: number): number;
  6825. }
  6826. /**
  6827. * Easing function with an exponential shape (see link below).
  6828. * @see https://easings.net/#easeInExpo
  6829. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6830. */
  6831. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6832. /** Defines the exponent of the function */
  6833. exponent: number;
  6834. /**
  6835. * Instantiates an exponential easing function
  6836. * @see https://easings.net/#easeInExpo
  6837. * @param exponent Defines the exponent of the function
  6838. */
  6839. constructor(
  6840. /** Defines the exponent of the function */
  6841. exponent?: number);
  6842. /** @hidden */
  6843. easeInCore(gradient: number): number;
  6844. }
  6845. /**
  6846. * Easing function with a power shape (see link below).
  6847. * @see https://easings.net/#easeInQuad
  6848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6849. */
  6850. export class PowerEase extends EasingFunction implements IEasingFunction {
  6851. /** Defines the power of the function */
  6852. power: number;
  6853. /**
  6854. * Instantiates an power base easing function
  6855. * @see https://easings.net/#easeInQuad
  6856. * @param power Defines the power of the function
  6857. */
  6858. constructor(
  6859. /** Defines the power of the function */
  6860. power?: number);
  6861. /** @hidden */
  6862. easeInCore(gradient: number): number;
  6863. }
  6864. /**
  6865. * Easing function with a power of 2 shape (see link below).
  6866. * @see https://easings.net/#easeInQuad
  6867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6868. */
  6869. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6870. /** @hidden */
  6871. easeInCore(gradient: number): number;
  6872. }
  6873. /**
  6874. * Easing function with a power of 4 shape (see link below).
  6875. * @see https://easings.net/#easeInQuart
  6876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6877. */
  6878. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6879. /** @hidden */
  6880. easeInCore(gradient: number): number;
  6881. }
  6882. /**
  6883. * Easing function with a power of 5 shape (see link below).
  6884. * @see https://easings.net/#easeInQuint
  6885. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6886. */
  6887. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6888. /** @hidden */
  6889. easeInCore(gradient: number): number;
  6890. }
  6891. /**
  6892. * Easing function with a sin shape (see link below).
  6893. * @see https://easings.net/#easeInSine
  6894. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6895. */
  6896. export class SineEase extends EasingFunction implements IEasingFunction {
  6897. /** @hidden */
  6898. easeInCore(gradient: number): number;
  6899. }
  6900. /**
  6901. * Easing function with a bezier shape (see link below).
  6902. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6903. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6904. */
  6905. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6906. /** Defines the x component of the start tangent in the bezier curve */
  6907. x1: number;
  6908. /** Defines the y component of the start tangent in the bezier curve */
  6909. y1: number;
  6910. /** Defines the x component of the end tangent in the bezier curve */
  6911. x2: number;
  6912. /** Defines the y component of the end tangent in the bezier curve */
  6913. y2: number;
  6914. /**
  6915. * Instantiates a bezier function
  6916. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6917. * @param x1 Defines the x component of the start tangent in the bezier curve
  6918. * @param y1 Defines the y component of the start tangent in the bezier curve
  6919. * @param x2 Defines the x component of the end tangent in the bezier curve
  6920. * @param y2 Defines the y component of the end tangent in the bezier curve
  6921. */
  6922. constructor(
  6923. /** Defines the x component of the start tangent in the bezier curve */
  6924. x1?: number,
  6925. /** Defines the y component of the start tangent in the bezier curve */
  6926. y1?: number,
  6927. /** Defines the x component of the end tangent in the bezier curve */
  6928. x2?: number,
  6929. /** Defines the y component of the end tangent in the bezier curve */
  6930. y2?: number);
  6931. /** @hidden */
  6932. easeInCore(gradient: number): number;
  6933. }
  6934. }
  6935. declare module "babylonjs/Animations/animationKey" {
  6936. /**
  6937. * Defines an interface which represents an animation key frame
  6938. */
  6939. export interface IAnimationKey {
  6940. /**
  6941. * Frame of the key frame
  6942. */
  6943. frame: number;
  6944. /**
  6945. * Value at the specifies key frame
  6946. */
  6947. value: any;
  6948. /**
  6949. * The input tangent for the cubic hermite spline
  6950. */
  6951. inTangent?: any;
  6952. /**
  6953. * The output tangent for the cubic hermite spline
  6954. */
  6955. outTangent?: any;
  6956. /**
  6957. * The animation interpolation type
  6958. */
  6959. interpolation?: AnimationKeyInterpolation;
  6960. }
  6961. /**
  6962. * Enum for the animation key frame interpolation type
  6963. */
  6964. export enum AnimationKeyInterpolation {
  6965. /**
  6966. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6967. */
  6968. STEP = 1
  6969. }
  6970. }
  6971. declare module "babylonjs/Animations/animationRange" {
  6972. /**
  6973. * Represents the range of an animation
  6974. */
  6975. export class AnimationRange {
  6976. /**The name of the animation range**/
  6977. name: string;
  6978. /**The starting frame of the animation */
  6979. from: number;
  6980. /**The ending frame of the animation*/
  6981. to: number;
  6982. /**
  6983. * Initializes the range of an animation
  6984. * @param name The name of the animation range
  6985. * @param from The starting frame of the animation
  6986. * @param to The ending frame of the animation
  6987. */
  6988. constructor(
  6989. /**The name of the animation range**/
  6990. name: string,
  6991. /**The starting frame of the animation */
  6992. from: number,
  6993. /**The ending frame of the animation*/
  6994. to: number);
  6995. /**
  6996. * Makes a copy of the animation range
  6997. * @returns A copy of the animation range
  6998. */
  6999. clone(): AnimationRange;
  7000. }
  7001. }
  7002. declare module "babylonjs/Animations/animationEvent" {
  7003. /**
  7004. * Composed of a frame, and an action function
  7005. */
  7006. export class AnimationEvent {
  7007. /** The frame for which the event is triggered **/
  7008. frame: number;
  7009. /** The event to perform when triggered **/
  7010. action: (currentFrame: number) => void;
  7011. /** Specifies if the event should be triggered only once**/
  7012. onlyOnce?: boolean | undefined;
  7013. /**
  7014. * Specifies if the animation event is done
  7015. */
  7016. isDone: boolean;
  7017. /**
  7018. * Initializes the animation event
  7019. * @param frame The frame for which the event is triggered
  7020. * @param action The event to perform when triggered
  7021. * @param onlyOnce Specifies if the event should be triggered only once
  7022. */
  7023. constructor(
  7024. /** The frame for which the event is triggered **/
  7025. frame: number,
  7026. /** The event to perform when triggered **/
  7027. action: (currentFrame: number) => void,
  7028. /** Specifies if the event should be triggered only once**/
  7029. onlyOnce?: boolean | undefined);
  7030. /** @hidden */
  7031. _clone(): AnimationEvent;
  7032. }
  7033. }
  7034. declare module "babylonjs/Behaviors/behavior" {
  7035. import { Nullable } from "babylonjs/types";
  7036. /**
  7037. * Interface used to define a behavior
  7038. */
  7039. export interface Behavior<T> {
  7040. /** gets or sets behavior's name */
  7041. name: string;
  7042. /**
  7043. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7044. */
  7045. init(): void;
  7046. /**
  7047. * Called when the behavior is attached to a target
  7048. * @param target defines the target where the behavior is attached to
  7049. */
  7050. attach(target: T): void;
  7051. /**
  7052. * Called when the behavior is detached from its target
  7053. */
  7054. detach(): void;
  7055. }
  7056. /**
  7057. * Interface implemented by classes supporting behaviors
  7058. */
  7059. export interface IBehaviorAware<T> {
  7060. /**
  7061. * Attach a behavior
  7062. * @param behavior defines the behavior to attach
  7063. * @returns the current host
  7064. */
  7065. addBehavior(behavior: Behavior<T>): T;
  7066. /**
  7067. * Remove a behavior from the current object
  7068. * @param behavior defines the behavior to detach
  7069. * @returns the current host
  7070. */
  7071. removeBehavior(behavior: Behavior<T>): T;
  7072. /**
  7073. * Gets a behavior using its name to search
  7074. * @param name defines the name to search
  7075. * @returns the behavior or null if not found
  7076. */
  7077. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7078. }
  7079. }
  7080. declare module "babylonjs/Collisions/intersectionInfo" {
  7081. import { Nullable } from "babylonjs/types";
  7082. /**
  7083. * @hidden
  7084. */
  7085. export class IntersectionInfo {
  7086. bu: Nullable<number>;
  7087. bv: Nullable<number>;
  7088. distance: number;
  7089. faceId: number;
  7090. subMeshId: number;
  7091. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7092. }
  7093. }
  7094. declare module "babylonjs/Culling/boundingSphere" {
  7095. import { DeepImmutable } from "babylonjs/types";
  7096. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7097. /**
  7098. * Class used to store bounding sphere information
  7099. */
  7100. export class BoundingSphere {
  7101. /**
  7102. * Gets the center of the bounding sphere in local space
  7103. */
  7104. readonly center: Vector3;
  7105. /**
  7106. * Radius of the bounding sphere in local space
  7107. */
  7108. radius: number;
  7109. /**
  7110. * Gets the center of the bounding sphere in world space
  7111. */
  7112. readonly centerWorld: Vector3;
  7113. /**
  7114. * Radius of the bounding sphere in world space
  7115. */
  7116. radiusWorld: number;
  7117. /**
  7118. * Gets the minimum vector in local space
  7119. */
  7120. readonly minimum: Vector3;
  7121. /**
  7122. * Gets the maximum vector in local space
  7123. */
  7124. readonly maximum: Vector3;
  7125. private _worldMatrix;
  7126. private static readonly TmpVector3;
  7127. /**
  7128. * Creates a new bounding sphere
  7129. * @param min defines the minimum vector (in local space)
  7130. * @param max defines the maximum vector (in local space)
  7131. * @param worldMatrix defines the new world matrix
  7132. */
  7133. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7134. /**
  7135. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7136. * @param min defines the new minimum vector (in local space)
  7137. * @param max defines the new maximum vector (in local space)
  7138. * @param worldMatrix defines the new world matrix
  7139. */
  7140. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7141. /**
  7142. * Scale the current bounding sphere by applying a scale factor
  7143. * @param factor defines the scale factor to apply
  7144. * @returns the current bounding box
  7145. */
  7146. scale(factor: number): BoundingSphere;
  7147. /**
  7148. * Gets the world matrix of the bounding box
  7149. * @returns a matrix
  7150. */
  7151. getWorldMatrix(): DeepImmutable<Matrix>;
  7152. /** @hidden */
  7153. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7154. /**
  7155. * Tests if the bounding sphere is intersecting the frustum planes
  7156. * @param frustumPlanes defines the frustum planes to test
  7157. * @returns true if there is an intersection
  7158. */
  7159. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7160. /**
  7161. * Tests if the bounding sphere center is in between the frustum planes.
  7162. * Used for optimistic fast inclusion.
  7163. * @param frustumPlanes defines the frustum planes to test
  7164. * @returns true if the sphere center is in between the frustum planes
  7165. */
  7166. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7167. /**
  7168. * Tests if a point is inside the bounding sphere
  7169. * @param point defines the point to test
  7170. * @returns true if the point is inside the bounding sphere
  7171. */
  7172. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7173. /**
  7174. * Checks if two sphere intersct
  7175. * @param sphere0 sphere 0
  7176. * @param sphere1 sphere 1
  7177. * @returns true if the speres intersect
  7178. */
  7179. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7180. }
  7181. }
  7182. declare module "babylonjs/Culling/boundingBox" {
  7183. import { DeepImmutable } from "babylonjs/types";
  7184. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7187. /**
  7188. * Class used to store bounding box information
  7189. */
  7190. export class BoundingBox implements ICullable {
  7191. /**
  7192. * Gets the 8 vectors representing the bounding box in local space
  7193. */
  7194. readonly vectors: Vector3[];
  7195. /**
  7196. * Gets the center of the bounding box in local space
  7197. */
  7198. readonly center: Vector3;
  7199. /**
  7200. * Gets the center of the bounding box in world space
  7201. */
  7202. readonly centerWorld: Vector3;
  7203. /**
  7204. * Gets the extend size in local space
  7205. */
  7206. readonly extendSize: Vector3;
  7207. /**
  7208. * Gets the extend size in world space
  7209. */
  7210. readonly extendSizeWorld: Vector3;
  7211. /**
  7212. * Gets the OBB (object bounding box) directions
  7213. */
  7214. readonly directions: Vector3[];
  7215. /**
  7216. * Gets the 8 vectors representing the bounding box in world space
  7217. */
  7218. readonly vectorsWorld: Vector3[];
  7219. /**
  7220. * Gets the minimum vector in world space
  7221. */
  7222. readonly minimumWorld: Vector3;
  7223. /**
  7224. * Gets the maximum vector in world space
  7225. */
  7226. readonly maximumWorld: Vector3;
  7227. /**
  7228. * Gets the minimum vector in local space
  7229. */
  7230. readonly minimum: Vector3;
  7231. /**
  7232. * Gets the maximum vector in local space
  7233. */
  7234. readonly maximum: Vector3;
  7235. private _worldMatrix;
  7236. private static readonly TmpVector3;
  7237. /**
  7238. * @hidden
  7239. */
  7240. _tag: number;
  7241. /**
  7242. * Creates a new bounding box
  7243. * @param min defines the minimum vector (in local space)
  7244. * @param max defines the maximum vector (in local space)
  7245. * @param worldMatrix defines the new world matrix
  7246. */
  7247. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7248. /**
  7249. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7250. * @param min defines the new minimum vector (in local space)
  7251. * @param max defines the new maximum vector (in local space)
  7252. * @param worldMatrix defines the new world matrix
  7253. */
  7254. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7255. /**
  7256. * Scale the current bounding box by applying a scale factor
  7257. * @param factor defines the scale factor to apply
  7258. * @returns the current bounding box
  7259. */
  7260. scale(factor: number): BoundingBox;
  7261. /**
  7262. * Gets the world matrix of the bounding box
  7263. * @returns a matrix
  7264. */
  7265. getWorldMatrix(): DeepImmutable<Matrix>;
  7266. /** @hidden */
  7267. _update(world: DeepImmutable<Matrix>): void;
  7268. /**
  7269. * Tests if the bounding box is intersecting the frustum planes
  7270. * @param frustumPlanes defines the frustum planes to test
  7271. * @returns true if there is an intersection
  7272. */
  7273. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /**
  7275. * Tests if the bounding box is entirely inside the frustum planes
  7276. * @param frustumPlanes defines the frustum planes to test
  7277. * @returns true if there is an inclusion
  7278. */
  7279. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7280. /**
  7281. * Tests if a point is inside the bounding box
  7282. * @param point defines the point to test
  7283. * @returns true if the point is inside the bounding box
  7284. */
  7285. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7286. /**
  7287. * Tests if the bounding box intersects with a bounding sphere
  7288. * @param sphere defines the sphere to test
  7289. * @returns true if there is an intersection
  7290. */
  7291. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7292. /**
  7293. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7294. * @param min defines the min vector to use
  7295. * @param max defines the max vector to use
  7296. * @returns true if there is an intersection
  7297. */
  7298. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7299. /**
  7300. * Tests if two bounding boxes are intersections
  7301. * @param box0 defines the first box to test
  7302. * @param box1 defines the second box to test
  7303. * @returns true if there is an intersection
  7304. */
  7305. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7306. /**
  7307. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7308. * @param minPoint defines the minimum vector of the bounding box
  7309. * @param maxPoint defines the maximum vector of the bounding box
  7310. * @param sphereCenter defines the sphere center
  7311. * @param sphereRadius defines the sphere radius
  7312. * @returns true if there is an intersection
  7313. */
  7314. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7315. /**
  7316. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7317. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7318. * @param frustumPlanes defines the frustum planes to test
  7319. * @return true if there is an inclusion
  7320. */
  7321. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7322. /**
  7323. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7324. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7325. * @param frustumPlanes defines the frustum planes to test
  7326. * @return true if there is an intersection
  7327. */
  7328. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7329. }
  7330. }
  7331. declare module "babylonjs/Collisions/collider" {
  7332. import { Nullable, IndicesArray } from "babylonjs/types";
  7333. import { Vector3, Plane } from "babylonjs/Maths/math";
  7334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7335. /** @hidden */
  7336. export class Collider {
  7337. /** Define if a collision was found */
  7338. collisionFound: boolean;
  7339. /**
  7340. * Define last intersection point in local space
  7341. */
  7342. intersectionPoint: Vector3;
  7343. /**
  7344. * Define last collided mesh
  7345. */
  7346. collidedMesh: Nullable<AbstractMesh>;
  7347. private _collisionPoint;
  7348. private _planeIntersectionPoint;
  7349. private _tempVector;
  7350. private _tempVector2;
  7351. private _tempVector3;
  7352. private _tempVector4;
  7353. private _edge;
  7354. private _baseToVertex;
  7355. private _destinationPoint;
  7356. private _slidePlaneNormal;
  7357. private _displacementVector;
  7358. /** @hidden */
  7359. _radius: Vector3;
  7360. /** @hidden */
  7361. _retry: number;
  7362. private _velocity;
  7363. private _basePoint;
  7364. private _epsilon;
  7365. /** @hidden */
  7366. _velocityWorldLength: number;
  7367. /** @hidden */
  7368. _basePointWorld: Vector3;
  7369. private _velocityWorld;
  7370. private _normalizedVelocity;
  7371. /** @hidden */
  7372. _initialVelocity: Vector3;
  7373. /** @hidden */
  7374. _initialPosition: Vector3;
  7375. private _nearestDistance;
  7376. private _collisionMask;
  7377. collisionMask: number;
  7378. /**
  7379. * Gets the plane normal used to compute the sliding response (in local space)
  7380. */
  7381. readonly slidePlaneNormal: Vector3;
  7382. /** @hidden */
  7383. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7384. /** @hidden */
  7385. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7386. /** @hidden */
  7387. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7388. /** @hidden */
  7389. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7390. /** @hidden */
  7391. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7392. /** @hidden */
  7393. _getResponse(pos: Vector3, vel: Vector3): void;
  7394. }
  7395. }
  7396. declare module "babylonjs/Culling/boundingInfo" {
  7397. import { DeepImmutable } from "babylonjs/types";
  7398. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7399. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7400. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7401. import { Collider } from "babylonjs/Collisions/collider";
  7402. /**
  7403. * Interface for cullable objects
  7404. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7405. */
  7406. export interface ICullable {
  7407. /**
  7408. * Checks if the object or part of the object is in the frustum
  7409. * @param frustumPlanes Camera near/planes
  7410. * @returns true if the object is in frustum otherwise false
  7411. */
  7412. isInFrustum(frustumPlanes: Plane[]): boolean;
  7413. /**
  7414. * Checks if a cullable object (mesh...) is in the camera frustum
  7415. * Unlike isInFrustum this cheks the full bounding box
  7416. * @param frustumPlanes Camera near/planes
  7417. * @returns true if the object is in frustum otherwise false
  7418. */
  7419. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7420. }
  7421. /**
  7422. * Info for a bounding data of a mesh
  7423. */
  7424. export class BoundingInfo implements ICullable {
  7425. /**
  7426. * Bounding box for the mesh
  7427. */
  7428. readonly boundingBox: BoundingBox;
  7429. /**
  7430. * Bounding sphere for the mesh
  7431. */
  7432. readonly boundingSphere: BoundingSphere;
  7433. private _isLocked;
  7434. private static readonly TmpVector3;
  7435. /**
  7436. * Constructs bounding info
  7437. * @param minimum min vector of the bounding box/sphere
  7438. * @param maximum max vector of the bounding box/sphere
  7439. * @param worldMatrix defines the new world matrix
  7440. */
  7441. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7442. /**
  7443. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7444. * @param min defines the new minimum vector (in local space)
  7445. * @param max defines the new maximum vector (in local space)
  7446. * @param worldMatrix defines the new world matrix
  7447. */
  7448. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7449. /**
  7450. * min vector of the bounding box/sphere
  7451. */
  7452. readonly minimum: Vector3;
  7453. /**
  7454. * max vector of the bounding box/sphere
  7455. */
  7456. readonly maximum: Vector3;
  7457. /**
  7458. * If the info is locked and won't be updated to avoid perf overhead
  7459. */
  7460. isLocked: boolean;
  7461. /**
  7462. * Updates the bounding sphere and box
  7463. * @param world world matrix to be used to update
  7464. */
  7465. update(world: DeepImmutable<Matrix>): void;
  7466. /**
  7467. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7468. * @param center New center of the bounding info
  7469. * @param extend New extend of the bounding info
  7470. * @returns the current bounding info
  7471. */
  7472. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7473. /**
  7474. * Scale the current bounding info by applying a scale factor
  7475. * @param factor defines the scale factor to apply
  7476. * @returns the current bounding info
  7477. */
  7478. scale(factor: number): BoundingInfo;
  7479. /**
  7480. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7481. * @param frustumPlanes defines the frustum to test
  7482. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7483. * @returns true if the bounding info is in the frustum planes
  7484. */
  7485. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7486. /**
  7487. * Gets the world distance between the min and max points of the bounding box
  7488. */
  7489. readonly diagonalLength: number;
  7490. /**
  7491. * Checks if a cullable object (mesh...) is in the camera frustum
  7492. * Unlike isInFrustum this cheks the full bounding box
  7493. * @param frustumPlanes Camera near/planes
  7494. * @returns true if the object is in frustum otherwise false
  7495. */
  7496. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7497. /** @hidden */
  7498. _checkCollision(collider: Collider): boolean;
  7499. /**
  7500. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7501. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7502. * @param point the point to check intersection with
  7503. * @returns if the point intersects
  7504. */
  7505. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7506. /**
  7507. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7508. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7509. * @param boundingInfo the bounding info to check intersection with
  7510. * @param precise if the intersection should be done using OBB
  7511. * @returns if the bounding info intersects
  7512. */
  7513. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7514. }
  7515. }
  7516. declare module "babylonjs/Misc/smartArray" {
  7517. /**
  7518. * Defines an array and its length.
  7519. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7520. */
  7521. export interface ISmartArrayLike<T> {
  7522. /**
  7523. * The data of the array.
  7524. */
  7525. data: Array<T>;
  7526. /**
  7527. * The active length of the array.
  7528. */
  7529. length: number;
  7530. }
  7531. /**
  7532. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7533. */
  7534. export class SmartArray<T> implements ISmartArrayLike<T> {
  7535. /**
  7536. * The full set of data from the array.
  7537. */
  7538. data: Array<T>;
  7539. /**
  7540. * The active length of the array.
  7541. */
  7542. length: number;
  7543. protected _id: number;
  7544. /**
  7545. * Instantiates a Smart Array.
  7546. * @param capacity defines the default capacity of the array.
  7547. */
  7548. constructor(capacity: number);
  7549. /**
  7550. * Pushes a value at the end of the active data.
  7551. * @param value defines the object to push in the array.
  7552. */
  7553. push(value: T): void;
  7554. /**
  7555. * Iterates over the active data and apply the lambda to them.
  7556. * @param func defines the action to apply on each value.
  7557. */
  7558. forEach(func: (content: T) => void): void;
  7559. /**
  7560. * Sorts the full sets of data.
  7561. * @param compareFn defines the comparison function to apply.
  7562. */
  7563. sort(compareFn: (a: T, b: T) => number): void;
  7564. /**
  7565. * Resets the active data to an empty array.
  7566. */
  7567. reset(): void;
  7568. /**
  7569. * Releases all the data from the array as well as the array.
  7570. */
  7571. dispose(): void;
  7572. /**
  7573. * Concats the active data with a given array.
  7574. * @param array defines the data to concatenate with.
  7575. */
  7576. concat(array: any): void;
  7577. /**
  7578. * Returns the position of a value in the active data.
  7579. * @param value defines the value to find the index for
  7580. * @returns the index if found in the active data otherwise -1
  7581. */
  7582. indexOf(value: T): number;
  7583. /**
  7584. * Returns whether an element is part of the active data.
  7585. * @param value defines the value to look for
  7586. * @returns true if found in the active data otherwise false
  7587. */
  7588. contains(value: T): boolean;
  7589. private static _GlobalId;
  7590. }
  7591. /**
  7592. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7593. * The data in this array can only be present once
  7594. */
  7595. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7596. private _duplicateId;
  7597. /**
  7598. * Pushes a value at the end of the active data.
  7599. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7600. * @param value defines the object to push in the array.
  7601. */
  7602. push(value: T): void;
  7603. /**
  7604. * Pushes a value at the end of the active data.
  7605. * If the data is already present, it won t be added again
  7606. * @param value defines the object to push in the array.
  7607. * @returns true if added false if it was already present
  7608. */
  7609. pushNoDuplicate(value: T): boolean;
  7610. /**
  7611. * Resets the active data to an empty array.
  7612. */
  7613. reset(): void;
  7614. /**
  7615. * Concats the active data with a given array.
  7616. * This ensures no dupplicate will be present in the result.
  7617. * @param array defines the data to concatenate with.
  7618. */
  7619. concatWithNoDuplicate(array: any): void;
  7620. }
  7621. }
  7622. declare module "babylonjs/Misc/iInspectable" {
  7623. /**
  7624. * Enum that determines the text-wrapping mode to use.
  7625. */
  7626. export enum InspectableType {
  7627. /**
  7628. * Checkbox for booleans
  7629. */
  7630. Checkbox = 0,
  7631. /**
  7632. * Sliders for numbers
  7633. */
  7634. Slider = 1,
  7635. /**
  7636. * Vector3
  7637. */
  7638. Vector3 = 2,
  7639. /**
  7640. * Quaternions
  7641. */
  7642. Quaternion = 3,
  7643. /**
  7644. * Color3
  7645. */
  7646. Color3 = 4
  7647. }
  7648. /**
  7649. * Interface used to define custom inspectable properties.
  7650. * This interface is used by the inspector to display custom property grids
  7651. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7652. */
  7653. export interface IInspectable {
  7654. /**
  7655. * Gets the label to display
  7656. */
  7657. label: string;
  7658. /**
  7659. * Gets the name of the property to edit
  7660. */
  7661. propertyName: string;
  7662. /**
  7663. * Gets the type of the editor to use
  7664. */
  7665. type: InspectableType;
  7666. /**
  7667. * Gets the minimum value of the property when using in "slider" mode
  7668. */
  7669. min?: number;
  7670. /**
  7671. * Gets the maximum value of the property when using in "slider" mode
  7672. */
  7673. max?: number;
  7674. /**
  7675. * Gets the setp to use when using in "slider" mode
  7676. */
  7677. step?: number;
  7678. }
  7679. }
  7680. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7681. import { Nullable } from "babylonjs/types";
  7682. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7683. /**
  7684. * This represents the required contract to create a new type of texture loader.
  7685. */
  7686. export interface IInternalTextureLoader {
  7687. /**
  7688. * Defines wether the loader supports cascade loading the different faces.
  7689. */
  7690. supportCascades: boolean;
  7691. /**
  7692. * This returns if the loader support the current file information.
  7693. * @param extension defines the file extension of the file being loaded
  7694. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7695. * @param fallback defines the fallback internal texture if any
  7696. * @param isBase64 defines whether the texture is encoded as a base64
  7697. * @param isBuffer defines whether the texture data are stored as a buffer
  7698. * @returns true if the loader can load the specified file
  7699. */
  7700. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7701. /**
  7702. * Transform the url before loading if required.
  7703. * @param rootUrl the url of the texture
  7704. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7705. * @returns the transformed texture
  7706. */
  7707. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7708. /**
  7709. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7710. * @param rootUrl the url of the texture
  7711. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7712. * @returns the fallback texture
  7713. */
  7714. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7715. /**
  7716. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7717. * @param data contains the texture data
  7718. * @param texture defines the BabylonJS internal texture
  7719. * @param createPolynomials will be true if polynomials have been requested
  7720. * @param onLoad defines the callback to trigger once the texture is ready
  7721. * @param onError defines the callback to trigger in case of error
  7722. */
  7723. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7724. /**
  7725. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7726. * @param data contains the texture data
  7727. * @param texture defines the BabylonJS internal texture
  7728. * @param callback defines the method to call once ready to upload
  7729. */
  7730. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7731. }
  7732. }
  7733. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7734. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7735. import { Nullable } from "babylonjs/types";
  7736. import { Scene } from "babylonjs/scene";
  7737. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7738. module "babylonjs/Engines/engine" {
  7739. interface Engine {
  7740. /**
  7741. * Creates a depth stencil cube texture.
  7742. * This is only available in WebGL 2.
  7743. * @param size The size of face edge in the cube texture.
  7744. * @param options The options defining the cube texture.
  7745. * @returns The cube texture
  7746. */
  7747. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7748. /**
  7749. * Creates a cube texture
  7750. * @param rootUrl defines the url where the files to load is located
  7751. * @param scene defines the current scene
  7752. * @param files defines the list of files to load (1 per face)
  7753. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7754. * @param onLoad defines an optional callback raised when the texture is loaded
  7755. * @param onError defines an optional callback raised if there is an issue to load the texture
  7756. * @param format defines the format of the data
  7757. * @param forcedExtension defines the extension to use to pick the right loader
  7758. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7759. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7760. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7761. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7762. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7763. * @returns the cube texture as an InternalTexture
  7764. */
  7765. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7766. /**
  7767. * Creates a cube texture
  7768. * @param rootUrl defines the url where the files to load is located
  7769. * @param scene defines the current scene
  7770. * @param files defines the list of files to load (1 per face)
  7771. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7772. * @param onLoad defines an optional callback raised when the texture is loaded
  7773. * @param onError defines an optional callback raised if there is an issue to load the texture
  7774. * @param format defines the format of the data
  7775. * @param forcedExtension defines the extension to use to pick the right loader
  7776. * @returns the cube texture as an InternalTexture
  7777. */
  7778. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7779. /**
  7780. * Creates a cube texture
  7781. * @param rootUrl defines the url where the files to load is located
  7782. * @param scene defines the current scene
  7783. * @param files defines the list of files to load (1 per face)
  7784. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7785. * @param onLoad defines an optional callback raised when the texture is loaded
  7786. * @param onError defines an optional callback raised if there is an issue to load the texture
  7787. * @param format defines the format of the data
  7788. * @param forcedExtension defines the extension to use to pick the right loader
  7789. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7790. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7791. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7792. * @returns the cube texture as an InternalTexture
  7793. */
  7794. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7795. /** @hidden */
  7796. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7797. /** @hidden */
  7798. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7799. /** @hidden */
  7800. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7801. /** @hidden */
  7802. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7803. }
  7804. }
  7805. }
  7806. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7807. import { Nullable } from "babylonjs/types";
  7808. import { Scene } from "babylonjs/scene";
  7809. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7811. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7812. /**
  7813. * Class for creating a cube texture
  7814. */
  7815. export class CubeTexture extends BaseTexture {
  7816. private _delayedOnLoad;
  7817. /**
  7818. * The url of the texture
  7819. */
  7820. url: string;
  7821. /**
  7822. * Gets or sets the center of the bounding box associated with the cube texture.
  7823. * It must define where the camera used to render the texture was set
  7824. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7825. */
  7826. boundingBoxPosition: Vector3;
  7827. private _boundingBoxSize;
  7828. /**
  7829. * Gets or sets the size of the bounding box associated with the cube texture
  7830. * When defined, the cubemap will switch to local mode
  7831. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7832. * @example https://www.babylonjs-playground.com/#RNASML
  7833. */
  7834. /**
  7835. * Returns the bounding box size
  7836. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7837. */
  7838. boundingBoxSize: Vector3;
  7839. protected _rotationY: number;
  7840. /**
  7841. * Sets texture matrix rotation angle around Y axis in radians.
  7842. */
  7843. /**
  7844. * Gets texture matrix rotation angle around Y axis radians.
  7845. */
  7846. rotationY: number;
  7847. /**
  7848. * Are mip maps generated for this texture or not.
  7849. */
  7850. readonly noMipmap: boolean;
  7851. private _noMipmap;
  7852. private _files;
  7853. private _extensions;
  7854. private _textureMatrix;
  7855. private _format;
  7856. private _createPolynomials;
  7857. /** @hidden */
  7858. _prefiltered: boolean;
  7859. /**
  7860. * Creates a cube texture from an array of image urls
  7861. * @param files defines an array of image urls
  7862. * @param scene defines the hosting scene
  7863. * @param noMipmap specifies if mip maps are not used
  7864. * @returns a cube texture
  7865. */
  7866. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7867. /**
  7868. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7869. * @param url defines the url of the prefiltered texture
  7870. * @param scene defines the scene the texture is attached to
  7871. * @param forcedExtension defines the extension of the file if different from the url
  7872. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7873. * @return the prefiltered texture
  7874. */
  7875. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7876. /**
  7877. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7878. * as prefiltered data.
  7879. * @param rootUrl defines the url of the texture or the root name of the six images
  7880. * @param scene defines the scene the texture is attached to
  7881. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7882. * @param noMipmap defines if mipmaps should be created or not
  7883. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7884. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7885. * @param onError defines a callback triggered in case of error during load
  7886. * @param format defines the internal format to use for the texture once loaded
  7887. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7888. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7889. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7890. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7891. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7892. * @return the cube texture
  7893. */
  7894. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7895. /**
  7896. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7897. */
  7898. readonly isPrefiltered: boolean;
  7899. /**
  7900. * Get the current class name of the texture useful for serialization or dynamic coding.
  7901. * @returns "CubeTexture"
  7902. */
  7903. getClassName(): string;
  7904. /**
  7905. * Update the url (and optional buffer) of this texture if url was null during construction.
  7906. * @param url the url of the texture
  7907. * @param forcedExtension defines the extension to use
  7908. * @param onLoad callback called when the texture is loaded (defaults to null)
  7909. */
  7910. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7911. /**
  7912. * Delays loading of the cube texture
  7913. * @param forcedExtension defines the extension to use
  7914. */
  7915. delayLoad(forcedExtension?: string): void;
  7916. /**
  7917. * Returns the reflection texture matrix
  7918. * @returns the reflection texture matrix
  7919. */
  7920. getReflectionTextureMatrix(): Matrix;
  7921. /**
  7922. * Sets the reflection texture matrix
  7923. * @param value Reflection texture matrix
  7924. */
  7925. setReflectionTextureMatrix(value: Matrix): void;
  7926. /**
  7927. * Parses text to create a cube texture
  7928. * @param parsedTexture define the serialized text to read from
  7929. * @param scene defines the hosting scene
  7930. * @param rootUrl defines the root url of the cube texture
  7931. * @returns a cube texture
  7932. */
  7933. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7934. /**
  7935. * Makes a clone, or deep copy, of the cube texture
  7936. * @returns a new cube texture
  7937. */
  7938. clone(): CubeTexture;
  7939. }
  7940. }
  7941. declare module "babylonjs/Shaders/postprocess.vertex" {
  7942. /** @hidden */
  7943. export var postprocessVertexShader: {
  7944. name: string;
  7945. shader: string;
  7946. };
  7947. }
  7948. declare module "babylonjs/Cameras/targetCamera" {
  7949. import { Nullable } from "babylonjs/types";
  7950. import { Camera } from "babylonjs/Cameras/camera";
  7951. import { Scene } from "babylonjs/scene";
  7952. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7953. /**
  7954. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7955. * This is the base of the follow, arc rotate cameras and Free camera
  7956. * @see http://doc.babylonjs.com/features/cameras
  7957. */
  7958. export class TargetCamera extends Camera {
  7959. private static _RigCamTransformMatrix;
  7960. private static _TargetTransformMatrix;
  7961. private static _TargetFocalPoint;
  7962. /**
  7963. * Define the current direction the camera is moving to
  7964. */
  7965. cameraDirection: Vector3;
  7966. /**
  7967. * Define the current rotation the camera is rotating to
  7968. */
  7969. cameraRotation: Vector2;
  7970. /**
  7971. * When set, the up vector of the camera will be updated by the rotation of the camera
  7972. */
  7973. updateUpVectorFromRotation: boolean;
  7974. private _tmpQuaternion;
  7975. /**
  7976. * Define the current rotation of the camera
  7977. */
  7978. rotation: Vector3;
  7979. /**
  7980. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7981. */
  7982. rotationQuaternion: Quaternion;
  7983. /**
  7984. * Define the current speed of the camera
  7985. */
  7986. speed: number;
  7987. /**
  7988. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7989. * around all axis.
  7990. */
  7991. noRotationConstraint: boolean;
  7992. /**
  7993. * Define the current target of the camera as an object or a position.
  7994. */
  7995. lockedTarget: any;
  7996. /** @hidden */
  7997. _currentTarget: Vector3;
  7998. /** @hidden */
  7999. _initialFocalDistance: number;
  8000. /** @hidden */
  8001. _viewMatrix: Matrix;
  8002. /** @hidden */
  8003. _camMatrix: Matrix;
  8004. /** @hidden */
  8005. _cameraTransformMatrix: Matrix;
  8006. /** @hidden */
  8007. _cameraRotationMatrix: Matrix;
  8008. /** @hidden */
  8009. _referencePoint: Vector3;
  8010. /** @hidden */
  8011. _transformedReferencePoint: Vector3;
  8012. protected _globalCurrentTarget: Vector3;
  8013. protected _globalCurrentUpVector: Vector3;
  8014. /** @hidden */
  8015. _reset: () => void;
  8016. private _defaultUp;
  8017. /**
  8018. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8019. * This is the base of the follow, arc rotate cameras and Free camera
  8020. * @see http://doc.babylonjs.com/features/cameras
  8021. * @param name Defines the name of the camera in the scene
  8022. * @param position Defines the start position of the camera in the scene
  8023. * @param scene Defines the scene the camera belongs to
  8024. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8025. */
  8026. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8027. /**
  8028. * Gets the position in front of the camera at a given distance.
  8029. * @param distance The distance from the camera we want the position to be
  8030. * @returns the position
  8031. */
  8032. getFrontPosition(distance: number): Vector3;
  8033. /** @hidden */
  8034. _getLockedTargetPosition(): Nullable<Vector3>;
  8035. private _storedPosition;
  8036. private _storedRotation;
  8037. private _storedRotationQuaternion;
  8038. /**
  8039. * Store current camera state of the camera (fov, position, rotation, etc..)
  8040. * @returns the camera
  8041. */
  8042. storeState(): Camera;
  8043. /**
  8044. * Restored camera state. You must call storeState() first
  8045. * @returns whether it was successful or not
  8046. * @hidden
  8047. */
  8048. _restoreStateValues(): boolean;
  8049. /** @hidden */
  8050. _initCache(): void;
  8051. /** @hidden */
  8052. _updateCache(ignoreParentClass?: boolean): void;
  8053. /** @hidden */
  8054. _isSynchronizedViewMatrix(): boolean;
  8055. /** @hidden */
  8056. _computeLocalCameraSpeed(): number;
  8057. /**
  8058. * Defines the target the camera should look at.
  8059. * This will automatically adapt alpha beta and radius to fit within the new target.
  8060. * @param target Defines the new target as a Vector or a mesh
  8061. */
  8062. setTarget(target: Vector3): void;
  8063. /**
  8064. * Return the current target position of the camera. This value is expressed in local space.
  8065. * @returns the target position
  8066. */
  8067. getTarget(): Vector3;
  8068. /** @hidden */
  8069. _decideIfNeedsToMove(): boolean;
  8070. /** @hidden */
  8071. _updatePosition(): void;
  8072. /** @hidden */
  8073. _checkInputs(): void;
  8074. protected _updateCameraRotationMatrix(): void;
  8075. /**
  8076. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8077. * @returns the current camera
  8078. */
  8079. private _rotateUpVectorWithCameraRotationMatrix;
  8080. private _cachedRotationZ;
  8081. private _cachedQuaternionRotationZ;
  8082. /** @hidden */
  8083. _getViewMatrix(): Matrix;
  8084. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8085. /**
  8086. * @hidden
  8087. */
  8088. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8089. /**
  8090. * @hidden
  8091. */
  8092. _updateRigCameras(): void;
  8093. private _getRigCamPositionAndTarget;
  8094. /**
  8095. * Gets the current object class name.
  8096. * @return the class name
  8097. */
  8098. getClassName(): string;
  8099. }
  8100. }
  8101. declare module "babylonjs/Cameras/cameraInputsManager" {
  8102. import { Nullable } from "babylonjs/types";
  8103. import { Camera } from "babylonjs/Cameras/camera";
  8104. /**
  8105. * @ignore
  8106. * This is a list of all the different input types that are available in the application.
  8107. * Fo instance: ArcRotateCameraGamepadInput...
  8108. */
  8109. export var CameraInputTypes: {};
  8110. /**
  8111. * This is the contract to implement in order to create a new input class.
  8112. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8113. */
  8114. export interface ICameraInput<TCamera extends Camera> {
  8115. /**
  8116. * Defines the camera the input is attached to.
  8117. */
  8118. camera: Nullable<TCamera>;
  8119. /**
  8120. * Gets the class name of the current intput.
  8121. * @returns the class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Get the friendly name associated with the input class.
  8126. * @returns the input friendly name
  8127. */
  8128. getSimpleName(): string;
  8129. /**
  8130. * Attach the input controls to a specific dom element to get the input from.
  8131. * @param element Defines the element the controls should be listened from
  8132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8133. */
  8134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8135. /**
  8136. * Detach the current controls from the specified dom element.
  8137. * @param element Defines the element to stop listening the inputs from
  8138. */
  8139. detachControl(element: Nullable<HTMLElement>): void;
  8140. /**
  8141. * Update the current camera state depending on the inputs that have been used this frame.
  8142. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8143. */
  8144. checkInputs?: () => void;
  8145. }
  8146. /**
  8147. * Represents a map of input types to input instance or input index to input instance.
  8148. */
  8149. export interface CameraInputsMap<TCamera extends Camera> {
  8150. /**
  8151. * Accessor to the input by input type.
  8152. */
  8153. [name: string]: ICameraInput<TCamera>;
  8154. /**
  8155. * Accessor to the input by input index.
  8156. */
  8157. [idx: number]: ICameraInput<TCamera>;
  8158. }
  8159. /**
  8160. * This represents the input manager used within a camera.
  8161. * It helps dealing with all the different kind of input attached to a camera.
  8162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8163. */
  8164. export class CameraInputsManager<TCamera extends Camera> {
  8165. /**
  8166. * Defines the list of inputs attahed to the camera.
  8167. */
  8168. attached: CameraInputsMap<TCamera>;
  8169. /**
  8170. * Defines the dom element the camera is collecting inputs from.
  8171. * This is null if the controls have not been attached.
  8172. */
  8173. attachedElement: Nullable<HTMLElement>;
  8174. /**
  8175. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8176. */
  8177. noPreventDefault: boolean;
  8178. /**
  8179. * Defined the camera the input manager belongs to.
  8180. */
  8181. camera: TCamera;
  8182. /**
  8183. * Update the current camera state depending on the inputs that have been used this frame.
  8184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8185. */
  8186. checkInputs: () => void;
  8187. /**
  8188. * Instantiate a new Camera Input Manager.
  8189. * @param camera Defines the camera the input manager blongs to
  8190. */
  8191. constructor(camera: TCamera);
  8192. /**
  8193. * Add an input method to a camera
  8194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8195. * @param input camera input method
  8196. */
  8197. add(input: ICameraInput<TCamera>): void;
  8198. /**
  8199. * Remove a specific input method from a camera
  8200. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8201. * @param inputToRemove camera input method
  8202. */
  8203. remove(inputToRemove: ICameraInput<TCamera>): void;
  8204. /**
  8205. * Remove a specific input type from a camera
  8206. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8207. * @param inputType the type of the input to remove
  8208. */
  8209. removeByType(inputType: string): void;
  8210. private _addCheckInputs;
  8211. /**
  8212. * Attach the input controls to the currently attached dom element to listen the events from.
  8213. * @param input Defines the input to attach
  8214. */
  8215. attachInput(input: ICameraInput<TCamera>): void;
  8216. /**
  8217. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8218. * @param element Defines the dom element to collect the events from
  8219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8220. */
  8221. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8222. /**
  8223. * Detach the current manager inputs controls from a specific dom element.
  8224. * @param element Defines the dom element to collect the events from
  8225. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8226. */
  8227. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8228. /**
  8229. * Rebuild the dynamic inputCheck function from the current list of
  8230. * defined inputs in the manager.
  8231. */
  8232. rebuildInputCheck(): void;
  8233. /**
  8234. * Remove all attached input methods from a camera
  8235. */
  8236. clear(): void;
  8237. /**
  8238. * Serialize the current input manager attached to a camera.
  8239. * This ensures than once parsed,
  8240. * the input associated to the camera will be identical to the current ones
  8241. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8242. */
  8243. serialize(serializedCamera: any): void;
  8244. /**
  8245. * Parses an input manager serialized JSON to restore the previous list of inputs
  8246. * and states associated to a camera.
  8247. * @param parsedCamera Defines the JSON to parse
  8248. */
  8249. parse(parsedCamera: any): void;
  8250. }
  8251. }
  8252. declare module "babylonjs/Events/keyboardEvents" {
  8253. /**
  8254. * Gather the list of keyboard event types as constants.
  8255. */
  8256. export class KeyboardEventTypes {
  8257. /**
  8258. * The keydown event is fired when a key becomes active (pressed).
  8259. */
  8260. static readonly KEYDOWN: number;
  8261. /**
  8262. * The keyup event is fired when a key has been released.
  8263. */
  8264. static readonly KEYUP: number;
  8265. }
  8266. /**
  8267. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8268. */
  8269. export class KeyboardInfo {
  8270. /**
  8271. * Defines the type of event (KeyboardEventTypes)
  8272. */
  8273. type: number;
  8274. /**
  8275. * Defines the related dom event
  8276. */
  8277. event: KeyboardEvent;
  8278. /**
  8279. * Instantiates a new keyboard info.
  8280. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8281. * @param type Defines the type of event (KeyboardEventTypes)
  8282. * @param event Defines the related dom event
  8283. */
  8284. constructor(
  8285. /**
  8286. * Defines the type of event (KeyboardEventTypes)
  8287. */
  8288. type: number,
  8289. /**
  8290. * Defines the related dom event
  8291. */
  8292. event: KeyboardEvent);
  8293. }
  8294. /**
  8295. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8296. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8297. */
  8298. export class KeyboardInfoPre extends KeyboardInfo {
  8299. /**
  8300. * Defines the type of event (KeyboardEventTypes)
  8301. */
  8302. type: number;
  8303. /**
  8304. * Defines the related dom event
  8305. */
  8306. event: KeyboardEvent;
  8307. /**
  8308. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8309. */
  8310. skipOnPointerObservable: boolean;
  8311. /**
  8312. * Instantiates a new keyboard pre info.
  8313. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8314. * @param type Defines the type of event (KeyboardEventTypes)
  8315. * @param event Defines the related dom event
  8316. */
  8317. constructor(
  8318. /**
  8319. * Defines the type of event (KeyboardEventTypes)
  8320. */
  8321. type: number,
  8322. /**
  8323. * Defines the related dom event
  8324. */
  8325. event: KeyboardEvent);
  8326. }
  8327. }
  8328. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8329. import { Nullable } from "babylonjs/types";
  8330. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8331. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8332. /**
  8333. * Manage the keyboard inputs to control the movement of a free camera.
  8334. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8335. */
  8336. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8337. /**
  8338. * Defines the camera the input is attached to.
  8339. */
  8340. camera: FreeCamera;
  8341. /**
  8342. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8343. */
  8344. keysUp: number[];
  8345. /**
  8346. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8347. */
  8348. keysDown: number[];
  8349. /**
  8350. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8351. */
  8352. keysLeft: number[];
  8353. /**
  8354. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8355. */
  8356. keysRight: number[];
  8357. private _keys;
  8358. private _onCanvasBlurObserver;
  8359. private _onKeyboardObserver;
  8360. private _engine;
  8361. private _scene;
  8362. /**
  8363. * Attach the input controls to a specific dom element to get the input from.
  8364. * @param element Defines the element the controls should be listened from
  8365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8366. */
  8367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8368. /**
  8369. * Detach the current controls from the specified dom element.
  8370. * @param element Defines the element to stop listening the inputs from
  8371. */
  8372. detachControl(element: Nullable<HTMLElement>): void;
  8373. /**
  8374. * Update the current camera state depending on the inputs that have been used this frame.
  8375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8376. */
  8377. checkInputs(): void;
  8378. /**
  8379. * Gets the class name of the current intput.
  8380. * @returns the class name
  8381. */
  8382. getClassName(): string;
  8383. /** @hidden */
  8384. _onLostFocus(): void;
  8385. /**
  8386. * Get the friendly name associated with the input class.
  8387. * @returns the input friendly name
  8388. */
  8389. getSimpleName(): string;
  8390. }
  8391. }
  8392. declare module "babylonjs/Materials/multiMaterial" {
  8393. import { Nullable } from "babylonjs/types";
  8394. import { Scene } from "babylonjs/scene";
  8395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8396. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  8397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8398. import { Material } from "babylonjs/Materials/material";
  8399. /**
  8400. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8401. * separate meshes. This can be use to improve performances.
  8402. * @see http://doc.babylonjs.com/how_to/multi_materials
  8403. */
  8404. export class MultiMaterial extends Material {
  8405. private _subMaterials;
  8406. /**
  8407. * Gets or Sets the list of Materials used within the multi material.
  8408. * They need to be ordered according to the submeshes order in the associated mesh
  8409. */
  8410. subMaterials: Nullable<Material>[];
  8411. /**
  8412. * Function used to align with Node.getChildren()
  8413. * @returns the list of Materials used within the multi material
  8414. */
  8415. getChildren(): Nullable<Material>[];
  8416. /**
  8417. * Instantiates a new Multi Material
  8418. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8419. * separate meshes. This can be use to improve performances.
  8420. * @see http://doc.babylonjs.com/how_to/multi_materials
  8421. * @param name Define the name in the scene
  8422. * @param scene Define the scene the material belongs to
  8423. */
  8424. constructor(name: string, scene: Scene);
  8425. private _hookArray;
  8426. /**
  8427. * Get one of the submaterial by its index in the submaterials array
  8428. * @param index The index to look the sub material at
  8429. * @returns The Material if the index has been defined
  8430. */
  8431. getSubMaterial(index: number): Nullable<Material>;
  8432. /**
  8433. * Get the list of active textures for the whole sub materials list.
  8434. * @returns All the textures that will be used during the rendering
  8435. */
  8436. getActiveTextures(): BaseTexture[];
  8437. /**
  8438. * Gets the current class name of the material e.g. "MultiMaterial"
  8439. * Mainly use in serialization.
  8440. * @returns the class name
  8441. */
  8442. getClassName(): string;
  8443. /**
  8444. * Checks if the material is ready to render the requested sub mesh
  8445. * @param mesh Define the mesh the submesh belongs to
  8446. * @param subMesh Define the sub mesh to look readyness for
  8447. * @param useInstances Define whether or not the material is used with instances
  8448. * @returns true if ready, otherwise false
  8449. */
  8450. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8451. /**
  8452. * Clones the current material and its related sub materials
  8453. * @param name Define the name of the newly cloned material
  8454. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8455. * @returns the cloned material
  8456. */
  8457. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8458. /**
  8459. * Serializes the materials into a JSON representation.
  8460. * @returns the JSON representation
  8461. */
  8462. serialize(): any;
  8463. /**
  8464. * Dispose the material and release its associated resources
  8465. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  8466. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  8467. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  8468. */
  8469. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8470. /**
  8471. * Creates a MultiMaterial from parsed MultiMaterial data.
  8472. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8473. * @param scene defines the hosting scene
  8474. * @returns a new MultiMaterial
  8475. */
  8476. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8477. }
  8478. }
  8479. declare module "babylonjs/Loading/sceneLoaderFlags" {
  8480. /**
  8481. * Class used to represent data loading progression
  8482. */
  8483. export class SceneLoaderFlags {
  8484. private static _ForceFullSceneLoadingForIncremental;
  8485. private static _ShowLoadingScreen;
  8486. private static _CleanBoneMatrixWeights;
  8487. private static _loggingLevel;
  8488. /**
  8489. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8490. */
  8491. static ForceFullSceneLoadingForIncremental: boolean;
  8492. /**
  8493. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8494. */
  8495. static ShowLoadingScreen: boolean;
  8496. /**
  8497. * Defines the current logging level (while loading the scene)
  8498. * @ignorenaming
  8499. */
  8500. static loggingLevel: number;
  8501. /**
  8502. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8503. */
  8504. static CleanBoneMatrixWeights: boolean;
  8505. }
  8506. }
  8507. declare module "babylonjs/Meshes/transformNode" {
  8508. import { DeepImmutable } from "babylonjs/types";
  8509. import { Observable } from "babylonjs/Misc/observable";
  8510. import { Nullable } from "babylonjs/types";
  8511. import { Camera } from "babylonjs/Cameras/camera";
  8512. import { Scene } from "babylonjs/scene";
  8513. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  8514. import { Node } from "babylonjs/node";
  8515. import { Bone } from "babylonjs/Bones/bone";
  8516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8517. /**
  8518. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  8519. * @see https://doc.babylonjs.com/how_to/transformnode
  8520. */
  8521. export class TransformNode extends Node {
  8522. /**
  8523. * Object will not rotate to face the camera
  8524. */
  8525. static BILLBOARDMODE_NONE: number;
  8526. /**
  8527. * Object will rotate to face the camera but only on the x axis
  8528. */
  8529. static BILLBOARDMODE_X: number;
  8530. /**
  8531. * Object will rotate to face the camera but only on the y axis
  8532. */
  8533. static BILLBOARDMODE_Y: number;
  8534. /**
  8535. * Object will rotate to face the camera but only on the z axis
  8536. */
  8537. static BILLBOARDMODE_Z: number;
  8538. /**
  8539. * Object will rotate to face the camera
  8540. */
  8541. static BILLBOARDMODE_ALL: number;
  8542. private _forward;
  8543. private _forwardInverted;
  8544. private _up;
  8545. private _right;
  8546. private _rightInverted;
  8547. private _position;
  8548. private _rotation;
  8549. private _rotationQuaternion;
  8550. protected _scaling: Vector3;
  8551. protected _isDirty: boolean;
  8552. private _transformToBoneReferal;
  8553. private _billboardMode;
  8554. /**
  8555. * Gets or sets the billboard mode. Default is 0.
  8556. *
  8557. * | Value | Type | Description |
  8558. * | --- | --- | --- |
  8559. * | 0 | BILLBOARDMODE_NONE | |
  8560. * | 1 | BILLBOARDMODE_X | |
  8561. * | 2 | BILLBOARDMODE_Y | |
  8562. * | 4 | BILLBOARDMODE_Z | |
  8563. * | 7 | BILLBOARDMODE_ALL | |
  8564. *
  8565. */
  8566. billboardMode: number;
  8567. private _preserveParentRotationForBillboard;
  8568. /**
  8569. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8570. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8571. */
  8572. preserveParentRotationForBillboard: boolean;
  8573. /**
  8574. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  8575. */
  8576. scalingDeterminant: number;
  8577. private _infiniteDistance;
  8578. /**
  8579. * Gets or sets the distance of the object to max, often used by skybox
  8580. */
  8581. infiniteDistance: boolean;
  8582. /**
  8583. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8584. * By default the system will update normals to compensate
  8585. */
  8586. ignoreNonUniformScaling: boolean;
  8587. /**
  8588. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  8589. */
  8590. reIntegrateRotationIntoRotationQuaternion: boolean;
  8591. /** @hidden */
  8592. _poseMatrix: Nullable<Matrix>;
  8593. /** @hidden */
  8594. _localMatrix: Matrix;
  8595. private _usePivotMatrix;
  8596. private _absolutePosition;
  8597. private _pivotMatrix;
  8598. private _pivotMatrixInverse;
  8599. protected _postMultiplyPivotMatrix: boolean;
  8600. protected _isWorldMatrixFrozen: boolean;
  8601. /** @hidden */
  8602. _indexInSceneTransformNodesArray: number;
  8603. /**
  8604. * An event triggered after the world matrix is updated
  8605. */
  8606. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8607. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8608. /**
  8609. * Gets a string identifying the name of the class
  8610. * @returns "TransformNode" string
  8611. */
  8612. getClassName(): string;
  8613. /**
  8614. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8615. */
  8616. position: Vector3;
  8617. /**
  8618. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  8619. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8620. */
  8621. rotation: Vector3;
  8622. /**
  8623. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  8624. */
  8625. scaling: Vector3;
  8626. /**
  8627. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  8628. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8629. */
  8630. rotationQuaternion: Nullable<Quaternion>;
  8631. /**
  8632. * The forward direction of that transform in world space.
  8633. */
  8634. readonly forward: Vector3;
  8635. /**
  8636. * The up direction of that transform in world space.
  8637. */
  8638. readonly up: Vector3;
  8639. /**
  8640. * The right direction of that transform in world space.
  8641. */
  8642. readonly right: Vector3;
  8643. /**
  8644. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8645. * @param matrix the matrix to copy the pose from
  8646. * @returns this TransformNode.
  8647. */
  8648. updatePoseMatrix(matrix: Matrix): TransformNode;
  8649. /**
  8650. * Returns the mesh Pose matrix.
  8651. * @returns the pose matrix
  8652. */
  8653. getPoseMatrix(): Matrix;
  8654. /** @hidden */
  8655. _isSynchronized(): boolean;
  8656. /** @hidden */
  8657. _initCache(): void;
  8658. /**
  8659. * Flag the transform node as dirty (Forcing it to update everything)
  8660. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8661. * @returns this transform node
  8662. */
  8663. markAsDirty(property: string): TransformNode;
  8664. /**
  8665. * Returns the current mesh absolute position.
  8666. * Returns a Vector3.
  8667. */
  8668. readonly absolutePosition: Vector3;
  8669. /**
  8670. * Sets a new matrix to apply before all other transformation
  8671. * @param matrix defines the transform matrix
  8672. * @returns the current TransformNode
  8673. */
  8674. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8675. /**
  8676. * Sets a new pivot matrix to the current node
  8677. * @param matrix defines the new pivot matrix to use
  8678. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  8679. * @returns the current TransformNode
  8680. */
  8681. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8682. /**
  8683. * Returns the mesh pivot matrix.
  8684. * Default : Identity.
  8685. * @returns the matrix
  8686. */
  8687. getPivotMatrix(): Matrix;
  8688. /**
  8689. * Prevents the World matrix to be computed any longer.
  8690. * @returns the TransformNode.
  8691. */
  8692. freezeWorldMatrix(): TransformNode;
  8693. /**
  8694. * Allows back the World matrix computation.
  8695. * @returns the TransformNode.
  8696. */
  8697. unfreezeWorldMatrix(): this;
  8698. /**
  8699. * True if the World matrix has been frozen.
  8700. */
  8701. readonly isWorldMatrixFrozen: boolean;
  8702. /**
  8703. * Retuns the mesh absolute position in the World.
  8704. * @returns a Vector3.
  8705. */
  8706. getAbsolutePosition(): Vector3;
  8707. /**
  8708. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8709. * @param absolutePosition the absolute position to set
  8710. * @returns the TransformNode.
  8711. */
  8712. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8713. /**
  8714. * Sets the mesh position in its local space.
  8715. * @param vector3 the position to set in localspace
  8716. * @returns the TransformNode.
  8717. */
  8718. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8719. /**
  8720. * Returns the mesh position in the local space from the current World matrix values.
  8721. * @returns a new Vector3.
  8722. */
  8723. getPositionExpressedInLocalSpace(): Vector3;
  8724. /**
  8725. * Translates the mesh along the passed Vector3 in its local space.
  8726. * @param vector3 the distance to translate in localspace
  8727. * @returns the TransformNode.
  8728. */
  8729. locallyTranslate(vector3: Vector3): TransformNode;
  8730. private static _lookAtVectorCache;
  8731. /**
  8732. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8733. * @param targetPoint the position (must be in same space as current mesh) to look at
  8734. * @param yawCor optional yaw (y-axis) correction in radians
  8735. * @param pitchCor optional pitch (x-axis) correction in radians
  8736. * @param rollCor optional roll (z-axis) correction in radians
  8737. * @param space the choosen space of the target
  8738. * @returns the TransformNode.
  8739. */
  8740. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8741. /**
  8742. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8743. * This Vector3 is expressed in the World space.
  8744. * @param localAxis axis to rotate
  8745. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8746. */
  8747. getDirection(localAxis: Vector3): Vector3;
  8748. /**
  8749. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8750. * localAxis is expressed in the mesh local space.
  8751. * result is computed in the Wordl space from the mesh World matrix.
  8752. * @param localAxis axis to rotate
  8753. * @param result the resulting transformnode
  8754. * @returns this TransformNode.
  8755. */
  8756. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8757. /**
  8758. * Sets this transform node rotation to the given local axis.
  8759. * @param localAxis the axis in local space
  8760. * @param yawCor optional yaw (y-axis) correction in radians
  8761. * @param pitchCor optional pitch (x-axis) correction in radians
  8762. * @param rollCor optional roll (z-axis) correction in radians
  8763. * @returns this TransformNode
  8764. */
  8765. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8766. /**
  8767. * Sets a new pivot point to the current node
  8768. * @param point defines the new pivot point to use
  8769. * @param space defines if the point is in world or local space (local by default)
  8770. * @returns the current TransformNode
  8771. */
  8772. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8773. /**
  8774. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8775. * @returns the pivot point
  8776. */
  8777. getPivotPoint(): Vector3;
  8778. /**
  8779. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8780. * @param result the vector3 to store the result
  8781. * @returns this TransformNode.
  8782. */
  8783. getPivotPointToRef(result: Vector3): TransformNode;
  8784. /**
  8785. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8786. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8787. */
  8788. getAbsolutePivotPoint(): Vector3;
  8789. /**
  8790. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8791. * @param result vector3 to store the result
  8792. * @returns this TransformNode.
  8793. */
  8794. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8795. /**
  8796. * Defines the passed node as the parent of the current node.
  8797. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8798. * @see https://doc.babylonjs.com/how_to/parenting
  8799. * @param node the node ot set as the parent
  8800. * @returns this TransformNode.
  8801. */
  8802. setParent(node: Nullable<Node>): TransformNode;
  8803. private _nonUniformScaling;
  8804. /**
  8805. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8806. */
  8807. readonly nonUniformScaling: boolean;
  8808. /** @hidden */
  8809. _updateNonUniformScalingState(value: boolean): boolean;
  8810. /**
  8811. * Attach the current TransformNode to another TransformNode associated with a bone
  8812. * @param bone Bone affecting the TransformNode
  8813. * @param affectedTransformNode TransformNode associated with the bone
  8814. * @returns this object
  8815. */
  8816. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8817. /**
  8818. * Detach the transform node if its associated with a bone
  8819. * @returns this object
  8820. */
  8821. detachFromBone(): TransformNode;
  8822. private static _rotationAxisCache;
  8823. /**
  8824. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8825. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8826. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8827. * The passed axis is also normalized.
  8828. * @param axis the axis to rotate around
  8829. * @param amount the amount to rotate in radians
  8830. * @param space Space to rotate in (Default: local)
  8831. * @returns the TransformNode.
  8832. */
  8833. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8834. /**
  8835. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8836. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8837. * The passed axis is also normalized. .
  8838. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8839. * @param point the point to rotate around
  8840. * @param axis the axis to rotate around
  8841. * @param amount the amount to rotate in radians
  8842. * @returns the TransformNode
  8843. */
  8844. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8845. /**
  8846. * Translates the mesh along the axis vector for the passed distance in the given space.
  8847. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8848. * @param axis the axis to translate in
  8849. * @param distance the distance to translate
  8850. * @param space Space to rotate in (Default: local)
  8851. * @returns the TransformNode.
  8852. */
  8853. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8854. /**
  8855. * Adds a rotation step to the mesh current rotation.
  8856. * x, y, z are Euler angles expressed in radians.
  8857. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8858. * This means this rotation is made in the mesh local space only.
  8859. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8860. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8861. * ```javascript
  8862. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8863. * ```
  8864. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8865. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  8866. * @param x Rotation to add
  8867. * @param y Rotation to add
  8868. * @param z Rotation to add
  8869. * @returns the TransformNode.
  8870. */
  8871. addRotation(x: number, y: number, z: number): TransformNode;
  8872. /**
  8873. * @hidden
  8874. */
  8875. protected _getEffectiveParent(): Nullable<Node>;
  8876. /**
  8877. * Computes the world matrix of the node
  8878. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8879. * @returns the world matrix
  8880. */
  8881. computeWorldMatrix(force?: boolean): Matrix;
  8882. protected _afterComputeWorldMatrix(): void;
  8883. /**
  8884. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8885. * @param func callback function to add
  8886. *
  8887. * @returns the TransformNode.
  8888. */
  8889. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8890. /**
  8891. * Removes a registered callback function.
  8892. * @param func callback function to remove
  8893. * @returns the TransformNode.
  8894. */
  8895. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8896. /**
  8897. * Gets the position of the current mesh in camera space
  8898. * @param camera defines the camera to use
  8899. * @returns a position
  8900. */
  8901. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8902. /**
  8903. * Returns the distance from the mesh to the active camera
  8904. * @param camera defines the camera to use
  8905. * @returns the distance
  8906. */
  8907. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8908. /**
  8909. * Clone the current transform node
  8910. * @param name Name of the new clone
  8911. * @param newParent New parent for the clone
  8912. * @param doNotCloneChildren Do not clone children hierarchy
  8913. * @returns the new transform node
  8914. */
  8915. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8916. /**
  8917. * Serializes the objects information.
  8918. * @param currentSerializationObject defines the object to serialize in
  8919. * @returns the serialized object
  8920. */
  8921. serialize(currentSerializationObject?: any): any;
  8922. /**
  8923. * Returns a new TransformNode object parsed from the source provided.
  8924. * @param parsedTransformNode is the source.
  8925. * @param scene the scne the object belongs to
  8926. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8927. * @returns a new TransformNode object parsed from the source provided.
  8928. */
  8929. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8930. /**
  8931. * Get all child-transformNodes of this node
  8932. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  8933. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  8934. * @returns an array of TransformNode
  8935. */
  8936. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8937. /**
  8938. * Releases resources associated with this transform node.
  8939. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8940. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8941. */
  8942. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8943. /**
  8944. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8945. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8946. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8947. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8948. * @returns the current mesh
  8949. */
  8950. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8951. }
  8952. }
  8953. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8954. /**
  8955. * Class used to override all child animations of a given target
  8956. */
  8957. export class AnimationPropertiesOverride {
  8958. /**
  8959. * Gets or sets a value indicating if animation blending must be used
  8960. */
  8961. enableBlending: boolean;
  8962. /**
  8963. * Gets or sets the blending speed to use when enableBlending is true
  8964. */
  8965. blendingSpeed: number;
  8966. /**
  8967. * Gets or sets the default loop mode to use
  8968. */
  8969. loopMode: number;
  8970. }
  8971. }
  8972. declare module "babylonjs/Bones/bone" {
  8973. import { Skeleton } from "babylonjs/Bones/skeleton";
  8974. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8975. import { Nullable } from "babylonjs/types";
  8976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8977. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8978. import { Node } from "babylonjs/node";
  8979. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8980. /**
  8981. * Class used to store bone information
  8982. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8983. */
  8984. export class Bone extends Node {
  8985. /**
  8986. * defines the bone name
  8987. */
  8988. name: string;
  8989. private static _tmpVecs;
  8990. private static _tmpQuat;
  8991. private static _tmpMats;
  8992. /**
  8993. * Gets the list of child bones
  8994. */
  8995. children: Bone[];
  8996. /** Gets the animations associated with this bone */
  8997. animations: import("babylonjs/Animations/animation").Animation[];
  8998. /**
  8999. * Gets or sets bone length
  9000. */
  9001. length: number;
  9002. /**
  9003. * @hidden Internal only
  9004. * Set this value to map this bone to a different index in the transform matrices
  9005. * Set this value to -1 to exclude the bone from the transform matrices
  9006. */
  9007. _index: Nullable<number>;
  9008. private _skeleton;
  9009. private _localMatrix;
  9010. private _restPose;
  9011. private _baseMatrix;
  9012. private _absoluteTransform;
  9013. private _invertedAbsoluteTransform;
  9014. private _parent;
  9015. private _scalingDeterminant;
  9016. private _worldTransform;
  9017. private _localScaling;
  9018. private _localRotation;
  9019. private _localPosition;
  9020. private _needToDecompose;
  9021. private _needToCompose;
  9022. /** @hidden */
  9023. _linkedTransformNode: Nullable<TransformNode>;
  9024. /** @hidden */
  9025. _waitingTransformNodeId: Nullable<string>;
  9026. /** @hidden */
  9027. /** @hidden */
  9028. _matrix: Matrix;
  9029. /**
  9030. * Create a new bone
  9031. * @param name defines the bone name
  9032. * @param skeleton defines the parent skeleton
  9033. * @param parentBone defines the parent (can be null if the bone is the root)
  9034. * @param localMatrix defines the local matrix
  9035. * @param restPose defines the rest pose matrix
  9036. * @param baseMatrix defines the base matrix
  9037. * @param index defines index of the bone in the hiearchy
  9038. */
  9039. constructor(
  9040. /**
  9041. * defines the bone name
  9042. */
  9043. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9044. /**
  9045. * Gets the current object class name.
  9046. * @return the class name
  9047. */
  9048. getClassName(): string;
  9049. /**
  9050. * Gets the parent skeleton
  9051. * @returns a skeleton
  9052. */
  9053. getSkeleton(): Skeleton;
  9054. /**
  9055. * Gets parent bone
  9056. * @returns a bone or null if the bone is the root of the bone hierarchy
  9057. */
  9058. getParent(): Nullable<Bone>;
  9059. /**
  9060. * Returns an array containing the root bones
  9061. * @returns an array containing the root bones
  9062. */
  9063. getChildren(): Array<Bone>;
  9064. /**
  9065. * Sets the parent bone
  9066. * @param parent defines the parent (can be null if the bone is the root)
  9067. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9068. */
  9069. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9070. /**
  9071. * Gets the local matrix
  9072. * @returns a matrix
  9073. */
  9074. getLocalMatrix(): Matrix;
  9075. /**
  9076. * Gets the base matrix (initial matrix which remains unchanged)
  9077. * @returns a matrix
  9078. */
  9079. getBaseMatrix(): Matrix;
  9080. /**
  9081. * Gets the rest pose matrix
  9082. * @returns a matrix
  9083. */
  9084. getRestPose(): Matrix;
  9085. /**
  9086. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9087. */
  9088. getWorldMatrix(): Matrix;
  9089. /**
  9090. * Sets the local matrix to rest pose matrix
  9091. */
  9092. returnToRest(): void;
  9093. /**
  9094. * Gets the inverse of the absolute transform matrix.
  9095. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9096. * @returns a matrix
  9097. */
  9098. getInvertedAbsoluteTransform(): Matrix;
  9099. /**
  9100. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9101. * @returns a matrix
  9102. */
  9103. getAbsoluteTransform(): Matrix;
  9104. /**
  9105. * Links with the given transform node.
  9106. * The local matrix of this bone is copied from the transform node every frame.
  9107. * @param transformNode defines the transform node to link to
  9108. */
  9109. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9110. /** Gets or sets current position (in local space) */
  9111. position: Vector3;
  9112. /** Gets or sets current rotation (in local space) */
  9113. rotation: Vector3;
  9114. /** Gets or sets current rotation quaternion (in local space) */
  9115. rotationQuaternion: Quaternion;
  9116. /** Gets or sets current scaling (in local space) */
  9117. scaling: Vector3;
  9118. /**
  9119. * Gets the animation properties override
  9120. */
  9121. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9122. private _decompose;
  9123. private _compose;
  9124. /**
  9125. * Update the base and local matrices
  9126. * @param matrix defines the new base or local matrix
  9127. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9128. * @param updateLocalMatrix defines if the local matrix should be updated
  9129. */
  9130. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9131. /** @hidden */
  9132. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9133. /**
  9134. * Flag the bone as dirty (Forcing it to update everything)
  9135. */
  9136. markAsDirty(): void;
  9137. /** @hidden */
  9138. _markAsDirtyAndCompose(): void;
  9139. private _markAsDirtyAndDecompose;
  9140. /**
  9141. * Translate the bone in local or world space
  9142. * @param vec The amount to translate the bone
  9143. * @param space The space that the translation is in
  9144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9145. */
  9146. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9147. /**
  9148. * Set the postion of the bone in local or world space
  9149. * @param position The position to set the bone
  9150. * @param space The space that the position is in
  9151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9152. */
  9153. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9154. /**
  9155. * Set the absolute position of the bone (world space)
  9156. * @param position The position to set the bone
  9157. * @param mesh The mesh that this bone is attached to
  9158. */
  9159. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9160. /**
  9161. * Scale the bone on the x, y and z axes (in local space)
  9162. * @param x The amount to scale the bone on the x axis
  9163. * @param y The amount to scale the bone on the y axis
  9164. * @param z The amount to scale the bone on the z axis
  9165. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9166. */
  9167. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9168. /**
  9169. * Set the bone scaling in local space
  9170. * @param scale defines the scaling vector
  9171. */
  9172. setScale(scale: Vector3): void;
  9173. /**
  9174. * Gets the current scaling in local space
  9175. * @returns the current scaling vector
  9176. */
  9177. getScale(): Vector3;
  9178. /**
  9179. * Gets the current scaling in local space and stores it in a target vector
  9180. * @param result defines the target vector
  9181. */
  9182. getScaleToRef(result: Vector3): void;
  9183. /**
  9184. * Set the yaw, pitch, and roll of the bone in local or world space
  9185. * @param yaw The rotation of the bone on the y axis
  9186. * @param pitch The rotation of the bone on the x axis
  9187. * @param roll The rotation of the bone on the z axis
  9188. * @param space The space that the axes of rotation are in
  9189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9190. */
  9191. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9192. /**
  9193. * Add a rotation to the bone on an axis in local or world space
  9194. * @param axis The axis to rotate the bone on
  9195. * @param amount The amount to rotate the bone
  9196. * @param space The space that the axis is in
  9197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9198. */
  9199. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9200. /**
  9201. * Set the rotation of the bone to a particular axis angle in local or world space
  9202. * @param axis The axis to rotate the bone on
  9203. * @param angle The angle that the bone should be rotated to
  9204. * @param space The space that the axis is in
  9205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9206. */
  9207. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9208. /**
  9209. * Set the euler rotation of the bone in local of world space
  9210. * @param rotation The euler rotation that the bone should be set to
  9211. * @param space The space that the rotation is in
  9212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9213. */
  9214. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9215. /**
  9216. * Set the quaternion rotation of the bone in local of world space
  9217. * @param quat The quaternion rotation that the bone should be set to
  9218. * @param space The space that the rotation is in
  9219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9220. */
  9221. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9222. /**
  9223. * Set the rotation matrix of the bone in local of world space
  9224. * @param rotMat The rotation matrix that the bone should be set to
  9225. * @param space The space that the rotation is in
  9226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9227. */
  9228. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9229. private _rotateWithMatrix;
  9230. private _getNegativeRotationToRef;
  9231. /**
  9232. * Get the position of the bone in local or world space
  9233. * @param space The space that the returned position is in
  9234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9235. * @returns The position of the bone
  9236. */
  9237. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9238. /**
  9239. * Copy the position of the bone to a vector3 in local or world space
  9240. * @param space The space that the returned position is in
  9241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9242. * @param result The vector3 to copy the position to
  9243. */
  9244. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9245. /**
  9246. * Get the absolute position of the bone (world space)
  9247. * @param mesh The mesh that this bone is attached to
  9248. * @returns The absolute position of the bone
  9249. */
  9250. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9251. /**
  9252. * Copy the absolute position of the bone (world space) to the result param
  9253. * @param mesh The mesh that this bone is attached to
  9254. * @param result The vector3 to copy the absolute position to
  9255. */
  9256. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9257. /**
  9258. * Compute the absolute transforms of this bone and its children
  9259. */
  9260. computeAbsoluteTransforms(): void;
  9261. /**
  9262. * Get the world direction from an axis that is in the local space of the bone
  9263. * @param localAxis The local direction that is used to compute the world direction
  9264. * @param mesh The mesh that this bone is attached to
  9265. * @returns The world direction
  9266. */
  9267. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9268. /**
  9269. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9270. * @param localAxis The local direction that is used to compute the world direction
  9271. * @param mesh The mesh that this bone is attached to
  9272. * @param result The vector3 that the world direction will be copied to
  9273. */
  9274. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9275. /**
  9276. * Get the euler rotation of the bone in local or world space
  9277. * @param space The space that the rotation should be in
  9278. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9279. * @returns The euler rotation
  9280. */
  9281. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9282. /**
  9283. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9284. * @param space The space that the rotation should be in
  9285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9286. * @param result The vector3 that the rotation should be copied to
  9287. */
  9288. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9289. /**
  9290. * Get the quaternion rotation of the bone in either local or world space
  9291. * @param space The space that the rotation should be in
  9292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9293. * @returns The quaternion rotation
  9294. */
  9295. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9296. /**
  9297. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9298. * @param space The space that the rotation should be in
  9299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9300. * @param result The quaternion that the rotation should be copied to
  9301. */
  9302. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9303. /**
  9304. * Get the rotation matrix of the bone in local or world space
  9305. * @param space The space that the rotation should be in
  9306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9307. * @returns The rotation matrix
  9308. */
  9309. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9310. /**
  9311. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9312. * @param space The space that the rotation should be in
  9313. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9314. * @param result The quaternion that the rotation should be copied to
  9315. */
  9316. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9317. /**
  9318. * Get the world position of a point that is in the local space of the bone
  9319. * @param position The local position
  9320. * @param mesh The mesh that this bone is attached to
  9321. * @returns The world position
  9322. */
  9323. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9324. /**
  9325. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9326. * @param position The local position
  9327. * @param mesh The mesh that this bone is attached to
  9328. * @param result The vector3 that the world position should be copied to
  9329. */
  9330. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9331. /**
  9332. * Get the local position of a point that is in world space
  9333. * @param position The world position
  9334. * @param mesh The mesh that this bone is attached to
  9335. * @returns The local position
  9336. */
  9337. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9338. /**
  9339. * Get the local position of a point that is in world space and copy it to the result param
  9340. * @param position The world position
  9341. * @param mesh The mesh that this bone is attached to
  9342. * @param result The vector3 that the local position should be copied to
  9343. */
  9344. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9345. }
  9346. }
  9347. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  9348. import { Nullable } from "babylonjs/types";
  9349. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  9350. import { Scene } from "babylonjs/scene";
  9351. module "babylonjs/Engines/engine" {
  9352. interface Engine {
  9353. /**
  9354. * Creates a raw texture
  9355. * @param data defines the data to store in the texture
  9356. * @param width defines the width of the texture
  9357. * @param height defines the height of the texture
  9358. * @param format defines the format of the data
  9359. * @param generateMipMaps defines if the engine should generate the mip levels
  9360. * @param invertY defines if data must be stored with Y axis inverted
  9361. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9362. * @param compression defines the compression used (null by default)
  9363. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9364. * @returns the raw texture inside an InternalTexture
  9365. */
  9366. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9367. /**
  9368. * Update a raw texture
  9369. * @param texture defines the texture to update
  9370. * @param data defines the data to store in the texture
  9371. * @param format defines the format of the data
  9372. * @param invertY defines if data must be stored with Y axis inverted
  9373. */
  9374. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9375. /**
  9376. * Update a raw texture
  9377. * @param texture defines the texture to update
  9378. * @param data defines the data to store in the texture
  9379. * @param format defines the format of the data
  9380. * @param invertY defines if data must be stored with Y axis inverted
  9381. * @param compression defines the compression used (null by default)
  9382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9383. */
  9384. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9385. /**
  9386. * Creates a new raw cube texture
  9387. * @param data defines the array of data to use to create each face
  9388. * @param size defines the size of the textures
  9389. * @param format defines the format of the data
  9390. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9391. * @param generateMipMaps defines if the engine should generate the mip levels
  9392. * @param invertY defines if data must be stored with Y axis inverted
  9393. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9394. * @param compression defines the compression used (null by default)
  9395. * @returns the cube texture as an InternalTexture
  9396. */
  9397. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9398. /**
  9399. * Update a raw cube texture
  9400. * @param texture defines the texture to udpdate
  9401. * @param data defines the data to store
  9402. * @param format defines the data format
  9403. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9404. * @param invertY defines if data must be stored with Y axis inverted
  9405. */
  9406. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9407. /**
  9408. * Update a raw cube texture
  9409. * @param texture defines the texture to udpdate
  9410. * @param data defines the data to store
  9411. * @param format defines the data format
  9412. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9413. * @param invertY defines if data must be stored with Y axis inverted
  9414. * @param compression defines the compression used (null by default)
  9415. */
  9416. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9417. /**
  9418. * Update a raw cube texture
  9419. * @param texture defines the texture to udpdate
  9420. * @param data defines the data to store
  9421. * @param format defines the data format
  9422. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9423. * @param invertY defines if data must be stored with Y axis inverted
  9424. * @param compression defines the compression used (null by default)
  9425. * @param level defines which level of the texture to update
  9426. */
  9427. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9428. /**
  9429. * Creates a new raw cube texture from a specified url
  9430. * @param url defines the url where the data is located
  9431. * @param scene defines the current scene
  9432. * @param size defines the size of the textures
  9433. * @param format defines the format of the data
  9434. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9435. * @param noMipmap defines if the engine should avoid generating the mip levels
  9436. * @param callback defines a callback used to extract texture data from loaded data
  9437. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9438. * @param onLoad defines a callback called when texture is loaded
  9439. * @param onError defines a callback called if there is an error
  9440. * @returns the cube texture as an InternalTexture
  9441. */
  9442. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  9443. /**
  9444. * Creates a new raw cube texture from a specified url
  9445. * @param url defines the url where the data is located
  9446. * @param scene defines the current scene
  9447. * @param size defines the size of the textures
  9448. * @param format defines the format of the data
  9449. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9450. * @param noMipmap defines if the engine should avoid generating the mip levels
  9451. * @param callback defines a callback used to extract texture data from loaded data
  9452. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9453. * @param onLoad defines a callback called when texture is loaded
  9454. * @param onError defines a callback called if there is an error
  9455. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9456. * @param invertY defines if data must be stored with Y axis inverted
  9457. * @returns the cube texture as an InternalTexture
  9458. */
  9459. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  9460. /**
  9461. * Creates a new raw 3D texture
  9462. * @param data defines the data used to create the texture
  9463. * @param width defines the width of the texture
  9464. * @param height defines the height of the texture
  9465. * @param depth defines the depth of the texture
  9466. * @param format defines the format of the texture
  9467. * @param generateMipMaps defines if the engine must generate mip levels
  9468. * @param invertY defines if data must be stored with Y axis inverted
  9469. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9470. * @param compression defines the compressed used (can be null)
  9471. * @param textureType defines the compressed used (can be null)
  9472. * @returns a new raw 3D texture (stored in an InternalTexture)
  9473. */
  9474. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9475. /**
  9476. * Update a raw 3D texture
  9477. * @param texture defines the texture to update
  9478. * @param data defines the data to store
  9479. * @param format defines the data format
  9480. * @param invertY defines if data must be stored with Y axis inverted
  9481. */
  9482. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9483. /**
  9484. * Update a raw 3D texture
  9485. * @param texture defines the texture to update
  9486. * @param data defines the data to store
  9487. * @param format defines the data format
  9488. * @param invertY defines if data must be stored with Y axis inverted
  9489. * @param compression defines the used compression (can be null)
  9490. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9491. */
  9492. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9493. }
  9494. }
  9495. }
  9496. declare module "babylonjs/Materials/Textures/rawTexture" {
  9497. import { Scene } from "babylonjs/scene";
  9498. import { Texture } from "babylonjs/Materials/Textures/texture";
  9499. import "babylonjs/Engines/Extensions/engine.rawTexture";
  9500. /**
  9501. * Raw texture can help creating a texture directly from an array of data.
  9502. * This can be super useful if you either get the data from an uncompressed source or
  9503. * if you wish to create your texture pixel by pixel.
  9504. */
  9505. export class RawTexture extends Texture {
  9506. /**
  9507. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9508. */
  9509. format: number;
  9510. private _engine;
  9511. /**
  9512. * Instantiates a new RawTexture.
  9513. * Raw texture can help creating a texture directly from an array of data.
  9514. * This can be super useful if you either get the data from an uncompressed source or
  9515. * if you wish to create your texture pixel by pixel.
  9516. * @param data define the array of data to use to create the texture
  9517. * @param width define the width of the texture
  9518. * @param height define the height of the texture
  9519. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9520. * @param scene define the scene the texture belongs to
  9521. * @param generateMipMaps define whether mip maps should be generated or not
  9522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9524. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9525. */
  9526. constructor(data: ArrayBufferView, width: number, height: number,
  9527. /**
  9528. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9529. */
  9530. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9531. /**
  9532. * Updates the texture underlying data.
  9533. * @param data Define the new data of the texture
  9534. */
  9535. update(data: ArrayBufferView): void;
  9536. /**
  9537. * Creates a luminance texture from some data.
  9538. * @param data Define the texture data
  9539. * @param width Define the width of the texture
  9540. * @param height Define the height of the texture
  9541. * @param scene Define the scene the texture belongs to
  9542. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9543. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9544. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9545. * @returns the luminance texture
  9546. */
  9547. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9548. /**
  9549. * Creates a luminance alpha texture from some data.
  9550. * @param data Define the texture data
  9551. * @param width Define the width of the texture
  9552. * @param height Define the height of the texture
  9553. * @param scene Define the scene the texture belongs to
  9554. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9555. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9556. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9557. * @returns the luminance alpha texture
  9558. */
  9559. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9560. /**
  9561. * Creates an alpha texture from some data.
  9562. * @param data Define the texture data
  9563. * @param width Define the width of the texture
  9564. * @param height Define the height of the texture
  9565. * @param scene Define the scene the texture belongs to
  9566. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9567. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9568. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9569. * @returns the alpha texture
  9570. */
  9571. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9572. /**
  9573. * Creates a RGB texture from some data.
  9574. * @param data Define the texture data
  9575. * @param width Define the width of the texture
  9576. * @param height Define the height of the texture
  9577. * @param scene Define the scene the texture belongs to
  9578. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9579. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9580. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9581. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9582. * @returns the RGB alpha texture
  9583. */
  9584. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9585. /**
  9586. * Creates a RGBA texture from some data.
  9587. * @param data Define the texture data
  9588. * @param width Define the width of the texture
  9589. * @param height Define the height of the texture
  9590. * @param scene Define the scene the texture belongs to
  9591. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9592. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9593. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9594. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9595. * @returns the RGBA texture
  9596. */
  9597. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9598. /**
  9599. * Creates a R texture from some data.
  9600. * @param data Define the texture data
  9601. * @param width Define the width of the texture
  9602. * @param height Define the height of the texture
  9603. * @param scene Define the scene the texture belongs to
  9604. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9605. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9606. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9607. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9608. * @returns the R texture
  9609. */
  9610. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9611. }
  9612. }
  9613. declare module "babylonjs/Animations/runtimeAnimation" {
  9614. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  9615. import { Animatable } from "babylonjs/Animations/animatable";
  9616. import { Scene } from "babylonjs/scene";
  9617. /**
  9618. * Defines a runtime animation
  9619. */
  9620. export class RuntimeAnimation {
  9621. private _events;
  9622. /**
  9623. * The current frame of the runtime animation
  9624. */
  9625. private _currentFrame;
  9626. /**
  9627. * The animation used by the runtime animation
  9628. */
  9629. private _animation;
  9630. /**
  9631. * The target of the runtime animation
  9632. */
  9633. private _target;
  9634. /**
  9635. * The initiating animatable
  9636. */
  9637. private _host;
  9638. /**
  9639. * The original value of the runtime animation
  9640. */
  9641. private _originalValue;
  9642. /**
  9643. * The original blend value of the runtime animation
  9644. */
  9645. private _originalBlendValue;
  9646. /**
  9647. * The offsets cache of the runtime animation
  9648. */
  9649. private _offsetsCache;
  9650. /**
  9651. * The high limits cache of the runtime animation
  9652. */
  9653. private _highLimitsCache;
  9654. /**
  9655. * Specifies if the runtime animation has been stopped
  9656. */
  9657. private _stopped;
  9658. /**
  9659. * The blending factor of the runtime animation
  9660. */
  9661. private _blendingFactor;
  9662. /**
  9663. * The BabylonJS scene
  9664. */
  9665. private _scene;
  9666. /**
  9667. * The current value of the runtime animation
  9668. */
  9669. private _currentValue;
  9670. /** @hidden */
  9671. _animationState: _IAnimationState;
  9672. /**
  9673. * The active target of the runtime animation
  9674. */
  9675. private _activeTargets;
  9676. private _currentActiveTarget;
  9677. private _directTarget;
  9678. /**
  9679. * The target path of the runtime animation
  9680. */
  9681. private _targetPath;
  9682. /**
  9683. * The weight of the runtime animation
  9684. */
  9685. private _weight;
  9686. /**
  9687. * The ratio offset of the runtime animation
  9688. */
  9689. private _ratioOffset;
  9690. /**
  9691. * The previous delay of the runtime animation
  9692. */
  9693. private _previousDelay;
  9694. /**
  9695. * The previous ratio of the runtime animation
  9696. */
  9697. private _previousRatio;
  9698. private _enableBlending;
  9699. private _keys;
  9700. private _minFrame;
  9701. private _maxFrame;
  9702. private _minValue;
  9703. private _maxValue;
  9704. private _targetIsArray;
  9705. /**
  9706. * Gets the current frame of the runtime animation
  9707. */
  9708. readonly currentFrame: number;
  9709. /**
  9710. * Gets the weight of the runtime animation
  9711. */
  9712. readonly weight: number;
  9713. /**
  9714. * Gets the current value of the runtime animation
  9715. */
  9716. readonly currentValue: any;
  9717. /**
  9718. * Gets the target path of the runtime animation
  9719. */
  9720. readonly targetPath: string;
  9721. /**
  9722. * Gets the actual target of the runtime animation
  9723. */
  9724. readonly target: any;
  9725. /** @hidden */
  9726. _onLoop: () => void;
  9727. /**
  9728. * Create a new RuntimeAnimation object
  9729. * @param target defines the target of the animation
  9730. * @param animation defines the source animation object
  9731. * @param scene defines the hosting scene
  9732. * @param host defines the initiating Animatable
  9733. */
  9734. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9735. private _preparePath;
  9736. /**
  9737. * Gets the animation from the runtime animation
  9738. */
  9739. readonly animation: Animation;
  9740. /**
  9741. * Resets the runtime animation to the beginning
  9742. * @param restoreOriginal defines whether to restore the target property to the original value
  9743. */
  9744. reset(restoreOriginal?: boolean): void;
  9745. /**
  9746. * Specifies if the runtime animation is stopped
  9747. * @returns Boolean specifying if the runtime animation is stopped
  9748. */
  9749. isStopped(): boolean;
  9750. /**
  9751. * Disposes of the runtime animation
  9752. */
  9753. dispose(): void;
  9754. /**
  9755. * Apply the interpolated value to the target
  9756. * @param currentValue defines the value computed by the animation
  9757. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9758. */
  9759. setValue(currentValue: any, weight: number): void;
  9760. private _getOriginalValues;
  9761. private _setValue;
  9762. /**
  9763. * Gets the loop pmode of the runtime animation
  9764. * @returns Loop Mode
  9765. */
  9766. private _getCorrectLoopMode;
  9767. /**
  9768. * Move the current animation to a given frame
  9769. * @param frame defines the frame to move to
  9770. */
  9771. goToFrame(frame: number): void;
  9772. /**
  9773. * @hidden Internal use only
  9774. */
  9775. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9776. /**
  9777. * Execute the current animation
  9778. * @param delay defines the delay to add to the current frame
  9779. * @param from defines the lower bound of the animation range
  9780. * @param to defines the upper bound of the animation range
  9781. * @param loop defines if the current animation must loop
  9782. * @param speedRatio defines the current speed ratio
  9783. * @param weight defines the weight of the animation (default is -1 so no weight)
  9784. * @param onLoop optional callback called when animation loops
  9785. * @returns a boolean indicating if the animation is running
  9786. */
  9787. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9788. }
  9789. }
  9790. declare module "babylonjs/Animations/animatable" {
  9791. import { Animation } from "babylonjs/Animations/animation";
  9792. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  9793. import { Nullable } from "babylonjs/types";
  9794. import { Observable } from "babylonjs/Misc/observable";
  9795. import { Scene } from "babylonjs/scene";
  9796. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  9797. import { Node } from "babylonjs/node";
  9798. /**
  9799. * Class used to store an actual running animation
  9800. */
  9801. export class Animatable {
  9802. /** defines the target object */
  9803. target: any;
  9804. /** defines the starting frame number (default is 0) */
  9805. fromFrame: number;
  9806. /** defines the ending frame number (default is 100) */
  9807. toFrame: number;
  9808. /** defines if the animation must loop (default is false) */
  9809. loopAnimation: boolean;
  9810. /** defines a callback to call when animation ends if it is not looping */
  9811. onAnimationEnd?: (() => void) | null | undefined;
  9812. /** defines a callback to call when animation loops */
  9813. onAnimationLoop?: (() => void) | null | undefined;
  9814. private _localDelayOffset;
  9815. private _pausedDelay;
  9816. private _runtimeAnimations;
  9817. private _paused;
  9818. private _scene;
  9819. private _speedRatio;
  9820. private _weight;
  9821. private _syncRoot;
  9822. /**
  9823. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9824. * This will only apply for non looping animation (default is true)
  9825. */
  9826. disposeOnEnd: boolean;
  9827. /**
  9828. * Gets a boolean indicating if the animation has started
  9829. */
  9830. animationStarted: boolean;
  9831. /**
  9832. * Observer raised when the animation ends
  9833. */
  9834. onAnimationEndObservable: Observable<Animatable>;
  9835. /**
  9836. * Observer raised when the animation loops
  9837. */
  9838. onAnimationLoopObservable: Observable<Animatable>;
  9839. /**
  9840. * Gets the root Animatable used to synchronize and normalize animations
  9841. */
  9842. readonly syncRoot: Nullable<Animatable>;
  9843. /**
  9844. * Gets the current frame of the first RuntimeAnimation
  9845. * Used to synchronize Animatables
  9846. */
  9847. readonly masterFrame: number;
  9848. /**
  9849. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9850. */
  9851. weight: number;
  9852. /**
  9853. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9854. */
  9855. speedRatio: number;
  9856. /**
  9857. * Creates a new Animatable
  9858. * @param scene defines the hosting scene
  9859. * @param target defines the target object
  9860. * @param fromFrame defines the starting frame number (default is 0)
  9861. * @param toFrame defines the ending frame number (default is 100)
  9862. * @param loopAnimation defines if the animation must loop (default is false)
  9863. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9864. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9865. * @param animations defines a group of animation to add to the new Animatable
  9866. * @param onAnimationLoop defines a callback to call when animation loops
  9867. */
  9868. constructor(scene: Scene,
  9869. /** defines the target object */
  9870. target: any,
  9871. /** defines the starting frame number (default is 0) */
  9872. fromFrame?: number,
  9873. /** defines the ending frame number (default is 100) */
  9874. toFrame?: number,
  9875. /** defines if the animation must loop (default is false) */
  9876. loopAnimation?: boolean, speedRatio?: number,
  9877. /** defines a callback to call when animation ends if it is not looping */
  9878. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9879. /** defines a callback to call when animation loops */
  9880. onAnimationLoop?: (() => void) | null | undefined);
  9881. /**
  9882. * Synchronize and normalize current Animatable with a source Animatable
  9883. * This is useful when using animation weights and when animations are not of the same length
  9884. * @param root defines the root Animatable to synchronize with
  9885. * @returns the current Animatable
  9886. */
  9887. syncWith(root: Animatable): Animatable;
  9888. /**
  9889. * Gets the list of runtime animations
  9890. * @returns an array of RuntimeAnimation
  9891. */
  9892. getAnimations(): RuntimeAnimation[];
  9893. /**
  9894. * Adds more animations to the current animatable
  9895. * @param target defines the target of the animations
  9896. * @param animations defines the new animations to add
  9897. */
  9898. appendAnimations(target: any, animations: Animation[]): void;
  9899. /**
  9900. * Gets the source animation for a specific property
  9901. * @param property defines the propertyu to look for
  9902. * @returns null or the source animation for the given property
  9903. */
  9904. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9905. /**
  9906. * Gets the runtime animation for a specific property
  9907. * @param property defines the propertyu to look for
  9908. * @returns null or the runtime animation for the given property
  9909. */
  9910. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9911. /**
  9912. * Resets the animatable to its original state
  9913. */
  9914. reset(): void;
  9915. /**
  9916. * Allows the animatable to blend with current running animations
  9917. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9918. * @param blendingSpeed defines the blending speed to use
  9919. */
  9920. enableBlending(blendingSpeed: number): void;
  9921. /**
  9922. * Disable animation blending
  9923. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9924. */
  9925. disableBlending(): void;
  9926. /**
  9927. * Jump directly to a given frame
  9928. * @param frame defines the frame to jump to
  9929. */
  9930. goToFrame(frame: number): void;
  9931. /**
  9932. * Pause the animation
  9933. */
  9934. pause(): void;
  9935. /**
  9936. * Restart the animation
  9937. */
  9938. restart(): void;
  9939. private _raiseOnAnimationEnd;
  9940. /**
  9941. * Stop and delete the current animation
  9942. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9943. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  9944. */
  9945. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9946. /**
  9947. * Wait asynchronously for the animation to end
  9948. * @returns a promise which will be fullfilled when the animation ends
  9949. */
  9950. waitAsync(): Promise<Animatable>;
  9951. /** @hidden */
  9952. _animate(delay: number): boolean;
  9953. }
  9954. module "babylonjs/scene" {
  9955. interface Scene {
  9956. /** @hidden */
  9957. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9958. /** @hidden */
  9959. _processLateAnimationBindingsForMatrices(holder: {
  9960. totalWeight: number;
  9961. animations: RuntimeAnimation[];
  9962. originalValue: Matrix;
  9963. }): any;
  9964. /** @hidden */
  9965. _processLateAnimationBindingsForQuaternions(holder: {
  9966. totalWeight: number;
  9967. animations: RuntimeAnimation[];
  9968. originalValue: Quaternion;
  9969. }, refQuaternion: Quaternion): Quaternion;
  9970. /** @hidden */
  9971. _processLateAnimationBindings(): void;
  9972. /**
  9973. * Will start the animation sequence of a given target
  9974. * @param target defines the target
  9975. * @param from defines from which frame should animation start
  9976. * @param to defines until which frame should animation run.
  9977. * @param weight defines the weight to apply to the animation (1.0 by default)
  9978. * @param loop defines if the animation loops
  9979. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9980. * @param onAnimationEnd defines the function to be executed when the animation ends
  9981. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9982. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9983. * @param onAnimationLoop defines the callback to call when an animation loops
  9984. * @returns the animatable object created for this animation
  9985. */
  9986. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9987. /**
  9988. * Will start the animation sequence of a given target
  9989. * @param target defines the target
  9990. * @param from defines from which frame should animation start
  9991. * @param to defines until which frame should animation run.
  9992. * @param loop defines if the animation loops
  9993. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9994. * @param onAnimationEnd defines the function to be executed when the animation ends
  9995. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9996. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9997. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9998. * @param onAnimationLoop defines the callback to call when an animation loops
  9999. * @returns the animatable object created for this animation
  10000. */
  10001. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  10002. /**
  10003. * Will start the animation sequence of a given target and its hierarchy
  10004. * @param target defines the target
  10005. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  10006. * @param from defines from which frame should animation start
  10007. * @param to defines until which frame should animation run.
  10008. * @param loop defines if the animation loops
  10009. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  10010. * @param onAnimationEnd defines the function to be executed when the animation ends
  10011. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  10012. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10013. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  10014. * @param onAnimationLoop defines the callback to call when an animation loops
  10015. * @returns the list of created animatables
  10016. */
  10017. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  10018. /**
  10019. * Begin a new animation on a given node
  10020. * @param target defines the target where the animation will take place
  10021. * @param animations defines the list of animations to start
  10022. * @param from defines the initial value
  10023. * @param to defines the final value
  10024. * @param loop defines if you want animation to loop (off by default)
  10025. * @param speedRatio defines the speed ratio to apply to all animations
  10026. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10027. * @param onAnimationLoop defines the callback to call when an animation loops
  10028. * @returns the list of created animatables
  10029. */
  10030. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  10031. /**
  10032. * Begin a new animation on a given node and its hierarchy
  10033. * @param target defines the root node where the animation will take place
  10034. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  10035. * @param animations defines the list of animations to start
  10036. * @param from defines the initial value
  10037. * @param to defines the final value
  10038. * @param loop defines if you want animation to loop (off by default)
  10039. * @param speedRatio defines the speed ratio to apply to all animations
  10040. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10041. * @param onAnimationLoop defines the callback to call when an animation loops
  10042. * @returns the list of animatables created for all nodes
  10043. */
  10044. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  10045. /**
  10046. * Gets the animatable associated with a specific target
  10047. * @param target defines the target of the animatable
  10048. * @returns the required animatable if found
  10049. */
  10050. getAnimatableByTarget(target: any): Nullable<Animatable>;
  10051. /**
  10052. * Gets all animatables associated with a given target
  10053. * @param target defines the target to look animatables for
  10054. * @returns an array of Animatables
  10055. */
  10056. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  10057. /**
  10058. * Stops and removes all animations that have been applied to the scene
  10059. */
  10060. stopAllAnimations(): void;
  10061. }
  10062. }
  10063. module "babylonjs/Bones/bone" {
  10064. interface Bone {
  10065. /**
  10066. * Copy an animation range from another bone
  10067. * @param source defines the source bone
  10068. * @param rangeName defines the range name to copy
  10069. * @param frameOffset defines the frame offset
  10070. * @param rescaleAsRequired defines if rescaling must be applied if required
  10071. * @param skelDimensionsRatio defines the scaling ratio
  10072. * @returns true if operation was successful
  10073. */
  10074. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  10075. }
  10076. }
  10077. }
  10078. declare module "babylonjs/Bones/skeleton" {
  10079. import { Bone } from "babylonjs/Bones/bone";
  10080. import { IAnimatable } from "babylonjs/Misc/tools";
  10081. import { Observable } from "babylonjs/Misc/observable";
  10082. import { Vector3, Matrix } from "babylonjs/Maths/math";
  10083. import { Scene } from "babylonjs/scene";
  10084. import { Nullable } from "babylonjs/types";
  10085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10086. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  10087. import { Animatable } from "babylonjs/Animations/animatable";
  10088. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10089. import { Animation } from "babylonjs/Animations/animation";
  10090. import { AnimationRange } from "babylonjs/Animations/animationRange";
  10091. import { IInspectable } from "babylonjs/Misc/iInspectable";
  10092. /**
  10093. * Class used to handle skinning animations
  10094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  10095. */
  10096. export class Skeleton implements IAnimatable {
  10097. /** defines the skeleton name */
  10098. name: string;
  10099. /** defines the skeleton Id */
  10100. id: string;
  10101. /**
  10102. * Defines the list of child bones
  10103. */
  10104. bones: Bone[];
  10105. /**
  10106. * Defines an estimate of the dimension of the skeleton at rest
  10107. */
  10108. dimensionsAtRest: Vector3;
  10109. /**
  10110. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  10111. */
  10112. needInitialSkinMatrix: boolean;
  10113. /**
  10114. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  10115. */
  10116. overrideMesh: Nullable<AbstractMesh>;
  10117. /**
  10118. * Gets the list of animations attached to this skeleton
  10119. */
  10120. animations: Array<Animation>;
  10121. private _scene;
  10122. private _isDirty;
  10123. private _transformMatrices;
  10124. private _transformMatrixTexture;
  10125. private _meshesWithPoseMatrix;
  10126. private _animatables;
  10127. private _identity;
  10128. private _synchronizedWithMesh;
  10129. private _ranges;
  10130. private _lastAbsoluteTransformsUpdateId;
  10131. private _canUseTextureForBones;
  10132. private _uniqueId;
  10133. /** @hidden */
  10134. _numBonesWithLinkedTransformNode: number;
  10135. /** @hidden */
  10136. _hasWaitingData: Nullable<boolean>;
  10137. /**
  10138. * Specifies if the skeleton should be serialized
  10139. */
  10140. doNotSerialize: boolean;
  10141. private _useTextureToStoreBoneMatrices;
  10142. /**
  10143. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10144. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  10145. */
  10146. useTextureToStoreBoneMatrices: boolean;
  10147. private _animationPropertiesOverride;
  10148. /**
  10149. * Gets or sets the animation properties override
  10150. */
  10151. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10152. /**
  10153. * List of inspectable custom properties (used by the Inspector)
  10154. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10155. */
  10156. inspectableCustomProperties: IInspectable[];
  10157. /**
  10158. * An observable triggered before computing the skeleton's matrices
  10159. */
  10160. onBeforeComputeObservable: Observable<Skeleton>;
  10161. /**
  10162. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10163. */
  10164. readonly isUsingTextureForMatrices: boolean;
  10165. /**
  10166. * Gets the unique ID of this skeleton
  10167. */
  10168. readonly uniqueId: number;
  10169. /**
  10170. * Creates a new skeleton
  10171. * @param name defines the skeleton name
  10172. * @param id defines the skeleton Id
  10173. * @param scene defines the hosting scene
  10174. */
  10175. constructor(
  10176. /** defines the skeleton name */
  10177. name: string,
  10178. /** defines the skeleton Id */
  10179. id: string, scene: Scene);
  10180. /**
  10181. * Gets the current object class name.
  10182. * @return the class name
  10183. */
  10184. getClassName(): string;
  10185. /**
  10186. * Returns an array containing the root bones
  10187. * @returns an array containing the root bones
  10188. */
  10189. getChildren(): Array<Bone>;
  10190. /**
  10191. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10192. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10193. * @returns a Float32Array containing matrices data
  10194. */
  10195. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10196. /**
  10197. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10198. * @returns a raw texture containing the data
  10199. */
  10200. getTransformMatrixTexture(): Nullable<RawTexture>;
  10201. /**
  10202. * Gets the current hosting scene
  10203. * @returns a scene object
  10204. */
  10205. getScene(): Scene;
  10206. /**
  10207. * Gets a string representing the current skeleton data
  10208. * @param fullDetails defines a boolean indicating if we want a verbose version
  10209. * @returns a string representing the current skeleton data
  10210. */
  10211. toString(fullDetails?: boolean): string;
  10212. /**
  10213. * Get bone's index searching by name
  10214. * @param name defines bone's name to search for
  10215. * @return the indice of the bone. Returns -1 if not found
  10216. */
  10217. getBoneIndexByName(name: string): number;
  10218. /**
  10219. * Creater a new animation range
  10220. * @param name defines the name of the range
  10221. * @param from defines the start key
  10222. * @param to defines the end key
  10223. */
  10224. createAnimationRange(name: string, from: number, to: number): void;
  10225. /**
  10226. * Delete a specific animation range
  10227. * @param name defines the name of the range
  10228. * @param deleteFrames defines if frames must be removed as well
  10229. */
  10230. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10231. /**
  10232. * Gets a specific animation range
  10233. * @param name defines the name of the range to look for
  10234. * @returns the requested animation range or null if not found
  10235. */
  10236. getAnimationRange(name: string): Nullable<AnimationRange>;
  10237. /**
  10238. * Gets the list of all animation ranges defined on this skeleton
  10239. * @returns an array
  10240. */
  10241. getAnimationRanges(): Nullable<AnimationRange>[];
  10242. /**
  10243. * Copy animation range from a source skeleton.
  10244. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10245. * @param source defines the source skeleton
  10246. * @param name defines the name of the range to copy
  10247. * @param rescaleAsRequired defines if rescaling must be applied if required
  10248. * @returns true if operation was successful
  10249. */
  10250. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10251. /**
  10252. * Forces the skeleton to go to rest pose
  10253. */
  10254. returnToRest(): void;
  10255. private _getHighestAnimationFrame;
  10256. /**
  10257. * Begin a specific animation range
  10258. * @param name defines the name of the range to start
  10259. * @param loop defines if looping must be turned on (false by default)
  10260. * @param speedRatio defines the speed ratio to apply (1 by default)
  10261. * @param onAnimationEnd defines a callback which will be called when animation will end
  10262. * @returns a new animatable
  10263. */
  10264. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10265. /** @hidden */
  10266. _markAsDirty(): void;
  10267. /** @hidden */
  10268. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10269. /** @hidden */
  10270. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10271. private _computeTransformMatrices;
  10272. /**
  10273. * Build all resources required to render a skeleton
  10274. */
  10275. prepare(): void;
  10276. /**
  10277. * Gets the list of animatables currently running for this skeleton
  10278. * @returns an array of animatables
  10279. */
  10280. getAnimatables(): IAnimatable[];
  10281. /**
  10282. * Clone the current skeleton
  10283. * @param name defines the name of the new skeleton
  10284. * @param id defines the id of the new skeleton
  10285. * @returns the new skeleton
  10286. */
  10287. clone(name: string, id: string): Skeleton;
  10288. /**
  10289. * Enable animation blending for this skeleton
  10290. * @param blendingSpeed defines the blending speed to apply
  10291. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10292. */
  10293. enableBlending(blendingSpeed?: number): void;
  10294. /**
  10295. * Releases all resources associated with the current skeleton
  10296. */
  10297. dispose(): void;
  10298. /**
  10299. * Serialize the skeleton in a JSON object
  10300. * @returns a JSON object
  10301. */
  10302. serialize(): any;
  10303. /**
  10304. * Creates a new skeleton from serialized data
  10305. * @param parsedSkeleton defines the serialized data
  10306. * @param scene defines the hosting scene
  10307. * @returns a new skeleton
  10308. */
  10309. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10310. /**
  10311. * Compute all node absolute transforms
  10312. * @param forceUpdate defines if computation must be done even if cache is up to date
  10313. */
  10314. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10315. /**
  10316. * Gets the root pose matrix
  10317. * @returns a matrix
  10318. */
  10319. getPoseMatrix(): Nullable<Matrix>;
  10320. /**
  10321. * Sorts bones per internal index
  10322. */
  10323. sortBones(): void;
  10324. private _sortBones;
  10325. }
  10326. }
  10327. declare module "babylonjs/Morph/morphTarget" {
  10328. import { IAnimatable } from "babylonjs/Misc/tools";
  10329. import { Observable } from "babylonjs/Misc/observable";
  10330. import { Nullable, FloatArray } from "babylonjs/types";
  10331. import { Scene } from "babylonjs/scene";
  10332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10333. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10334. /**
  10335. * Defines a target to use with MorphTargetManager
  10336. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10337. */
  10338. export class MorphTarget implements IAnimatable {
  10339. /** defines the name of the target */
  10340. name: string;
  10341. /**
  10342. * Gets or sets the list of animations
  10343. */
  10344. animations: import("babylonjs/Animations/animation").Animation[];
  10345. private _scene;
  10346. private _positions;
  10347. private _normals;
  10348. private _tangents;
  10349. private _influence;
  10350. /**
  10351. * Observable raised when the influence changes
  10352. */
  10353. onInfluenceChanged: Observable<boolean>;
  10354. /** @hidden */
  10355. _onDataLayoutChanged: Observable<void>;
  10356. /**
  10357. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10358. */
  10359. influence: number;
  10360. /**
  10361. * Gets or sets the id of the morph Target
  10362. */
  10363. id: string;
  10364. private _animationPropertiesOverride;
  10365. /**
  10366. * Gets or sets the animation properties override
  10367. */
  10368. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10369. /**
  10370. * Creates a new MorphTarget
  10371. * @param name defines the name of the target
  10372. * @param influence defines the influence to use
  10373. * @param scene defines the scene the morphtarget belongs to
  10374. */
  10375. constructor(
  10376. /** defines the name of the target */
  10377. name: string, influence?: number, scene?: Nullable<Scene>);
  10378. /**
  10379. * Gets a boolean defining if the target contains position data
  10380. */
  10381. readonly hasPositions: boolean;
  10382. /**
  10383. * Gets a boolean defining if the target contains normal data
  10384. */
  10385. readonly hasNormals: boolean;
  10386. /**
  10387. * Gets a boolean defining if the target contains tangent data
  10388. */
  10389. readonly hasTangents: boolean;
  10390. /**
  10391. * Affects position data to this target
  10392. * @param data defines the position data to use
  10393. */
  10394. setPositions(data: Nullable<FloatArray>): void;
  10395. /**
  10396. * Gets the position data stored in this target
  10397. * @returns a FloatArray containing the position data (or null if not present)
  10398. */
  10399. getPositions(): Nullable<FloatArray>;
  10400. /**
  10401. * Affects normal data to this target
  10402. * @param data defines the normal data to use
  10403. */
  10404. setNormals(data: Nullable<FloatArray>): void;
  10405. /**
  10406. * Gets the normal data stored in this target
  10407. * @returns a FloatArray containing the normal data (or null if not present)
  10408. */
  10409. getNormals(): Nullable<FloatArray>;
  10410. /**
  10411. * Affects tangent data to this target
  10412. * @param data defines the tangent data to use
  10413. */
  10414. setTangents(data: Nullable<FloatArray>): void;
  10415. /**
  10416. * Gets the tangent data stored in this target
  10417. * @returns a FloatArray containing the tangent data (or null if not present)
  10418. */
  10419. getTangents(): Nullable<FloatArray>;
  10420. /**
  10421. * Serializes the current target into a Serialization object
  10422. * @returns the serialized object
  10423. */
  10424. serialize(): any;
  10425. /**
  10426. * Returns the string "MorphTarget"
  10427. * @returns "MorphTarget"
  10428. */
  10429. getClassName(): string;
  10430. /**
  10431. * Creates a new target from serialized data
  10432. * @param serializationObject defines the serialized data to use
  10433. * @returns a new MorphTarget
  10434. */
  10435. static Parse(serializationObject: any): MorphTarget;
  10436. /**
  10437. * Creates a MorphTarget from mesh data
  10438. * @param mesh defines the source mesh
  10439. * @param name defines the name to use for the new target
  10440. * @param influence defines the influence to attach to the target
  10441. * @returns a new MorphTarget
  10442. */
  10443. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10444. }
  10445. }
  10446. declare module "babylonjs/Morph/morphTargetManager" {
  10447. import { Nullable } from "babylonjs/types";
  10448. import { Scene } from "babylonjs/scene";
  10449. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  10450. /**
  10451. * This class is used to deform meshes using morphing between different targets
  10452. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10453. */
  10454. export class MorphTargetManager {
  10455. private _targets;
  10456. private _targetInfluenceChangedObservers;
  10457. private _targetDataLayoutChangedObservers;
  10458. private _activeTargets;
  10459. private _scene;
  10460. private _influences;
  10461. private _supportsNormals;
  10462. private _supportsTangents;
  10463. private _vertexCount;
  10464. private _uniqueId;
  10465. private _tempInfluences;
  10466. /**
  10467. * Creates a new MorphTargetManager
  10468. * @param scene defines the current scene
  10469. */
  10470. constructor(scene?: Nullable<Scene>);
  10471. /**
  10472. * Gets the unique ID of this manager
  10473. */
  10474. readonly uniqueId: number;
  10475. /**
  10476. * Gets the number of vertices handled by this manager
  10477. */
  10478. readonly vertexCount: number;
  10479. /**
  10480. * Gets a boolean indicating if this manager supports morphing of normals
  10481. */
  10482. readonly supportsNormals: boolean;
  10483. /**
  10484. * Gets a boolean indicating if this manager supports morphing of tangents
  10485. */
  10486. readonly supportsTangents: boolean;
  10487. /**
  10488. * Gets the number of targets stored in this manager
  10489. */
  10490. readonly numTargets: number;
  10491. /**
  10492. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10493. */
  10494. readonly numInfluencers: number;
  10495. /**
  10496. * Gets the list of influences (one per target)
  10497. */
  10498. readonly influences: Float32Array;
  10499. /**
  10500. * Gets the active target at specified index. An active target is a target with an influence > 0
  10501. * @param index defines the index to check
  10502. * @returns the requested target
  10503. */
  10504. getActiveTarget(index: number): MorphTarget;
  10505. /**
  10506. * Gets the target at specified index
  10507. * @param index defines the index to check
  10508. * @returns the requested target
  10509. */
  10510. getTarget(index: number): MorphTarget;
  10511. /**
  10512. * Add a new target to this manager
  10513. * @param target defines the target to add
  10514. */
  10515. addTarget(target: MorphTarget): void;
  10516. /**
  10517. * Removes a target from the manager
  10518. * @param target defines the target to remove
  10519. */
  10520. removeTarget(target: MorphTarget): void;
  10521. /**
  10522. * Serializes the current manager into a Serialization object
  10523. * @returns the serialized object
  10524. */
  10525. serialize(): any;
  10526. private _syncActiveTargets;
  10527. /**
  10528. * Syncrhonize the targets with all the meshes using this morph target manager
  10529. */
  10530. synchronize(): void;
  10531. /**
  10532. * Creates a new MorphTargetManager from serialized data
  10533. * @param serializationObject defines the serialized data
  10534. * @param scene defines the hosting scene
  10535. * @returns the new MorphTargetManager
  10536. */
  10537. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10538. }
  10539. }
  10540. declare module "babylonjs/sceneComponent" {
  10541. import { Scene } from "babylonjs/scene";
  10542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10543. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10544. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10545. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10546. import { Nullable } from "babylonjs/types";
  10547. import { Camera } from "babylonjs/Cameras/camera";
  10548. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10549. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10550. import { AbstractScene } from "babylonjs/abstractScene";
  10551. /**
  10552. * Groups all the scene component constants in one place to ease maintenance.
  10553. * @hidden
  10554. */
  10555. export class SceneComponentConstants {
  10556. static readonly NAME_EFFECTLAYER: string;
  10557. static readonly NAME_LAYER: string;
  10558. static readonly NAME_LENSFLARESYSTEM: string;
  10559. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10560. static readonly NAME_PARTICLESYSTEM: string;
  10561. static readonly NAME_GAMEPAD: string;
  10562. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10563. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10564. static readonly NAME_DEPTHRENDERER: string;
  10565. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10566. static readonly NAME_SPRITE: string;
  10567. static readonly NAME_OUTLINERENDERER: string;
  10568. static readonly NAME_PROCEDURALTEXTURE: string;
  10569. static readonly NAME_SHADOWGENERATOR: string;
  10570. static readonly NAME_OCTREE: string;
  10571. static readonly NAME_PHYSICSENGINE: string;
  10572. static readonly NAME_AUDIO: string;
  10573. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10574. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10575. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10576. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10577. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10578. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10579. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10580. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10581. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10582. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10583. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10584. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10585. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10586. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10587. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10588. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10589. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10590. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10591. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10592. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10593. static readonly STEP_AFTERRENDER_AUDIO: number;
  10594. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10595. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10596. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10597. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10598. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10599. static readonly STEP_POINTERMOVE_SPRITE: number;
  10600. static readonly STEP_POINTERDOWN_SPRITE: number;
  10601. static readonly STEP_POINTERUP_SPRITE: number;
  10602. }
  10603. /**
  10604. * This represents a scene component.
  10605. *
  10606. * This is used to decouple the dependency the scene is having on the different workloads like
  10607. * layers, post processes...
  10608. */
  10609. export interface ISceneComponent {
  10610. /**
  10611. * The name of the component. Each component must have a unique name.
  10612. */
  10613. name: string;
  10614. /**
  10615. * The scene the component belongs to.
  10616. */
  10617. scene: Scene;
  10618. /**
  10619. * Register the component to one instance of a scene.
  10620. */
  10621. register(): void;
  10622. /**
  10623. * Rebuilds the elements related to this component in case of
  10624. * context lost for instance.
  10625. */
  10626. rebuild(): void;
  10627. /**
  10628. * Disposes the component and the associated ressources.
  10629. */
  10630. dispose(): void;
  10631. }
  10632. /**
  10633. * This represents a SERIALIZABLE scene component.
  10634. *
  10635. * This extends Scene Component to add Serialization methods on top.
  10636. */
  10637. export interface ISceneSerializableComponent extends ISceneComponent {
  10638. /**
  10639. * Adds all the elements from the container to the scene
  10640. * @param container the container holding the elements
  10641. */
  10642. addFromContainer(container: AbstractScene): void;
  10643. /**
  10644. * Removes all the elements in the container from the scene
  10645. * @param container contains the elements to remove
  10646. * @param dispose if the removed element should be disposed (default: false)
  10647. */
  10648. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10649. /**
  10650. * Serializes the component data to the specified json object
  10651. * @param serializationObject The object to serialize to
  10652. */
  10653. serialize(serializationObject: any): void;
  10654. }
  10655. /**
  10656. * Strong typing of a Mesh related stage step action
  10657. */
  10658. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10659. /**
  10660. * Strong typing of a Evaluate Sub Mesh related stage step action
  10661. */
  10662. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10663. /**
  10664. * Strong typing of a Active Mesh related stage step action
  10665. */
  10666. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10667. /**
  10668. * Strong typing of a Camera related stage step action
  10669. */
  10670. export type CameraStageAction = (camera: Camera) => void;
  10671. /**
  10672. * Strong typing of a Camera Frame buffer related stage step action
  10673. */
  10674. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10675. /**
  10676. * Strong typing of a Render Target related stage step action
  10677. */
  10678. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10679. /**
  10680. * Strong typing of a RenderingGroup related stage step action
  10681. */
  10682. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10683. /**
  10684. * Strong typing of a Mesh Render related stage step action
  10685. */
  10686. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10687. /**
  10688. * Strong typing of a simple stage step action
  10689. */
  10690. export type SimpleStageAction = () => void;
  10691. /**
  10692. * Strong typing of a render target action.
  10693. */
  10694. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10695. /**
  10696. * Strong typing of a pointer move action.
  10697. */
  10698. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10699. /**
  10700. * Strong typing of a pointer up/down action.
  10701. */
  10702. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10703. /**
  10704. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10705. * @hidden
  10706. */
  10707. export class Stage<T extends Function> extends Array<{
  10708. index: number;
  10709. component: ISceneComponent;
  10710. action: T;
  10711. }> {
  10712. /**
  10713. * Hide ctor from the rest of the world.
  10714. * @param items The items to add.
  10715. */
  10716. private constructor();
  10717. /**
  10718. * Creates a new Stage.
  10719. * @returns A new instance of a Stage
  10720. */
  10721. static Create<T extends Function>(): Stage<T>;
  10722. /**
  10723. * Registers a step in an ordered way in the targeted stage.
  10724. * @param index Defines the position to register the step in
  10725. * @param component Defines the component attached to the step
  10726. * @param action Defines the action to launch during the step
  10727. */
  10728. registerStep(index: number, component: ISceneComponent, action: T): void;
  10729. /**
  10730. * Clears all the steps from the stage.
  10731. */
  10732. clear(): void;
  10733. }
  10734. }
  10735. declare module "babylonjs/Meshes/meshLODLevel" {
  10736. import { Mesh } from "babylonjs/Meshes/mesh";
  10737. import { Nullable } from "babylonjs/types";
  10738. /**
  10739. * Class used to represent a specific level of detail of a mesh
  10740. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10741. */
  10742. export class MeshLODLevel {
  10743. /** Defines the distance where this level should star being displayed */
  10744. distance: number;
  10745. /** Defines the mesh to use to render this level */
  10746. mesh: Nullable<Mesh>;
  10747. /**
  10748. * Creates a new LOD level
  10749. * @param distance defines the distance where this level should star being displayed
  10750. * @param mesh defines the mesh to use to render this level
  10751. */
  10752. constructor(
  10753. /** Defines the distance where this level should star being displayed */
  10754. distance: number,
  10755. /** Defines the mesh to use to render this level */
  10756. mesh: Nullable<Mesh>);
  10757. }
  10758. }
  10759. declare module "babylonjs/Lights/shadowLight" {
  10760. import { Camera } from "babylonjs/Cameras/camera";
  10761. import { Scene } from "babylonjs/scene";
  10762. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10764. import { Light } from "babylonjs/Lights/light";
  10765. /**
  10766. * Interface describing all the common properties and methods a shadow light needs to implement.
  10767. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10768. * as well as binding the different shadow properties to the effects.
  10769. */
  10770. export interface IShadowLight extends Light {
  10771. /**
  10772. * The light id in the scene (used in scene.findLighById for instance)
  10773. */
  10774. id: string;
  10775. /**
  10776. * The position the shdow will be casted from.
  10777. */
  10778. position: Vector3;
  10779. /**
  10780. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10781. */
  10782. direction: Vector3;
  10783. /**
  10784. * The transformed position. Position of the light in world space taking parenting in account.
  10785. */
  10786. transformedPosition: Vector3;
  10787. /**
  10788. * The transformed direction. Direction of the light in world space taking parenting in account.
  10789. */
  10790. transformedDirection: Vector3;
  10791. /**
  10792. * The friendly name of the light in the scene.
  10793. */
  10794. name: string;
  10795. /**
  10796. * Defines the shadow projection clipping minimum z value.
  10797. */
  10798. shadowMinZ: number;
  10799. /**
  10800. * Defines the shadow projection clipping maximum z value.
  10801. */
  10802. shadowMaxZ: number;
  10803. /**
  10804. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10805. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10806. */
  10807. computeTransformedInformation(): boolean;
  10808. /**
  10809. * Gets the scene the light belongs to.
  10810. * @returns The scene
  10811. */
  10812. getScene(): Scene;
  10813. /**
  10814. * Callback defining a custom Projection Matrix Builder.
  10815. * This can be used to override the default projection matrix computation.
  10816. */
  10817. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10818. /**
  10819. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10820. * @param matrix The materix to updated with the projection information
  10821. * @param viewMatrix The transform matrix of the light
  10822. * @param renderList The list of mesh to render in the map
  10823. * @returns The current light
  10824. */
  10825. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10826. /**
  10827. * Gets the current depth scale used in ESM.
  10828. * @returns The scale
  10829. */
  10830. getDepthScale(): number;
  10831. /**
  10832. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10833. * @returns true if a cube texture needs to be use
  10834. */
  10835. needCube(): boolean;
  10836. /**
  10837. * Detects if the projection matrix requires to be recomputed this frame.
  10838. * @returns true if it requires to be recomputed otherwise, false.
  10839. */
  10840. needProjectionMatrixCompute(): boolean;
  10841. /**
  10842. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10843. */
  10844. forceProjectionMatrixCompute(): void;
  10845. /**
  10846. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10847. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10848. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10849. */
  10850. getShadowDirection(faceIndex?: number): Vector3;
  10851. /**
  10852. * Gets the minZ used for shadow according to both the scene and the light.
  10853. * @param activeCamera The camera we are returning the min for
  10854. * @returns the depth min z
  10855. */
  10856. getDepthMinZ(activeCamera: Camera): number;
  10857. /**
  10858. * Gets the maxZ used for shadow according to both the scene and the light.
  10859. * @param activeCamera The camera we are returning the max for
  10860. * @returns the depth max z
  10861. */
  10862. getDepthMaxZ(activeCamera: Camera): number;
  10863. }
  10864. /**
  10865. * Base implementation IShadowLight
  10866. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10867. */
  10868. export abstract class ShadowLight extends Light implements IShadowLight {
  10869. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10870. protected _position: Vector3;
  10871. protected _setPosition(value: Vector3): void;
  10872. /**
  10873. * Sets the position the shadow will be casted from. Also use as the light position for both
  10874. * point and spot lights.
  10875. */
  10876. /**
  10877. * Sets the position the shadow will be casted from. Also use as the light position for both
  10878. * point and spot lights.
  10879. */
  10880. position: Vector3;
  10881. protected _direction: Vector3;
  10882. protected _setDirection(value: Vector3): void;
  10883. /**
  10884. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10885. * Also use as the light direction on spot and directional lights.
  10886. */
  10887. /**
  10888. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10889. * Also use as the light direction on spot and directional lights.
  10890. */
  10891. direction: Vector3;
  10892. private _shadowMinZ;
  10893. /**
  10894. * Gets the shadow projection clipping minimum z value.
  10895. */
  10896. /**
  10897. * Sets the shadow projection clipping minimum z value.
  10898. */
  10899. shadowMinZ: number;
  10900. private _shadowMaxZ;
  10901. /**
  10902. * Sets the shadow projection clipping maximum z value.
  10903. */
  10904. /**
  10905. * Gets the shadow projection clipping maximum z value.
  10906. */
  10907. shadowMaxZ: number;
  10908. /**
  10909. * Callback defining a custom Projection Matrix Builder.
  10910. * This can be used to override the default projection matrix computation.
  10911. */
  10912. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10913. /**
  10914. * The transformed position. Position of the light in world space taking parenting in account.
  10915. */
  10916. transformedPosition: Vector3;
  10917. /**
  10918. * The transformed direction. Direction of the light in world space taking parenting in account.
  10919. */
  10920. transformedDirection: Vector3;
  10921. private _needProjectionMatrixCompute;
  10922. /**
  10923. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10924. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10925. */
  10926. computeTransformedInformation(): boolean;
  10927. /**
  10928. * Return the depth scale used for the shadow map.
  10929. * @returns the depth scale.
  10930. */
  10931. getDepthScale(): number;
  10932. /**
  10933. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10934. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10935. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10936. */
  10937. getShadowDirection(faceIndex?: number): Vector3;
  10938. /**
  10939. * Returns the ShadowLight absolute position in the World.
  10940. * @returns the position vector in world space
  10941. */
  10942. getAbsolutePosition(): Vector3;
  10943. /**
  10944. * Sets the ShadowLight direction toward the passed target.
  10945. * @param target The point to target in local space
  10946. * @returns the updated ShadowLight direction
  10947. */
  10948. setDirectionToTarget(target: Vector3): Vector3;
  10949. /**
  10950. * Returns the light rotation in euler definition.
  10951. * @returns the x y z rotation in local space.
  10952. */
  10953. getRotation(): Vector3;
  10954. /**
  10955. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10956. * @returns true if a cube texture needs to be use
  10957. */
  10958. needCube(): boolean;
  10959. /**
  10960. * Detects if the projection matrix requires to be recomputed this frame.
  10961. * @returns true if it requires to be recomputed otherwise, false.
  10962. */
  10963. needProjectionMatrixCompute(): boolean;
  10964. /**
  10965. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10966. */
  10967. forceProjectionMatrixCompute(): void;
  10968. /** @hidden */
  10969. _initCache(): void;
  10970. /** @hidden */
  10971. _isSynchronized(): boolean;
  10972. /**
  10973. * Computes the world matrix of the node
  10974. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10975. * @returns the world matrix
  10976. */
  10977. computeWorldMatrix(force?: boolean): Matrix;
  10978. /**
  10979. * Gets the minZ used for shadow according to both the scene and the light.
  10980. * @param activeCamera The camera we are returning the min for
  10981. * @returns the depth min z
  10982. */
  10983. getDepthMinZ(activeCamera: Camera): number;
  10984. /**
  10985. * Gets the maxZ used for shadow according to both the scene and the light.
  10986. * @param activeCamera The camera we are returning the max for
  10987. * @returns the depth max z
  10988. */
  10989. getDepthMaxZ(activeCamera: Camera): number;
  10990. /**
  10991. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10992. * @param matrix The materix to updated with the projection information
  10993. * @param viewMatrix The transform matrix of the light
  10994. * @param renderList The list of mesh to render in the map
  10995. * @returns The current light
  10996. */
  10997. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10998. }
  10999. }
  11000. declare module "babylonjs/Materials/materialHelper" {
  11001. import { Nullable } from "babylonjs/types";
  11002. import { Scene } from "babylonjs/scene";
  11003. import { Engine } from "babylonjs/Engines/engine";
  11004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11005. import { Light } from "babylonjs/Lights/light";
  11006. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11007. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  11008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11009. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11010. /**
  11011. * "Static Class" containing the most commonly used helper while dealing with material for
  11012. * rendering purpose.
  11013. *
  11014. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  11015. *
  11016. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  11017. */
  11018. export class MaterialHelper {
  11019. /**
  11020. * Bind the current view position to an effect.
  11021. * @param effect The effect to be bound
  11022. * @param scene The scene the eyes position is used from
  11023. */
  11024. static BindEyePosition(effect: Effect, scene: Scene): void;
  11025. /**
  11026. * Helps preparing the defines values about the UVs in used in the effect.
  11027. * UVs are shared as much as we can accross channels in the shaders.
  11028. * @param texture The texture we are preparing the UVs for
  11029. * @param defines The defines to update
  11030. * @param key The channel key "diffuse", "specular"... used in the shader
  11031. */
  11032. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  11033. /**
  11034. * Binds a texture matrix value to its corrsponding uniform
  11035. * @param texture The texture to bind the matrix for
  11036. * @param uniformBuffer The uniform buffer receivin the data
  11037. * @param key The channel key "diffuse", "specular"... used in the shader
  11038. */
  11039. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  11040. /**
  11041. * Gets the current status of the fog (should it be enabled?)
  11042. * @param mesh defines the mesh to evaluate for fog support
  11043. * @param scene defines the hosting scene
  11044. * @returns true if fog must be enabled
  11045. */
  11046. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  11047. /**
  11048. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  11049. * @param mesh defines the current mesh
  11050. * @param scene defines the current scene
  11051. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  11052. * @param pointsCloud defines if point cloud rendering has to be turned on
  11053. * @param fogEnabled defines if fog has to be turned on
  11054. * @param alphaTest defines if alpha testing has to be turned on
  11055. * @param defines defines the current list of defines
  11056. */
  11057. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  11058. /**
  11059. * Helper used to prepare the list of defines associated with frame values for shader compilation
  11060. * @param scene defines the current scene
  11061. * @param engine defines the current engine
  11062. * @param defines specifies the list of active defines
  11063. * @param useInstances defines if instances have to be turned on
  11064. * @param useClipPlane defines if clip plane have to be turned on
  11065. */
  11066. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  11067. /**
  11068. * Prepares the defines for bones
  11069. * @param mesh The mesh containing the geometry data we will draw
  11070. * @param defines The defines to update
  11071. */
  11072. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  11073. /**
  11074. * Prepares the defines for morph targets
  11075. * @param mesh The mesh containing the geometry data we will draw
  11076. * @param defines The defines to update
  11077. */
  11078. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  11079. /**
  11080. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  11081. * @param mesh The mesh containing the geometry data we will draw
  11082. * @param defines The defines to update
  11083. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  11084. * @param useBones Precise whether bones should be used or not (override mesh info)
  11085. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  11086. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  11087. * @returns false if defines are considered not dirty and have not been checked
  11088. */
  11089. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  11090. /**
  11091. * Prepares the defines related to multiview
  11092. * @param scene The scene we are intending to draw
  11093. * @param defines The defines to update
  11094. */
  11095. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  11096. /**
  11097. * Prepares the defines related to the light information passed in parameter
  11098. * @param scene The scene we are intending to draw
  11099. * @param mesh The mesh the effect is compiling for
  11100. * @param defines The defines to update
  11101. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11102. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  11103. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  11104. * @returns true if normals will be required for the rest of the effect
  11105. */
  11106. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  11107. /**
  11108. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  11109. * that won t be acctive due to defines being turned off.
  11110. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  11111. * @param samplersList The samplers list
  11112. * @param defines The defines helping in the list generation
  11113. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  11114. */
  11115. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11116. /**
  11117. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11118. * @param defines The defines to update while falling back
  11119. * @param fallbacks The authorized effect fallbacks
  11120. * @param maxSimultaneousLights The maximum number of lights allowed
  11121. * @param rank the current rank of the Effect
  11122. * @returns The newly affected rank
  11123. */
  11124. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11125. /**
  11126. * Prepares the list of attributes required for morph targets according to the effect defines.
  11127. * @param attribs The current list of supported attribs
  11128. * @param mesh The mesh to prepare the morph targets attributes for
  11129. * @param defines The current Defines of the effect
  11130. */
  11131. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11132. /**
  11133. * Prepares the list of attributes required for bones according to the effect defines.
  11134. * @param attribs The current list of supported attribs
  11135. * @param mesh The mesh to prepare the bones attributes for
  11136. * @param defines The current Defines of the effect
  11137. * @param fallbacks The current efffect fallback strategy
  11138. */
  11139. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11140. /**
  11141. * Check and prepare the list of attributes required for instances according to the effect defines.
  11142. * @param attribs The current list of supported attribs
  11143. * @param defines The current MaterialDefines of the effect
  11144. */
  11145. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11146. /**
  11147. * Add the list of attributes required for instances to the attribs array.
  11148. * @param attribs The current list of supported attribs
  11149. */
  11150. static PushAttributesForInstances(attribs: string[]): void;
  11151. /**
  11152. * Binds the light shadow information to the effect for the given mesh.
  11153. * @param light The light containing the generator
  11154. * @param scene The scene the lights belongs to
  11155. * @param mesh The mesh we are binding the information to render
  11156. * @param lightIndex The light index in the effect used to render the mesh
  11157. * @param effect The effect we are binding the data to
  11158. */
  11159. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11160. /**
  11161. * Binds the light information to the effect.
  11162. * @param light The light containing the generator
  11163. * @param effect The effect we are binding the data to
  11164. * @param lightIndex The light index in the effect used to render
  11165. */
  11166. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11167. /**
  11168. * Binds the lights information from the scene to the effect for the given mesh.
  11169. * @param scene The scene the lights belongs to
  11170. * @param mesh The mesh we are binding the information to render
  11171. * @param effect The effect we are binding the data to
  11172. * @param defines The generated defines for the effect
  11173. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11174. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11175. */
  11176. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11177. private static _tempFogColor;
  11178. /**
  11179. * Binds the fog information from the scene to the effect for the given mesh.
  11180. * @param scene The scene the lights belongs to
  11181. * @param mesh The mesh we are binding the information to render
  11182. * @param effect The effect we are binding the data to
  11183. * @param linearSpace Defines if the fog effect is applied in linear space
  11184. */
  11185. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11186. /**
  11187. * Binds the bones information from the mesh to the effect.
  11188. * @param mesh The mesh we are binding the information to render
  11189. * @param effect The effect we are binding the data to
  11190. */
  11191. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11192. /**
  11193. * Binds the morph targets information from the mesh to the effect.
  11194. * @param abstractMesh The mesh we are binding the information to render
  11195. * @param effect The effect we are binding the data to
  11196. */
  11197. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11198. /**
  11199. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11200. * @param defines The generated defines used in the effect
  11201. * @param effect The effect we are binding the data to
  11202. * @param scene The scene we are willing to render with logarithmic scale for
  11203. */
  11204. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11205. /**
  11206. * Binds the clip plane information from the scene to the effect.
  11207. * @param scene The scene the clip plane information are extracted from
  11208. * @param effect The effect we are binding the data to
  11209. */
  11210. static BindClipPlane(effect: Effect, scene: Scene): void;
  11211. }
  11212. }
  11213. declare module "babylonjs/Shaders/shadowMap.fragment" {
  11214. /** @hidden */
  11215. export var shadowMapPixelShader: {
  11216. name: string;
  11217. shader: string;
  11218. };
  11219. }
  11220. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  11221. /** @hidden */
  11222. export var bonesDeclaration: {
  11223. name: string;
  11224. shader: string;
  11225. };
  11226. }
  11227. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  11228. /** @hidden */
  11229. export var morphTargetsVertexGlobalDeclaration: {
  11230. name: string;
  11231. shader: string;
  11232. };
  11233. }
  11234. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  11235. /** @hidden */
  11236. export var morphTargetsVertexDeclaration: {
  11237. name: string;
  11238. shader: string;
  11239. };
  11240. }
  11241. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  11242. /** @hidden */
  11243. export var instancesDeclaration: {
  11244. name: string;
  11245. shader: string;
  11246. };
  11247. }
  11248. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  11249. /** @hidden */
  11250. export var helperFunctions: {
  11251. name: string;
  11252. shader: string;
  11253. };
  11254. }
  11255. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  11256. /** @hidden */
  11257. export var morphTargetsVertex: {
  11258. name: string;
  11259. shader: string;
  11260. };
  11261. }
  11262. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  11263. /** @hidden */
  11264. export var instancesVertex: {
  11265. name: string;
  11266. shader: string;
  11267. };
  11268. }
  11269. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  11270. /** @hidden */
  11271. export var bonesVertex: {
  11272. name: string;
  11273. shader: string;
  11274. };
  11275. }
  11276. declare module "babylonjs/Shaders/shadowMap.vertex" {
  11277. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  11278. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  11279. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  11280. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  11281. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11282. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  11283. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  11284. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  11285. /** @hidden */
  11286. export var shadowMapVertexShader: {
  11287. name: string;
  11288. shader: string;
  11289. };
  11290. }
  11291. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  11292. /** @hidden */
  11293. export var depthBoxBlurPixelShader: {
  11294. name: string;
  11295. shader: string;
  11296. };
  11297. }
  11298. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  11299. import { Nullable } from "babylonjs/types";
  11300. import { Scene } from "babylonjs/scene";
  11301. import { Matrix } from "babylonjs/Maths/math";
  11302. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11304. import { Mesh } from "babylonjs/Meshes/mesh";
  11305. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  11306. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11307. import { Effect } from "babylonjs/Materials/effect";
  11308. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11309. import "babylonjs/Shaders/shadowMap.fragment";
  11310. import "babylonjs/Shaders/shadowMap.vertex";
  11311. import "babylonjs/Shaders/depthBoxBlur.fragment";
  11312. import { Observable } from "babylonjs/Misc/observable";
  11313. /**
  11314. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11315. */
  11316. export interface ICustomShaderOptions {
  11317. /**
  11318. * Gets or sets the custom shader name to use
  11319. */
  11320. shaderName: string;
  11321. /**
  11322. * The list of attribute names used in the shader
  11323. */
  11324. attributes?: string[];
  11325. /**
  11326. * The list of unifrom names used in the shader
  11327. */
  11328. uniforms?: string[];
  11329. /**
  11330. * The list of sampler names used in the shader
  11331. */
  11332. samplers?: string[];
  11333. /**
  11334. * The list of defines used in the shader
  11335. */
  11336. defines?: string[];
  11337. }
  11338. /**
  11339. * Interface to implement to create a shadow generator compatible with BJS.
  11340. */
  11341. export interface IShadowGenerator {
  11342. /**
  11343. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11344. * @returns The render target texture if present otherwise, null
  11345. */
  11346. getShadowMap(): Nullable<RenderTargetTexture>;
  11347. /**
  11348. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11349. * @returns The render target texture if the shadow map is present otherwise, null
  11350. */
  11351. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11352. /**
  11353. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11354. * @param subMesh The submesh we want to render in the shadow map
  11355. * @param useInstances Defines wether will draw in the map using instances
  11356. * @returns true if ready otherwise, false
  11357. */
  11358. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11359. /**
  11360. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11361. * @param defines Defines of the material we want to update
  11362. * @param lightIndex Index of the light in the enabled light list of the material
  11363. */
  11364. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11365. /**
  11366. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11367. * defined in the generator but impacting the effect).
  11368. * It implies the unifroms available on the materials are the standard BJS ones.
  11369. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11370. * @param effect The effect we are binfing the information for
  11371. */
  11372. bindShadowLight(lightIndex: string, effect: Effect): void;
  11373. /**
  11374. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11375. * (eq to shadow prjection matrix * light transform matrix)
  11376. * @returns The transform matrix used to create the shadow map
  11377. */
  11378. getTransformMatrix(): Matrix;
  11379. /**
  11380. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11381. * Cube and 2D textures for instance.
  11382. */
  11383. recreateShadowMap(): void;
  11384. /**
  11385. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11386. * @param onCompiled Callback triggered at the and of the effects compilation
  11387. * @param options Sets of optional options forcing the compilation with different modes
  11388. */
  11389. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11390. useInstances: boolean;
  11391. }>): void;
  11392. /**
  11393. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11394. * @param options Sets of optional options forcing the compilation with different modes
  11395. * @returns A promise that resolves when the compilation completes
  11396. */
  11397. forceCompilationAsync(options?: Partial<{
  11398. useInstances: boolean;
  11399. }>): Promise<void>;
  11400. /**
  11401. * Serializes the shadow generator setup to a json object.
  11402. * @returns The serialized JSON object
  11403. */
  11404. serialize(): any;
  11405. /**
  11406. * Disposes the Shadow map and related Textures and effects.
  11407. */
  11408. dispose(): void;
  11409. }
  11410. /**
  11411. * Default implementation IShadowGenerator.
  11412. * This is the main object responsible of generating shadows in the framework.
  11413. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11414. */
  11415. export class ShadowGenerator implements IShadowGenerator {
  11416. /**
  11417. * Shadow generator mode None: no filtering applied.
  11418. */
  11419. static readonly FILTER_NONE: number;
  11420. /**
  11421. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11422. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11423. */
  11424. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11425. /**
  11426. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11427. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11428. */
  11429. static readonly FILTER_POISSONSAMPLING: number;
  11430. /**
  11431. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11432. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11433. */
  11434. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11435. /**
  11436. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11437. * edge artifacts on steep falloff.
  11438. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11439. */
  11440. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11441. /**
  11442. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11443. * edge artifacts on steep falloff.
  11444. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11445. */
  11446. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11447. /**
  11448. * Shadow generator mode PCF: Percentage Closer Filtering
  11449. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11450. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11451. */
  11452. static readonly FILTER_PCF: number;
  11453. /**
  11454. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11455. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11456. * Contact Hardening
  11457. */
  11458. static readonly FILTER_PCSS: number;
  11459. /**
  11460. * Reserved for PCF and PCSS
  11461. * Highest Quality.
  11462. *
  11463. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11464. *
  11465. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11466. */
  11467. static readonly QUALITY_HIGH: number;
  11468. /**
  11469. * Reserved for PCF and PCSS
  11470. * Good tradeoff for quality/perf cross devices
  11471. *
  11472. * Execute PCF on a 3*3 kernel.
  11473. *
  11474. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11475. */
  11476. static readonly QUALITY_MEDIUM: number;
  11477. /**
  11478. * Reserved for PCF and PCSS
  11479. * The lowest quality but the fastest.
  11480. *
  11481. * Execute PCF on a 1*1 kernel.
  11482. *
  11483. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11484. */
  11485. static readonly QUALITY_LOW: number;
  11486. /** Gets or sets the custom shader name to use */
  11487. customShaderOptions: ICustomShaderOptions;
  11488. /**
  11489. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11490. */
  11491. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11492. /**
  11493. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11494. */
  11495. onAfterShadowMapRenderObservable: Observable<Effect>;
  11496. /**
  11497. * Observable triggered before a mesh is rendered in the shadow map.
  11498. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11499. */
  11500. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11501. /**
  11502. * Observable triggered after a mesh is rendered in the shadow map.
  11503. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11504. */
  11505. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11506. private _bias;
  11507. /**
  11508. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11509. */
  11510. /**
  11511. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11512. */
  11513. bias: number;
  11514. private _normalBias;
  11515. /**
  11516. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11517. */
  11518. /**
  11519. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11520. */
  11521. normalBias: number;
  11522. private _blurBoxOffset;
  11523. /**
  11524. * Gets the blur box offset: offset applied during the blur pass.
  11525. * Only useful if useKernelBlur = false
  11526. */
  11527. /**
  11528. * Sets the blur box offset: offset applied during the blur pass.
  11529. * Only useful if useKernelBlur = false
  11530. */
  11531. blurBoxOffset: number;
  11532. private _blurScale;
  11533. /**
  11534. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11535. * 2 means half of the size.
  11536. */
  11537. /**
  11538. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11539. * 2 means half of the size.
  11540. */
  11541. blurScale: number;
  11542. private _blurKernel;
  11543. /**
  11544. * Gets the blur kernel: kernel size of the blur pass.
  11545. * Only useful if useKernelBlur = true
  11546. */
  11547. /**
  11548. * Sets the blur kernel: kernel size of the blur pass.
  11549. * Only useful if useKernelBlur = true
  11550. */
  11551. blurKernel: number;
  11552. private _useKernelBlur;
  11553. /**
  11554. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11555. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11556. */
  11557. /**
  11558. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11559. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11560. */
  11561. useKernelBlur: boolean;
  11562. private _depthScale;
  11563. /**
  11564. * Gets the depth scale used in ESM mode.
  11565. */
  11566. /**
  11567. * Sets the depth scale used in ESM mode.
  11568. * This can override the scale stored on the light.
  11569. */
  11570. depthScale: number;
  11571. private _filter;
  11572. /**
  11573. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11574. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11575. */
  11576. /**
  11577. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11578. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11579. */
  11580. filter: number;
  11581. /**
  11582. * Gets if the current filter is set to Poisson Sampling.
  11583. */
  11584. /**
  11585. * Sets the current filter to Poisson Sampling.
  11586. */
  11587. usePoissonSampling: boolean;
  11588. /**
  11589. * Gets if the current filter is set to ESM.
  11590. */
  11591. /**
  11592. * Sets the current filter is to ESM.
  11593. */
  11594. useExponentialShadowMap: boolean;
  11595. /**
  11596. * Gets if the current filter is set to filtered ESM.
  11597. */
  11598. /**
  11599. * Gets if the current filter is set to filtered ESM.
  11600. */
  11601. useBlurExponentialShadowMap: boolean;
  11602. /**
  11603. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11604. * exponential to prevent steep falloff artifacts).
  11605. */
  11606. /**
  11607. * Sets the current filter to "close ESM" (using the inverse of the
  11608. * exponential to prevent steep falloff artifacts).
  11609. */
  11610. useCloseExponentialShadowMap: boolean;
  11611. /**
  11612. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11613. * exponential to prevent steep falloff artifacts).
  11614. */
  11615. /**
  11616. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11617. * exponential to prevent steep falloff artifacts).
  11618. */
  11619. useBlurCloseExponentialShadowMap: boolean;
  11620. /**
  11621. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11622. */
  11623. /**
  11624. * Sets the current filter to "PCF" (percentage closer filtering).
  11625. */
  11626. usePercentageCloserFiltering: boolean;
  11627. private _filteringQuality;
  11628. /**
  11629. * Gets the PCF or PCSS Quality.
  11630. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11631. */
  11632. /**
  11633. * Sets the PCF or PCSS Quality.
  11634. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11635. */
  11636. filteringQuality: number;
  11637. /**
  11638. * Gets if the current filter is set to "PCSS" (contact hardening).
  11639. */
  11640. /**
  11641. * Sets the current filter to "PCSS" (contact hardening).
  11642. */
  11643. useContactHardeningShadow: boolean;
  11644. private _contactHardeningLightSizeUVRatio;
  11645. /**
  11646. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11647. * Using a ratio helps keeping shape stability independently of the map size.
  11648. *
  11649. * It does not account for the light projection as it was having too much
  11650. * instability during the light setup or during light position changes.
  11651. *
  11652. * Only valid if useContactHardeningShadow is true.
  11653. */
  11654. /**
  11655. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11656. * Using a ratio helps keeping shape stability independently of the map size.
  11657. *
  11658. * It does not account for the light projection as it was having too much
  11659. * instability during the light setup or during light position changes.
  11660. *
  11661. * Only valid if useContactHardeningShadow is true.
  11662. */
  11663. contactHardeningLightSizeUVRatio: number;
  11664. private _darkness;
  11665. /** Gets or sets the actual darkness of a shadow */
  11666. darkness: number;
  11667. /**
  11668. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11669. * 0 means strongest and 1 would means no shadow.
  11670. * @returns the darkness.
  11671. */
  11672. getDarkness(): number;
  11673. /**
  11674. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11675. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11676. * @returns the shadow generator allowing fluent coding.
  11677. */
  11678. setDarkness(darkness: number): ShadowGenerator;
  11679. private _transparencyShadow;
  11680. /** Gets or sets the ability to have transparent shadow */
  11681. transparencyShadow: boolean;
  11682. /**
  11683. * Sets the ability to have transparent shadow (boolean).
  11684. * @param transparent True if transparent else False
  11685. * @returns the shadow generator allowing fluent coding
  11686. */
  11687. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11688. private _shadowMap;
  11689. private _shadowMap2;
  11690. /**
  11691. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11692. * @returns The render target texture if present otherwise, null
  11693. */
  11694. getShadowMap(): Nullable<RenderTargetTexture>;
  11695. /**
  11696. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11697. * @returns The render target texture if the shadow map is present otherwise, null
  11698. */
  11699. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11700. /**
  11701. * Gets the class name of that object
  11702. * @returns "ShadowGenerator"
  11703. */
  11704. getClassName(): string;
  11705. /**
  11706. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11707. * @param mesh Mesh to add
  11708. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11709. * @returns the Shadow Generator itself
  11710. */
  11711. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11712. /**
  11713. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11714. * @param mesh Mesh to remove
  11715. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11716. * @returns the Shadow Generator itself
  11717. */
  11718. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11719. /**
  11720. * Controls the extent to which the shadows fade out at the edge of the frustum
  11721. * Used only by directionals and spots
  11722. */
  11723. frustumEdgeFalloff: number;
  11724. private _light;
  11725. /**
  11726. * Returns the associated light object.
  11727. * @returns the light generating the shadow
  11728. */
  11729. getLight(): IShadowLight;
  11730. /**
  11731. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11732. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11733. * It might on the other hand introduce peter panning.
  11734. */
  11735. forceBackFacesOnly: boolean;
  11736. private _scene;
  11737. private _lightDirection;
  11738. private _effect;
  11739. private _viewMatrix;
  11740. private _projectionMatrix;
  11741. private _transformMatrix;
  11742. private _cachedPosition;
  11743. private _cachedDirection;
  11744. private _cachedDefines;
  11745. private _currentRenderID;
  11746. private _boxBlurPostprocess;
  11747. private _kernelBlurXPostprocess;
  11748. private _kernelBlurYPostprocess;
  11749. private _blurPostProcesses;
  11750. private _mapSize;
  11751. private _currentFaceIndex;
  11752. private _currentFaceIndexCache;
  11753. private _textureType;
  11754. private _defaultTextureMatrix;
  11755. /** @hidden */
  11756. static _SceneComponentInitialization: (scene: Scene) => void;
  11757. /**
  11758. * Creates a ShadowGenerator object.
  11759. * A ShadowGenerator is the required tool to use the shadows.
  11760. * Each light casting shadows needs to use its own ShadowGenerator.
  11761. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11762. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11763. * @param light The light object generating the shadows.
  11764. * @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.
  11765. */
  11766. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11767. private _initializeGenerator;
  11768. private _initializeShadowMap;
  11769. private _initializeBlurRTTAndPostProcesses;
  11770. private _renderForShadowMap;
  11771. private _renderSubMeshForShadowMap;
  11772. private _applyFilterValues;
  11773. /**
  11774. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11775. * @param onCompiled Callback triggered at the and of the effects compilation
  11776. * @param options Sets of optional options forcing the compilation with different modes
  11777. */
  11778. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11779. useInstances: boolean;
  11780. }>): void;
  11781. /**
  11782. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11783. * @param options Sets of optional options forcing the compilation with different modes
  11784. * @returns A promise that resolves when the compilation completes
  11785. */
  11786. forceCompilationAsync(options?: Partial<{
  11787. useInstances: boolean;
  11788. }>): Promise<void>;
  11789. /**
  11790. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11791. * @param subMesh The submesh we want to render in the shadow map
  11792. * @param useInstances Defines wether will draw in the map using instances
  11793. * @returns true if ready otherwise, false
  11794. */
  11795. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11796. /**
  11797. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11798. * @param defines Defines of the material we want to update
  11799. * @param lightIndex Index of the light in the enabled light list of the material
  11800. */
  11801. prepareDefines(defines: any, lightIndex: number): void;
  11802. /**
  11803. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11804. * defined in the generator but impacting the effect).
  11805. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11806. * @param effect The effect we are binfing the information for
  11807. */
  11808. bindShadowLight(lightIndex: string, effect: Effect): void;
  11809. /**
  11810. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11811. * (eq to shadow prjection matrix * light transform matrix)
  11812. * @returns The transform matrix used to create the shadow map
  11813. */
  11814. getTransformMatrix(): Matrix;
  11815. /**
  11816. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11817. * Cube and 2D textures for instance.
  11818. */
  11819. recreateShadowMap(): void;
  11820. private _disposeBlurPostProcesses;
  11821. private _disposeRTTandPostProcesses;
  11822. /**
  11823. * Disposes the ShadowGenerator.
  11824. * Returns nothing.
  11825. */
  11826. dispose(): void;
  11827. /**
  11828. * Serializes the shadow generator setup to a json object.
  11829. * @returns The serialized JSON object
  11830. */
  11831. serialize(): any;
  11832. /**
  11833. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11834. * @param parsedShadowGenerator The JSON object to parse
  11835. * @param scene The scene to create the shadow map for
  11836. * @returns The parsed shadow generator
  11837. */
  11838. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11839. }
  11840. }
  11841. declare module "babylonjs/Lights/light" {
  11842. import { Nullable } from "babylonjs/types";
  11843. import { Scene } from "babylonjs/scene";
  11844. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11845. import { Node } from "babylonjs/node";
  11846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11847. import { Effect } from "babylonjs/Materials/effect";
  11848. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11849. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11850. /**
  11851. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11852. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11853. * 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.
  11854. */
  11855. export abstract class Light extends Node {
  11856. /**
  11857. * Falloff Default: light is falling off following the material specification:
  11858. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11859. */
  11860. static readonly FALLOFF_DEFAULT: number;
  11861. /**
  11862. * Falloff Physical: light is falling off following the inverse squared distance law.
  11863. */
  11864. static readonly FALLOFF_PHYSICAL: number;
  11865. /**
  11866. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11867. * to enhance interoperability with other engines.
  11868. */
  11869. static readonly FALLOFF_GLTF: number;
  11870. /**
  11871. * Falloff Standard: light is falling off like in the standard material
  11872. * to enhance interoperability with other materials.
  11873. */
  11874. static readonly FALLOFF_STANDARD: number;
  11875. /**
  11876. * If every light affecting the material is in this lightmapMode,
  11877. * material.lightmapTexture adds or multiplies
  11878. * (depends on material.useLightmapAsShadowmap)
  11879. * after every other light calculations.
  11880. */
  11881. static readonly LIGHTMAP_DEFAULT: number;
  11882. /**
  11883. * material.lightmapTexture as only diffuse lighting from this light
  11884. * adds only specular lighting from this light
  11885. * adds dynamic shadows
  11886. */
  11887. static readonly LIGHTMAP_SPECULAR: number;
  11888. /**
  11889. * material.lightmapTexture as only lighting
  11890. * no light calculation from this light
  11891. * only adds dynamic shadows from this light
  11892. */
  11893. static readonly LIGHTMAP_SHADOWSONLY: number;
  11894. /**
  11895. * Each light type uses the default quantity according to its type:
  11896. * point/spot lights use luminous intensity
  11897. * directional lights use illuminance
  11898. */
  11899. static readonly INTENSITYMODE_AUTOMATIC: number;
  11900. /**
  11901. * lumen (lm)
  11902. */
  11903. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11904. /**
  11905. * candela (lm/sr)
  11906. */
  11907. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11908. /**
  11909. * lux (lm/m^2)
  11910. */
  11911. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11912. /**
  11913. * nit (cd/m^2)
  11914. */
  11915. static readonly INTENSITYMODE_LUMINANCE: number;
  11916. /**
  11917. * Light type const id of the point light.
  11918. */
  11919. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11920. /**
  11921. * Light type const id of the directional light.
  11922. */
  11923. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11924. /**
  11925. * Light type const id of the spot light.
  11926. */
  11927. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11928. /**
  11929. * Light type const id of the hemispheric light.
  11930. */
  11931. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11932. /**
  11933. * Diffuse gives the basic color to an object.
  11934. */
  11935. diffuse: Color3;
  11936. /**
  11937. * Specular produces a highlight color on an object.
  11938. * Note: This is note affecting PBR materials.
  11939. */
  11940. specular: Color3;
  11941. /**
  11942. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11943. * falling off base on range or angle.
  11944. * This can be set to any values in Light.FALLOFF_x.
  11945. *
  11946. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11947. * other types of materials.
  11948. */
  11949. falloffType: number;
  11950. /**
  11951. * Strength of the light.
  11952. * Note: By default it is define in the framework own unit.
  11953. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11954. */
  11955. intensity: number;
  11956. private _range;
  11957. protected _inverseSquaredRange: number;
  11958. /**
  11959. * Defines how far from the source the light is impacting in scene units.
  11960. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11961. */
  11962. /**
  11963. * Defines how far from the source the light is impacting in scene units.
  11964. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11965. */
  11966. range: number;
  11967. /**
  11968. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11969. * of light.
  11970. */
  11971. private _photometricScale;
  11972. private _intensityMode;
  11973. /**
  11974. * Gets the photometric scale used to interpret the intensity.
  11975. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11976. */
  11977. /**
  11978. * Sets the photometric scale used to interpret the intensity.
  11979. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11980. */
  11981. intensityMode: number;
  11982. private _radius;
  11983. /**
  11984. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11985. */
  11986. /**
  11987. * sets the light radius used by PBR Materials to simulate soft area lights.
  11988. */
  11989. radius: number;
  11990. private _renderPriority;
  11991. /**
  11992. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11993. * exceeding the number allowed of the materials.
  11994. */
  11995. renderPriority: number;
  11996. private _shadowEnabled;
  11997. /**
  11998. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11999. * the current shadow generator.
  12000. */
  12001. /**
  12002. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12003. * the current shadow generator.
  12004. */
  12005. shadowEnabled: boolean;
  12006. private _includedOnlyMeshes;
  12007. /**
  12008. * Gets the only meshes impacted by this light.
  12009. */
  12010. /**
  12011. * Sets the only meshes impacted by this light.
  12012. */
  12013. includedOnlyMeshes: AbstractMesh[];
  12014. private _excludedMeshes;
  12015. /**
  12016. * Gets the meshes not impacted by this light.
  12017. */
  12018. /**
  12019. * Sets the meshes not impacted by this light.
  12020. */
  12021. excludedMeshes: AbstractMesh[];
  12022. private _excludeWithLayerMask;
  12023. /**
  12024. * Gets the layer id use to find what meshes are not impacted by the light.
  12025. * Inactive if 0
  12026. */
  12027. /**
  12028. * Sets the layer id use to find what meshes are not impacted by the light.
  12029. * Inactive if 0
  12030. */
  12031. excludeWithLayerMask: number;
  12032. private _includeOnlyWithLayerMask;
  12033. /**
  12034. * Gets the layer id use to find what meshes are impacted by the light.
  12035. * Inactive if 0
  12036. */
  12037. /**
  12038. * Sets the layer id use to find what meshes are impacted by the light.
  12039. * Inactive if 0
  12040. */
  12041. includeOnlyWithLayerMask: number;
  12042. private _lightmapMode;
  12043. /**
  12044. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12045. */
  12046. /**
  12047. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12048. */
  12049. lightmapMode: number;
  12050. /**
  12051. * Shadow generator associted to the light.
  12052. * @hidden Internal use only.
  12053. */
  12054. _shadowGenerator: Nullable<IShadowGenerator>;
  12055. /**
  12056. * @hidden Internal use only.
  12057. */
  12058. _excludedMeshesIds: string[];
  12059. /**
  12060. * @hidden Internal use only.
  12061. */
  12062. _includedOnlyMeshesIds: string[];
  12063. /**
  12064. * The current light unifom buffer.
  12065. * @hidden Internal use only.
  12066. */
  12067. _uniformBuffer: UniformBuffer;
  12068. /**
  12069. * Creates a Light object in the scene.
  12070. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12071. * @param name The firendly name of the light
  12072. * @param scene The scene the light belongs too
  12073. */
  12074. constructor(name: string, scene: Scene);
  12075. protected abstract _buildUniformLayout(): void;
  12076. /**
  12077. * Sets the passed Effect "effect" with the Light information.
  12078. * @param effect The effect to update
  12079. * @param lightIndex The index of the light in the effect to update
  12080. * @returns The light
  12081. */
  12082. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12083. /**
  12084. * Returns the string "Light".
  12085. * @returns the class name
  12086. */
  12087. getClassName(): string;
  12088. /** @hidden */
  12089. readonly _isLight: boolean;
  12090. /**
  12091. * Converts the light information to a readable string for debug purpose.
  12092. * @param fullDetails Supports for multiple levels of logging within scene loading
  12093. * @returns the human readable light info
  12094. */
  12095. toString(fullDetails?: boolean): string;
  12096. /** @hidden */
  12097. protected _syncParentEnabledState(): void;
  12098. /**
  12099. * Set the enabled state of this node.
  12100. * @param value - the new enabled state
  12101. */
  12102. setEnabled(value: boolean): void;
  12103. /**
  12104. * Returns the Light associated shadow generator if any.
  12105. * @return the associated shadow generator.
  12106. */
  12107. getShadowGenerator(): Nullable<IShadowGenerator>;
  12108. /**
  12109. * Returns a Vector3, the absolute light position in the World.
  12110. * @returns the world space position of the light
  12111. */
  12112. getAbsolutePosition(): Vector3;
  12113. /**
  12114. * Specifies if the light will affect the passed mesh.
  12115. * @param mesh The mesh to test against the light
  12116. * @return true the mesh is affected otherwise, false.
  12117. */
  12118. canAffectMesh(mesh: AbstractMesh): boolean;
  12119. /**
  12120. * Sort function to order lights for rendering.
  12121. * @param a First Light object to compare to second.
  12122. * @param b Second Light object to compare first.
  12123. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12124. */
  12125. static CompareLightsPriority(a: Light, b: Light): number;
  12126. /**
  12127. * Releases resources associated with this node.
  12128. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12129. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12130. */
  12131. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12132. /**
  12133. * Returns the light type ID (integer).
  12134. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12135. */
  12136. getTypeID(): number;
  12137. /**
  12138. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12139. * @returns the scaled intensity in intensity mode unit
  12140. */
  12141. getScaledIntensity(): number;
  12142. /**
  12143. * Returns a new Light object, named "name", from the current one.
  12144. * @param name The name of the cloned light
  12145. * @returns the new created light
  12146. */
  12147. clone(name: string): Nullable<Light>;
  12148. /**
  12149. * Serializes the current light into a Serialization object.
  12150. * @returns the serialized object.
  12151. */
  12152. serialize(): any;
  12153. /**
  12154. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12155. * This new light is named "name" and added to the passed scene.
  12156. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12157. * @param name The friendly name of the light
  12158. * @param scene The scene the new light will belong to
  12159. * @returns the constructor function
  12160. */
  12161. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12162. /**
  12163. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12164. * @param parsedLight The JSON representation of the light
  12165. * @param scene The scene to create the parsed light in
  12166. * @returns the created light after parsing
  12167. */
  12168. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12169. private _hookArrayForExcluded;
  12170. private _hookArrayForIncludedOnly;
  12171. private _resyncMeshes;
  12172. /**
  12173. * Forces the meshes to update their light related information in their rendering used effects
  12174. * @hidden Internal Use Only
  12175. */
  12176. _markMeshesAsLightDirty(): void;
  12177. /**
  12178. * Recomputes the cached photometric scale if needed.
  12179. */
  12180. private _computePhotometricScale;
  12181. /**
  12182. * Returns the Photometric Scale according to the light type and intensity mode.
  12183. */
  12184. private _getPhotometricScale;
  12185. /**
  12186. * Reorder the light in the scene according to their defined priority.
  12187. * @hidden Internal Use Only
  12188. */
  12189. _reorderLightsInScene(): void;
  12190. /**
  12191. * Prepares the list of defines specific to the light type.
  12192. * @param defines the list of defines
  12193. * @param lightIndex defines the index of the light for the effect
  12194. */
  12195. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12196. }
  12197. }
  12198. declare module "babylonjs/Meshes/instancedMesh" {
  12199. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  12200. import { Vector3, Matrix } from "babylonjs/Maths/math";
  12201. import { Camera } from "babylonjs/Cameras/camera";
  12202. import { Node } from "babylonjs/node";
  12203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12204. import { Mesh } from "babylonjs/Meshes/mesh";
  12205. import { Material } from "babylonjs/Materials/material";
  12206. import { Skeleton } from "babylonjs/Bones/skeleton";
  12207. import { Light } from "babylonjs/Lights/light";
  12208. /**
  12209. * Creates an instance based on a source mesh.
  12210. */
  12211. export class InstancedMesh extends AbstractMesh {
  12212. private _sourceMesh;
  12213. private _currentLOD;
  12214. /** @hidden */
  12215. _indexInSourceMeshInstanceArray: number;
  12216. constructor(name: string, source: Mesh);
  12217. /**
  12218. * Returns the string "InstancedMesh".
  12219. */
  12220. getClassName(): string;
  12221. /** Gets the list of lights affecting that mesh */
  12222. readonly lightSources: Light[];
  12223. _resyncLightSources(): void;
  12224. _resyncLighSource(light: Light): void;
  12225. _removeLightSource(light: Light): void;
  12226. /**
  12227. * If the source mesh receives shadows
  12228. */
  12229. readonly receiveShadows: boolean;
  12230. /**
  12231. * The material of the source mesh
  12232. */
  12233. readonly material: Nullable<Material>;
  12234. /**
  12235. * Visibility of the source mesh
  12236. */
  12237. readonly visibility: number;
  12238. /**
  12239. * Skeleton of the source mesh
  12240. */
  12241. readonly skeleton: Nullable<Skeleton>;
  12242. /**
  12243. * Rendering ground id of the source mesh
  12244. */
  12245. renderingGroupId: number;
  12246. /**
  12247. * Returns the total number of vertices (integer).
  12248. */
  12249. getTotalVertices(): number;
  12250. /**
  12251. * Returns a positive integer : the total number of indices in this mesh geometry.
  12252. * @returns the numner of indices or zero if the mesh has no geometry.
  12253. */
  12254. getTotalIndices(): number;
  12255. /**
  12256. * The source mesh of the instance
  12257. */
  12258. readonly sourceMesh: Mesh;
  12259. /**
  12260. * Is this node ready to be used/rendered
  12261. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12262. * @return {boolean} is it ready
  12263. */
  12264. isReady(completeCheck?: boolean): boolean;
  12265. /**
  12266. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12267. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12268. * @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.
  12269. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12270. */
  12271. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12272. /**
  12273. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12274. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12275. * The `data` are either a numeric array either a Float32Array.
  12276. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12277. * 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).
  12278. * Note that a new underlying VertexBuffer object is created each call.
  12279. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12280. *
  12281. * Possible `kind` values :
  12282. * - VertexBuffer.PositionKind
  12283. * - VertexBuffer.UVKind
  12284. * - VertexBuffer.UV2Kind
  12285. * - VertexBuffer.UV3Kind
  12286. * - VertexBuffer.UV4Kind
  12287. * - VertexBuffer.UV5Kind
  12288. * - VertexBuffer.UV6Kind
  12289. * - VertexBuffer.ColorKind
  12290. * - VertexBuffer.MatricesIndicesKind
  12291. * - VertexBuffer.MatricesIndicesExtraKind
  12292. * - VertexBuffer.MatricesWeightsKind
  12293. * - VertexBuffer.MatricesWeightsExtraKind
  12294. *
  12295. * Returns the Mesh.
  12296. */
  12297. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12298. /**
  12299. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12300. * If the mesh has no geometry, it is simply returned as it is.
  12301. * The `data` are either a numeric array either a Float32Array.
  12302. * No new underlying VertexBuffer object is created.
  12303. * 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.
  12304. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12305. *
  12306. * Possible `kind` values :
  12307. * - VertexBuffer.PositionKind
  12308. * - VertexBuffer.UVKind
  12309. * - VertexBuffer.UV2Kind
  12310. * - VertexBuffer.UV3Kind
  12311. * - VertexBuffer.UV4Kind
  12312. * - VertexBuffer.UV5Kind
  12313. * - VertexBuffer.UV6Kind
  12314. * - VertexBuffer.ColorKind
  12315. * - VertexBuffer.MatricesIndicesKind
  12316. * - VertexBuffer.MatricesIndicesExtraKind
  12317. * - VertexBuffer.MatricesWeightsKind
  12318. * - VertexBuffer.MatricesWeightsExtraKind
  12319. *
  12320. * Returns the Mesh.
  12321. */
  12322. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12323. /**
  12324. * Sets the mesh indices.
  12325. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12326. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12327. * This method creates a new index buffer each call.
  12328. * Returns the Mesh.
  12329. */
  12330. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12331. /**
  12332. * Boolean : True if the mesh owns the requested kind of data.
  12333. */
  12334. isVerticesDataPresent(kind: string): boolean;
  12335. /**
  12336. * Returns an array of indices (IndicesArray).
  12337. */
  12338. getIndices(): Nullable<IndicesArray>;
  12339. readonly _positions: Nullable<Vector3[]>;
  12340. /**
  12341. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12342. * This means the mesh underlying bounding box and sphere are recomputed.
  12343. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12344. * @returns the current mesh
  12345. */
  12346. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12347. /** @hidden */
  12348. _preActivate(): InstancedMesh;
  12349. /** @hidden */
  12350. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12351. /** @hidden */
  12352. _postActivate(): void;
  12353. getWorldMatrix(): Matrix;
  12354. readonly isAnInstance: boolean;
  12355. /**
  12356. * Returns the current associated LOD AbstractMesh.
  12357. */
  12358. getLOD(camera: Camera): AbstractMesh;
  12359. /** @hidden */
  12360. _syncSubMeshes(): InstancedMesh;
  12361. /** @hidden */
  12362. _generatePointsArray(): boolean;
  12363. /**
  12364. * Creates a new InstancedMesh from the current mesh.
  12365. * - name (string) : the cloned mesh name
  12366. * - newParent (optional Node) : the optional Node to parent the clone to.
  12367. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12368. *
  12369. * Returns the clone.
  12370. */
  12371. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12372. /**
  12373. * Disposes the InstancedMesh.
  12374. * Returns nothing.
  12375. */
  12376. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12377. }
  12378. }
  12379. declare module "babylonjs/Materials/shaderMaterial" {
  12380. import { Scene } from "babylonjs/scene";
  12381. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  12382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12383. import { Mesh } from "babylonjs/Meshes/mesh";
  12384. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  12385. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12386. import { Texture } from "babylonjs/Materials/Textures/texture";
  12387. import { Material } from "babylonjs/Materials/material";
  12388. /**
  12389. * Defines the options associated with the creation of a shader material.
  12390. */
  12391. export interface IShaderMaterialOptions {
  12392. /**
  12393. * Does the material work in alpha blend mode
  12394. */
  12395. needAlphaBlending: boolean;
  12396. /**
  12397. * Does the material work in alpha test mode
  12398. */
  12399. needAlphaTesting: boolean;
  12400. /**
  12401. * The list of attribute names used in the shader
  12402. */
  12403. attributes: string[];
  12404. /**
  12405. * The list of unifrom names used in the shader
  12406. */
  12407. uniforms: string[];
  12408. /**
  12409. * The list of UBO names used in the shader
  12410. */
  12411. uniformBuffers: string[];
  12412. /**
  12413. * The list of sampler names used in the shader
  12414. */
  12415. samplers: string[];
  12416. /**
  12417. * The list of defines used in the shader
  12418. */
  12419. defines: string[];
  12420. }
  12421. /**
  12422. * 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.
  12423. *
  12424. * This returned material effects how the mesh will look based on the code in the shaders.
  12425. *
  12426. * @see http://doc.babylonjs.com/how_to/shader_material
  12427. */
  12428. export class ShaderMaterial extends Material {
  12429. private _shaderPath;
  12430. private _options;
  12431. private _textures;
  12432. private _textureArrays;
  12433. private _floats;
  12434. private _ints;
  12435. private _floatsArrays;
  12436. private _colors3;
  12437. private _colors3Arrays;
  12438. private _colors4;
  12439. private _vectors2;
  12440. private _vectors3;
  12441. private _vectors4;
  12442. private _matrices;
  12443. private _matrices3x3;
  12444. private _matrices2x2;
  12445. private _vectors2Arrays;
  12446. private _vectors3Arrays;
  12447. private _cachedWorldViewMatrix;
  12448. private _cachedWorldViewProjectionMatrix;
  12449. private _renderId;
  12450. /**
  12451. * Instantiate a new shader material.
  12452. * 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.
  12453. * This returned material effects how the mesh will look based on the code in the shaders.
  12454. * @see http://doc.babylonjs.com/how_to/shader_material
  12455. * @param name Define the name of the material in the scene
  12456. * @param scene Define the scene the material belongs to
  12457. * @param shaderPath Defines the route to the shader code in one of three ways:
  12458. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12459. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12460. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12461. * @param options Define the options used to create the shader
  12462. */
  12463. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12464. /**
  12465. * Gets the options used to compile the shader.
  12466. * They can be modified to trigger a new compilation
  12467. */
  12468. readonly options: IShaderMaterialOptions;
  12469. /**
  12470. * Gets the current class name of the material e.g. "ShaderMaterial"
  12471. * Mainly use in serialization.
  12472. * @returns the class name
  12473. */
  12474. getClassName(): string;
  12475. /**
  12476. * Specifies if the material will require alpha blending
  12477. * @returns a boolean specifying if alpha blending is needed
  12478. */
  12479. needAlphaBlending(): boolean;
  12480. /**
  12481. * Specifies if this material should be rendered in alpha test mode
  12482. * @returns a boolean specifying if an alpha test is needed.
  12483. */
  12484. needAlphaTesting(): boolean;
  12485. private _checkUniform;
  12486. /**
  12487. * Set a texture in the shader.
  12488. * @param name Define the name of the uniform samplers as defined in the shader
  12489. * @param texture Define the texture to bind to this sampler
  12490. * @return the material itself allowing "fluent" like uniform updates
  12491. */
  12492. setTexture(name: string, texture: Texture): ShaderMaterial;
  12493. /**
  12494. * Set a texture array in the shader.
  12495. * @param name Define the name of the uniform sampler array as defined in the shader
  12496. * @param textures Define the list of textures to bind to this sampler
  12497. * @return the material itself allowing "fluent" like uniform updates
  12498. */
  12499. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12500. /**
  12501. * Set a float in the shader.
  12502. * @param name Define the name of the uniform as defined in the shader
  12503. * @param value Define the value to give to the uniform
  12504. * @return the material itself allowing "fluent" like uniform updates
  12505. */
  12506. setFloat(name: string, value: number): ShaderMaterial;
  12507. /**
  12508. * Set a int in the shader.
  12509. * @param name Define the name of the uniform as defined in the shader
  12510. * @param value Define the value to give to the uniform
  12511. * @return the material itself allowing "fluent" like uniform updates
  12512. */
  12513. setInt(name: string, value: number): ShaderMaterial;
  12514. /**
  12515. * Set an array of floats in the shader.
  12516. * @param name Define the name of the uniform as defined in the shader
  12517. * @param value Define the value to give to the uniform
  12518. * @return the material itself allowing "fluent" like uniform updates
  12519. */
  12520. setFloats(name: string, value: number[]): ShaderMaterial;
  12521. /**
  12522. * Set a vec3 in the shader from a Color3.
  12523. * @param name Define the name of the uniform as defined in the shader
  12524. * @param value Define the value to give to the uniform
  12525. * @return the material itself allowing "fluent" like uniform updates
  12526. */
  12527. setColor3(name: string, value: Color3): ShaderMaterial;
  12528. /**
  12529. * Set a vec3 array in the shader from a Color3 array.
  12530. * @param name Define the name of the uniform as defined in the shader
  12531. * @param value Define the value to give to the uniform
  12532. * @return the material itself allowing "fluent" like uniform updates
  12533. */
  12534. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12535. /**
  12536. * Set a vec4 in the shader from a Color4.
  12537. * @param name Define the name of the uniform as defined in the shader
  12538. * @param value Define the value to give to the uniform
  12539. * @return the material itself allowing "fluent" like uniform updates
  12540. */
  12541. setColor4(name: string, value: Color4): ShaderMaterial;
  12542. /**
  12543. * Set a vec2 in the shader from a Vector2.
  12544. * @param name Define the name of the uniform as defined in the shader
  12545. * @param value Define the value to give to the uniform
  12546. * @return the material itself allowing "fluent" like uniform updates
  12547. */
  12548. setVector2(name: string, value: Vector2): ShaderMaterial;
  12549. /**
  12550. * Set a vec3 in the shader from a Vector3.
  12551. * @param name Define the name of the uniform as defined in the shader
  12552. * @param value Define the value to give to the uniform
  12553. * @return the material itself allowing "fluent" like uniform updates
  12554. */
  12555. setVector3(name: string, value: Vector3): ShaderMaterial;
  12556. /**
  12557. * Set a vec4 in the shader from a Vector4.
  12558. * @param name Define the name of the uniform as defined in the shader
  12559. * @param value Define the value to give to the uniform
  12560. * @return the material itself allowing "fluent" like uniform updates
  12561. */
  12562. setVector4(name: string, value: Vector4): ShaderMaterial;
  12563. /**
  12564. * Set a mat4 in the shader from a Matrix.
  12565. * @param name Define the name of the uniform as defined in the shader
  12566. * @param value Define the value to give to the uniform
  12567. * @return the material itself allowing "fluent" like uniform updates
  12568. */
  12569. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12570. /**
  12571. * Set a mat3 in the shader from a Float32Array.
  12572. * @param name Define the name of the uniform as defined in the shader
  12573. * @param value Define the value to give to the uniform
  12574. * @return the material itself allowing "fluent" like uniform updates
  12575. */
  12576. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12577. /**
  12578. * Set a mat2 in the shader from a Float32Array.
  12579. * @param name Define the name of the uniform as defined in the shader
  12580. * @param value Define the value to give to the uniform
  12581. * @return the material itself allowing "fluent" like uniform updates
  12582. */
  12583. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12584. /**
  12585. * Set a vec2 array in the shader from a number array.
  12586. * @param name Define the name of the uniform as defined in the shader
  12587. * @param value Define the value to give to the uniform
  12588. * @return the material itself allowing "fluent" like uniform updates
  12589. */
  12590. setArray2(name: string, value: number[]): ShaderMaterial;
  12591. /**
  12592. * Set a vec3 array in the shader from a number array.
  12593. * @param name Define the name of the uniform as defined in the shader
  12594. * @param value Define the value to give to the uniform
  12595. * @return the material itself allowing "fluent" like uniform updates
  12596. */
  12597. setArray3(name: string, value: number[]): ShaderMaterial;
  12598. private _checkCache;
  12599. /**
  12600. * Specifies that the submesh is ready to be used
  12601. * @param mesh defines the mesh to check
  12602. * @param subMesh defines which submesh to check
  12603. * @param useInstances specifies that instances should be used
  12604. * @returns a boolean indicating that the submesh is ready or not
  12605. */
  12606. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12607. /**
  12608. * Checks if the material is ready to render the requested mesh
  12609. * @param mesh Define the mesh to render
  12610. * @param useInstances Define whether or not the material is used with instances
  12611. * @returns true if ready, otherwise false
  12612. */
  12613. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12614. /**
  12615. * Binds the world matrix to the material
  12616. * @param world defines the world transformation matrix
  12617. */
  12618. bindOnlyWorldMatrix(world: Matrix): void;
  12619. /**
  12620. * Binds the material to the mesh
  12621. * @param world defines the world transformation matrix
  12622. * @param mesh defines the mesh to bind the material to
  12623. */
  12624. bind(world: Matrix, mesh?: Mesh): void;
  12625. /**
  12626. * Gets the active textures from the material
  12627. * @returns an array of textures
  12628. */
  12629. getActiveTextures(): BaseTexture[];
  12630. /**
  12631. * Specifies if the material uses a texture
  12632. * @param texture defines the texture to check against the material
  12633. * @returns a boolean specifying if the material uses the texture
  12634. */
  12635. hasTexture(texture: BaseTexture): boolean;
  12636. /**
  12637. * Makes a duplicate of the material, and gives it a new name
  12638. * @param name defines the new name for the duplicated material
  12639. * @returns the cloned material
  12640. */
  12641. clone(name: string): ShaderMaterial;
  12642. /**
  12643. * Disposes the material
  12644. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12645. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12646. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12647. */
  12648. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12649. /**
  12650. * Serializes this material in a JSON representation
  12651. * @returns the serialized material object
  12652. */
  12653. serialize(): any;
  12654. /**
  12655. * Creates a shader material from parsed shader material data
  12656. * @param source defines the JSON represnetation of the material
  12657. * @param scene defines the hosting scene
  12658. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12659. * @returns a new material
  12660. */
  12661. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12662. }
  12663. }
  12664. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  12665. /** @hidden */
  12666. export var clipPlaneFragmentDeclaration: {
  12667. name: string;
  12668. shader: string;
  12669. };
  12670. }
  12671. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  12672. /** @hidden */
  12673. export var clipPlaneFragment: {
  12674. name: string;
  12675. shader: string;
  12676. };
  12677. }
  12678. declare module "babylonjs/Shaders/color.fragment" {
  12679. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12680. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12681. /** @hidden */
  12682. export var colorPixelShader: {
  12683. name: string;
  12684. shader: string;
  12685. };
  12686. }
  12687. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  12688. /** @hidden */
  12689. export var clipPlaneVertexDeclaration: {
  12690. name: string;
  12691. shader: string;
  12692. };
  12693. }
  12694. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  12695. /** @hidden */
  12696. export var clipPlaneVertex: {
  12697. name: string;
  12698. shader: string;
  12699. };
  12700. }
  12701. declare module "babylonjs/Shaders/color.vertex" {
  12702. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  12703. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12704. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  12705. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  12706. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  12707. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12708. /** @hidden */
  12709. export var colorVertexShader: {
  12710. name: string;
  12711. shader: string;
  12712. };
  12713. }
  12714. declare module "babylonjs/Meshes/linesMesh" {
  12715. import { Nullable } from "babylonjs/types";
  12716. import { Scene } from "babylonjs/scene";
  12717. import { Color3 } from "babylonjs/Maths/math";
  12718. import { Node } from "babylonjs/node";
  12719. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12720. import { Mesh } from "babylonjs/Meshes/mesh";
  12721. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  12722. import { Effect } from "babylonjs/Materials/effect";
  12723. import { Material } from "babylonjs/Materials/material";
  12724. import "babylonjs/Shaders/color.fragment";
  12725. import "babylonjs/Shaders/color.vertex";
  12726. /**
  12727. * Line mesh
  12728. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12729. */
  12730. export class LinesMesh extends Mesh {
  12731. /**
  12732. * If vertex color should be applied to the mesh
  12733. */
  12734. readonly useVertexColor?: boolean | undefined;
  12735. /**
  12736. * If vertex alpha should be applied to the mesh
  12737. */
  12738. readonly useVertexAlpha?: boolean | undefined;
  12739. /**
  12740. * Color of the line (Default: White)
  12741. */
  12742. color: Color3;
  12743. /**
  12744. * Alpha of the line (Default: 1)
  12745. */
  12746. alpha: number;
  12747. /**
  12748. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12749. * This margin is expressed in world space coordinates, so its value may vary.
  12750. * Default value is 0.1
  12751. */
  12752. intersectionThreshold: number;
  12753. private _colorShader;
  12754. private color4;
  12755. /**
  12756. * Creates a new LinesMesh
  12757. * @param name defines the name
  12758. * @param scene defines the hosting scene
  12759. * @param parent defines the parent mesh if any
  12760. * @param source defines the optional source LinesMesh used to clone data from
  12761. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12762. * When false, achieved by calling a clone(), also passing False.
  12763. * This will make creation of children, recursive.
  12764. * @param useVertexColor defines if this LinesMesh supports vertex color
  12765. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12766. */
  12767. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12768. /**
  12769. * If vertex color should be applied to the mesh
  12770. */
  12771. useVertexColor?: boolean | undefined,
  12772. /**
  12773. * If vertex alpha should be applied to the mesh
  12774. */
  12775. useVertexAlpha?: boolean | undefined);
  12776. private _addClipPlaneDefine;
  12777. private _removeClipPlaneDefine;
  12778. isReady(): boolean;
  12779. /**
  12780. * Returns the string "LineMesh"
  12781. */
  12782. getClassName(): string;
  12783. /**
  12784. * @hidden
  12785. */
  12786. /**
  12787. * @hidden
  12788. */
  12789. material: Material;
  12790. /**
  12791. * @hidden
  12792. */
  12793. readonly checkCollisions: boolean;
  12794. /** @hidden */
  12795. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12796. /** @hidden */
  12797. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12798. /**
  12799. * Disposes of the line mesh
  12800. * @param doNotRecurse If children should be disposed
  12801. */
  12802. dispose(doNotRecurse?: boolean): void;
  12803. /**
  12804. * Returns a new LineMesh object cloned from the current one.
  12805. */
  12806. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12807. /**
  12808. * Creates a new InstancedLinesMesh object from the mesh model.
  12809. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12810. * @param name defines the name of the new instance
  12811. * @returns a new InstancedLinesMesh
  12812. */
  12813. createInstance(name: string): InstancedLinesMesh;
  12814. }
  12815. /**
  12816. * Creates an instance based on a source LinesMesh
  12817. */
  12818. export class InstancedLinesMesh extends InstancedMesh {
  12819. /**
  12820. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12821. * This margin is expressed in world space coordinates, so its value may vary.
  12822. * Initilized with the intersectionThreshold value of the source LinesMesh
  12823. */
  12824. intersectionThreshold: number;
  12825. constructor(name: string, source: LinesMesh);
  12826. /**
  12827. * Returns the string "InstancedLinesMesh".
  12828. */
  12829. getClassName(): string;
  12830. }
  12831. }
  12832. declare module "babylonjs/Meshes/groundMesh" {
  12833. import { Scene } from "babylonjs/scene";
  12834. import { Vector3 } from "babylonjs/Maths/math";
  12835. import { Mesh } from "babylonjs/Meshes/mesh";
  12836. /**
  12837. * Mesh representing the gorund
  12838. */
  12839. export class GroundMesh extends Mesh {
  12840. /** If octree should be generated */
  12841. generateOctree: boolean;
  12842. private _heightQuads;
  12843. /** @hidden */
  12844. _subdivisionsX: number;
  12845. /** @hidden */
  12846. _subdivisionsY: number;
  12847. /** @hidden */
  12848. _width: number;
  12849. /** @hidden */
  12850. _height: number;
  12851. /** @hidden */
  12852. _minX: number;
  12853. /** @hidden */
  12854. _maxX: number;
  12855. /** @hidden */
  12856. _minZ: number;
  12857. /** @hidden */
  12858. _maxZ: number;
  12859. constructor(name: string, scene: Scene);
  12860. /**
  12861. * "GroundMesh"
  12862. * @returns "GroundMesh"
  12863. */
  12864. getClassName(): string;
  12865. /**
  12866. * The minimum of x and y subdivisions
  12867. */
  12868. readonly subdivisions: number;
  12869. /**
  12870. * X subdivisions
  12871. */
  12872. readonly subdivisionsX: number;
  12873. /**
  12874. * Y subdivisions
  12875. */
  12876. readonly subdivisionsY: number;
  12877. /**
  12878. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12879. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12880. * @param chunksCount the number of subdivisions for x and y
  12881. * @param octreeBlocksSize (Default: 32)
  12882. */
  12883. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12884. /**
  12885. * Returns a height (y) value in the Worl system :
  12886. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12887. * @param x x coordinate
  12888. * @param z z coordinate
  12889. * @returns the ground y position if (x, z) are outside the ground surface.
  12890. */
  12891. getHeightAtCoordinates(x: number, z: number): number;
  12892. /**
  12893. * Returns a normalized vector (Vector3) orthogonal to the ground
  12894. * at the ground coordinates (x, z) expressed in the World system.
  12895. * @param x x coordinate
  12896. * @param z z coordinate
  12897. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12898. */
  12899. getNormalAtCoordinates(x: number, z: number): Vector3;
  12900. /**
  12901. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12902. * at the ground coordinates (x, z) expressed in the World system.
  12903. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12904. * @param x x coordinate
  12905. * @param z z coordinate
  12906. * @param ref vector to store the result
  12907. * @returns the GroundMesh.
  12908. */
  12909. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12910. /**
  12911. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12912. * if the ground has been updated.
  12913. * This can be used in the render loop.
  12914. * @returns the GroundMesh.
  12915. */
  12916. updateCoordinateHeights(): GroundMesh;
  12917. private _getFacetAt;
  12918. private _initHeightQuads;
  12919. private _computeHeightQuads;
  12920. /**
  12921. * Serializes this ground mesh
  12922. * @param serializationObject object to write serialization to
  12923. */
  12924. serialize(serializationObject: any): void;
  12925. /**
  12926. * Parses a serialized ground mesh
  12927. * @param parsedMesh the serialized mesh
  12928. * @param scene the scene to create the ground mesh in
  12929. * @returns the created ground mesh
  12930. */
  12931. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  12932. }
  12933. }
  12934. declare module "babylonjs/Physics/physicsJoint" {
  12935. import { Vector3 } from "babylonjs/Maths/math";
  12936. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  12937. /**
  12938. * Interface for Physics-Joint data
  12939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12940. */
  12941. export interface PhysicsJointData {
  12942. /**
  12943. * The main pivot of the joint
  12944. */
  12945. mainPivot?: Vector3;
  12946. /**
  12947. * The connected pivot of the joint
  12948. */
  12949. connectedPivot?: Vector3;
  12950. /**
  12951. * The main axis of the joint
  12952. */
  12953. mainAxis?: Vector3;
  12954. /**
  12955. * The connected axis of the joint
  12956. */
  12957. connectedAxis?: Vector3;
  12958. /**
  12959. * The collision of the joint
  12960. */
  12961. collision?: boolean;
  12962. /**
  12963. * Native Oimo/Cannon/Energy data
  12964. */
  12965. nativeParams?: any;
  12966. }
  12967. /**
  12968. * This is a holder class for the physics joint created by the physics plugin
  12969. * It holds a set of functions to control the underlying joint
  12970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12971. */
  12972. export class PhysicsJoint {
  12973. /**
  12974. * The type of the physics joint
  12975. */
  12976. type: number;
  12977. /**
  12978. * The data for the physics joint
  12979. */
  12980. jointData: PhysicsJointData;
  12981. private _physicsJoint;
  12982. protected _physicsPlugin: IPhysicsEnginePlugin;
  12983. /**
  12984. * Initializes the physics joint
  12985. * @param type The type of the physics joint
  12986. * @param jointData The data for the physics joint
  12987. */
  12988. constructor(
  12989. /**
  12990. * The type of the physics joint
  12991. */
  12992. type: number,
  12993. /**
  12994. * The data for the physics joint
  12995. */
  12996. jointData: PhysicsJointData);
  12997. /**
  12998. * Gets the physics joint
  12999. */
  13000. /**
  13001. * Sets the physics joint
  13002. */
  13003. physicsJoint: any;
  13004. /**
  13005. * Sets the physics plugin
  13006. */
  13007. physicsPlugin: IPhysicsEnginePlugin;
  13008. /**
  13009. * Execute a function that is physics-plugin specific.
  13010. * @param {Function} func the function that will be executed.
  13011. * It accepts two parameters: the physics world and the physics joint
  13012. */
  13013. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  13014. /**
  13015. * Distance-Joint type
  13016. */
  13017. static DistanceJoint: number;
  13018. /**
  13019. * Hinge-Joint type
  13020. */
  13021. static HingeJoint: number;
  13022. /**
  13023. * Ball-and-Socket joint type
  13024. */
  13025. static BallAndSocketJoint: number;
  13026. /**
  13027. * Wheel-Joint type
  13028. */
  13029. static WheelJoint: number;
  13030. /**
  13031. * Slider-Joint type
  13032. */
  13033. static SliderJoint: number;
  13034. /**
  13035. * Prismatic-Joint type
  13036. */
  13037. static PrismaticJoint: number;
  13038. /**
  13039. * Universal-Joint type
  13040. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  13041. */
  13042. static UniversalJoint: number;
  13043. /**
  13044. * Hinge-Joint 2 type
  13045. */
  13046. static Hinge2Joint: number;
  13047. /**
  13048. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  13049. */
  13050. static PointToPointJoint: number;
  13051. /**
  13052. * Spring-Joint type
  13053. */
  13054. static SpringJoint: number;
  13055. /**
  13056. * Lock-Joint type
  13057. */
  13058. static LockJoint: number;
  13059. }
  13060. /**
  13061. * A class representing a physics distance joint
  13062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13063. */
  13064. export class DistanceJoint extends PhysicsJoint {
  13065. /**
  13066. *
  13067. * @param jointData The data for the Distance-Joint
  13068. */
  13069. constructor(jointData: DistanceJointData);
  13070. /**
  13071. * Update the predefined distance.
  13072. * @param maxDistance The maximum preferred distance
  13073. * @param minDistance The minimum preferred distance
  13074. */
  13075. updateDistance(maxDistance: number, minDistance?: number): void;
  13076. }
  13077. /**
  13078. * Represents a Motor-Enabled Joint
  13079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13080. */
  13081. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  13082. /**
  13083. * Initializes the Motor-Enabled Joint
  13084. * @param type The type of the joint
  13085. * @param jointData The physica joint data for the joint
  13086. */
  13087. constructor(type: number, jointData: PhysicsJointData);
  13088. /**
  13089. * Set the motor values.
  13090. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13091. * @param force the force to apply
  13092. * @param maxForce max force for this motor.
  13093. */
  13094. setMotor(force?: number, maxForce?: number): void;
  13095. /**
  13096. * Set the motor's limits.
  13097. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13098. * @param upperLimit The upper limit of the motor
  13099. * @param lowerLimit The lower limit of the motor
  13100. */
  13101. setLimit(upperLimit: number, lowerLimit?: number): void;
  13102. }
  13103. /**
  13104. * This class represents a single physics Hinge-Joint
  13105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13106. */
  13107. export class HingeJoint extends MotorEnabledJoint {
  13108. /**
  13109. * Initializes the Hinge-Joint
  13110. * @param jointData The joint data for the Hinge-Joint
  13111. */
  13112. constructor(jointData: PhysicsJointData);
  13113. /**
  13114. * Set the motor values.
  13115. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13116. * @param {number} force the force to apply
  13117. * @param {number} maxForce max force for this motor.
  13118. */
  13119. setMotor(force?: number, maxForce?: number): void;
  13120. /**
  13121. * Set the motor's limits.
  13122. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13123. * @param upperLimit The upper limit of the motor
  13124. * @param lowerLimit The lower limit of the motor
  13125. */
  13126. setLimit(upperLimit: number, lowerLimit?: number): void;
  13127. }
  13128. /**
  13129. * This class represents a dual hinge physics joint (same as wheel joint)
  13130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13131. */
  13132. export class Hinge2Joint extends MotorEnabledJoint {
  13133. /**
  13134. * Initializes the Hinge2-Joint
  13135. * @param jointData The joint data for the Hinge2-Joint
  13136. */
  13137. constructor(jointData: PhysicsJointData);
  13138. /**
  13139. * Set the motor values.
  13140. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13141. * @param {number} targetSpeed the speed the motor is to reach
  13142. * @param {number} maxForce max force for this motor.
  13143. * @param {motorIndex} the motor's index, 0 or 1.
  13144. */
  13145. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13146. /**
  13147. * Set the motor limits.
  13148. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13149. * @param {number} upperLimit the upper limit
  13150. * @param {number} lowerLimit lower limit
  13151. * @param {motorIndex} the motor's index, 0 or 1.
  13152. */
  13153. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13154. }
  13155. /**
  13156. * Interface for a motor enabled joint
  13157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13158. */
  13159. export interface IMotorEnabledJoint {
  13160. /**
  13161. * Physics joint
  13162. */
  13163. physicsJoint: any;
  13164. /**
  13165. * Sets the motor of the motor-enabled joint
  13166. * @param force The force of the motor
  13167. * @param maxForce The maximum force of the motor
  13168. * @param motorIndex The index of the motor
  13169. */
  13170. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13171. /**
  13172. * Sets the limit of the motor
  13173. * @param upperLimit The upper limit of the motor
  13174. * @param lowerLimit The lower limit of the motor
  13175. * @param motorIndex The index of the motor
  13176. */
  13177. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13178. }
  13179. /**
  13180. * Joint data for a Distance-Joint
  13181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13182. */
  13183. export interface DistanceJointData extends PhysicsJointData {
  13184. /**
  13185. * Max distance the 2 joint objects can be apart
  13186. */
  13187. maxDistance: number;
  13188. }
  13189. /**
  13190. * Joint data from a spring joint
  13191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13192. */
  13193. export interface SpringJointData extends PhysicsJointData {
  13194. /**
  13195. * Length of the spring
  13196. */
  13197. length: number;
  13198. /**
  13199. * Stiffness of the spring
  13200. */
  13201. stiffness: number;
  13202. /**
  13203. * Damping of the spring
  13204. */
  13205. damping: number;
  13206. /** this callback will be called when applying the force to the impostors. */
  13207. forceApplicationCallback: () => void;
  13208. }
  13209. }
  13210. declare module "babylonjs/Physics/physicsRaycastResult" {
  13211. import { Vector3 } from "babylonjs/Maths/math";
  13212. /**
  13213. * Holds the data for the raycast result
  13214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13215. */
  13216. export class PhysicsRaycastResult {
  13217. private _hasHit;
  13218. private _hitDistance;
  13219. private _hitNormalWorld;
  13220. private _hitPointWorld;
  13221. private _rayFromWorld;
  13222. private _rayToWorld;
  13223. /**
  13224. * Gets if there was a hit
  13225. */
  13226. readonly hasHit: boolean;
  13227. /**
  13228. * Gets the distance from the hit
  13229. */
  13230. readonly hitDistance: number;
  13231. /**
  13232. * Gets the hit normal/direction in the world
  13233. */
  13234. readonly hitNormalWorld: Vector3;
  13235. /**
  13236. * Gets the hit point in the world
  13237. */
  13238. readonly hitPointWorld: Vector3;
  13239. /**
  13240. * Gets the ray "start point" of the ray in the world
  13241. */
  13242. readonly rayFromWorld: Vector3;
  13243. /**
  13244. * Gets the ray "end point" of the ray in the world
  13245. */
  13246. readonly rayToWorld: Vector3;
  13247. /**
  13248. * Sets the hit data (normal & point in world space)
  13249. * @param hitNormalWorld defines the normal in world space
  13250. * @param hitPointWorld defines the point in world space
  13251. */
  13252. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13253. /**
  13254. * Sets the distance from the start point to the hit point
  13255. * @param distance
  13256. */
  13257. setHitDistance(distance: number): void;
  13258. /**
  13259. * Calculates the distance manually
  13260. */
  13261. calculateHitDistance(): void;
  13262. /**
  13263. * Resets all the values to default
  13264. * @param from The from point on world space
  13265. * @param to The to point on world space
  13266. */
  13267. reset(from?: Vector3, to?: Vector3): void;
  13268. }
  13269. /**
  13270. * Interface for the size containing width and height
  13271. */
  13272. interface IXYZ {
  13273. /**
  13274. * X
  13275. */
  13276. x: number;
  13277. /**
  13278. * Y
  13279. */
  13280. y: number;
  13281. /**
  13282. * Z
  13283. */
  13284. z: number;
  13285. }
  13286. }
  13287. declare module "babylonjs/Physics/IPhysicsEngine" {
  13288. import { Nullable } from "babylonjs/types";
  13289. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  13290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13291. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  13292. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  13293. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  13294. /**
  13295. * Interface used to describe a physics joint
  13296. */
  13297. export interface PhysicsImpostorJoint {
  13298. /** Defines the main impostor to which the joint is linked */
  13299. mainImpostor: PhysicsImpostor;
  13300. /** Defines the impostor that is connected to the main impostor using this joint */
  13301. connectedImpostor: PhysicsImpostor;
  13302. /** Defines the joint itself */
  13303. joint: PhysicsJoint;
  13304. }
  13305. /** @hidden */
  13306. export interface IPhysicsEnginePlugin {
  13307. world: any;
  13308. name: string;
  13309. setGravity(gravity: Vector3): void;
  13310. setTimeStep(timeStep: number): void;
  13311. getTimeStep(): number;
  13312. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13313. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13314. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13315. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13316. removePhysicsBody(impostor: PhysicsImpostor): void;
  13317. generateJoint(joint: PhysicsImpostorJoint): void;
  13318. removeJoint(joint: PhysicsImpostorJoint): void;
  13319. isSupported(): boolean;
  13320. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13321. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13322. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13323. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13324. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13325. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13326. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13327. getBodyMass(impostor: PhysicsImpostor): number;
  13328. getBodyFriction(impostor: PhysicsImpostor): number;
  13329. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13330. getBodyRestitution(impostor: PhysicsImpostor): number;
  13331. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13332. getBodyPressure?(impostor: PhysicsImpostor): number;
  13333. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13334. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13335. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13336. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13337. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13338. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13339. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13340. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13341. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13342. sleepBody(impostor: PhysicsImpostor): void;
  13343. wakeUpBody(impostor: PhysicsImpostor): void;
  13344. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13345. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13346. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13347. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13348. getRadius(impostor: PhysicsImpostor): number;
  13349. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13350. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13351. dispose(): void;
  13352. }
  13353. /**
  13354. * Interface used to define a physics engine
  13355. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13356. */
  13357. export interface IPhysicsEngine {
  13358. /**
  13359. * Gets the gravity vector used by the simulation
  13360. */
  13361. gravity: Vector3;
  13362. /**
  13363. * Sets the gravity vector used by the simulation
  13364. * @param gravity defines the gravity vector to use
  13365. */
  13366. setGravity(gravity: Vector3): void;
  13367. /**
  13368. * Set the time step of the physics engine.
  13369. * Default is 1/60.
  13370. * To slow it down, enter 1/600 for example.
  13371. * To speed it up, 1/30
  13372. * @param newTimeStep the new timestep to apply to this world.
  13373. */
  13374. setTimeStep(newTimeStep: number): void;
  13375. /**
  13376. * Get the time step of the physics engine.
  13377. * @returns the current time step
  13378. */
  13379. getTimeStep(): number;
  13380. /**
  13381. * Release all resources
  13382. */
  13383. dispose(): void;
  13384. /**
  13385. * Gets the name of the current physics plugin
  13386. * @returns the name of the plugin
  13387. */
  13388. getPhysicsPluginName(): string;
  13389. /**
  13390. * Adding a new impostor for the impostor tracking.
  13391. * This will be done by the impostor itself.
  13392. * @param impostor the impostor to add
  13393. */
  13394. addImpostor(impostor: PhysicsImpostor): void;
  13395. /**
  13396. * Remove an impostor from the engine.
  13397. * This impostor and its mesh will not longer be updated by the physics engine.
  13398. * @param impostor the impostor to remove
  13399. */
  13400. removeImpostor(impostor: PhysicsImpostor): void;
  13401. /**
  13402. * Add a joint to the physics engine
  13403. * @param mainImpostor defines the main impostor to which the joint is added.
  13404. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13405. * @param joint defines the joint that will connect both impostors.
  13406. */
  13407. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13408. /**
  13409. * Removes a joint from the simulation
  13410. * @param mainImpostor defines the impostor used with the joint
  13411. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13412. * @param joint defines the joint to remove
  13413. */
  13414. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13415. /**
  13416. * Gets the current plugin used to run the simulation
  13417. * @returns current plugin
  13418. */
  13419. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13420. /**
  13421. * Gets the list of physic impostors
  13422. * @returns an array of PhysicsImpostor
  13423. */
  13424. getImpostors(): Array<PhysicsImpostor>;
  13425. /**
  13426. * Gets the impostor for a physics enabled object
  13427. * @param object defines the object impersonated by the impostor
  13428. * @returns the PhysicsImpostor or null if not found
  13429. */
  13430. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13431. /**
  13432. * Gets the impostor for a physics body object
  13433. * @param body defines physics body used by the impostor
  13434. * @returns the PhysicsImpostor or null if not found
  13435. */
  13436. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13437. /**
  13438. * Does a raycast in the physics world
  13439. * @param from when should the ray start?
  13440. * @param to when should the ray end?
  13441. * @returns PhysicsRaycastResult
  13442. */
  13443. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13444. /**
  13445. * Called by the scene. No need to call it.
  13446. * @param delta defines the timespam between frames
  13447. */
  13448. _step(delta: number): void;
  13449. }
  13450. }
  13451. declare module "babylonjs/Physics/physicsImpostor" {
  13452. import { Nullable, IndicesArray } from "babylonjs/types";
  13453. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  13454. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13456. import { Scene } from "babylonjs/scene";
  13457. import { Bone } from "babylonjs/Bones/bone";
  13458. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  13459. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  13460. /**
  13461. * The interface for the physics imposter parameters
  13462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13463. */
  13464. export interface PhysicsImpostorParameters {
  13465. /**
  13466. * The mass of the physics imposter
  13467. */
  13468. mass: number;
  13469. /**
  13470. * The friction of the physics imposter
  13471. */
  13472. friction?: number;
  13473. /**
  13474. * The coefficient of restitution of the physics imposter
  13475. */
  13476. restitution?: number;
  13477. /**
  13478. * The native options of the physics imposter
  13479. */
  13480. nativeOptions?: any;
  13481. /**
  13482. * Specifies if the parent should be ignored
  13483. */
  13484. ignoreParent?: boolean;
  13485. /**
  13486. * Specifies if bi-directional transformations should be disabled
  13487. */
  13488. disableBidirectionalTransformation?: boolean;
  13489. /**
  13490. * The pressure inside the physics imposter, soft object only
  13491. */
  13492. pressure?: number;
  13493. /**
  13494. * The stiffness the physics imposter, soft object only
  13495. */
  13496. stiffness?: number;
  13497. /**
  13498. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13499. */
  13500. velocityIterations?: number;
  13501. /**
  13502. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13503. */
  13504. positionIterations?: number;
  13505. /**
  13506. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13507. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13508. * Add to fix multiple points
  13509. */
  13510. fixedPoints?: number;
  13511. /**
  13512. * The collision margin around a soft object
  13513. */
  13514. margin?: number;
  13515. /**
  13516. * The collision margin around a soft object
  13517. */
  13518. damping?: number;
  13519. /**
  13520. * The path for a rope based on an extrusion
  13521. */
  13522. path?: any;
  13523. /**
  13524. * The shape of an extrusion used for a rope based on an extrusion
  13525. */
  13526. shape?: any;
  13527. }
  13528. /**
  13529. * Interface for a physics-enabled object
  13530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13531. */
  13532. export interface IPhysicsEnabledObject {
  13533. /**
  13534. * The position of the physics-enabled object
  13535. */
  13536. position: Vector3;
  13537. /**
  13538. * The rotation of the physics-enabled object
  13539. */
  13540. rotationQuaternion: Nullable<Quaternion>;
  13541. /**
  13542. * The scale of the physics-enabled object
  13543. */
  13544. scaling: Vector3;
  13545. /**
  13546. * The rotation of the physics-enabled object
  13547. */
  13548. rotation?: Vector3;
  13549. /**
  13550. * The parent of the physics-enabled object
  13551. */
  13552. parent?: any;
  13553. /**
  13554. * The bounding info of the physics-enabled object
  13555. * @returns The bounding info of the physics-enabled object
  13556. */
  13557. getBoundingInfo(): BoundingInfo;
  13558. /**
  13559. * Computes the world matrix
  13560. * @param force Specifies if the world matrix should be computed by force
  13561. * @returns A world matrix
  13562. */
  13563. computeWorldMatrix(force: boolean): Matrix;
  13564. /**
  13565. * Gets the world matrix
  13566. * @returns A world matrix
  13567. */
  13568. getWorldMatrix?(): Matrix;
  13569. /**
  13570. * Gets the child meshes
  13571. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13572. * @returns An array of abstract meshes
  13573. */
  13574. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13575. /**
  13576. * Gets the vertex data
  13577. * @param kind The type of vertex data
  13578. * @returns A nullable array of numbers, or a float32 array
  13579. */
  13580. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13581. /**
  13582. * Gets the indices from the mesh
  13583. * @returns A nullable array of index arrays
  13584. */
  13585. getIndices?(): Nullable<IndicesArray>;
  13586. /**
  13587. * Gets the scene from the mesh
  13588. * @returns the indices array or null
  13589. */
  13590. getScene?(): Scene;
  13591. /**
  13592. * Gets the absolute position from the mesh
  13593. * @returns the absolute position
  13594. */
  13595. getAbsolutePosition(): Vector3;
  13596. /**
  13597. * Gets the absolute pivot point from the mesh
  13598. * @returns the absolute pivot point
  13599. */
  13600. getAbsolutePivotPoint(): Vector3;
  13601. /**
  13602. * Rotates the mesh
  13603. * @param axis The axis of rotation
  13604. * @param amount The amount of rotation
  13605. * @param space The space of the rotation
  13606. * @returns The rotation transform node
  13607. */
  13608. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13609. /**
  13610. * Translates the mesh
  13611. * @param axis The axis of translation
  13612. * @param distance The distance of translation
  13613. * @param space The space of the translation
  13614. * @returns The transform node
  13615. */
  13616. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13617. /**
  13618. * Sets the absolute position of the mesh
  13619. * @param absolutePosition The absolute position of the mesh
  13620. * @returns The transform node
  13621. */
  13622. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13623. /**
  13624. * Gets the class name of the mesh
  13625. * @returns The class name
  13626. */
  13627. getClassName(): string;
  13628. }
  13629. /**
  13630. * Represents a physics imposter
  13631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13632. */
  13633. export class PhysicsImpostor {
  13634. /**
  13635. * The physics-enabled object used as the physics imposter
  13636. */
  13637. object: IPhysicsEnabledObject;
  13638. /**
  13639. * The type of the physics imposter
  13640. */
  13641. type: number;
  13642. private _options;
  13643. private _scene?;
  13644. /**
  13645. * The default object size of the imposter
  13646. */
  13647. static DEFAULT_OBJECT_SIZE: Vector3;
  13648. /**
  13649. * The identity quaternion of the imposter
  13650. */
  13651. static IDENTITY_QUATERNION: Quaternion;
  13652. /** @hidden */
  13653. _pluginData: any;
  13654. private _physicsEngine;
  13655. private _physicsBody;
  13656. private _bodyUpdateRequired;
  13657. private _onBeforePhysicsStepCallbacks;
  13658. private _onAfterPhysicsStepCallbacks;
  13659. /** @hidden */
  13660. _onPhysicsCollideCallbacks: Array<{
  13661. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13662. otherImpostors: Array<PhysicsImpostor>;
  13663. }>;
  13664. private _deltaPosition;
  13665. private _deltaRotation;
  13666. private _deltaRotationConjugated;
  13667. /** @hidden */
  13668. _isFromLine: boolean;
  13669. private _parent;
  13670. private _isDisposed;
  13671. private static _tmpVecs;
  13672. private static _tmpQuat;
  13673. /**
  13674. * Specifies if the physics imposter is disposed
  13675. */
  13676. readonly isDisposed: boolean;
  13677. /**
  13678. * Gets the mass of the physics imposter
  13679. */
  13680. mass: number;
  13681. /**
  13682. * Gets the coefficient of friction
  13683. */
  13684. /**
  13685. * Sets the coefficient of friction
  13686. */
  13687. friction: number;
  13688. /**
  13689. * Gets the coefficient of restitution
  13690. */
  13691. /**
  13692. * Sets the coefficient of restitution
  13693. */
  13694. restitution: number;
  13695. /**
  13696. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13697. */
  13698. /**
  13699. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13700. */
  13701. pressure: number;
  13702. /**
  13703. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13704. */
  13705. /**
  13706. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13707. */
  13708. stiffness: number;
  13709. /**
  13710. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13711. */
  13712. /**
  13713. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13714. */
  13715. velocityIterations: number;
  13716. /**
  13717. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13718. */
  13719. /**
  13720. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13721. */
  13722. positionIterations: number;
  13723. /**
  13724. * The unique id of the physics imposter
  13725. * set by the physics engine when adding this impostor to the array
  13726. */
  13727. uniqueId: number;
  13728. /**
  13729. * @hidden
  13730. */
  13731. soft: boolean;
  13732. /**
  13733. * @hidden
  13734. */
  13735. segments: number;
  13736. private _joints;
  13737. /**
  13738. * Initializes the physics imposter
  13739. * @param object The physics-enabled object used as the physics imposter
  13740. * @param type The type of the physics imposter
  13741. * @param _options The options for the physics imposter
  13742. * @param _scene The Babylon scene
  13743. */
  13744. constructor(
  13745. /**
  13746. * The physics-enabled object used as the physics imposter
  13747. */
  13748. object: IPhysicsEnabledObject,
  13749. /**
  13750. * The type of the physics imposter
  13751. */
  13752. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13753. /**
  13754. * This function will completly initialize this impostor.
  13755. * It will create a new body - but only if this mesh has no parent.
  13756. * If it has, this impostor will not be used other than to define the impostor
  13757. * of the child mesh.
  13758. * @hidden
  13759. */
  13760. _init(): void;
  13761. private _getPhysicsParent;
  13762. /**
  13763. * Should a new body be generated.
  13764. * @returns boolean specifying if body initialization is required
  13765. */
  13766. isBodyInitRequired(): boolean;
  13767. /**
  13768. * Sets the updated scaling
  13769. * @param updated Specifies if the scaling is updated
  13770. */
  13771. setScalingUpdated(): void;
  13772. /**
  13773. * Force a regeneration of this or the parent's impostor's body.
  13774. * Use under cautious - This will remove all joints already implemented.
  13775. */
  13776. forceUpdate(): void;
  13777. /**
  13778. * Gets the body that holds this impostor. Either its own, or its parent.
  13779. */
  13780. /**
  13781. * Set the physics body. Used mainly by the physics engine/plugin
  13782. */
  13783. physicsBody: any;
  13784. /**
  13785. * Get the parent of the physics imposter
  13786. * @returns Physics imposter or null
  13787. */
  13788. /**
  13789. * Sets the parent of the physics imposter
  13790. */
  13791. parent: Nullable<PhysicsImpostor>;
  13792. /**
  13793. * Resets the update flags
  13794. */
  13795. resetUpdateFlags(): void;
  13796. /**
  13797. * Gets the object extend size
  13798. * @returns the object extend size
  13799. */
  13800. getObjectExtendSize(): Vector3;
  13801. /**
  13802. * Gets the object center
  13803. * @returns The object center
  13804. */
  13805. getObjectCenter(): Vector3;
  13806. /**
  13807. * Get a specific parametes from the options parameter
  13808. * @param paramName The object parameter name
  13809. * @returns The object parameter
  13810. */
  13811. getParam(paramName: string): any;
  13812. /**
  13813. * Sets a specific parameter in the options given to the physics plugin
  13814. * @param paramName The parameter name
  13815. * @param value The value of the parameter
  13816. */
  13817. setParam(paramName: string, value: number): void;
  13818. /**
  13819. * Specifically change the body's mass option. Won't recreate the physics body object
  13820. * @param mass The mass of the physics imposter
  13821. */
  13822. setMass(mass: number): void;
  13823. /**
  13824. * Gets the linear velocity
  13825. * @returns linear velocity or null
  13826. */
  13827. getLinearVelocity(): Nullable<Vector3>;
  13828. /**
  13829. * Sets the linear velocity
  13830. * @param velocity linear velocity or null
  13831. */
  13832. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13833. /**
  13834. * Gets the angular velocity
  13835. * @returns angular velocity or null
  13836. */
  13837. getAngularVelocity(): Nullable<Vector3>;
  13838. /**
  13839. * Sets the angular velocity
  13840. * @param velocity The velocity or null
  13841. */
  13842. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13843. /**
  13844. * Execute a function with the physics plugin native code
  13845. * Provide a function the will have two variables - the world object and the physics body object
  13846. * @param func The function to execute with the physics plugin native code
  13847. */
  13848. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13849. /**
  13850. * Register a function that will be executed before the physics world is stepping forward
  13851. * @param func The function to execute before the physics world is stepped forward
  13852. */
  13853. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13854. /**
  13855. * Unregister a function that will be executed before the physics world is stepping forward
  13856. * @param func The function to execute before the physics world is stepped forward
  13857. */
  13858. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13859. /**
  13860. * Register a function that will be executed after the physics step
  13861. * @param func The function to execute after physics step
  13862. */
  13863. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13864. /**
  13865. * Unregisters a function that will be executed after the physics step
  13866. * @param func The function to execute after physics step
  13867. */
  13868. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13869. /**
  13870. * register a function that will be executed when this impostor collides against a different body
  13871. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13872. * @param func Callback that is executed on collision
  13873. */
  13874. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13875. /**
  13876. * Unregisters the physics imposter on contact
  13877. * @param collideAgainst The physics object to collide against
  13878. * @param func Callback to execute on collision
  13879. */
  13880. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13881. private _tmpQuat;
  13882. private _tmpQuat2;
  13883. /**
  13884. * Get the parent rotation
  13885. * @returns The parent rotation
  13886. */
  13887. getParentsRotation(): Quaternion;
  13888. /**
  13889. * this function is executed by the physics engine.
  13890. */
  13891. beforeStep: () => void;
  13892. /**
  13893. * this function is executed by the physics engine
  13894. */
  13895. afterStep: () => void;
  13896. /**
  13897. * Legacy collision detection event support
  13898. */
  13899. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13900. /**
  13901. * event and body object due to cannon's event-based architecture.
  13902. */
  13903. onCollide: (e: {
  13904. body: any;
  13905. }) => void;
  13906. /**
  13907. * Apply a force
  13908. * @param force The force to apply
  13909. * @param contactPoint The contact point for the force
  13910. * @returns The physics imposter
  13911. */
  13912. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13913. /**
  13914. * Apply an impulse
  13915. * @param force The impulse force
  13916. * @param contactPoint The contact point for the impulse force
  13917. * @returns The physics imposter
  13918. */
  13919. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13920. /**
  13921. * A help function to create a joint
  13922. * @param otherImpostor A physics imposter used to create a joint
  13923. * @param jointType The type of joint
  13924. * @param jointData The data for the joint
  13925. * @returns The physics imposter
  13926. */
  13927. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  13928. /**
  13929. * Add a joint to this impostor with a different impostor
  13930. * @param otherImpostor A physics imposter used to add a joint
  13931. * @param joint The joint to add
  13932. * @returns The physics imposter
  13933. */
  13934. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  13935. /**
  13936. * Add an anchor to a cloth impostor
  13937. * @param otherImpostor rigid impostor to anchor to
  13938. * @param width ratio across width from 0 to 1
  13939. * @param height ratio up height from 0 to 1
  13940. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  13941. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  13942. * @returns impostor the soft imposter
  13943. */
  13944. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13945. /**
  13946. * Add a hook to a rope impostor
  13947. * @param otherImpostor rigid impostor to anchor to
  13948. * @param length ratio across rope from 0 to 1
  13949. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  13950. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  13951. * @returns impostor the rope imposter
  13952. */
  13953. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13954. /**
  13955. * Will keep this body still, in a sleep mode.
  13956. * @returns the physics imposter
  13957. */
  13958. sleep(): PhysicsImpostor;
  13959. /**
  13960. * Wake the body up.
  13961. * @returns The physics imposter
  13962. */
  13963. wakeUp(): PhysicsImpostor;
  13964. /**
  13965. * Clones the physics imposter
  13966. * @param newObject The physics imposter clones to this physics-enabled object
  13967. * @returns A nullable physics imposter
  13968. */
  13969. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13970. /**
  13971. * Disposes the physics imposter
  13972. */
  13973. dispose(): void;
  13974. /**
  13975. * Sets the delta position
  13976. * @param position The delta position amount
  13977. */
  13978. setDeltaPosition(position: Vector3): void;
  13979. /**
  13980. * Sets the delta rotation
  13981. * @param rotation The delta rotation amount
  13982. */
  13983. setDeltaRotation(rotation: Quaternion): void;
  13984. /**
  13985. * Gets the box size of the physics imposter and stores the result in the input parameter
  13986. * @param result Stores the box size
  13987. * @returns The physics imposter
  13988. */
  13989. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  13990. /**
  13991. * Gets the radius of the physics imposter
  13992. * @returns Radius of the physics imposter
  13993. */
  13994. getRadius(): number;
  13995. /**
  13996. * Sync a bone with this impostor
  13997. * @param bone The bone to sync to the impostor.
  13998. * @param boneMesh The mesh that the bone is influencing.
  13999. * @param jointPivot The pivot of the joint / bone in local space.
  14000. * @param distToJoint Optional distance from the impostor to the joint.
  14001. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14002. */
  14003. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  14004. /**
  14005. * Sync impostor to a bone
  14006. * @param bone The bone that the impostor will be synced to.
  14007. * @param boneMesh The mesh that the bone is influencing.
  14008. * @param jointPivot The pivot of the joint / bone in local space.
  14009. * @param distToJoint Optional distance from the impostor to the joint.
  14010. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14011. * @param boneAxis Optional vector3 axis the bone is aligned with
  14012. */
  14013. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  14014. /**
  14015. * No-Imposter type
  14016. */
  14017. static NoImpostor: number;
  14018. /**
  14019. * Sphere-Imposter type
  14020. */
  14021. static SphereImpostor: number;
  14022. /**
  14023. * Box-Imposter type
  14024. */
  14025. static BoxImpostor: number;
  14026. /**
  14027. * Plane-Imposter type
  14028. */
  14029. static PlaneImpostor: number;
  14030. /**
  14031. * Mesh-imposter type
  14032. */
  14033. static MeshImpostor: number;
  14034. /**
  14035. * Cylinder-Imposter type
  14036. */
  14037. static CylinderImpostor: number;
  14038. /**
  14039. * Particle-Imposter type
  14040. */
  14041. static ParticleImpostor: number;
  14042. /**
  14043. * Heightmap-Imposter type
  14044. */
  14045. static HeightmapImpostor: number;
  14046. /**
  14047. * ConvexHull-Impostor type (Ammo.js plugin only)
  14048. */
  14049. static ConvexHullImpostor: number;
  14050. /**
  14051. * Rope-Imposter type
  14052. */
  14053. static RopeImpostor: number;
  14054. /**
  14055. * Cloth-Imposter type
  14056. */
  14057. static ClothImpostor: number;
  14058. /**
  14059. * Softbody-Imposter type
  14060. */
  14061. static SoftbodyImpostor: number;
  14062. }
  14063. }
  14064. declare module "babylonjs/Meshes/mesh" {
  14065. import { Observable } from "babylonjs/Misc/observable";
  14066. import { IAnimatable } from "babylonjs/Misc/tools";
  14067. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  14068. import { Camera } from "babylonjs/Cameras/camera";
  14069. import { Scene } from "babylonjs/scene";
  14070. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  14071. import { Engine } from "babylonjs/Engines/engine";
  14072. import { Node } from "babylonjs/node";
  14073. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  14074. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  14075. import { Buffer } from "babylonjs/Meshes/buffer";
  14076. import { Geometry } from "babylonjs/Meshes/geometry";
  14077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14078. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14079. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  14080. import { Effect } from "babylonjs/Materials/effect";
  14081. import { Material } from "babylonjs/Materials/material";
  14082. import { Skeleton } from "babylonjs/Bones/skeleton";
  14083. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  14084. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  14085. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  14086. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  14087. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  14088. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  14089. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  14090. /**
  14091. * @hidden
  14092. **/
  14093. export class _CreationDataStorage {
  14094. closePath?: boolean;
  14095. closeArray?: boolean;
  14096. idx: number[];
  14097. dashSize: number;
  14098. gapSize: number;
  14099. path3D: Path3D;
  14100. pathArray: Vector3[][];
  14101. arc: number;
  14102. radius: number;
  14103. cap: number;
  14104. tessellation: number;
  14105. }
  14106. /**
  14107. * @hidden
  14108. **/
  14109. class _InstanceDataStorage {
  14110. visibleInstances: any;
  14111. batchCache: _InstancesBatch;
  14112. instancesBufferSize: number;
  14113. instancesBuffer: Nullable<Buffer>;
  14114. instancesData: Float32Array;
  14115. overridenInstanceCount: number;
  14116. isFrozen: boolean;
  14117. previousBatch: Nullable<_InstancesBatch>;
  14118. hardwareInstancedRendering: boolean;
  14119. sideOrientation: number;
  14120. }
  14121. /**
  14122. * @hidden
  14123. **/
  14124. export class _InstancesBatch {
  14125. mustReturn: boolean;
  14126. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  14127. renderSelf: boolean[];
  14128. hardwareInstancedRendering: boolean[];
  14129. }
  14130. /**
  14131. * Class used to represent renderable models
  14132. */
  14133. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  14134. /**
  14135. * Mesh side orientation : usually the external or front surface
  14136. */
  14137. static readonly FRONTSIDE: number;
  14138. /**
  14139. * Mesh side orientation : usually the internal or back surface
  14140. */
  14141. static readonly BACKSIDE: number;
  14142. /**
  14143. * Mesh side orientation : both internal and external or front and back surfaces
  14144. */
  14145. static readonly DOUBLESIDE: number;
  14146. /**
  14147. * Mesh side orientation : by default, `FRONTSIDE`
  14148. */
  14149. static readonly DEFAULTSIDE: number;
  14150. /**
  14151. * Mesh cap setting : no cap
  14152. */
  14153. static readonly NO_CAP: number;
  14154. /**
  14155. * Mesh cap setting : one cap at the beginning of the mesh
  14156. */
  14157. static readonly CAP_START: number;
  14158. /**
  14159. * Mesh cap setting : one cap at the end of the mesh
  14160. */
  14161. static readonly CAP_END: number;
  14162. /**
  14163. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  14164. */
  14165. static readonly CAP_ALL: number;
  14166. /**
  14167. * Mesh pattern setting : no flip or rotate
  14168. */
  14169. static readonly NO_FLIP: number;
  14170. /**
  14171. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  14172. */
  14173. static readonly FLIP_TILE: number;
  14174. /**
  14175. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  14176. */
  14177. static readonly ROTATE_TILE: number;
  14178. /**
  14179. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14180. */
  14181. static readonly FLIP_ROW: number;
  14182. /**
  14183. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14184. */
  14185. static readonly ROTATE_ROW: number;
  14186. /**
  14187. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14188. */
  14189. static readonly FLIP_N_ROTATE_TILE: number;
  14190. /**
  14191. * Mesh pattern setting : rotate pattern and rotate
  14192. */
  14193. static readonly FLIP_N_ROTATE_ROW: number;
  14194. /**
  14195. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14196. */
  14197. static readonly CENTER: number;
  14198. /**
  14199. * Mesh tile positioning : part tiles on left
  14200. */
  14201. static readonly LEFT: number;
  14202. /**
  14203. * Mesh tile positioning : part tiles on right
  14204. */
  14205. static readonly RIGHT: number;
  14206. /**
  14207. * Mesh tile positioning : part tiles on top
  14208. */
  14209. static readonly TOP: number;
  14210. /**
  14211. * Mesh tile positioning : part tiles on bottom
  14212. */
  14213. static readonly BOTTOM: number;
  14214. /**
  14215. * Gets the default side orientation.
  14216. * @param orientation the orientation to value to attempt to get
  14217. * @returns the default orientation
  14218. * @hidden
  14219. */
  14220. static _GetDefaultSideOrientation(orientation?: number): number;
  14221. private _internalMeshDataInfo;
  14222. /**
  14223. * An event triggered before rendering the mesh
  14224. */
  14225. readonly onBeforeRenderObservable: Observable<Mesh>;
  14226. /**
  14227. * An event triggered before binding the mesh
  14228. */
  14229. readonly onBeforeBindObservable: Observable<Mesh>;
  14230. /**
  14231. * An event triggered after rendering the mesh
  14232. */
  14233. readonly onAfterRenderObservable: Observable<Mesh>;
  14234. /**
  14235. * An event triggered before drawing the mesh
  14236. */
  14237. readonly onBeforeDrawObservable: Observable<Mesh>;
  14238. private _onBeforeDrawObserver;
  14239. /**
  14240. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14241. */
  14242. onBeforeDraw: () => void;
  14243. /**
  14244. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14245. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14246. */
  14247. delayLoadState: number;
  14248. /**
  14249. * Gets the list of instances created from this mesh
  14250. * it is not supposed to be modified manually.
  14251. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14252. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14253. */
  14254. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  14255. /**
  14256. * Gets the file containing delay loading data for this mesh
  14257. */
  14258. delayLoadingFile: string;
  14259. /** @hidden */
  14260. _binaryInfo: any;
  14261. /**
  14262. * User defined function used to change how LOD level selection is done
  14263. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14264. */
  14265. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14266. /**
  14267. * Gets or sets the morph target manager
  14268. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14269. */
  14270. morphTargetManager: Nullable<MorphTargetManager>;
  14271. /** @hidden */
  14272. _creationDataStorage: Nullable<_CreationDataStorage>;
  14273. /** @hidden */
  14274. _geometry: Nullable<Geometry>;
  14275. /** @hidden */
  14276. _delayInfo: Array<string>;
  14277. /** @hidden */
  14278. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14279. /** @hidden */
  14280. _instanceDataStorage: _InstanceDataStorage;
  14281. private _effectiveMaterial;
  14282. /** @hidden */
  14283. _shouldGenerateFlatShading: boolean;
  14284. /** @hidden */
  14285. _originalBuilderSideOrientation: number;
  14286. /**
  14287. * Use this property to change the original side orientation defined at construction time
  14288. */
  14289. overrideMaterialSideOrientation: Nullable<number>;
  14290. /**
  14291. * Gets the source mesh (the one used to clone this one from)
  14292. */
  14293. readonly source: Nullable<Mesh>;
  14294. /**
  14295. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14296. */
  14297. isUnIndexed: boolean;
  14298. /**
  14299. * @constructor
  14300. * @param name The value used by scene.getMeshByName() to do a lookup.
  14301. * @param scene The scene to add this mesh to.
  14302. * @param parent The parent of this mesh, if it has one
  14303. * @param source An optional Mesh from which geometry is shared, cloned.
  14304. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14305. * When false, achieved by calling a clone(), also passing False.
  14306. * This will make creation of children, recursive.
  14307. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14308. */
  14309. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14310. /**
  14311. * Gets the class name
  14312. * @returns the string "Mesh".
  14313. */
  14314. getClassName(): string;
  14315. /** @hidden */
  14316. readonly _isMesh: boolean;
  14317. /**
  14318. * Returns a description of this mesh
  14319. * @param fullDetails define if full details about this mesh must be used
  14320. * @returns a descriptive string representing this mesh
  14321. */
  14322. toString(fullDetails?: boolean): string;
  14323. /** @hidden */
  14324. _unBindEffect(): void;
  14325. /**
  14326. * Gets a boolean indicating if this mesh has LOD
  14327. */
  14328. readonly hasLODLevels: boolean;
  14329. /**
  14330. * Gets the list of MeshLODLevel associated with the current mesh
  14331. * @returns an array of MeshLODLevel
  14332. */
  14333. getLODLevels(): MeshLODLevel[];
  14334. private _sortLODLevels;
  14335. /**
  14336. * Add a mesh as LOD level triggered at the given distance.
  14337. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14338. * @param distance The distance from the center of the object to show this level
  14339. * @param mesh The mesh to be added as LOD level (can be null)
  14340. * @return This mesh (for chaining)
  14341. */
  14342. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14343. /**
  14344. * Returns the LOD level mesh at the passed distance or null if not found.
  14345. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14346. * @param distance The distance from the center of the object to show this level
  14347. * @returns a Mesh or `null`
  14348. */
  14349. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14350. /**
  14351. * Remove a mesh from the LOD array
  14352. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14353. * @param mesh defines the mesh to be removed
  14354. * @return This mesh (for chaining)
  14355. */
  14356. removeLODLevel(mesh: Mesh): Mesh;
  14357. /**
  14358. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14359. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14360. * @param camera defines the camera to use to compute distance
  14361. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14362. * @return This mesh (for chaining)
  14363. */
  14364. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14365. /**
  14366. * Gets the mesh internal Geometry object
  14367. */
  14368. readonly geometry: Nullable<Geometry>;
  14369. /**
  14370. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14371. * @returns the total number of vertices
  14372. */
  14373. getTotalVertices(): number;
  14374. /**
  14375. * Returns the content of an associated vertex buffer
  14376. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14377. * - VertexBuffer.PositionKind
  14378. * - VertexBuffer.UVKind
  14379. * - VertexBuffer.UV2Kind
  14380. * - VertexBuffer.UV3Kind
  14381. * - VertexBuffer.UV4Kind
  14382. * - VertexBuffer.UV5Kind
  14383. * - VertexBuffer.UV6Kind
  14384. * - VertexBuffer.ColorKind
  14385. * - VertexBuffer.MatricesIndicesKind
  14386. * - VertexBuffer.MatricesIndicesExtraKind
  14387. * - VertexBuffer.MatricesWeightsKind
  14388. * - VertexBuffer.MatricesWeightsExtraKind
  14389. * @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
  14390. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14391. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14392. */
  14393. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14394. /**
  14395. * Returns the mesh VertexBuffer object from the requested `kind`
  14396. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14397. * - VertexBuffer.PositionKind
  14398. * - VertexBuffer.NormalKind
  14399. * - VertexBuffer.UVKind
  14400. * - VertexBuffer.UV2Kind
  14401. * - VertexBuffer.UV3Kind
  14402. * - VertexBuffer.UV4Kind
  14403. * - VertexBuffer.UV5Kind
  14404. * - VertexBuffer.UV6Kind
  14405. * - VertexBuffer.ColorKind
  14406. * - VertexBuffer.MatricesIndicesKind
  14407. * - VertexBuffer.MatricesIndicesExtraKind
  14408. * - VertexBuffer.MatricesWeightsKind
  14409. * - VertexBuffer.MatricesWeightsExtraKind
  14410. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14411. */
  14412. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14413. /**
  14414. * Tests if a specific vertex buffer is associated with this mesh
  14415. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14416. * - VertexBuffer.PositionKind
  14417. * - VertexBuffer.NormalKind
  14418. * - VertexBuffer.UVKind
  14419. * - VertexBuffer.UV2Kind
  14420. * - VertexBuffer.UV3Kind
  14421. * - VertexBuffer.UV4Kind
  14422. * - VertexBuffer.UV5Kind
  14423. * - VertexBuffer.UV6Kind
  14424. * - VertexBuffer.ColorKind
  14425. * - VertexBuffer.MatricesIndicesKind
  14426. * - VertexBuffer.MatricesIndicesExtraKind
  14427. * - VertexBuffer.MatricesWeightsKind
  14428. * - VertexBuffer.MatricesWeightsExtraKind
  14429. * @returns a boolean
  14430. */
  14431. isVerticesDataPresent(kind: string): boolean;
  14432. /**
  14433. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14434. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14435. * - VertexBuffer.PositionKind
  14436. * - VertexBuffer.UVKind
  14437. * - VertexBuffer.UV2Kind
  14438. * - VertexBuffer.UV3Kind
  14439. * - VertexBuffer.UV4Kind
  14440. * - VertexBuffer.UV5Kind
  14441. * - VertexBuffer.UV6Kind
  14442. * - VertexBuffer.ColorKind
  14443. * - VertexBuffer.MatricesIndicesKind
  14444. * - VertexBuffer.MatricesIndicesExtraKind
  14445. * - VertexBuffer.MatricesWeightsKind
  14446. * - VertexBuffer.MatricesWeightsExtraKind
  14447. * @returns a boolean
  14448. */
  14449. isVertexBufferUpdatable(kind: string): boolean;
  14450. /**
  14451. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14452. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14453. * - VertexBuffer.PositionKind
  14454. * - VertexBuffer.NormalKind
  14455. * - VertexBuffer.UVKind
  14456. * - VertexBuffer.UV2Kind
  14457. * - VertexBuffer.UV3Kind
  14458. * - VertexBuffer.UV4Kind
  14459. * - VertexBuffer.UV5Kind
  14460. * - VertexBuffer.UV6Kind
  14461. * - VertexBuffer.ColorKind
  14462. * - VertexBuffer.MatricesIndicesKind
  14463. * - VertexBuffer.MatricesIndicesExtraKind
  14464. * - VertexBuffer.MatricesWeightsKind
  14465. * - VertexBuffer.MatricesWeightsExtraKind
  14466. * @returns an array of strings
  14467. */
  14468. getVerticesDataKinds(): string[];
  14469. /**
  14470. * Returns a positive integer : the total number of indices in this mesh geometry.
  14471. * @returns the numner of indices or zero if the mesh has no geometry.
  14472. */
  14473. getTotalIndices(): number;
  14474. /**
  14475. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14476. * @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.
  14477. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14478. * @returns the indices array or an empty array if the mesh has no geometry
  14479. */
  14480. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14481. readonly isBlocked: boolean;
  14482. /**
  14483. * Determine if the current mesh is ready to be rendered
  14484. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14485. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14486. * @returns true if all associated assets are ready (material, textures, shaders)
  14487. */
  14488. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14489. /**
  14490. * 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.
  14491. */
  14492. readonly areNormalsFrozen: boolean;
  14493. /**
  14494. * 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.
  14495. * @returns the current mesh
  14496. */
  14497. freezeNormals(): Mesh;
  14498. /**
  14499. * 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
  14500. * @returns the current mesh
  14501. */
  14502. unfreezeNormals(): Mesh;
  14503. /**
  14504. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14505. */
  14506. overridenInstanceCount: number;
  14507. /** @hidden */
  14508. _preActivate(): Mesh;
  14509. /** @hidden */
  14510. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14511. /** @hidden */
  14512. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14513. /**
  14514. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14515. * This means the mesh underlying bounding box and sphere are recomputed.
  14516. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14517. * @returns the current mesh
  14518. */
  14519. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14520. /** @hidden */
  14521. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14522. /**
  14523. * This function will subdivide the mesh into multiple submeshes
  14524. * @param count defines the expected number of submeshes
  14525. */
  14526. subdivide(count: number): void;
  14527. /**
  14528. * Copy a FloatArray into a specific associated vertex buffer
  14529. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14530. * - VertexBuffer.PositionKind
  14531. * - VertexBuffer.UVKind
  14532. * - VertexBuffer.UV2Kind
  14533. * - VertexBuffer.UV3Kind
  14534. * - VertexBuffer.UV4Kind
  14535. * - VertexBuffer.UV5Kind
  14536. * - VertexBuffer.UV6Kind
  14537. * - VertexBuffer.ColorKind
  14538. * - VertexBuffer.MatricesIndicesKind
  14539. * - VertexBuffer.MatricesIndicesExtraKind
  14540. * - VertexBuffer.MatricesWeightsKind
  14541. * - VertexBuffer.MatricesWeightsExtraKind
  14542. * @param data defines the data source
  14543. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14544. * @param stride defines the data stride size (can be null)
  14545. * @returns the current mesh
  14546. */
  14547. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14548. /**
  14549. * Flags an associated vertex buffer as updatable
  14550. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14551. * - VertexBuffer.PositionKind
  14552. * - VertexBuffer.UVKind
  14553. * - VertexBuffer.UV2Kind
  14554. * - VertexBuffer.UV3Kind
  14555. * - VertexBuffer.UV4Kind
  14556. * - VertexBuffer.UV5Kind
  14557. * - VertexBuffer.UV6Kind
  14558. * - VertexBuffer.ColorKind
  14559. * - VertexBuffer.MatricesIndicesKind
  14560. * - VertexBuffer.MatricesIndicesExtraKind
  14561. * - VertexBuffer.MatricesWeightsKind
  14562. * - VertexBuffer.MatricesWeightsExtraKind
  14563. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14564. */
  14565. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14566. /**
  14567. * Sets the mesh global Vertex Buffer
  14568. * @param buffer defines the buffer to use
  14569. * @returns the current mesh
  14570. */
  14571. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14572. /**
  14573. * Update a specific associated vertex buffer
  14574. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14575. * - VertexBuffer.PositionKind
  14576. * - VertexBuffer.UVKind
  14577. * - VertexBuffer.UV2Kind
  14578. * - VertexBuffer.UV3Kind
  14579. * - VertexBuffer.UV4Kind
  14580. * - VertexBuffer.UV5Kind
  14581. * - VertexBuffer.UV6Kind
  14582. * - VertexBuffer.ColorKind
  14583. * - VertexBuffer.MatricesIndicesKind
  14584. * - VertexBuffer.MatricesIndicesExtraKind
  14585. * - VertexBuffer.MatricesWeightsKind
  14586. * - VertexBuffer.MatricesWeightsExtraKind
  14587. * @param data defines the data source
  14588. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14589. * @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)
  14590. * @returns the current mesh
  14591. */
  14592. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14593. /**
  14594. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14595. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14596. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14597. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14598. * @returns the current mesh
  14599. */
  14600. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14601. /**
  14602. * Creates a un-shared specific occurence of the geometry for the mesh.
  14603. * @returns the current mesh
  14604. */
  14605. makeGeometryUnique(): Mesh;
  14606. /**
  14607. * Set the index buffer of this mesh
  14608. * @param indices defines the source data
  14609. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14610. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14611. * @returns the current mesh
  14612. */
  14613. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14614. /**
  14615. * Update the current index buffer
  14616. * @param indices defines the source data
  14617. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14618. * @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)
  14619. * @returns the current mesh
  14620. */
  14621. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14622. /**
  14623. * Invert the geometry to move from a right handed system to a left handed one.
  14624. * @returns the current mesh
  14625. */
  14626. toLeftHanded(): Mesh;
  14627. /** @hidden */
  14628. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14629. /** @hidden */
  14630. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14631. /**
  14632. * Registers for this mesh a javascript function called just before the rendering process
  14633. * @param func defines the function to call before rendering this mesh
  14634. * @returns the current mesh
  14635. */
  14636. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14637. /**
  14638. * Disposes a previously registered javascript function called before the rendering
  14639. * @param func defines the function to remove
  14640. * @returns the current mesh
  14641. */
  14642. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14643. /**
  14644. * Registers for this mesh a javascript function called just after the rendering is complete
  14645. * @param func defines the function to call after rendering this mesh
  14646. * @returns the current mesh
  14647. */
  14648. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14649. /**
  14650. * Disposes a previously registered javascript function called after the rendering.
  14651. * @param func defines the function to remove
  14652. * @returns the current mesh
  14653. */
  14654. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14655. /** @hidden */
  14656. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14657. /** @hidden */
  14658. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14659. /** @hidden */
  14660. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14661. /** @hidden */
  14662. _rebuild(): void;
  14663. /** @hidden */
  14664. _freeze(): void;
  14665. /** @hidden */
  14666. _unFreeze(): void;
  14667. /**
  14668. * 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
  14669. * @param subMesh defines the subMesh to render
  14670. * @param enableAlphaMode defines if alpha mode can be changed
  14671. * @returns the current mesh
  14672. */
  14673. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14674. private _onBeforeDraw;
  14675. /**
  14676. * Renormalize the mesh and patch it up if there are no weights
  14677. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14678. * However in the case of zero weights then we set just a single influence to 1.
  14679. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14680. */
  14681. cleanMatrixWeights(): void;
  14682. private normalizeSkinFourWeights;
  14683. private normalizeSkinWeightsAndExtra;
  14684. /**
  14685. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14686. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14687. * the user know there was an issue with importing the mesh
  14688. * @returns a validation object with skinned, valid and report string
  14689. */
  14690. validateSkinning(): {
  14691. skinned: boolean;
  14692. valid: boolean;
  14693. report: string;
  14694. };
  14695. /** @hidden */
  14696. _checkDelayState(): Mesh;
  14697. private _queueLoad;
  14698. /**
  14699. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14700. * A mesh is in the frustum if its bounding box intersects the frustum
  14701. * @param frustumPlanes defines the frustum to test
  14702. * @returns true if the mesh is in the frustum planes
  14703. */
  14704. isInFrustum(frustumPlanes: Plane[]): boolean;
  14705. /**
  14706. * Sets the mesh material by the material or multiMaterial `id` property
  14707. * @param id is a string identifying the material or the multiMaterial
  14708. * @returns the current mesh
  14709. */
  14710. setMaterialByID(id: string): Mesh;
  14711. /**
  14712. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14713. * @returns an array of IAnimatable
  14714. */
  14715. getAnimatables(): IAnimatable[];
  14716. /**
  14717. * Modifies the mesh geometry according to the passed transformation matrix.
  14718. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14719. * The mesh normals are modified using the same transformation.
  14720. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14721. * @param transform defines the transform matrix to use
  14722. * @see http://doc.babylonjs.com/resources/baking_transformations
  14723. * @returns the current mesh
  14724. */
  14725. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14726. /**
  14727. * Modifies the mesh geometry according to its own current World Matrix.
  14728. * The mesh World Matrix is then reset.
  14729. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14730. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14731. * @see http://doc.babylonjs.com/resources/baking_transformations
  14732. * @returns the current mesh
  14733. */
  14734. bakeCurrentTransformIntoVertices(): Mesh;
  14735. /** @hidden */
  14736. readonly _positions: Nullable<Vector3[]>;
  14737. /** @hidden */
  14738. _resetPointsArrayCache(): Mesh;
  14739. /** @hidden */
  14740. _generatePointsArray(): boolean;
  14741. /**
  14742. * Returns a new Mesh object generated from the current mesh properties.
  14743. * This method must not get confused with createInstance()
  14744. * @param name is a string, the name given to the new mesh
  14745. * @param newParent can be any Node object (default `null`)
  14746. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14747. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14748. * @returns a new mesh
  14749. */
  14750. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14751. /**
  14752. * Releases resources associated with this mesh.
  14753. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14754. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14755. */
  14756. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14757. /**
  14758. * Modifies the mesh geometry according to a displacement map.
  14759. * 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.
  14760. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14761. * @param url is a string, the URL from the image file is to be downloaded.
  14762. * @param minHeight is the lower limit of the displacement.
  14763. * @param maxHeight is the upper limit of the displacement.
  14764. * @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.
  14765. * @param uvOffset is an optional vector2 used to offset UV.
  14766. * @param uvScale is an optional vector2 used to scale UV.
  14767. * @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.
  14768. * @returns the Mesh.
  14769. */
  14770. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14771. /**
  14772. * Modifies the mesh geometry according to a displacementMap buffer.
  14773. * 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.
  14774. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14775. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14776. * @param heightMapWidth is the width of the buffer image.
  14777. * @param heightMapHeight is the height of the buffer image.
  14778. * @param minHeight is the lower limit of the displacement.
  14779. * @param maxHeight is the upper limit of the displacement.
  14780. * @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.
  14781. * @param uvOffset is an optional vector2 used to offset UV.
  14782. * @param uvScale is an optional vector2 used to scale UV.
  14783. * @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.
  14784. * @returns the Mesh.
  14785. */
  14786. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14787. /**
  14788. * Modify the mesh to get a flat shading rendering.
  14789. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14790. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14791. * @returns current mesh
  14792. */
  14793. convertToFlatShadedMesh(): Mesh;
  14794. /**
  14795. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14796. * In other words, more vertices, no more indices and a single bigger VBO.
  14797. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14798. * @returns current mesh
  14799. */
  14800. convertToUnIndexedMesh(): Mesh;
  14801. /**
  14802. * Inverses facet orientations.
  14803. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14804. * @param flipNormals will also inverts the normals
  14805. * @returns current mesh
  14806. */
  14807. flipFaces(flipNormals?: boolean): Mesh;
  14808. /**
  14809. * Increase the number of facets and hence vertices in a mesh
  14810. * Vertex normals are interpolated from existing vertex normals
  14811. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14812. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14813. */
  14814. increaseVertices(numberPerEdge: number): void;
  14815. /**
  14816. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14817. * This will undo any application of covertToFlatShadedMesh
  14818. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14819. */
  14820. forceSharedVertices(): void;
  14821. /** @hidden */
  14822. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14823. /** @hidden */
  14824. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14825. /**
  14826. * Creates a new InstancedMesh object from the mesh model.
  14827. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14828. * @param name defines the name of the new instance
  14829. * @returns a new InstancedMesh
  14830. */
  14831. createInstance(name: string): InstancedMesh;
  14832. /**
  14833. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14834. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14835. * @returns the current mesh
  14836. */
  14837. synchronizeInstances(): Mesh;
  14838. /**
  14839. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14840. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14841. * This should be used together with the simplification to avoid disappearing triangles.
  14842. * @param successCallback an optional success callback to be called after the optimization finished.
  14843. * @returns the current mesh
  14844. */
  14845. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14846. /**
  14847. * Serialize current mesh
  14848. * @param serializationObject defines the object which will receive the serialization data
  14849. */
  14850. serialize(serializationObject: any): void;
  14851. /** @hidden */
  14852. _syncGeometryWithMorphTargetManager(): void;
  14853. /** @hidden */
  14854. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14855. /**
  14856. * Returns a new Mesh object parsed from the source provided.
  14857. * @param parsedMesh is the source
  14858. * @param scene defines the hosting scene
  14859. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14860. * @returns a new Mesh
  14861. */
  14862. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14863. /**
  14864. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14865. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14866. * @param name defines the name of the mesh to create
  14867. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14868. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14869. * @param closePath creates a seam between the first and the last points of each path of the path array
  14870. * @param offset is taken in account only if the `pathArray` is containing a single path
  14871. * @param scene defines the hosting scene
  14872. * @param updatable defines if the mesh must be flagged as updatable
  14873. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14874. * @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)
  14875. * @returns a new Mesh
  14876. */
  14877. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14878. /**
  14879. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14880. * @param name defines the name of the mesh to create
  14881. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14882. * @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
  14883. * @param scene defines the hosting scene
  14884. * @param updatable defines if the mesh must be flagged as updatable
  14885. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14886. * @returns a new Mesh
  14887. */
  14888. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14889. /**
  14890. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14891. * @param name defines the name of the mesh to create
  14892. * @param size sets the size (float) of each box side (default 1)
  14893. * @param scene defines the hosting scene
  14894. * @param updatable defines if the mesh must be flagged as updatable
  14895. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14896. * @returns a new Mesh
  14897. */
  14898. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14899. /**
  14900. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14901. * @param name defines the name of the mesh to create
  14902. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14903. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14904. * @param scene defines the hosting scene
  14905. * @param updatable defines if the mesh must be flagged as updatable
  14906. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14907. * @returns a new Mesh
  14908. */
  14909. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14910. /**
  14911. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14912. * @param name defines the name of the mesh to create
  14913. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14914. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14915. * @param scene defines the hosting scene
  14916. * @returns a new Mesh
  14917. */
  14918. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  14919. /**
  14920. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  14921. * @param name defines the name of the mesh to create
  14922. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  14923. * @param diameterTop set the top cap diameter (floats, default 1)
  14924. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  14925. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  14926. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  14927. * @param scene defines the hosting scene
  14928. * @param updatable defines if the mesh must be flagged as updatable
  14929. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14930. * @returns a new Mesh
  14931. */
  14932. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  14933. /**
  14934. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  14935. * @param name defines the name of the mesh to create
  14936. * @param diameter sets the diameter size (float) of the torus (default 1)
  14937. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  14938. * @param tessellation sets the number of torus sides (postive integer, default 16)
  14939. * @param scene defines the hosting scene
  14940. * @param updatable defines if the mesh must be flagged as updatable
  14941. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14942. * @returns a new Mesh
  14943. */
  14944. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14945. /**
  14946. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  14947. * @param name defines the name of the mesh to create
  14948. * @param radius sets the global radius size (float) of the torus knot (default 2)
  14949. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  14950. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  14951. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  14952. * @param p the number of windings on X axis (positive integers, default 2)
  14953. * @param q the number of windings on Y axis (positive integers, default 3)
  14954. * @param scene defines the hosting scene
  14955. * @param updatable defines if the mesh must be flagged as updatable
  14956. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14957. * @returns a new Mesh
  14958. */
  14959. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14960. /**
  14961. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  14962. * @param name defines the name of the mesh to create
  14963. * @param points is an array successive Vector3
  14964. * @param scene defines the hosting scene
  14965. * @param updatable defines if the mesh must be flagged as updatable
  14966. * @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).
  14967. * @returns a new Mesh
  14968. */
  14969. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  14970. /**
  14971. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  14972. * @param name defines the name of the mesh to create
  14973. * @param points is an array successive Vector3
  14974. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  14975. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  14976. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  14977. * @param scene defines the hosting scene
  14978. * @param updatable defines if the mesh must be flagged as updatable
  14979. * @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)
  14980. * @returns a new Mesh
  14981. */
  14982. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  14983. /**
  14984. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  14985. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  14986. * 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.
  14987. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14988. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14989. * Remember you can only change the shape positions, not their number when updating a polygon.
  14990. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  14991. * @param name defines the name of the mesh to create
  14992. * @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
  14993. * @param scene defines the hosting scene
  14994. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14995. * @param updatable defines if the mesh must be flagged as updatable
  14996. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14997. * @param earcutInjection can be used to inject your own earcut reference
  14998. * @returns a new Mesh
  14999. */
  15000. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15001. /**
  15002. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  15003. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  15004. * @param name defines the name of the mesh to create
  15005. * @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
  15006. * @param depth defines the height of extrusion
  15007. * @param scene defines the hosting scene
  15008. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15009. * @param updatable defines if the mesh must be flagged as updatable
  15010. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15011. * @param earcutInjection can be used to inject your own earcut reference
  15012. * @returns a new Mesh
  15013. */
  15014. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15015. /**
  15016. * Creates an extruded shape mesh.
  15017. * 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
  15018. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15019. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15020. * @param name defines the name of the mesh to create
  15021. * @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
  15022. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15023. * @param scale is the value to scale the shape
  15024. * @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
  15025. * @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
  15026. * @param scene defines the hosting scene
  15027. * @param updatable defines if the mesh must be flagged as updatable
  15028. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15029. * @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)
  15030. * @returns a new Mesh
  15031. */
  15032. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15033. /**
  15034. * Creates an custom extruded shape mesh.
  15035. * The custom extrusion is a parametric shape.
  15036. * It has no predefined shape. Its final shape will depend on the input parameters.
  15037. * Please consider using the same method from the MeshBuilder class instead
  15038. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15039. * @param name defines the name of the mesh to create
  15040. * @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
  15041. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15042. * @param scaleFunction is a custom Javascript function called on each path point
  15043. * @param rotationFunction is a custom Javascript function called on each path point
  15044. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  15045. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  15046. * @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
  15047. * @param scene defines the hosting scene
  15048. * @param updatable defines if the mesh must be flagged as updatable
  15049. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15050. * @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)
  15051. * @returns a new Mesh
  15052. */
  15053. 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;
  15054. /**
  15055. * Creates lathe mesh.
  15056. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15057. * Please consider using the same method from the MeshBuilder class instead
  15058. * @param name defines the name of the mesh to create
  15059. * @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
  15060. * @param radius is the radius value of the lathe
  15061. * @param tessellation is the side number of the lathe.
  15062. * @param scene defines the hosting scene
  15063. * @param updatable defines if the mesh must be flagged as updatable
  15064. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15065. * @returns a new Mesh
  15066. */
  15067. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15068. /**
  15069. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  15070. * @param name defines the name of the mesh to create
  15071. * @param size sets the size (float) of both sides of the plane at once (default 1)
  15072. * @param scene defines the hosting scene
  15073. * @param updatable defines if the mesh must be flagged as updatable
  15074. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15075. * @returns a new Mesh
  15076. */
  15077. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15078. /**
  15079. * Creates a ground mesh.
  15080. * Please consider using the same method from the MeshBuilder class instead
  15081. * @param name defines the name of the mesh to create
  15082. * @param width set the width of the ground
  15083. * @param height set the height of the ground
  15084. * @param subdivisions sets the number of subdivisions per side
  15085. * @param scene defines the hosting scene
  15086. * @param updatable defines if the mesh must be flagged as updatable
  15087. * @returns a new Mesh
  15088. */
  15089. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15090. /**
  15091. * Creates a tiled ground mesh.
  15092. * Please consider using the same method from the MeshBuilder class instead
  15093. * @param name defines the name of the mesh to create
  15094. * @param xmin set the ground minimum X coordinate
  15095. * @param zmin set the ground minimum Y coordinate
  15096. * @param xmax set the ground maximum X coordinate
  15097. * @param zmax set the ground maximum Z coordinate
  15098. * @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
  15099. * @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
  15100. * @param scene defines the hosting scene
  15101. * @param updatable defines if the mesh must be flagged as updatable
  15102. * @returns a new Mesh
  15103. */
  15104. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15105. w: number;
  15106. h: number;
  15107. }, precision: {
  15108. w: number;
  15109. h: number;
  15110. }, scene: Scene, updatable?: boolean): Mesh;
  15111. /**
  15112. * Creates a ground mesh from a height map.
  15113. * Please consider using the same method from the MeshBuilder class instead
  15114. * @see http://doc.babylonjs.com/babylon101/height_map
  15115. * @param name defines the name of the mesh to create
  15116. * @param url sets the URL of the height map image resource
  15117. * @param width set the ground width size
  15118. * @param height set the ground height size
  15119. * @param subdivisions sets the number of subdivision per side
  15120. * @param minHeight is the minimum altitude on the ground
  15121. * @param maxHeight is the maximum altitude on the ground
  15122. * @param scene defines the hosting scene
  15123. * @param updatable defines if the mesh must be flagged as updatable
  15124. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  15125. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  15126. * @returns a new Mesh
  15127. */
  15128. 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;
  15129. /**
  15130. * Creates a tube mesh.
  15131. * The tube is a parametric shape.
  15132. * It has no predefined shape. Its final shape will depend on the input parameters.
  15133. * Please consider using the same method from the MeshBuilder class instead
  15134. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15135. * @param name defines the name of the mesh to create
  15136. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  15137. * @param radius sets the tube radius size
  15138. * @param tessellation is the number of sides on the tubular surface
  15139. * @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
  15140. * @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
  15141. * @param scene defines the hosting scene
  15142. * @param updatable defines if the mesh must be flagged as updatable
  15143. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15144. * @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)
  15145. * @returns a new Mesh
  15146. */
  15147. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15148. (i: number, distance: number): number;
  15149. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15150. /**
  15151. * Creates a polyhedron mesh.
  15152. * Please consider using the same method from the MeshBuilder class instead.
  15153. * * 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
  15154. * * The parameter `size` (positive float, default 1) sets the polygon size
  15155. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  15156. * * 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`
  15157. * * 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
  15158. * * 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)`)
  15159. * * 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
  15160. * * 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
  15161. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15162. * * If you create a double-sided mesh, you can choose what parts of 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
  15163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15164. * @param name defines the name of the mesh to create
  15165. * @param options defines the options used to create the mesh
  15166. * @param scene defines the hosting scene
  15167. * @returns a new Mesh
  15168. */
  15169. static CreatePolyhedron(name: string, options: {
  15170. type?: number;
  15171. size?: number;
  15172. sizeX?: number;
  15173. sizeY?: number;
  15174. sizeZ?: number;
  15175. custom?: any;
  15176. faceUV?: Vector4[];
  15177. faceColors?: Color4[];
  15178. updatable?: boolean;
  15179. sideOrientation?: number;
  15180. }, scene: Scene): Mesh;
  15181. /**
  15182. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15183. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15184. * * 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`)
  15185. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15186. * * 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
  15187. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15188. * * If you create a double-sided mesh, you can choose what parts of 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
  15189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15190. * @param name defines the name of the mesh
  15191. * @param options defines the options used to create the mesh
  15192. * @param scene defines the hosting scene
  15193. * @returns a new Mesh
  15194. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15195. */
  15196. static CreateIcoSphere(name: string, options: {
  15197. radius?: number;
  15198. flat?: boolean;
  15199. subdivisions?: number;
  15200. sideOrientation?: number;
  15201. updatable?: boolean;
  15202. }, scene: Scene): Mesh;
  15203. /**
  15204. * Creates a decal mesh.
  15205. * Please consider using the same method from the MeshBuilder class instead.
  15206. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15207. * @param name defines the name of the mesh
  15208. * @param sourceMesh defines the mesh receiving the decal
  15209. * @param position sets the position of the decal in world coordinates
  15210. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15211. * @param size sets the decal scaling
  15212. * @param angle sets the angle to rotate the decal
  15213. * @returns a new Mesh
  15214. */
  15215. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15216. /**
  15217. * Prepare internal position array for software CPU skinning
  15218. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15219. */
  15220. setPositionsForCPUSkinning(): Float32Array;
  15221. /**
  15222. * Prepare internal normal array for software CPU skinning
  15223. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15224. */
  15225. setNormalsForCPUSkinning(): Float32Array;
  15226. /**
  15227. * Updates the vertex buffer by applying transformation from the bones
  15228. * @param skeleton defines the skeleton to apply to current mesh
  15229. * @returns the current mesh
  15230. */
  15231. applySkeleton(skeleton: Skeleton): Mesh;
  15232. /**
  15233. * 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
  15234. * @param meshes defines the list of meshes to scan
  15235. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15236. */
  15237. static MinMax(meshes: AbstractMesh[]): {
  15238. min: Vector3;
  15239. max: Vector3;
  15240. };
  15241. /**
  15242. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15243. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15244. * @returns a vector3
  15245. */
  15246. static Center(meshesOrMinMaxVector: {
  15247. min: Vector3;
  15248. max: Vector3;
  15249. } | AbstractMesh[]): Vector3;
  15250. /**
  15251. * Merge the array of meshes into a single mesh for performance reasons.
  15252. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15253. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15254. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15255. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15256. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15257. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15258. * @returns a new mesh
  15259. */
  15260. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15261. /** @hidden */
  15262. addInstance(instance: InstancedMesh): void;
  15263. /** @hidden */
  15264. removeInstance(instance: InstancedMesh): void;
  15265. }
  15266. }
  15267. declare module "babylonjs/Actions/action" {
  15268. import { Observable } from "babylonjs/Misc/observable";
  15269. import { Condition } from "babylonjs/Actions/condition";
  15270. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15271. import { ActionManager } from "babylonjs/Actions/actionManager";
  15272. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15273. /**
  15274. * Interface used to define Action
  15275. */
  15276. export interface IAction {
  15277. /**
  15278. * Trigger for the action
  15279. */
  15280. trigger: number;
  15281. /** Options of the trigger */
  15282. triggerOptions: any;
  15283. /**
  15284. * Gets the trigger parameters
  15285. * @returns the trigger parameters
  15286. */
  15287. getTriggerParameter(): any;
  15288. /**
  15289. * Internal only - executes current action event
  15290. * @hidden
  15291. */
  15292. _executeCurrent(evt?: ActionEvent): void;
  15293. /**
  15294. * Serialize placeholder for child classes
  15295. * @param parent of child
  15296. * @returns the serialized object
  15297. */
  15298. serialize(parent: any): any;
  15299. /**
  15300. * Internal only
  15301. * @hidden
  15302. */
  15303. _prepare(): void;
  15304. /**
  15305. * Internal only - manager for action
  15306. * @hidden
  15307. */
  15308. _actionManager: AbstractActionManager;
  15309. /**
  15310. * Adds action to chain of actions, may be a DoNothingAction
  15311. * @param action defines the next action to execute
  15312. * @returns The action passed in
  15313. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15314. */
  15315. then(action: IAction): IAction;
  15316. }
  15317. /**
  15318. * The action to be carried out following a trigger
  15319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15320. */
  15321. export class Action implements IAction {
  15322. /** the trigger, with or without parameters, for the action */
  15323. triggerOptions: any;
  15324. /**
  15325. * Trigger for the action
  15326. */
  15327. trigger: number;
  15328. /**
  15329. * Internal only - manager for action
  15330. * @hidden
  15331. */
  15332. _actionManager: ActionManager;
  15333. private _nextActiveAction;
  15334. private _child;
  15335. private _condition?;
  15336. private _triggerParameter;
  15337. /**
  15338. * An event triggered prior to action being executed.
  15339. */
  15340. onBeforeExecuteObservable: Observable<Action>;
  15341. /**
  15342. * Creates a new Action
  15343. * @param triggerOptions the trigger, with or without parameters, for the action
  15344. * @param condition an optional determinant of action
  15345. */
  15346. constructor(
  15347. /** the trigger, with or without parameters, for the action */
  15348. triggerOptions: any, condition?: Condition);
  15349. /**
  15350. * Internal only
  15351. * @hidden
  15352. */
  15353. _prepare(): void;
  15354. /**
  15355. * Gets the trigger parameters
  15356. * @returns the trigger parameters
  15357. */
  15358. getTriggerParameter(): any;
  15359. /**
  15360. * Internal only - executes current action event
  15361. * @hidden
  15362. */
  15363. _executeCurrent(evt?: ActionEvent): void;
  15364. /**
  15365. * Execute placeholder for child classes
  15366. * @param evt optional action event
  15367. */
  15368. execute(evt?: ActionEvent): void;
  15369. /**
  15370. * Skips to next active action
  15371. */
  15372. skipToNextActiveAction(): void;
  15373. /**
  15374. * Adds action to chain of actions, may be a DoNothingAction
  15375. * @param action defines the next action to execute
  15376. * @returns The action passed in
  15377. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15378. */
  15379. then(action: Action): Action;
  15380. /**
  15381. * Internal only
  15382. * @hidden
  15383. */
  15384. _getProperty(propertyPath: string): string;
  15385. /**
  15386. * Internal only
  15387. * @hidden
  15388. */
  15389. _getEffectiveTarget(target: any, propertyPath: string): any;
  15390. /**
  15391. * Serialize placeholder for child classes
  15392. * @param parent of child
  15393. * @returns the serialized object
  15394. */
  15395. serialize(parent: any): any;
  15396. /**
  15397. * Internal only called by serialize
  15398. * @hidden
  15399. */
  15400. protected _serialize(serializedAction: any, parent?: any): any;
  15401. /**
  15402. * Internal only
  15403. * @hidden
  15404. */
  15405. static _SerializeValueAsString: (value: any) => string;
  15406. /**
  15407. * Internal only
  15408. * @hidden
  15409. */
  15410. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  15411. name: string;
  15412. targetType: string;
  15413. value: string;
  15414. };
  15415. }
  15416. }
  15417. declare module "babylonjs/Actions/condition" {
  15418. import { ActionManager } from "babylonjs/Actions/actionManager";
  15419. /**
  15420. * A Condition applied to an Action
  15421. */
  15422. export class Condition {
  15423. /**
  15424. * Internal only - manager for action
  15425. * @hidden
  15426. */
  15427. _actionManager: ActionManager;
  15428. /**
  15429. * Internal only
  15430. * @hidden
  15431. */
  15432. _evaluationId: number;
  15433. /**
  15434. * Internal only
  15435. * @hidden
  15436. */
  15437. _currentResult: boolean;
  15438. /**
  15439. * Creates a new Condition
  15440. * @param actionManager the manager of the action the condition is applied to
  15441. */
  15442. constructor(actionManager: ActionManager);
  15443. /**
  15444. * Check if the current condition is valid
  15445. * @returns a boolean
  15446. */
  15447. isValid(): boolean;
  15448. /**
  15449. * Internal only
  15450. * @hidden
  15451. */
  15452. _getProperty(propertyPath: string): string;
  15453. /**
  15454. * Internal only
  15455. * @hidden
  15456. */
  15457. _getEffectiveTarget(target: any, propertyPath: string): any;
  15458. /**
  15459. * Serialize placeholder for child classes
  15460. * @returns the serialized object
  15461. */
  15462. serialize(): any;
  15463. /**
  15464. * Internal only
  15465. * @hidden
  15466. */
  15467. protected _serialize(serializedCondition: any): any;
  15468. }
  15469. /**
  15470. * Defines specific conditional operators as extensions of Condition
  15471. */
  15472. export class ValueCondition extends Condition {
  15473. /** path to specify the property of the target the conditional operator uses */
  15474. propertyPath: string;
  15475. /** the value compared by the conditional operator against the current value of the property */
  15476. value: any;
  15477. /** the conditional operator, default ValueCondition.IsEqual */
  15478. operator: number;
  15479. /**
  15480. * Internal only
  15481. * @hidden
  15482. */
  15483. private static _IsEqual;
  15484. /**
  15485. * Internal only
  15486. * @hidden
  15487. */
  15488. private static _IsDifferent;
  15489. /**
  15490. * Internal only
  15491. * @hidden
  15492. */
  15493. private static _IsGreater;
  15494. /**
  15495. * Internal only
  15496. * @hidden
  15497. */
  15498. private static _IsLesser;
  15499. /**
  15500. * returns the number for IsEqual
  15501. */
  15502. static readonly IsEqual: number;
  15503. /**
  15504. * Returns the number for IsDifferent
  15505. */
  15506. static readonly IsDifferent: number;
  15507. /**
  15508. * Returns the number for IsGreater
  15509. */
  15510. static readonly IsGreater: number;
  15511. /**
  15512. * Returns the number for IsLesser
  15513. */
  15514. static readonly IsLesser: number;
  15515. /**
  15516. * Internal only The action manager for the condition
  15517. * @hidden
  15518. */
  15519. _actionManager: ActionManager;
  15520. /**
  15521. * Internal only
  15522. * @hidden
  15523. */
  15524. private _target;
  15525. /**
  15526. * Internal only
  15527. * @hidden
  15528. */
  15529. private _effectiveTarget;
  15530. /**
  15531. * Internal only
  15532. * @hidden
  15533. */
  15534. private _property;
  15535. /**
  15536. * Creates a new ValueCondition
  15537. * @param actionManager manager for the action the condition applies to
  15538. * @param target for the action
  15539. * @param propertyPath path to specify the property of the target the conditional operator uses
  15540. * @param value the value compared by the conditional operator against the current value of the property
  15541. * @param operator the conditional operator, default ValueCondition.IsEqual
  15542. */
  15543. constructor(actionManager: ActionManager, target: any,
  15544. /** path to specify the property of the target the conditional operator uses */
  15545. propertyPath: string,
  15546. /** the value compared by the conditional operator against the current value of the property */
  15547. value: any,
  15548. /** the conditional operator, default ValueCondition.IsEqual */
  15549. operator?: number);
  15550. /**
  15551. * Compares the given value with the property value for the specified conditional operator
  15552. * @returns the result of the comparison
  15553. */
  15554. isValid(): boolean;
  15555. /**
  15556. * Serialize the ValueCondition into a JSON compatible object
  15557. * @returns serialization object
  15558. */
  15559. serialize(): any;
  15560. /**
  15561. * Gets the name of the conditional operator for the ValueCondition
  15562. * @param operator the conditional operator
  15563. * @returns the name
  15564. */
  15565. static GetOperatorName(operator: number): string;
  15566. }
  15567. /**
  15568. * Defines a predicate condition as an extension of Condition
  15569. */
  15570. export class PredicateCondition extends Condition {
  15571. /** defines the predicate function used to validate the condition */
  15572. predicate: () => boolean;
  15573. /**
  15574. * Internal only - manager for action
  15575. * @hidden
  15576. */
  15577. _actionManager: ActionManager;
  15578. /**
  15579. * Creates a new PredicateCondition
  15580. * @param actionManager manager for the action the condition applies to
  15581. * @param predicate defines the predicate function used to validate the condition
  15582. */
  15583. constructor(actionManager: ActionManager,
  15584. /** defines the predicate function used to validate the condition */
  15585. predicate: () => boolean);
  15586. /**
  15587. * @returns the validity of the predicate condition
  15588. */
  15589. isValid(): boolean;
  15590. }
  15591. /**
  15592. * Defines a state condition as an extension of Condition
  15593. */
  15594. export class StateCondition extends Condition {
  15595. /** Value to compare with target state */
  15596. value: string;
  15597. /**
  15598. * Internal only - manager for action
  15599. * @hidden
  15600. */
  15601. _actionManager: ActionManager;
  15602. /**
  15603. * Internal only
  15604. * @hidden
  15605. */
  15606. private _target;
  15607. /**
  15608. * Creates a new StateCondition
  15609. * @param actionManager manager for the action the condition applies to
  15610. * @param target of the condition
  15611. * @param value to compare with target state
  15612. */
  15613. constructor(actionManager: ActionManager, target: any,
  15614. /** Value to compare with target state */
  15615. value: string);
  15616. /**
  15617. * Gets a boolean indicating if the current condition is met
  15618. * @returns the validity of the state
  15619. */
  15620. isValid(): boolean;
  15621. /**
  15622. * Serialize the StateCondition into a JSON compatible object
  15623. * @returns serialization object
  15624. */
  15625. serialize(): any;
  15626. }
  15627. }
  15628. declare module "babylonjs/Actions/directActions" {
  15629. import { Action } from "babylonjs/Actions/action";
  15630. import { Condition } from "babylonjs/Actions/condition";
  15631. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15632. /**
  15633. * This defines an action responsible to toggle a boolean once triggered.
  15634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15635. */
  15636. export class SwitchBooleanAction extends Action {
  15637. /**
  15638. * The path to the boolean property in the target object
  15639. */
  15640. propertyPath: string;
  15641. private _target;
  15642. private _effectiveTarget;
  15643. private _property;
  15644. /**
  15645. * Instantiate the action
  15646. * @param triggerOptions defines the trigger options
  15647. * @param target defines the object containing the boolean
  15648. * @param propertyPath defines the path to the boolean property in the target object
  15649. * @param condition defines the trigger related conditions
  15650. */
  15651. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15652. /** @hidden */
  15653. _prepare(): void;
  15654. /**
  15655. * Execute the action toggle the boolean value.
  15656. */
  15657. execute(): void;
  15658. /**
  15659. * Serializes the actions and its related information.
  15660. * @param parent defines the object to serialize in
  15661. * @returns the serialized object
  15662. */
  15663. serialize(parent: any): any;
  15664. }
  15665. /**
  15666. * This defines an action responsible to set a the state field of the target
  15667. * to a desired value once triggered.
  15668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15669. */
  15670. export class SetStateAction extends Action {
  15671. /**
  15672. * The value to store in the state field.
  15673. */
  15674. value: string;
  15675. private _target;
  15676. /**
  15677. * Instantiate the action
  15678. * @param triggerOptions defines the trigger options
  15679. * @param target defines the object containing the state property
  15680. * @param value defines the value to store in the state field
  15681. * @param condition defines the trigger related conditions
  15682. */
  15683. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15684. /**
  15685. * Execute the action and store the value on the target state property.
  15686. */
  15687. execute(): void;
  15688. /**
  15689. * Serializes the actions and its related information.
  15690. * @param parent defines the object to serialize in
  15691. * @returns the serialized object
  15692. */
  15693. serialize(parent: any): any;
  15694. }
  15695. /**
  15696. * This defines an action responsible to set a property of the target
  15697. * to a desired value once triggered.
  15698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15699. */
  15700. export class SetValueAction extends Action {
  15701. /**
  15702. * The path of the property to set in the target.
  15703. */
  15704. propertyPath: string;
  15705. /**
  15706. * The value to set in the property
  15707. */
  15708. value: any;
  15709. private _target;
  15710. private _effectiveTarget;
  15711. private _property;
  15712. /**
  15713. * Instantiate the action
  15714. * @param triggerOptions defines the trigger options
  15715. * @param target defines the object containing the property
  15716. * @param propertyPath defines the path of the property to set in the target
  15717. * @param value defines the value to set in the property
  15718. * @param condition defines the trigger related conditions
  15719. */
  15720. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15721. /** @hidden */
  15722. _prepare(): void;
  15723. /**
  15724. * Execute the action and set the targetted property to the desired value.
  15725. */
  15726. execute(): void;
  15727. /**
  15728. * Serializes the actions and its related information.
  15729. * @param parent defines the object to serialize in
  15730. * @returns the serialized object
  15731. */
  15732. serialize(parent: any): any;
  15733. }
  15734. /**
  15735. * This defines an action responsible to increment the target value
  15736. * to a desired value once triggered.
  15737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15738. */
  15739. export class IncrementValueAction extends Action {
  15740. /**
  15741. * The path of the property to increment in the target.
  15742. */
  15743. propertyPath: string;
  15744. /**
  15745. * The value we should increment the property by.
  15746. */
  15747. value: any;
  15748. private _target;
  15749. private _effectiveTarget;
  15750. private _property;
  15751. /**
  15752. * Instantiate the action
  15753. * @param triggerOptions defines the trigger options
  15754. * @param target defines the object containing the property
  15755. * @param propertyPath defines the path of the property to increment in the target
  15756. * @param value defines the value value we should increment the property by
  15757. * @param condition defines the trigger related conditions
  15758. */
  15759. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15760. /** @hidden */
  15761. _prepare(): void;
  15762. /**
  15763. * Execute the action and increment the target of the value amount.
  15764. */
  15765. execute(): void;
  15766. /**
  15767. * Serializes the actions and its related information.
  15768. * @param parent defines the object to serialize in
  15769. * @returns the serialized object
  15770. */
  15771. serialize(parent: any): any;
  15772. }
  15773. /**
  15774. * This defines an action responsible to start an animation once triggered.
  15775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15776. */
  15777. export class PlayAnimationAction extends Action {
  15778. /**
  15779. * Where the animation should start (animation frame)
  15780. */
  15781. from: number;
  15782. /**
  15783. * Where the animation should stop (animation frame)
  15784. */
  15785. to: number;
  15786. /**
  15787. * Define if the animation should loop or stop after the first play.
  15788. */
  15789. loop?: boolean;
  15790. private _target;
  15791. /**
  15792. * Instantiate the action
  15793. * @param triggerOptions defines the trigger options
  15794. * @param target defines the target animation or animation name
  15795. * @param from defines from where the animation should start (animation frame)
  15796. * @param end defines where the animation should stop (animation frame)
  15797. * @param loop defines if the animation should loop or stop after the first play
  15798. * @param condition defines the trigger related conditions
  15799. */
  15800. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15801. /** @hidden */
  15802. _prepare(): void;
  15803. /**
  15804. * Execute the action and play the animation.
  15805. */
  15806. execute(): void;
  15807. /**
  15808. * Serializes the actions and its related information.
  15809. * @param parent defines the object to serialize in
  15810. * @returns the serialized object
  15811. */
  15812. serialize(parent: any): any;
  15813. }
  15814. /**
  15815. * This defines an action responsible to stop an animation once triggered.
  15816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15817. */
  15818. export class StopAnimationAction extends Action {
  15819. private _target;
  15820. /**
  15821. * Instantiate the action
  15822. * @param triggerOptions defines the trigger options
  15823. * @param target defines the target animation or animation name
  15824. * @param condition defines the trigger related conditions
  15825. */
  15826. constructor(triggerOptions: any, target: any, condition?: Condition);
  15827. /** @hidden */
  15828. _prepare(): void;
  15829. /**
  15830. * Execute the action and stop the animation.
  15831. */
  15832. execute(): void;
  15833. /**
  15834. * Serializes the actions and its related information.
  15835. * @param parent defines the object to serialize in
  15836. * @returns the serialized object
  15837. */
  15838. serialize(parent: any): any;
  15839. }
  15840. /**
  15841. * This defines an action responsible that does nothing once triggered.
  15842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15843. */
  15844. export class DoNothingAction extends Action {
  15845. /**
  15846. * Instantiate the action
  15847. * @param triggerOptions defines the trigger options
  15848. * @param condition defines the trigger related conditions
  15849. */
  15850. constructor(triggerOptions?: any, condition?: Condition);
  15851. /**
  15852. * Execute the action and do nothing.
  15853. */
  15854. execute(): void;
  15855. /**
  15856. * Serializes the actions and its related information.
  15857. * @param parent defines the object to serialize in
  15858. * @returns the serialized object
  15859. */
  15860. serialize(parent: any): any;
  15861. }
  15862. /**
  15863. * This defines an action responsible to trigger several actions once triggered.
  15864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15865. */
  15866. export class CombineAction extends Action {
  15867. /**
  15868. * The list of aggregated animations to run.
  15869. */
  15870. children: Action[];
  15871. /**
  15872. * Instantiate the action
  15873. * @param triggerOptions defines the trigger options
  15874. * @param children defines the list of aggregated animations to run
  15875. * @param condition defines the trigger related conditions
  15876. */
  15877. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15878. /** @hidden */
  15879. _prepare(): void;
  15880. /**
  15881. * Execute the action and executes all the aggregated actions.
  15882. */
  15883. execute(evt: ActionEvent): void;
  15884. /**
  15885. * Serializes the actions and its related information.
  15886. * @param parent defines the object to serialize in
  15887. * @returns the serialized object
  15888. */
  15889. serialize(parent: any): any;
  15890. }
  15891. /**
  15892. * This defines an action responsible to run code (external event) once triggered.
  15893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15894. */
  15895. export class ExecuteCodeAction extends Action {
  15896. /**
  15897. * The callback function to run.
  15898. */
  15899. func: (evt: ActionEvent) => void;
  15900. /**
  15901. * Instantiate the action
  15902. * @param triggerOptions defines the trigger options
  15903. * @param func defines the callback function to run
  15904. * @param condition defines the trigger related conditions
  15905. */
  15906. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15907. /**
  15908. * Execute the action and run the attached code.
  15909. */
  15910. execute(evt: ActionEvent): void;
  15911. }
  15912. /**
  15913. * This defines an action responsible to set the parent property of the target once triggered.
  15914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15915. */
  15916. export class SetParentAction extends Action {
  15917. private _parent;
  15918. private _target;
  15919. /**
  15920. * Instantiate the action
  15921. * @param triggerOptions defines the trigger options
  15922. * @param target defines the target containing the parent property
  15923. * @param parent defines from where the animation should start (animation frame)
  15924. * @param condition defines the trigger related conditions
  15925. */
  15926. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  15927. /** @hidden */
  15928. _prepare(): void;
  15929. /**
  15930. * Execute the action and set the parent property.
  15931. */
  15932. execute(): void;
  15933. /**
  15934. * Serializes the actions and its related information.
  15935. * @param parent defines the object to serialize in
  15936. * @returns the serialized object
  15937. */
  15938. serialize(parent: any): any;
  15939. }
  15940. }
  15941. declare module "babylonjs/Actions/actionManager" {
  15942. import { Nullable } from "babylonjs/types";
  15943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15944. import { Scene } from "babylonjs/scene";
  15945. import { IAction } from "babylonjs/Actions/action";
  15946. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  15947. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15948. /**
  15949. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  15950. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  15951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15952. */
  15953. export class ActionManager extends AbstractActionManager {
  15954. /**
  15955. * Nothing
  15956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15957. */
  15958. static readonly NothingTrigger: number;
  15959. /**
  15960. * On pick
  15961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15962. */
  15963. static readonly OnPickTrigger: number;
  15964. /**
  15965. * On left pick
  15966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15967. */
  15968. static readonly OnLeftPickTrigger: number;
  15969. /**
  15970. * On right pick
  15971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15972. */
  15973. static readonly OnRightPickTrigger: number;
  15974. /**
  15975. * On center pick
  15976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15977. */
  15978. static readonly OnCenterPickTrigger: number;
  15979. /**
  15980. * On pick down
  15981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15982. */
  15983. static readonly OnPickDownTrigger: number;
  15984. /**
  15985. * On double pick
  15986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15987. */
  15988. static readonly OnDoublePickTrigger: number;
  15989. /**
  15990. * On pick up
  15991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15992. */
  15993. static readonly OnPickUpTrigger: number;
  15994. /**
  15995. * On pick out.
  15996. * This trigger will only be raised if you also declared a OnPickDown
  15997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15998. */
  15999. static readonly OnPickOutTrigger: number;
  16000. /**
  16001. * On long press
  16002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16003. */
  16004. static readonly OnLongPressTrigger: number;
  16005. /**
  16006. * On pointer over
  16007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16008. */
  16009. static readonly OnPointerOverTrigger: number;
  16010. /**
  16011. * On pointer out
  16012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16013. */
  16014. static readonly OnPointerOutTrigger: number;
  16015. /**
  16016. * On every frame
  16017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16018. */
  16019. static readonly OnEveryFrameTrigger: number;
  16020. /**
  16021. * On intersection enter
  16022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16023. */
  16024. static readonly OnIntersectionEnterTrigger: number;
  16025. /**
  16026. * On intersection exit
  16027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16028. */
  16029. static readonly OnIntersectionExitTrigger: number;
  16030. /**
  16031. * On key down
  16032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16033. */
  16034. static readonly OnKeyDownTrigger: number;
  16035. /**
  16036. * On key up
  16037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16038. */
  16039. static readonly OnKeyUpTrigger: number;
  16040. private _scene;
  16041. /**
  16042. * Creates a new action manager
  16043. * @param scene defines the hosting scene
  16044. */
  16045. constructor(scene: Scene);
  16046. /**
  16047. * Releases all associated resources
  16048. */
  16049. dispose(): void;
  16050. /**
  16051. * Gets hosting scene
  16052. * @returns the hosting scene
  16053. */
  16054. getScene(): Scene;
  16055. /**
  16056. * Does this action manager handles actions of any of the given triggers
  16057. * @param triggers defines the triggers to be tested
  16058. * @return a boolean indicating whether one (or more) of the triggers is handled
  16059. */
  16060. hasSpecificTriggers(triggers: number[]): boolean;
  16061. /**
  16062. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  16063. * speed.
  16064. * @param triggerA defines the trigger to be tested
  16065. * @param triggerB defines the trigger to be tested
  16066. * @return a boolean indicating whether one (or more) of the triggers is handled
  16067. */
  16068. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  16069. /**
  16070. * Does this action manager handles actions of a given trigger
  16071. * @param trigger defines the trigger to be tested
  16072. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  16073. * @return whether the trigger is handled
  16074. */
  16075. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  16076. /**
  16077. * Does this action manager has pointer triggers
  16078. */
  16079. readonly hasPointerTriggers: boolean;
  16080. /**
  16081. * Does this action manager has pick triggers
  16082. */
  16083. readonly hasPickTriggers: boolean;
  16084. /**
  16085. * Registers an action to this action manager
  16086. * @param action defines the action to be registered
  16087. * @return the action amended (prepared) after registration
  16088. */
  16089. registerAction(action: IAction): Nullable<IAction>;
  16090. /**
  16091. * Unregisters an action to this action manager
  16092. * @param action defines the action to be unregistered
  16093. * @return a boolean indicating whether the action has been unregistered
  16094. */
  16095. unregisterAction(action: IAction): Boolean;
  16096. /**
  16097. * Process a specific trigger
  16098. * @param trigger defines the trigger to process
  16099. * @param evt defines the event details to be processed
  16100. */
  16101. processTrigger(trigger: number, evt?: IActionEvent): void;
  16102. /** @hidden */
  16103. _getEffectiveTarget(target: any, propertyPath: string): any;
  16104. /** @hidden */
  16105. _getProperty(propertyPath: string): string;
  16106. /**
  16107. * Serialize this manager to a JSON object
  16108. * @param name defines the property name to store this manager
  16109. * @returns a JSON representation of this manager
  16110. */
  16111. serialize(name: string): any;
  16112. /**
  16113. * Creates a new ActionManager from a JSON data
  16114. * @param parsedActions defines the JSON data to read from
  16115. * @param object defines the hosting mesh
  16116. * @param scene defines the hosting scene
  16117. */
  16118. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  16119. /**
  16120. * Get a trigger name by index
  16121. * @param trigger defines the trigger index
  16122. * @returns a trigger name
  16123. */
  16124. static GetTriggerName(trigger: number): string;
  16125. }
  16126. }
  16127. declare module "babylonjs/Culling/ray" {
  16128. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  16129. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  16130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16131. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16132. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  16133. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  16134. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  16135. /**
  16136. * Class representing a ray with position and direction
  16137. */
  16138. export class Ray {
  16139. /** origin point */
  16140. origin: Vector3;
  16141. /** direction */
  16142. direction: Vector3;
  16143. /** length of the ray */
  16144. length: number;
  16145. private static readonly TmpVector3;
  16146. private _tmpRay;
  16147. /**
  16148. * Creates a new ray
  16149. * @param origin origin point
  16150. * @param direction direction
  16151. * @param length length of the ray
  16152. */
  16153. constructor(
  16154. /** origin point */
  16155. origin: Vector3,
  16156. /** direction */
  16157. direction: Vector3,
  16158. /** length of the ray */
  16159. length?: number);
  16160. /**
  16161. * Checks if the ray intersects a box
  16162. * @param minimum bound of the box
  16163. * @param maximum bound of the box
  16164. * @param intersectionTreshold extra extend to be added to the box in all direction
  16165. * @returns if the box was hit
  16166. */
  16167. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  16168. /**
  16169. * Checks if the ray intersects a box
  16170. * @param box the bounding box to check
  16171. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  16172. * @returns if the box was hit
  16173. */
  16174. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  16175. /**
  16176. * If the ray hits a sphere
  16177. * @param sphere the bounding sphere to check
  16178. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  16179. * @returns true if it hits the sphere
  16180. */
  16181. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  16182. /**
  16183. * If the ray hits a triange
  16184. * @param vertex0 triangle vertex
  16185. * @param vertex1 triangle vertex
  16186. * @param vertex2 triangle vertex
  16187. * @returns intersection information if hit
  16188. */
  16189. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  16190. /**
  16191. * Checks if ray intersects a plane
  16192. * @param plane the plane to check
  16193. * @returns the distance away it was hit
  16194. */
  16195. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  16196. /**
  16197. * Checks if ray intersects a mesh
  16198. * @param mesh the mesh to check
  16199. * @param fastCheck if only the bounding box should checked
  16200. * @returns picking info of the intersecton
  16201. */
  16202. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16203. /**
  16204. * Checks if ray intersects a mesh
  16205. * @param meshes the meshes to check
  16206. * @param fastCheck if only the bounding box should checked
  16207. * @param results array to store result in
  16208. * @returns Array of picking infos
  16209. */
  16210. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16211. private _comparePickingInfo;
  16212. private static smallnum;
  16213. private static rayl;
  16214. /**
  16215. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16216. * @param sega the first point of the segment to test the intersection against
  16217. * @param segb the second point of the segment to test the intersection against
  16218. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16219. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16220. */
  16221. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16222. /**
  16223. * Update the ray from viewport position
  16224. * @param x position
  16225. * @param y y position
  16226. * @param viewportWidth viewport width
  16227. * @param viewportHeight viewport height
  16228. * @param world world matrix
  16229. * @param view view matrix
  16230. * @param projection projection matrix
  16231. * @returns this ray updated
  16232. */
  16233. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16234. /**
  16235. * Creates a ray with origin and direction of 0,0,0
  16236. * @returns the new ray
  16237. */
  16238. static Zero(): Ray;
  16239. /**
  16240. * Creates a new ray from screen space and viewport
  16241. * @param x position
  16242. * @param y y position
  16243. * @param viewportWidth viewport width
  16244. * @param viewportHeight viewport height
  16245. * @param world world matrix
  16246. * @param view view matrix
  16247. * @param projection projection matrix
  16248. * @returns new ray
  16249. */
  16250. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16251. /**
  16252. * 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
  16253. * transformed to the given world matrix.
  16254. * @param origin The origin point
  16255. * @param end The end point
  16256. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16257. * @returns the new ray
  16258. */
  16259. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16260. /**
  16261. * Transforms a ray by a matrix
  16262. * @param ray ray to transform
  16263. * @param matrix matrix to apply
  16264. * @returns the resulting new ray
  16265. */
  16266. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16267. /**
  16268. * Transforms a ray by a matrix
  16269. * @param ray ray to transform
  16270. * @param matrix matrix to apply
  16271. * @param result ray to store result in
  16272. */
  16273. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16274. /**
  16275. * Unproject a ray from screen space to object space
  16276. * @param sourceX defines the screen space x coordinate to use
  16277. * @param sourceY defines the screen space y coordinate to use
  16278. * @param viewportWidth defines the current width of the viewport
  16279. * @param viewportHeight defines the current height of the viewport
  16280. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16281. * @param view defines the view matrix to use
  16282. * @param projection defines the projection matrix to use
  16283. */
  16284. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16285. }
  16286. /**
  16287. * Type used to define predicate used to select faces when a mesh intersection is detected
  16288. */
  16289. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16290. module "babylonjs/scene" {
  16291. interface Scene {
  16292. /** @hidden */
  16293. _tempPickingRay: Nullable<Ray>;
  16294. /** @hidden */
  16295. _cachedRayForTransform: Ray;
  16296. /** @hidden */
  16297. _pickWithRayInverseMatrix: Matrix;
  16298. /** @hidden */
  16299. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16300. /** @hidden */
  16301. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16302. }
  16303. }
  16304. }
  16305. declare module "babylonjs/Sprites/spriteSceneComponent" {
  16306. import { Nullable } from "babylonjs/types";
  16307. import { Observable } from "babylonjs/Misc/observable";
  16308. import { Scene } from "babylonjs/scene";
  16309. import { Sprite } from "babylonjs/Sprites/sprite";
  16310. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16311. import { Ray } from "babylonjs/Culling/ray";
  16312. import { Camera } from "babylonjs/Cameras/camera";
  16313. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16314. import { ISceneComponent } from "babylonjs/sceneComponent";
  16315. module "babylonjs/scene" {
  16316. interface Scene {
  16317. /** @hidden */
  16318. _pointerOverSprite: Nullable<Sprite>;
  16319. /** @hidden */
  16320. _pickedDownSprite: Nullable<Sprite>;
  16321. /** @hidden */
  16322. _tempSpritePickingRay: Nullable<Ray>;
  16323. /**
  16324. * All of the sprite managers added to this scene
  16325. * @see http://doc.babylonjs.com/babylon101/sprites
  16326. */
  16327. spriteManagers: Array<ISpriteManager>;
  16328. /**
  16329. * An event triggered when sprites rendering is about to start
  16330. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16331. */
  16332. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16333. /**
  16334. * An event triggered when sprites rendering is done
  16335. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16336. */
  16337. onAfterSpritesRenderingObservable: Observable<Scene>;
  16338. /** @hidden */
  16339. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16340. /** Launch a ray to try to pick a sprite in the scene
  16341. * @param x position on screen
  16342. * @param y position on screen
  16343. * @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
  16344. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16345. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16346. * @returns a PickingInfo
  16347. */
  16348. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16349. /** Use the given ray to pick a sprite in the scene
  16350. * @param ray The ray (in world space) to use to pick meshes
  16351. * @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
  16352. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16353. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16354. * @returns a PickingInfo
  16355. */
  16356. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16357. /**
  16358. * Force the sprite under the pointer
  16359. * @param sprite defines the sprite to use
  16360. */
  16361. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16362. /**
  16363. * Gets the sprite under the pointer
  16364. * @returns a Sprite or null if no sprite is under the pointer
  16365. */
  16366. getPointerOverSprite(): Nullable<Sprite>;
  16367. }
  16368. }
  16369. /**
  16370. * Defines the sprite scene component responsible to manage sprites
  16371. * in a given scene.
  16372. */
  16373. export class SpriteSceneComponent implements ISceneComponent {
  16374. /**
  16375. * The component name helpfull to identify the component in the list of scene components.
  16376. */
  16377. readonly name: string;
  16378. /**
  16379. * The scene the component belongs to.
  16380. */
  16381. scene: Scene;
  16382. /** @hidden */
  16383. private _spritePredicate;
  16384. /**
  16385. * Creates a new instance of the component for the given scene
  16386. * @param scene Defines the scene to register the component in
  16387. */
  16388. constructor(scene: Scene);
  16389. /**
  16390. * Registers the component in a given scene
  16391. */
  16392. register(): void;
  16393. /**
  16394. * Rebuilds the elements related to this component in case of
  16395. * context lost for instance.
  16396. */
  16397. rebuild(): void;
  16398. /**
  16399. * Disposes the component and the associated ressources.
  16400. */
  16401. dispose(): void;
  16402. private _pickSpriteButKeepRay;
  16403. private _pointerMove;
  16404. private _pointerDown;
  16405. private _pointerUp;
  16406. }
  16407. }
  16408. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  16409. /** @hidden */
  16410. export var fogFragmentDeclaration: {
  16411. name: string;
  16412. shader: string;
  16413. };
  16414. }
  16415. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  16416. /** @hidden */
  16417. export var fogFragment: {
  16418. name: string;
  16419. shader: string;
  16420. };
  16421. }
  16422. declare module "babylonjs/Shaders/sprites.fragment" {
  16423. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  16424. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  16425. /** @hidden */
  16426. export var spritesPixelShader: {
  16427. name: string;
  16428. shader: string;
  16429. };
  16430. }
  16431. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  16432. /** @hidden */
  16433. export var fogVertexDeclaration: {
  16434. name: string;
  16435. shader: string;
  16436. };
  16437. }
  16438. declare module "babylonjs/Shaders/sprites.vertex" {
  16439. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  16440. /** @hidden */
  16441. export var spritesVertexShader: {
  16442. name: string;
  16443. shader: string;
  16444. };
  16445. }
  16446. declare module "babylonjs/Sprites/spriteManager" {
  16447. import { IDisposable, Scene } from "babylonjs/scene";
  16448. import { Nullable } from "babylonjs/types";
  16449. import { Observable } from "babylonjs/Misc/observable";
  16450. import { Sprite } from "babylonjs/Sprites/sprite";
  16451. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16452. import { Camera } from "babylonjs/Cameras/camera";
  16453. import { Texture } from "babylonjs/Materials/Textures/texture";
  16454. import "babylonjs/Shaders/sprites.fragment";
  16455. import "babylonjs/Shaders/sprites.vertex";
  16456. import { Ray } from "babylonjs/Culling/ray";
  16457. /**
  16458. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16459. */
  16460. export interface ISpriteManager extends IDisposable {
  16461. /**
  16462. * Restricts the camera to viewing objects with the same layerMask.
  16463. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16464. */
  16465. layerMask: number;
  16466. /**
  16467. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16468. */
  16469. isPickable: boolean;
  16470. /**
  16471. * Specifies the rendering group id for this mesh (0 by default)
  16472. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16473. */
  16474. renderingGroupId: number;
  16475. /**
  16476. * Defines the list of sprites managed by the manager.
  16477. */
  16478. sprites: Array<Sprite>;
  16479. /**
  16480. * Tests the intersection of a sprite with a specific ray.
  16481. * @param ray The ray we are sending to test the collision
  16482. * @param camera The camera space we are sending rays in
  16483. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16484. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16485. * @returns picking info or null.
  16486. */
  16487. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16488. /**
  16489. * Renders the list of sprites on screen.
  16490. */
  16491. render(): void;
  16492. }
  16493. /**
  16494. * Class used to manage multiple sprites on the same spritesheet
  16495. * @see http://doc.babylonjs.com/babylon101/sprites
  16496. */
  16497. export class SpriteManager implements ISpriteManager {
  16498. /** defines the manager's name */
  16499. name: string;
  16500. /** Gets the list of sprites */
  16501. sprites: Sprite[];
  16502. /** Gets or sets the rendering group id (0 by default) */
  16503. renderingGroupId: number;
  16504. /** Gets or sets camera layer mask */
  16505. layerMask: number;
  16506. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16507. fogEnabled: boolean;
  16508. /** Gets or sets a boolean indicating if the sprites are pickable */
  16509. isPickable: boolean;
  16510. /** Defines the default width of a cell in the spritesheet */
  16511. cellWidth: number;
  16512. /** Defines the default height of a cell in the spritesheet */
  16513. cellHeight: number;
  16514. /**
  16515. * An event triggered when the manager is disposed.
  16516. */
  16517. onDisposeObservable: Observable<SpriteManager>;
  16518. private _onDisposeObserver;
  16519. /**
  16520. * Callback called when the manager is disposed
  16521. */
  16522. onDispose: () => void;
  16523. private _capacity;
  16524. private _spriteTexture;
  16525. private _epsilon;
  16526. private _scene;
  16527. private _vertexData;
  16528. private _buffer;
  16529. private _vertexBuffers;
  16530. private _indexBuffer;
  16531. private _effectBase;
  16532. private _effectFog;
  16533. /**
  16534. * Gets or sets the spritesheet texture
  16535. */
  16536. texture: Texture;
  16537. /**
  16538. * Creates a new sprite manager
  16539. * @param name defines the manager's name
  16540. * @param imgUrl defines the sprite sheet url
  16541. * @param capacity defines the maximum allowed number of sprites
  16542. * @param cellSize defines the size of a sprite cell
  16543. * @param scene defines the hosting scene
  16544. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16545. * @param samplingMode defines the smapling mode to use with spritesheet
  16546. */
  16547. constructor(
  16548. /** defines the manager's name */
  16549. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16550. private _appendSpriteVertex;
  16551. /**
  16552. * Intersects the sprites with a ray
  16553. * @param ray defines the ray to intersect with
  16554. * @param camera defines the current active camera
  16555. * @param predicate defines a predicate used to select candidate sprites
  16556. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16557. * @returns null if no hit or a PickingInfo
  16558. */
  16559. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16560. /**
  16561. * Render all child sprites
  16562. */
  16563. render(): void;
  16564. /**
  16565. * Release associated resources
  16566. */
  16567. dispose(): void;
  16568. }
  16569. }
  16570. declare module "babylonjs/Sprites/sprite" {
  16571. import { Vector3, Color4 } from "babylonjs/Maths/math";
  16572. import { Nullable } from "babylonjs/types";
  16573. import { ActionManager } from "babylonjs/Actions/actionManager";
  16574. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16575. /**
  16576. * Class used to represent a sprite
  16577. * @see http://doc.babylonjs.com/babylon101/sprites
  16578. */
  16579. export class Sprite {
  16580. /** defines the name */
  16581. name: string;
  16582. /** Gets or sets the current world position */
  16583. position: Vector3;
  16584. /** Gets or sets the main color */
  16585. color: Color4;
  16586. /** Gets or sets the width */
  16587. width: number;
  16588. /** Gets or sets the height */
  16589. height: number;
  16590. /** Gets or sets rotation angle */
  16591. angle: number;
  16592. /** Gets or sets the cell index in the sprite sheet */
  16593. cellIndex: number;
  16594. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16595. invertU: number;
  16596. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16597. invertV: number;
  16598. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16599. disposeWhenFinishedAnimating: boolean;
  16600. /** Gets the list of attached animations */
  16601. animations: Animation[];
  16602. /** Gets or sets a boolean indicating if the sprite can be picked */
  16603. isPickable: boolean;
  16604. /**
  16605. * Gets or sets the associated action manager
  16606. */
  16607. actionManager: Nullable<ActionManager>;
  16608. private _animationStarted;
  16609. private _loopAnimation;
  16610. private _fromIndex;
  16611. private _toIndex;
  16612. private _delay;
  16613. private _direction;
  16614. private _manager;
  16615. private _time;
  16616. private _onAnimationEnd;
  16617. /**
  16618. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16619. */
  16620. isVisible: boolean;
  16621. /**
  16622. * Gets or sets the sprite size
  16623. */
  16624. size: number;
  16625. /**
  16626. * Creates a new Sprite
  16627. * @param name defines the name
  16628. * @param manager defines the manager
  16629. */
  16630. constructor(
  16631. /** defines the name */
  16632. name: string, manager: ISpriteManager);
  16633. /**
  16634. * Starts an animation
  16635. * @param from defines the initial key
  16636. * @param to defines the end key
  16637. * @param loop defines if the animation must loop
  16638. * @param delay defines the start delay (in ms)
  16639. * @param onAnimationEnd defines a callback to call when animation ends
  16640. */
  16641. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16642. /** Stops current animation (if any) */
  16643. stopAnimation(): void;
  16644. /** @hidden */
  16645. _animate(deltaTime: number): void;
  16646. /** Release associated resources */
  16647. dispose(): void;
  16648. }
  16649. }
  16650. declare module "babylonjs/Collisions/pickingInfo" {
  16651. import { Nullable } from "babylonjs/types";
  16652. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  16653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16654. import { Sprite } from "babylonjs/Sprites/sprite";
  16655. import { Ray } from "babylonjs/Culling/ray";
  16656. /**
  16657. * Information about the result of picking within a scene
  16658. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16659. */
  16660. export class PickingInfo {
  16661. /** @hidden */
  16662. _pickingUnavailable: boolean;
  16663. /**
  16664. * If the pick collided with an object
  16665. */
  16666. hit: boolean;
  16667. /**
  16668. * Distance away where the pick collided
  16669. */
  16670. distance: number;
  16671. /**
  16672. * The location of pick collision
  16673. */
  16674. pickedPoint: Nullable<Vector3>;
  16675. /**
  16676. * The mesh corresponding the the pick collision
  16677. */
  16678. pickedMesh: Nullable<AbstractMesh>;
  16679. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16680. bu: number;
  16681. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16682. bv: number;
  16683. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16684. faceId: number;
  16685. /** Id of the the submesh that was picked */
  16686. subMeshId: number;
  16687. /** If a sprite was picked, this will be the sprite the pick collided with */
  16688. pickedSprite: Nullable<Sprite>;
  16689. /**
  16690. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16691. */
  16692. originMesh: Nullable<AbstractMesh>;
  16693. /**
  16694. * The ray that was used to perform the picking.
  16695. */
  16696. ray: Nullable<Ray>;
  16697. /**
  16698. * Gets the normal correspodning to the face the pick collided with
  16699. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16700. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16701. * @returns The normal correspodning to the face the pick collided with
  16702. */
  16703. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16704. /**
  16705. * Gets the texture coordinates of where the pick occured
  16706. * @returns the vector containing the coordnates of the texture
  16707. */
  16708. getTextureCoordinates(): Nullable<Vector2>;
  16709. }
  16710. }
  16711. declare module "babylonjs/Events/pointerEvents" {
  16712. import { Nullable } from "babylonjs/types";
  16713. import { Vector2 } from "babylonjs/Maths/math";
  16714. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16715. import { Ray } from "babylonjs/Culling/ray";
  16716. /**
  16717. * Gather the list of pointer event types as constants.
  16718. */
  16719. export class PointerEventTypes {
  16720. /**
  16721. * 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.
  16722. */
  16723. static readonly POINTERDOWN: number;
  16724. /**
  16725. * The pointerup event is fired when a pointer is no longer active.
  16726. */
  16727. static readonly POINTERUP: number;
  16728. /**
  16729. * The pointermove event is fired when a pointer changes coordinates.
  16730. */
  16731. static readonly POINTERMOVE: number;
  16732. /**
  16733. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16734. */
  16735. static readonly POINTERWHEEL: number;
  16736. /**
  16737. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16738. */
  16739. static readonly POINTERPICK: number;
  16740. /**
  16741. * The pointertap event is fired when a the object has been touched and released without drag.
  16742. */
  16743. static readonly POINTERTAP: number;
  16744. /**
  16745. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16746. */
  16747. static readonly POINTERDOUBLETAP: number;
  16748. }
  16749. /**
  16750. * Base class of pointer info types.
  16751. */
  16752. export class PointerInfoBase {
  16753. /**
  16754. * Defines the type of event (PointerEventTypes)
  16755. */
  16756. type: number;
  16757. /**
  16758. * Defines the related dom event
  16759. */
  16760. event: PointerEvent | MouseWheelEvent;
  16761. /**
  16762. * Instantiates the base class of pointers info.
  16763. * @param type Defines the type of event (PointerEventTypes)
  16764. * @param event Defines the related dom event
  16765. */
  16766. constructor(
  16767. /**
  16768. * Defines the type of event (PointerEventTypes)
  16769. */
  16770. type: number,
  16771. /**
  16772. * Defines the related dom event
  16773. */
  16774. event: PointerEvent | MouseWheelEvent);
  16775. }
  16776. /**
  16777. * This class is used to store pointer related info for the onPrePointerObservable event.
  16778. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16779. */
  16780. export class PointerInfoPre extends PointerInfoBase {
  16781. /**
  16782. * Ray from a pointer if availible (eg. 6dof controller)
  16783. */
  16784. ray: Nullable<Ray>;
  16785. /**
  16786. * Defines the local position of the pointer on the canvas.
  16787. */
  16788. localPosition: Vector2;
  16789. /**
  16790. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16791. */
  16792. skipOnPointerObservable: boolean;
  16793. /**
  16794. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16795. * @param type Defines the type of event (PointerEventTypes)
  16796. * @param event Defines the related dom event
  16797. * @param localX Defines the local x coordinates of the pointer when the event occured
  16798. * @param localY Defines the local y coordinates of the pointer when the event occured
  16799. */
  16800. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16801. }
  16802. /**
  16803. * This type contains all the data related to a pointer event in Babylon.js.
  16804. * 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.
  16805. */
  16806. export class PointerInfo extends PointerInfoBase {
  16807. /**
  16808. * Defines the picking info associated to the info (if any)\
  16809. */
  16810. pickInfo: Nullable<PickingInfo>;
  16811. /**
  16812. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16813. * @param type Defines the type of event (PointerEventTypes)
  16814. * @param event Defines the related dom event
  16815. * @param pickInfo Defines the picking info associated to the info (if any)\
  16816. */
  16817. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16818. /**
  16819. * Defines the picking info associated to the info (if any)\
  16820. */
  16821. pickInfo: Nullable<PickingInfo>);
  16822. }
  16823. /**
  16824. * Data relating to a touch event on the screen.
  16825. */
  16826. export interface PointerTouch {
  16827. /**
  16828. * X coordinate of touch.
  16829. */
  16830. x: number;
  16831. /**
  16832. * Y coordinate of touch.
  16833. */
  16834. y: number;
  16835. /**
  16836. * Id of touch. Unique for each finger.
  16837. */
  16838. pointerId: number;
  16839. /**
  16840. * Event type passed from DOM.
  16841. */
  16842. type: any;
  16843. }
  16844. }
  16845. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  16846. import { Observable } from "babylonjs/Misc/observable";
  16847. import { Nullable } from "babylonjs/types";
  16848. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16849. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16850. /**
  16851. * Manage the mouse inputs to control the movement of a free camera.
  16852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16853. */
  16854. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16855. /**
  16856. * Define if touch is enabled in the mouse input
  16857. */
  16858. touchEnabled: boolean;
  16859. /**
  16860. * Defines the camera the input is attached to.
  16861. */
  16862. camera: FreeCamera;
  16863. /**
  16864. * Defines the buttons associated with the input to handle camera move.
  16865. */
  16866. buttons: number[];
  16867. /**
  16868. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16869. */
  16870. angularSensibility: number;
  16871. private _pointerInput;
  16872. private _onMouseMove;
  16873. private _observer;
  16874. private previousPosition;
  16875. /**
  16876. * Observable for when a pointer move event occurs containing the move offset
  16877. */
  16878. onPointerMovedObservable: Observable<{
  16879. offsetX: number;
  16880. offsetY: number;
  16881. }>;
  16882. /**
  16883. * @hidden
  16884. * If the camera should be rotated automatically based on pointer movement
  16885. */
  16886. _allowCameraRotation: boolean;
  16887. /**
  16888. * Manage the mouse inputs to control the movement of a free camera.
  16889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16890. * @param touchEnabled Defines if touch is enabled or not
  16891. */
  16892. constructor(
  16893. /**
  16894. * Define if touch is enabled in the mouse input
  16895. */
  16896. touchEnabled?: boolean);
  16897. /**
  16898. * Attach the input controls to a specific dom element to get the input from.
  16899. * @param element Defines the element the controls should be listened from
  16900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16901. */
  16902. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16903. /**
  16904. * Called on JS contextmenu event.
  16905. * Override this method to provide functionality.
  16906. */
  16907. protected onContextMenu(evt: PointerEvent): void;
  16908. /**
  16909. * Detach the current controls from the specified dom element.
  16910. * @param element Defines the element to stop listening the inputs from
  16911. */
  16912. detachControl(element: Nullable<HTMLElement>): void;
  16913. /**
  16914. * Gets the class name of the current intput.
  16915. * @returns the class name
  16916. */
  16917. getClassName(): string;
  16918. /**
  16919. * Get the friendly name associated with the input class.
  16920. * @returns the input friendly name
  16921. */
  16922. getSimpleName(): string;
  16923. }
  16924. }
  16925. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  16926. import { Nullable } from "babylonjs/types";
  16927. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16928. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16929. /**
  16930. * Manage the touch inputs to control the movement of a free camera.
  16931. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16932. */
  16933. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  16934. /**
  16935. * Defines the camera the input is attached to.
  16936. */
  16937. camera: FreeCamera;
  16938. /**
  16939. * Defines the touch sensibility for rotation.
  16940. * The higher the faster.
  16941. */
  16942. touchAngularSensibility: number;
  16943. /**
  16944. * Defines the touch sensibility for move.
  16945. * The higher the faster.
  16946. */
  16947. touchMoveSensibility: number;
  16948. private _offsetX;
  16949. private _offsetY;
  16950. private _pointerPressed;
  16951. private _pointerInput;
  16952. private _observer;
  16953. private _onLostFocus;
  16954. /**
  16955. * Attach the input controls to a specific dom element to get the input from.
  16956. * @param element Defines the element the controls should be listened from
  16957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16958. */
  16959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16960. /**
  16961. * Detach the current controls from the specified dom element.
  16962. * @param element Defines the element to stop listening the inputs from
  16963. */
  16964. detachControl(element: Nullable<HTMLElement>): void;
  16965. /**
  16966. * Update the current camera state depending on the inputs that have been used this frame.
  16967. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  16968. */
  16969. checkInputs(): void;
  16970. /**
  16971. * Gets the class name of the current intput.
  16972. * @returns the class name
  16973. */
  16974. getClassName(): string;
  16975. /**
  16976. * Get the friendly name associated with the input class.
  16977. * @returns the input friendly name
  16978. */
  16979. getSimpleName(): string;
  16980. }
  16981. }
  16982. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  16983. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16984. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  16985. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  16986. import { Nullable } from "babylonjs/types";
  16987. /**
  16988. * Default Inputs manager for the FreeCamera.
  16989. * It groups all the default supported inputs for ease of use.
  16990. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16991. */
  16992. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  16993. /**
  16994. * @hidden
  16995. */
  16996. _mouseInput: Nullable<FreeCameraMouseInput>;
  16997. /**
  16998. * Instantiates a new FreeCameraInputsManager.
  16999. * @param camera Defines the camera the inputs belong to
  17000. */
  17001. constructor(camera: FreeCamera);
  17002. /**
  17003. * Add keyboard input support to the input manager.
  17004. * @returns the current input manager
  17005. */
  17006. addKeyboard(): FreeCameraInputsManager;
  17007. /**
  17008. * Add mouse input support to the input manager.
  17009. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  17010. * @returns the current input manager
  17011. */
  17012. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  17013. /**
  17014. * Removes the mouse input support from the manager
  17015. * @returns the current input manager
  17016. */
  17017. removeMouse(): FreeCameraInputsManager;
  17018. /**
  17019. * Add touch input support to the input manager.
  17020. * @returns the current input manager
  17021. */
  17022. addTouch(): FreeCameraInputsManager;
  17023. /**
  17024. * Remove all attached input methods from a camera
  17025. */
  17026. clear(): void;
  17027. }
  17028. }
  17029. declare module "babylonjs/Cameras/freeCamera" {
  17030. import { Vector3 } from "babylonjs/Maths/math";
  17031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17032. import { Scene } from "babylonjs/scene";
  17033. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17034. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  17035. /**
  17036. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17037. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  17038. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17039. */
  17040. export class FreeCamera extends TargetCamera {
  17041. /**
  17042. * Define the collision ellipsoid of the camera.
  17043. * This is helpful to simulate a camera body like the player body around the camera
  17044. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  17045. */
  17046. ellipsoid: Vector3;
  17047. /**
  17048. * Define an offset for the position of the ellipsoid around the camera.
  17049. * This can be helpful to determine the center of the body near the gravity center of the body
  17050. * instead of its head.
  17051. */
  17052. ellipsoidOffset: Vector3;
  17053. /**
  17054. * Enable or disable collisions of the camera with the rest of the scene objects.
  17055. */
  17056. checkCollisions: boolean;
  17057. /**
  17058. * Enable or disable gravity on the camera.
  17059. */
  17060. applyGravity: boolean;
  17061. /**
  17062. * Define the input manager associated to the camera.
  17063. */
  17064. inputs: FreeCameraInputsManager;
  17065. /**
  17066. * Gets the input sensibility for a mouse input. (default is 2000.0)
  17067. * Higher values reduce sensitivity.
  17068. */
  17069. /**
  17070. * Sets the input sensibility for a mouse input. (default is 2000.0)
  17071. * Higher values reduce sensitivity.
  17072. */
  17073. angularSensibility: number;
  17074. /**
  17075. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  17076. */
  17077. keysUp: number[];
  17078. /**
  17079. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  17080. */
  17081. keysDown: number[];
  17082. /**
  17083. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  17084. */
  17085. keysLeft: number[];
  17086. /**
  17087. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  17088. */
  17089. keysRight: number[];
  17090. /**
  17091. * Event raised when the camera collide with a mesh in the scene.
  17092. */
  17093. onCollide: (collidedMesh: AbstractMesh) => void;
  17094. private _collider;
  17095. private _needMoveForGravity;
  17096. private _oldPosition;
  17097. private _diffPosition;
  17098. private _newPosition;
  17099. /** @hidden */
  17100. _localDirection: Vector3;
  17101. /** @hidden */
  17102. _transformedDirection: Vector3;
  17103. /**
  17104. * Instantiates a Free Camera.
  17105. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17106. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  17107. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17108. * @param name Define the name of the camera in the scene
  17109. * @param position Define the start position of the camera in the scene
  17110. * @param scene Define the scene the camera belongs to
  17111. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  17112. */
  17113. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  17114. /**
  17115. * Attached controls to the current camera.
  17116. * @param element Defines the element the controls should be listened from
  17117. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17118. */
  17119. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17120. /**
  17121. * Detach the current controls from the camera.
  17122. * The camera will stop reacting to inputs.
  17123. * @param element Defines the element to stop listening the inputs from
  17124. */
  17125. detachControl(element: HTMLElement): void;
  17126. private _collisionMask;
  17127. /**
  17128. * Define a collision mask to limit the list of object the camera can collide with
  17129. */
  17130. collisionMask: number;
  17131. /** @hidden */
  17132. _collideWithWorld(displacement: Vector3): void;
  17133. private _onCollisionPositionChange;
  17134. /** @hidden */
  17135. _checkInputs(): void;
  17136. /** @hidden */
  17137. _decideIfNeedsToMove(): boolean;
  17138. /** @hidden */
  17139. _updatePosition(): void;
  17140. /**
  17141. * Destroy the camera and release the current resources hold by it.
  17142. */
  17143. dispose(): void;
  17144. /**
  17145. * Gets the current object class name.
  17146. * @return the class name
  17147. */
  17148. getClassName(): string;
  17149. }
  17150. }
  17151. declare module "babylonjs/Gamepads/gamepad" {
  17152. import { Observable } from "babylonjs/Misc/observable";
  17153. /**
  17154. * Represents a gamepad control stick position
  17155. */
  17156. export class StickValues {
  17157. /**
  17158. * The x component of the control stick
  17159. */
  17160. x: number;
  17161. /**
  17162. * The y component of the control stick
  17163. */
  17164. y: number;
  17165. /**
  17166. * Initializes the gamepad x and y control stick values
  17167. * @param x The x component of the gamepad control stick value
  17168. * @param y The y component of the gamepad control stick value
  17169. */
  17170. constructor(
  17171. /**
  17172. * The x component of the control stick
  17173. */
  17174. x: number,
  17175. /**
  17176. * The y component of the control stick
  17177. */
  17178. y: number);
  17179. }
  17180. /**
  17181. * An interface which manages callbacks for gamepad button changes
  17182. */
  17183. export interface GamepadButtonChanges {
  17184. /**
  17185. * Called when a gamepad has been changed
  17186. */
  17187. changed: boolean;
  17188. /**
  17189. * Called when a gamepad press event has been triggered
  17190. */
  17191. pressChanged: boolean;
  17192. /**
  17193. * Called when a touch event has been triggered
  17194. */
  17195. touchChanged: boolean;
  17196. /**
  17197. * Called when a value has changed
  17198. */
  17199. valueChanged: boolean;
  17200. }
  17201. /**
  17202. * Represents a gamepad
  17203. */
  17204. export class Gamepad {
  17205. /**
  17206. * The id of the gamepad
  17207. */
  17208. id: string;
  17209. /**
  17210. * The index of the gamepad
  17211. */
  17212. index: number;
  17213. /**
  17214. * The browser gamepad
  17215. */
  17216. browserGamepad: any;
  17217. /**
  17218. * Specifies what type of gamepad this represents
  17219. */
  17220. type: number;
  17221. private _leftStick;
  17222. private _rightStick;
  17223. /** @hidden */
  17224. _isConnected: boolean;
  17225. private _leftStickAxisX;
  17226. private _leftStickAxisY;
  17227. private _rightStickAxisX;
  17228. private _rightStickAxisY;
  17229. /**
  17230. * Triggered when the left control stick has been changed
  17231. */
  17232. private _onleftstickchanged;
  17233. /**
  17234. * Triggered when the right control stick has been changed
  17235. */
  17236. private _onrightstickchanged;
  17237. /**
  17238. * Represents a gamepad controller
  17239. */
  17240. static GAMEPAD: number;
  17241. /**
  17242. * Represents a generic controller
  17243. */
  17244. static GENERIC: number;
  17245. /**
  17246. * Represents an XBox controller
  17247. */
  17248. static XBOX: number;
  17249. /**
  17250. * Represents a pose-enabled controller
  17251. */
  17252. static POSE_ENABLED: number;
  17253. /**
  17254. * Specifies whether the left control stick should be Y-inverted
  17255. */
  17256. protected _invertLeftStickY: boolean;
  17257. /**
  17258. * Specifies if the gamepad has been connected
  17259. */
  17260. readonly isConnected: boolean;
  17261. /**
  17262. * Initializes the gamepad
  17263. * @param id The id of the gamepad
  17264. * @param index The index of the gamepad
  17265. * @param browserGamepad The browser gamepad
  17266. * @param leftStickX The x component of the left joystick
  17267. * @param leftStickY The y component of the left joystick
  17268. * @param rightStickX The x component of the right joystick
  17269. * @param rightStickY The y component of the right joystick
  17270. */
  17271. constructor(
  17272. /**
  17273. * The id of the gamepad
  17274. */
  17275. id: string,
  17276. /**
  17277. * The index of the gamepad
  17278. */
  17279. index: number,
  17280. /**
  17281. * The browser gamepad
  17282. */
  17283. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17284. /**
  17285. * Callback triggered when the left joystick has changed
  17286. * @param callback
  17287. */
  17288. onleftstickchanged(callback: (values: StickValues) => void): void;
  17289. /**
  17290. * Callback triggered when the right joystick has changed
  17291. * @param callback
  17292. */
  17293. onrightstickchanged(callback: (values: StickValues) => void): void;
  17294. /**
  17295. * Gets the left joystick
  17296. */
  17297. /**
  17298. * Sets the left joystick values
  17299. */
  17300. leftStick: StickValues;
  17301. /**
  17302. * Gets the right joystick
  17303. */
  17304. /**
  17305. * Sets the right joystick value
  17306. */
  17307. rightStick: StickValues;
  17308. /**
  17309. * Updates the gamepad joystick positions
  17310. */
  17311. update(): void;
  17312. /**
  17313. * Disposes the gamepad
  17314. */
  17315. dispose(): void;
  17316. }
  17317. /**
  17318. * Represents a generic gamepad
  17319. */
  17320. export class GenericPad extends Gamepad {
  17321. private _buttons;
  17322. private _onbuttondown;
  17323. private _onbuttonup;
  17324. /**
  17325. * Observable triggered when a button has been pressed
  17326. */
  17327. onButtonDownObservable: Observable<number>;
  17328. /**
  17329. * Observable triggered when a button has been released
  17330. */
  17331. onButtonUpObservable: Observable<number>;
  17332. /**
  17333. * Callback triggered when a button has been pressed
  17334. * @param callback Called when a button has been pressed
  17335. */
  17336. onbuttondown(callback: (buttonPressed: number) => void): void;
  17337. /**
  17338. * Callback triggered when a button has been released
  17339. * @param callback Called when a button has been released
  17340. */
  17341. onbuttonup(callback: (buttonReleased: number) => void): void;
  17342. /**
  17343. * Initializes the generic gamepad
  17344. * @param id The id of the generic gamepad
  17345. * @param index The index of the generic gamepad
  17346. * @param browserGamepad The browser gamepad
  17347. */
  17348. constructor(id: string, index: number, browserGamepad: any);
  17349. private _setButtonValue;
  17350. /**
  17351. * Updates the generic gamepad
  17352. */
  17353. update(): void;
  17354. /**
  17355. * Disposes the generic gamepad
  17356. */
  17357. dispose(): void;
  17358. }
  17359. }
  17360. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  17361. import { Observable } from "babylonjs/Misc/observable";
  17362. import { Nullable } from "babylonjs/types";
  17363. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17364. import { TransformNode } from "babylonjs/Meshes/transformNode";
  17365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17366. import { Ray } from "babylonjs/Culling/ray";
  17367. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  17368. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  17369. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17370. /**
  17371. * Defines the types of pose enabled controllers that are supported
  17372. */
  17373. export enum PoseEnabledControllerType {
  17374. /**
  17375. * HTC Vive
  17376. */
  17377. VIVE = 0,
  17378. /**
  17379. * Oculus Rift
  17380. */
  17381. OCULUS = 1,
  17382. /**
  17383. * Windows mixed reality
  17384. */
  17385. WINDOWS = 2,
  17386. /**
  17387. * Samsung gear VR
  17388. */
  17389. GEAR_VR = 3,
  17390. /**
  17391. * Google Daydream
  17392. */
  17393. DAYDREAM = 4,
  17394. /**
  17395. * Generic
  17396. */
  17397. GENERIC = 5
  17398. }
  17399. /**
  17400. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17401. */
  17402. export interface MutableGamepadButton {
  17403. /**
  17404. * Value of the button/trigger
  17405. */
  17406. value: number;
  17407. /**
  17408. * If the button/trigger is currently touched
  17409. */
  17410. touched: boolean;
  17411. /**
  17412. * If the button/trigger is currently pressed
  17413. */
  17414. pressed: boolean;
  17415. }
  17416. /**
  17417. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17418. * @hidden
  17419. */
  17420. export interface ExtendedGamepadButton extends GamepadButton {
  17421. /**
  17422. * If the button/trigger is currently pressed
  17423. */
  17424. readonly pressed: boolean;
  17425. /**
  17426. * If the button/trigger is currently touched
  17427. */
  17428. readonly touched: boolean;
  17429. /**
  17430. * Value of the button/trigger
  17431. */
  17432. readonly value: number;
  17433. }
  17434. /** @hidden */
  17435. export interface _GamePadFactory {
  17436. /**
  17437. * Returns wether or not the current gamepad can be created for this type of controller.
  17438. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17439. * @returns true if it can be created, otherwise false
  17440. */
  17441. canCreate(gamepadInfo: any): boolean;
  17442. /**
  17443. * Creates a new instance of the Gamepad.
  17444. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17445. * @returns the new gamepad instance
  17446. */
  17447. create(gamepadInfo: any): Gamepad;
  17448. }
  17449. /**
  17450. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17451. */
  17452. export class PoseEnabledControllerHelper {
  17453. /** @hidden */
  17454. static _ControllerFactories: _GamePadFactory[];
  17455. /** @hidden */
  17456. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17457. /**
  17458. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17459. * @param vrGamepad the gamepad to initialized
  17460. * @returns a vr controller of the type the gamepad identified as
  17461. */
  17462. static InitiateController(vrGamepad: any): Gamepad;
  17463. }
  17464. /**
  17465. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17466. */
  17467. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17468. private _deviceRoomPosition;
  17469. private _deviceRoomRotationQuaternion;
  17470. /**
  17471. * The device position in babylon space
  17472. */
  17473. devicePosition: Vector3;
  17474. /**
  17475. * The device rotation in babylon space
  17476. */
  17477. deviceRotationQuaternion: Quaternion;
  17478. /**
  17479. * The scale factor of the device in babylon space
  17480. */
  17481. deviceScaleFactor: number;
  17482. /**
  17483. * (Likely devicePosition should be used instead) The device position in its room space
  17484. */
  17485. position: Vector3;
  17486. /**
  17487. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17488. */
  17489. rotationQuaternion: Quaternion;
  17490. /**
  17491. * The type of controller (Eg. Windows mixed reality)
  17492. */
  17493. controllerType: PoseEnabledControllerType;
  17494. protected _calculatedPosition: Vector3;
  17495. private _calculatedRotation;
  17496. /**
  17497. * The raw pose from the device
  17498. */
  17499. rawPose: DevicePose;
  17500. private _trackPosition;
  17501. private _maxRotationDistFromHeadset;
  17502. private _draggedRoomRotation;
  17503. /**
  17504. * @hidden
  17505. */
  17506. _disableTrackPosition(fixedPosition: Vector3): void;
  17507. /**
  17508. * Internal, the mesh attached to the controller
  17509. * @hidden
  17510. */
  17511. _mesh: Nullable<AbstractMesh>;
  17512. private _poseControlledCamera;
  17513. private _leftHandSystemQuaternion;
  17514. /**
  17515. * Internal, matrix used to convert room space to babylon space
  17516. * @hidden
  17517. */
  17518. _deviceToWorld: Matrix;
  17519. /**
  17520. * Node to be used when casting a ray from the controller
  17521. * @hidden
  17522. */
  17523. _pointingPoseNode: Nullable<TransformNode>;
  17524. /**
  17525. * Name of the child mesh that can be used to cast a ray from the controller
  17526. */
  17527. static readonly POINTING_POSE: string;
  17528. /**
  17529. * Creates a new PoseEnabledController from a gamepad
  17530. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17531. */
  17532. constructor(browserGamepad: any);
  17533. private _workingMatrix;
  17534. /**
  17535. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17536. */
  17537. update(): void;
  17538. /**
  17539. * Updates only the pose device and mesh without doing any button event checking
  17540. */
  17541. protected _updatePoseAndMesh(): void;
  17542. /**
  17543. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17544. * @param poseData raw pose fromthe device
  17545. */
  17546. updateFromDevice(poseData: DevicePose): void;
  17547. /**
  17548. * @hidden
  17549. */
  17550. _meshAttachedObservable: Observable<AbstractMesh>;
  17551. /**
  17552. * Attaches a mesh to the controller
  17553. * @param mesh the mesh to be attached
  17554. */
  17555. attachToMesh(mesh: AbstractMesh): void;
  17556. /**
  17557. * Attaches the controllers mesh to a camera
  17558. * @param camera the camera the mesh should be attached to
  17559. */
  17560. attachToPoseControlledCamera(camera: TargetCamera): void;
  17561. /**
  17562. * Disposes of the controller
  17563. */
  17564. dispose(): void;
  17565. /**
  17566. * The mesh that is attached to the controller
  17567. */
  17568. readonly mesh: Nullable<AbstractMesh>;
  17569. /**
  17570. * Gets the ray of the controller in the direction the controller is pointing
  17571. * @param length the length the resulting ray should be
  17572. * @returns a ray in the direction the controller is pointing
  17573. */
  17574. getForwardRay(length?: number): Ray;
  17575. }
  17576. }
  17577. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  17578. import { Observable } from "babylonjs/Misc/observable";
  17579. import { Scene } from "babylonjs/scene";
  17580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17581. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  17582. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  17583. /**
  17584. * Defines the WebVRController object that represents controllers tracked in 3D space
  17585. */
  17586. export abstract class WebVRController extends PoseEnabledController {
  17587. /**
  17588. * Internal, the default controller model for the controller
  17589. */
  17590. protected _defaultModel: AbstractMesh;
  17591. /**
  17592. * Fired when the trigger state has changed
  17593. */
  17594. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17595. /**
  17596. * Fired when the main button state has changed
  17597. */
  17598. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17599. /**
  17600. * Fired when the secondary button state has changed
  17601. */
  17602. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17603. /**
  17604. * Fired when the pad state has changed
  17605. */
  17606. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17607. /**
  17608. * Fired when controllers stick values have changed
  17609. */
  17610. onPadValuesChangedObservable: Observable<StickValues>;
  17611. /**
  17612. * Array of button availible on the controller
  17613. */
  17614. protected _buttons: Array<MutableGamepadButton>;
  17615. private _onButtonStateChange;
  17616. /**
  17617. * Fired when a controller button's state has changed
  17618. * @param callback the callback containing the button that was modified
  17619. */
  17620. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17621. /**
  17622. * X and Y axis corresponding to the controllers joystick
  17623. */
  17624. pad: StickValues;
  17625. /**
  17626. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17627. */
  17628. hand: string;
  17629. /**
  17630. * The default controller model for the controller
  17631. */
  17632. readonly defaultModel: AbstractMesh;
  17633. /**
  17634. * Creates a new WebVRController from a gamepad
  17635. * @param vrGamepad the gamepad that the WebVRController should be created from
  17636. */
  17637. constructor(vrGamepad: any);
  17638. /**
  17639. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17640. */
  17641. update(): void;
  17642. /**
  17643. * Function to be called when a button is modified
  17644. */
  17645. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17646. /**
  17647. * Loads a mesh and attaches it to the controller
  17648. * @param scene the scene the mesh should be added to
  17649. * @param meshLoaded callback for when the mesh has been loaded
  17650. */
  17651. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17652. private _setButtonValue;
  17653. private _changes;
  17654. private _checkChanges;
  17655. /**
  17656. * Disposes of th webVRCOntroller
  17657. */
  17658. dispose(): void;
  17659. }
  17660. }
  17661. declare module "babylonjs/Lights/hemisphericLight" {
  17662. import { Nullable } from "babylonjs/types";
  17663. import { Scene } from "babylonjs/scene";
  17664. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  17665. import { Effect } from "babylonjs/Materials/effect";
  17666. import { Light } from "babylonjs/Lights/light";
  17667. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17668. /**
  17669. * The HemisphericLight simulates the ambient environment light,
  17670. * so the passed direction is the light reflection direction, not the incoming direction.
  17671. */
  17672. export class HemisphericLight extends Light {
  17673. /**
  17674. * The groundColor is the light in the opposite direction to the one specified during creation.
  17675. * 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.
  17676. */
  17677. groundColor: Color3;
  17678. /**
  17679. * The light reflection direction, not the incoming direction.
  17680. */
  17681. direction: Vector3;
  17682. /**
  17683. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17684. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17685. * The HemisphericLight can't cast shadows.
  17686. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17687. * @param name The friendly name of the light
  17688. * @param direction The direction of the light reflection
  17689. * @param scene The scene the light belongs to
  17690. */
  17691. constructor(name: string, direction: Vector3, scene: Scene);
  17692. protected _buildUniformLayout(): void;
  17693. /**
  17694. * Returns the string "HemisphericLight".
  17695. * @return The class name
  17696. */
  17697. getClassName(): string;
  17698. /**
  17699. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17700. * Returns the updated direction.
  17701. * @param target The target the direction should point to
  17702. * @return The computed direction
  17703. */
  17704. setDirectionToTarget(target: Vector3): Vector3;
  17705. /**
  17706. * Returns the shadow generator associated to the light.
  17707. * @returns Always null for hemispheric lights because it does not support shadows.
  17708. */
  17709. getShadowGenerator(): Nullable<IShadowGenerator>;
  17710. /**
  17711. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17712. * @param effect The effect to update
  17713. * @param lightIndex The index of the light in the effect to update
  17714. * @returns The hemispheric light
  17715. */
  17716. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17717. /**
  17718. * Computes the world matrix of the node
  17719. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17720. * @param useWasUpdatedFlag defines a reserved property
  17721. * @returns the world matrix
  17722. */
  17723. computeWorldMatrix(): Matrix;
  17724. /**
  17725. * Returns the integer 3.
  17726. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17727. */
  17728. getTypeID(): number;
  17729. /**
  17730. * Prepares the list of defines specific to the light type.
  17731. * @param defines the list of defines
  17732. * @param lightIndex defines the index of the light for the effect
  17733. */
  17734. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17735. }
  17736. }
  17737. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  17738. /** @hidden */
  17739. export var vrMultiviewToSingleviewPixelShader: {
  17740. name: string;
  17741. shader: string;
  17742. };
  17743. }
  17744. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  17745. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17746. import { Scene } from "babylonjs/scene";
  17747. /**
  17748. * Renders to multiple views with a single draw call
  17749. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17750. */
  17751. export class MultiviewRenderTarget extends RenderTargetTexture {
  17752. /**
  17753. * Creates a multiview render target
  17754. * @param scene scene used with the render target
  17755. * @param size the size of the render target (used for each view)
  17756. */
  17757. constructor(scene: Scene, size?: number | {
  17758. width: number;
  17759. height: number;
  17760. } | {
  17761. ratio: number;
  17762. });
  17763. /**
  17764. * @hidden
  17765. * @param faceIndex the face index, if its a cube texture
  17766. */
  17767. _bindFrameBuffer(faceIndex?: number): void;
  17768. /**
  17769. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17770. * @returns the view count
  17771. */
  17772. getViewCount(): number;
  17773. }
  17774. }
  17775. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  17776. import { Camera } from "babylonjs/Cameras/camera";
  17777. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17778. import { Nullable } from "babylonjs/types";
  17779. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17780. import { Matrix } from "babylonjs/Maths/math";
  17781. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17782. module "babylonjs/Engines/engine" {
  17783. interface Engine {
  17784. /**
  17785. * Creates a new multiview render target
  17786. * @param width defines the width of the texture
  17787. * @param height defines the height of the texture
  17788. * @returns the created multiview texture
  17789. */
  17790. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17791. /**
  17792. * Binds a multiview framebuffer to be drawn to
  17793. * @param multiviewTexture texture to bind
  17794. */
  17795. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17796. }
  17797. }
  17798. module "babylonjs/Cameras/camera" {
  17799. interface Camera {
  17800. /**
  17801. * @hidden
  17802. * 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)
  17803. */
  17804. _useMultiviewToSingleView: boolean;
  17805. /**
  17806. * @hidden
  17807. * 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)
  17808. */
  17809. _multiviewTexture: Nullable<RenderTargetTexture>;
  17810. /**
  17811. * @hidden
  17812. * ensures the multiview texture of the camera exists and has the specified width/height
  17813. * @param width height to set on the multiview texture
  17814. * @param height width to set on the multiview texture
  17815. */
  17816. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17817. }
  17818. }
  17819. module "babylonjs/scene" {
  17820. interface Scene {
  17821. /** @hidden */
  17822. _transformMatrixR: Matrix;
  17823. /** @hidden */
  17824. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17825. /** @hidden */
  17826. _createMultiviewUbo(): void;
  17827. /** @hidden */
  17828. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17829. /** @hidden */
  17830. _renderMultiviewToSingleView(camera: Camera): void;
  17831. }
  17832. }
  17833. }
  17834. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  17835. import { Camera } from "babylonjs/Cameras/camera";
  17836. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17837. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  17838. import "babylonjs/Engines/Extensions/engine.multiview";
  17839. /**
  17840. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17841. * This will not be used for webXR as it supports displaying texture arrays directly
  17842. */
  17843. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17844. /**
  17845. * Initializes a VRMultiviewToSingleview
  17846. * @param name name of the post process
  17847. * @param camera camera to be applied to
  17848. * @param scaleFactor scaling factor to the size of the output texture
  17849. */
  17850. constructor(name: string, camera: Camera, scaleFactor: number);
  17851. }
  17852. }
  17853. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  17854. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  17855. import { Nullable } from "babylonjs/types";
  17856. import { Size } from "babylonjs/Maths/math";
  17857. import { Observable } from "babylonjs/Misc/observable";
  17858. module "babylonjs/Engines/engine" {
  17859. interface Engine {
  17860. /** @hidden */
  17861. _vrDisplay: any;
  17862. /** @hidden */
  17863. _vrSupported: boolean;
  17864. /** @hidden */
  17865. _oldSize: Size;
  17866. /** @hidden */
  17867. _oldHardwareScaleFactor: number;
  17868. /** @hidden */
  17869. _vrExclusivePointerMode: boolean;
  17870. /** @hidden */
  17871. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17872. /** @hidden */
  17873. _onVRDisplayPointerRestricted: () => void;
  17874. /** @hidden */
  17875. _onVRDisplayPointerUnrestricted: () => void;
  17876. /** @hidden */
  17877. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17878. /** @hidden */
  17879. _onVrDisplayDisconnect: Nullable<() => void>;
  17880. /** @hidden */
  17881. _onVrDisplayPresentChange: Nullable<() => void>;
  17882. /**
  17883. * Observable signaled when VR display mode changes
  17884. */
  17885. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17886. /**
  17887. * Observable signaled when VR request present is complete
  17888. */
  17889. onVRRequestPresentComplete: Observable<boolean>;
  17890. /**
  17891. * Observable signaled when VR request present starts
  17892. */
  17893. onVRRequestPresentStart: Observable<Engine>;
  17894. /**
  17895. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17896. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17897. */
  17898. isInVRExclusivePointerMode: boolean;
  17899. /**
  17900. * Gets a boolean indicating if a webVR device was detected
  17901. * @returns true if a webVR device was detected
  17902. */
  17903. isVRDevicePresent(): boolean;
  17904. /**
  17905. * Gets the current webVR device
  17906. * @returns the current webVR device (or null)
  17907. */
  17908. getVRDevice(): any;
  17909. /**
  17910. * Initializes a webVR display and starts listening to display change events
  17911. * The onVRDisplayChangedObservable will be notified upon these changes
  17912. * @returns A promise containing a VRDisplay and if vr is supported
  17913. */
  17914. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17915. /** @hidden */
  17916. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  17917. /**
  17918. * Call this function to switch to webVR mode
  17919. * Will do nothing if webVR is not supported or if there is no webVR device
  17920. * @see http://doc.babylonjs.com/how_to/webvr_camera
  17921. */
  17922. enableVR(): void;
  17923. /** @hidden */
  17924. _onVRFullScreenTriggered(): void;
  17925. }
  17926. }
  17927. }
  17928. declare module "babylonjs/Cameras/VR/webVRCamera" {
  17929. import { Nullable } from "babylonjs/types";
  17930. import { Observable } from "babylonjs/Misc/observable";
  17931. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17932. import { Scene } from "babylonjs/scene";
  17933. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17934. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  17935. import { Node } from "babylonjs/node";
  17936. import { Ray } from "babylonjs/Culling/ray";
  17937. import "babylonjs/Cameras/RigModes/webVRRigMode";
  17938. import "babylonjs/Engines/Extensions/engine.webVR";
  17939. /**
  17940. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  17941. * IMPORTANT!! The data is right-hand data.
  17942. * @export
  17943. * @interface DevicePose
  17944. */
  17945. export interface DevicePose {
  17946. /**
  17947. * The position of the device, values in array are [x,y,z].
  17948. */
  17949. readonly position: Nullable<Float32Array>;
  17950. /**
  17951. * The linearVelocity of the device, values in array are [x,y,z].
  17952. */
  17953. readonly linearVelocity: Nullable<Float32Array>;
  17954. /**
  17955. * The linearAcceleration of the device, values in array are [x,y,z].
  17956. */
  17957. readonly linearAcceleration: Nullable<Float32Array>;
  17958. /**
  17959. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  17960. */
  17961. readonly orientation: Nullable<Float32Array>;
  17962. /**
  17963. * The angularVelocity of the device, values in array are [x,y,z].
  17964. */
  17965. readonly angularVelocity: Nullable<Float32Array>;
  17966. /**
  17967. * The angularAcceleration of the device, values in array are [x,y,z].
  17968. */
  17969. readonly angularAcceleration: Nullable<Float32Array>;
  17970. }
  17971. /**
  17972. * Interface representing a pose controlled object in Babylon.
  17973. * A pose controlled object has both regular pose values as well as pose values
  17974. * from an external device such as a VR head mounted display
  17975. */
  17976. export interface PoseControlled {
  17977. /**
  17978. * The position of the object in babylon space.
  17979. */
  17980. position: Vector3;
  17981. /**
  17982. * The rotation quaternion of the object in babylon space.
  17983. */
  17984. rotationQuaternion: Quaternion;
  17985. /**
  17986. * The position of the device in babylon space.
  17987. */
  17988. devicePosition?: Vector3;
  17989. /**
  17990. * The rotation quaternion of the device in babylon space.
  17991. */
  17992. deviceRotationQuaternion: Quaternion;
  17993. /**
  17994. * The raw pose coming from the device.
  17995. */
  17996. rawPose: Nullable<DevicePose>;
  17997. /**
  17998. * The scale of the device to be used when translating from device space to babylon space.
  17999. */
  18000. deviceScaleFactor: number;
  18001. /**
  18002. * Updates the poseControlled values based on the input device pose.
  18003. * @param poseData the pose data to update the object with
  18004. */
  18005. updateFromDevice(poseData: DevicePose): void;
  18006. }
  18007. /**
  18008. * Set of options to customize the webVRCamera
  18009. */
  18010. export interface WebVROptions {
  18011. /**
  18012. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  18013. */
  18014. trackPosition?: boolean;
  18015. /**
  18016. * Sets the scale of the vrDevice in babylon space. (default: 1)
  18017. */
  18018. positionScale?: number;
  18019. /**
  18020. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  18021. */
  18022. displayName?: string;
  18023. /**
  18024. * Should the native controller meshes be initialized. (default: true)
  18025. */
  18026. controllerMeshes?: boolean;
  18027. /**
  18028. * Creating a default HemiLight only on controllers. (default: true)
  18029. */
  18030. defaultLightingOnControllers?: boolean;
  18031. /**
  18032. * If you don't want to use the default VR button of the helper. (default: false)
  18033. */
  18034. useCustomVRButton?: boolean;
  18035. /**
  18036. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  18037. */
  18038. customVRButton?: HTMLButtonElement;
  18039. /**
  18040. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  18041. */
  18042. rayLength?: number;
  18043. /**
  18044. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  18045. */
  18046. defaultHeight?: number;
  18047. /**
  18048. * If multiview should be used if availible (default: false)
  18049. */
  18050. useMultiview?: boolean;
  18051. }
  18052. /**
  18053. * This represents a WebVR camera.
  18054. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  18055. * @example http://doc.babylonjs.com/how_to/webvr_camera
  18056. */
  18057. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  18058. private webVROptions;
  18059. /**
  18060. * @hidden
  18061. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  18062. */
  18063. _vrDevice: any;
  18064. /**
  18065. * The rawPose of the vrDevice.
  18066. */
  18067. rawPose: Nullable<DevicePose>;
  18068. private _onVREnabled;
  18069. private _specsVersion;
  18070. private _attached;
  18071. private _frameData;
  18072. protected _descendants: Array<Node>;
  18073. private _deviceRoomPosition;
  18074. /** @hidden */
  18075. _deviceRoomRotationQuaternion: Quaternion;
  18076. private _standingMatrix;
  18077. /**
  18078. * Represents device position in babylon space.
  18079. */
  18080. devicePosition: Vector3;
  18081. /**
  18082. * Represents device rotation in babylon space.
  18083. */
  18084. deviceRotationQuaternion: Quaternion;
  18085. /**
  18086. * The scale of the device to be used when translating from device space to babylon space.
  18087. */
  18088. deviceScaleFactor: number;
  18089. private _deviceToWorld;
  18090. private _worldToDevice;
  18091. /**
  18092. * References to the webVR controllers for the vrDevice.
  18093. */
  18094. controllers: Array<WebVRController>;
  18095. /**
  18096. * Emits an event when a controller is attached.
  18097. */
  18098. onControllersAttachedObservable: Observable<WebVRController[]>;
  18099. /**
  18100. * Emits an event when a controller's mesh has been loaded;
  18101. */
  18102. onControllerMeshLoadedObservable: Observable<WebVRController>;
  18103. /**
  18104. * Emits an event when the HMD's pose has been updated.
  18105. */
  18106. onPoseUpdatedFromDeviceObservable: Observable<any>;
  18107. private _poseSet;
  18108. /**
  18109. * If the rig cameras be used as parent instead of this camera.
  18110. */
  18111. rigParenting: boolean;
  18112. private _lightOnControllers;
  18113. private _defaultHeight?;
  18114. /**
  18115. * Instantiates a WebVRFreeCamera.
  18116. * @param name The name of the WebVRFreeCamera
  18117. * @param position The starting anchor position for the camera
  18118. * @param scene The scene the camera belongs to
  18119. * @param webVROptions a set of customizable options for the webVRCamera
  18120. */
  18121. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  18122. /**
  18123. * Gets the device distance from the ground in meters.
  18124. * @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.
  18125. */
  18126. deviceDistanceToRoomGround(): number;
  18127. /**
  18128. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18129. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18130. */
  18131. useStandingMatrix(callback?: (bool: boolean) => void): void;
  18132. /**
  18133. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18134. * @returns A promise with a boolean set to if the standing matrix is supported.
  18135. */
  18136. useStandingMatrixAsync(): Promise<boolean>;
  18137. /**
  18138. * Disposes the camera
  18139. */
  18140. dispose(): void;
  18141. /**
  18142. * Gets a vrController by name.
  18143. * @param name The name of the controller to retreive
  18144. * @returns the controller matching the name specified or null if not found
  18145. */
  18146. getControllerByName(name: string): Nullable<WebVRController>;
  18147. private _leftController;
  18148. /**
  18149. * The controller corresponding to the users left hand.
  18150. */
  18151. readonly leftController: Nullable<WebVRController>;
  18152. private _rightController;
  18153. /**
  18154. * The controller corresponding to the users right hand.
  18155. */
  18156. readonly rightController: Nullable<WebVRController>;
  18157. /**
  18158. * Casts a ray forward from the vrCamera's gaze.
  18159. * @param length Length of the ray (default: 100)
  18160. * @returns the ray corresponding to the gaze
  18161. */
  18162. getForwardRay(length?: number): Ray;
  18163. /**
  18164. * @hidden
  18165. * Updates the camera based on device's frame data
  18166. */
  18167. _checkInputs(): void;
  18168. /**
  18169. * Updates the poseControlled values based on the input device pose.
  18170. * @param poseData Pose coming from the device
  18171. */
  18172. updateFromDevice(poseData: DevicePose): void;
  18173. private _htmlElementAttached;
  18174. private _detachIfAttached;
  18175. /**
  18176. * WebVR's attach control will start broadcasting frames to the device.
  18177. * Note that in certain browsers (chrome for example) this function must be called
  18178. * within a user-interaction callback. Example:
  18179. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18180. *
  18181. * @param element html element to attach the vrDevice to
  18182. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18183. */
  18184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18185. /**
  18186. * Detaches the camera from the html element and disables VR
  18187. *
  18188. * @param element html element to detach from
  18189. */
  18190. detachControl(element: HTMLElement): void;
  18191. /**
  18192. * @returns the name of this class
  18193. */
  18194. getClassName(): string;
  18195. /**
  18196. * Calls resetPose on the vrDisplay
  18197. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18198. */
  18199. resetToCurrentRotation(): void;
  18200. /**
  18201. * @hidden
  18202. * Updates the rig cameras (left and right eye)
  18203. */
  18204. _updateRigCameras(): void;
  18205. private _workingVector;
  18206. private _oneVector;
  18207. private _workingMatrix;
  18208. private updateCacheCalled;
  18209. private _correctPositionIfNotTrackPosition;
  18210. /**
  18211. * @hidden
  18212. * Updates the cached values of the camera
  18213. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18214. */
  18215. _updateCache(ignoreParentClass?: boolean): void;
  18216. /**
  18217. * @hidden
  18218. * Get current device position in babylon world
  18219. */
  18220. _computeDevicePosition(): void;
  18221. /**
  18222. * Updates the current device position and rotation in the babylon world
  18223. */
  18224. update(): void;
  18225. /**
  18226. * @hidden
  18227. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18228. * @returns an identity matrix
  18229. */
  18230. _getViewMatrix(): Matrix;
  18231. private _tmpMatrix;
  18232. /**
  18233. * This function is called by the two RIG cameras.
  18234. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18235. * @hidden
  18236. */
  18237. _getWebVRViewMatrix(): Matrix;
  18238. /** @hidden */
  18239. _getWebVRProjectionMatrix(): Matrix;
  18240. private _onGamepadConnectedObserver;
  18241. private _onGamepadDisconnectedObserver;
  18242. private _updateCacheWhenTrackingDisabledObserver;
  18243. /**
  18244. * Initializes the controllers and their meshes
  18245. */
  18246. initControllers(): void;
  18247. }
  18248. }
  18249. declare module "babylonjs/PostProcesses/postProcess" {
  18250. import { Nullable } from "babylonjs/types";
  18251. import { SmartArray } from "babylonjs/Misc/smartArray";
  18252. import { Observable } from "babylonjs/Misc/observable";
  18253. import { Color4, Vector2 } from "babylonjs/Maths/math";
  18254. import { Camera } from "babylonjs/Cameras/camera";
  18255. import { Effect } from "babylonjs/Materials/effect";
  18256. import "babylonjs/Shaders/postprocess.vertex";
  18257. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18258. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18259. import { Engine } from "babylonjs/Engines/engine";
  18260. /**
  18261. * Size options for a post process
  18262. */
  18263. export type PostProcessOptions = {
  18264. width: number;
  18265. height: number;
  18266. };
  18267. /**
  18268. * PostProcess can be used to apply a shader to a texture after it has been rendered
  18269. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18270. */
  18271. export class PostProcess {
  18272. /** Name of the PostProcess. */
  18273. name: string;
  18274. /**
  18275. * Gets or sets the unique id of the post process
  18276. */
  18277. uniqueId: number;
  18278. /**
  18279. * Width of the texture to apply the post process on
  18280. */
  18281. width: number;
  18282. /**
  18283. * Height of the texture to apply the post process on
  18284. */
  18285. height: number;
  18286. /**
  18287. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  18288. * @hidden
  18289. */
  18290. _outputTexture: Nullable<InternalTexture>;
  18291. /**
  18292. * Sampling mode used by the shader
  18293. * See https://doc.babylonjs.com/classes/3.1/texture
  18294. */
  18295. renderTargetSamplingMode: number;
  18296. /**
  18297. * Clear color to use when screen clearing
  18298. */
  18299. clearColor: Color4;
  18300. /**
  18301. * If the buffer needs to be cleared before applying the post process. (default: true)
  18302. * Should be set to false if shader will overwrite all previous pixels.
  18303. */
  18304. autoClear: boolean;
  18305. /**
  18306. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18307. */
  18308. alphaMode: number;
  18309. /**
  18310. * Sets the setAlphaBlendConstants of the babylon engine
  18311. */
  18312. alphaConstants: Color4;
  18313. /**
  18314. * Animations to be used for the post processing
  18315. */
  18316. animations: import("babylonjs/Animations/animation").Animation[];
  18317. /**
  18318. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18319. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18320. */
  18321. enablePixelPerfectMode: boolean;
  18322. /**
  18323. * Force the postprocess to be applied without taking in account viewport
  18324. */
  18325. forceFullscreenViewport: boolean;
  18326. /**
  18327. * List of inspectable custom properties (used by the Inspector)
  18328. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18329. */
  18330. inspectableCustomProperties: IInspectable[];
  18331. /**
  18332. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18333. *
  18334. * | Value | Type | Description |
  18335. * | ----- | ----------------------------------- | ----------- |
  18336. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18337. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18338. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18339. *
  18340. */
  18341. scaleMode: number;
  18342. /**
  18343. * Force textures to be a power of two (default: false)
  18344. */
  18345. alwaysForcePOT: boolean;
  18346. private _samples;
  18347. /**
  18348. * Number of sample textures (default: 1)
  18349. */
  18350. samples: number;
  18351. /**
  18352. * Modify the scale of the post process to be the same as the viewport (default: false)
  18353. */
  18354. adaptScaleToCurrentViewport: boolean;
  18355. private _camera;
  18356. private _scene;
  18357. private _engine;
  18358. private _options;
  18359. private _reusable;
  18360. private _textureType;
  18361. /**
  18362. * Smart array of input and output textures for the post process.
  18363. * @hidden
  18364. */
  18365. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  18366. /**
  18367. * The index in _textures that corresponds to the output texture.
  18368. * @hidden
  18369. */
  18370. _currentRenderTextureInd: number;
  18371. private _effect;
  18372. private _samplers;
  18373. private _fragmentUrl;
  18374. private _vertexUrl;
  18375. private _parameters;
  18376. private _scaleRatio;
  18377. protected _indexParameters: any;
  18378. private _shareOutputWithPostProcess;
  18379. private _texelSize;
  18380. private _forcedOutputTexture;
  18381. /**
  18382. * Returns the fragment url or shader name used in the post process.
  18383. * @returns the fragment url or name in the shader store.
  18384. */
  18385. getEffectName(): string;
  18386. /**
  18387. * An event triggered when the postprocess is activated.
  18388. */
  18389. onActivateObservable: Observable<Camera>;
  18390. private _onActivateObserver;
  18391. /**
  18392. * A function that is added to the onActivateObservable
  18393. */
  18394. onActivate: Nullable<(camera: Camera) => void>;
  18395. /**
  18396. * An event triggered when the postprocess changes its size.
  18397. */
  18398. onSizeChangedObservable: Observable<PostProcess>;
  18399. private _onSizeChangedObserver;
  18400. /**
  18401. * A function that is added to the onSizeChangedObservable
  18402. */
  18403. onSizeChanged: (postProcess: PostProcess) => void;
  18404. /**
  18405. * An event triggered when the postprocess applies its effect.
  18406. */
  18407. onApplyObservable: Observable<Effect>;
  18408. private _onApplyObserver;
  18409. /**
  18410. * A function that is added to the onApplyObservable
  18411. */
  18412. onApply: (effect: Effect) => void;
  18413. /**
  18414. * An event triggered before rendering the postprocess
  18415. */
  18416. onBeforeRenderObservable: Observable<Effect>;
  18417. private _onBeforeRenderObserver;
  18418. /**
  18419. * A function that is added to the onBeforeRenderObservable
  18420. */
  18421. onBeforeRender: (effect: Effect) => void;
  18422. /**
  18423. * An event triggered after rendering the postprocess
  18424. */
  18425. onAfterRenderObservable: Observable<Effect>;
  18426. private _onAfterRenderObserver;
  18427. /**
  18428. * A function that is added to the onAfterRenderObservable
  18429. */
  18430. onAfterRender: (efect: Effect) => void;
  18431. /**
  18432. * 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
  18433. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18434. */
  18435. inputTexture: InternalTexture;
  18436. /**
  18437. * Gets the camera which post process is applied to.
  18438. * @returns The camera the post process is applied to.
  18439. */
  18440. getCamera(): Camera;
  18441. /**
  18442. * Gets the texel size of the postprocess.
  18443. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18444. */
  18445. readonly texelSize: Vector2;
  18446. /**
  18447. * Creates a new instance PostProcess
  18448. * @param name The name of the PostProcess.
  18449. * @param fragmentUrl The url of the fragment shader to be used.
  18450. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18451. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18452. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18453. * @param camera The camera to apply the render pass to.
  18454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18455. * @param engine The engine which the post process will be applied. (default: current engine)
  18456. * @param reusable If the post process can be reused on the same frame. (default: false)
  18457. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18458. * @param textureType Type of textures used when performing the post process. (default: 0)
  18459. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18460. * @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
  18461. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18462. */
  18463. constructor(
  18464. /** Name of the PostProcess. */
  18465. 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);
  18466. /**
  18467. * Gets a string idenfifying the name of the class
  18468. * @returns "PostProcess" string
  18469. */
  18470. getClassName(): string;
  18471. /**
  18472. * Gets the engine which this post process belongs to.
  18473. * @returns The engine the post process was enabled with.
  18474. */
  18475. getEngine(): Engine;
  18476. /**
  18477. * The effect that is created when initializing the post process.
  18478. * @returns The created effect corresponding the the postprocess.
  18479. */
  18480. getEffect(): Effect;
  18481. /**
  18482. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18483. * @param postProcess The post process to share the output with.
  18484. * @returns This post process.
  18485. */
  18486. shareOutputWith(postProcess: PostProcess): PostProcess;
  18487. /**
  18488. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18489. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18490. */
  18491. useOwnOutput(): void;
  18492. /**
  18493. * Updates the effect with the current post process compile time values and recompiles the shader.
  18494. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18495. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18496. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18497. * @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
  18498. * @param onCompiled Called when the shader has been compiled.
  18499. * @param onError Called if there is an error when compiling a shader.
  18500. */
  18501. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18502. /**
  18503. * The post process is reusable if it can be used multiple times within one frame.
  18504. * @returns If the post process is reusable
  18505. */
  18506. isReusable(): boolean;
  18507. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18508. markTextureDirty(): void;
  18509. /**
  18510. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18511. * 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.
  18512. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18513. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18514. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18515. * @returns The target texture that was bound to be written to.
  18516. */
  18517. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18518. /**
  18519. * If the post process is supported.
  18520. */
  18521. readonly isSupported: boolean;
  18522. /**
  18523. * The aspect ratio of the output texture.
  18524. */
  18525. readonly aspectRatio: number;
  18526. /**
  18527. * Get a value indicating if the post-process is ready to be used
  18528. * @returns true if the post-process is ready (shader is compiled)
  18529. */
  18530. isReady(): boolean;
  18531. /**
  18532. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18533. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18534. */
  18535. apply(): Nullable<Effect>;
  18536. private _disposeTextures;
  18537. /**
  18538. * Disposes the post process.
  18539. * @param camera The camera to dispose the post process on.
  18540. */
  18541. dispose(camera?: Camera): void;
  18542. }
  18543. }
  18544. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  18545. /** @hidden */
  18546. export var kernelBlurVaryingDeclaration: {
  18547. name: string;
  18548. shader: string;
  18549. };
  18550. }
  18551. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  18552. /** @hidden */
  18553. export var kernelBlurFragment: {
  18554. name: string;
  18555. shader: string;
  18556. };
  18557. }
  18558. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  18559. /** @hidden */
  18560. export var kernelBlurFragment2: {
  18561. name: string;
  18562. shader: string;
  18563. };
  18564. }
  18565. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  18566. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18567. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  18568. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  18569. /** @hidden */
  18570. export var kernelBlurPixelShader: {
  18571. name: string;
  18572. shader: string;
  18573. };
  18574. }
  18575. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  18576. /** @hidden */
  18577. export var kernelBlurVertex: {
  18578. name: string;
  18579. shader: string;
  18580. };
  18581. }
  18582. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  18583. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18584. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  18585. /** @hidden */
  18586. export var kernelBlurVertexShader: {
  18587. name: string;
  18588. shader: string;
  18589. };
  18590. }
  18591. declare module "babylonjs/PostProcesses/blurPostProcess" {
  18592. import { Vector2 } from "babylonjs/Maths/math";
  18593. import { Nullable } from "babylonjs/types";
  18594. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18595. import { Camera } from "babylonjs/Cameras/camera";
  18596. import { Effect } from "babylonjs/Materials/effect";
  18597. import { Engine } from "babylonjs/Engines/engine";
  18598. import "babylonjs/Shaders/kernelBlur.fragment";
  18599. import "babylonjs/Shaders/kernelBlur.vertex";
  18600. /**
  18601. * The Blur Post Process which blurs an image based on a kernel and direction.
  18602. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18603. */
  18604. export class BlurPostProcess extends PostProcess {
  18605. /** The direction in which to blur the image. */
  18606. direction: Vector2;
  18607. private blockCompilation;
  18608. protected _kernel: number;
  18609. protected _idealKernel: number;
  18610. protected _packedFloat: boolean;
  18611. private _staticDefines;
  18612. /**
  18613. * Sets the length in pixels of the blur sample region
  18614. */
  18615. /**
  18616. * Gets the length in pixels of the blur sample region
  18617. */
  18618. kernel: number;
  18619. /**
  18620. * Sets wether or not the blur needs to unpack/repack floats
  18621. */
  18622. /**
  18623. * Gets wether or not the blur is unpacking/repacking floats
  18624. */
  18625. packedFloat: boolean;
  18626. /**
  18627. * Creates a new instance BlurPostProcess
  18628. * @param name The name of the effect.
  18629. * @param direction The direction in which to blur the image.
  18630. * @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.
  18631. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18632. * @param camera The camera to apply the render pass to.
  18633. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18634. * @param engine The engine which the post process will be applied. (default: current engine)
  18635. * @param reusable If the post process can be reused on the same frame. (default: false)
  18636. * @param textureType Type of textures used when performing the post process. (default: 0)
  18637. * @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)
  18638. */
  18639. constructor(name: string,
  18640. /** The direction in which to blur the image. */
  18641. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18642. /**
  18643. * Updates the effect with the current post process compile time values and recompiles the shader.
  18644. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18645. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18646. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18647. * @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
  18648. * @param onCompiled Called when the shader has been compiled.
  18649. * @param onError Called if there is an error when compiling a shader.
  18650. */
  18651. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18652. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18653. /**
  18654. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18655. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18656. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18657. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18658. * The gaps between physical kernels are compensated for in the weighting of the samples
  18659. * @param idealKernel Ideal blur kernel.
  18660. * @return Nearest best kernel.
  18661. */
  18662. protected _nearestBestKernel(idealKernel: number): number;
  18663. /**
  18664. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18665. * @param x The point on the Gaussian distribution to sample.
  18666. * @return the value of the Gaussian function at x.
  18667. */
  18668. protected _gaussianWeight(x: number): number;
  18669. /**
  18670. * Generates a string that can be used as a floating point number in GLSL.
  18671. * @param x Value to print.
  18672. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18673. * @return GLSL float string.
  18674. */
  18675. protected _glslFloat(x: number, decimalFigures?: number): string;
  18676. }
  18677. }
  18678. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18679. import { Scene } from "babylonjs/scene";
  18680. import { Plane } from "babylonjs/Maths/math";
  18681. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18682. /**
  18683. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18684. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18685. * You can then easily use it as a reflectionTexture on a flat surface.
  18686. * In case the surface is not a plane, please consider relying on reflection probes.
  18687. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18688. */
  18689. export class MirrorTexture extends RenderTargetTexture {
  18690. private scene;
  18691. /**
  18692. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18693. * 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.
  18694. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18695. */
  18696. mirrorPlane: Plane;
  18697. /**
  18698. * Define the blur ratio used to blur the reflection if needed.
  18699. */
  18700. blurRatio: number;
  18701. /**
  18702. * Define the adaptive blur kernel used to blur the reflection if needed.
  18703. * This will autocompute the closest best match for the `blurKernel`
  18704. */
  18705. adaptiveBlurKernel: number;
  18706. /**
  18707. * Define the blur kernel used to blur the reflection if needed.
  18708. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18709. */
  18710. blurKernel: number;
  18711. /**
  18712. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18713. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18714. */
  18715. blurKernelX: number;
  18716. /**
  18717. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18718. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18719. */
  18720. blurKernelY: number;
  18721. private _autoComputeBlurKernel;
  18722. protected _onRatioRescale(): void;
  18723. private _updateGammaSpace;
  18724. private _imageProcessingConfigChangeObserver;
  18725. private _transformMatrix;
  18726. private _mirrorMatrix;
  18727. private _savedViewMatrix;
  18728. private _blurX;
  18729. private _blurY;
  18730. private _adaptiveBlurKernel;
  18731. private _blurKernelX;
  18732. private _blurKernelY;
  18733. private _blurRatio;
  18734. /**
  18735. * Instantiates a Mirror Texture.
  18736. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18737. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18738. * You can then easily use it as a reflectionTexture on a flat surface.
  18739. * In case the surface is not a plane, please consider relying on reflection probes.
  18740. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18741. * @param name
  18742. * @param size
  18743. * @param scene
  18744. * @param generateMipMaps
  18745. * @param type
  18746. * @param samplingMode
  18747. * @param generateDepthBuffer
  18748. */
  18749. constructor(name: string, size: number | {
  18750. width: number;
  18751. height: number;
  18752. } | {
  18753. ratio: number;
  18754. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18755. private _preparePostProcesses;
  18756. /**
  18757. * Clone the mirror texture.
  18758. * @returns the cloned texture
  18759. */
  18760. clone(): MirrorTexture;
  18761. /**
  18762. * Serialize the texture to a JSON representation you could use in Parse later on
  18763. * @returns the serialized JSON representation
  18764. */
  18765. serialize(): any;
  18766. /**
  18767. * Dispose the texture and release its associated resources.
  18768. */
  18769. dispose(): void;
  18770. }
  18771. }
  18772. declare module "babylonjs/Materials/Textures/texture" {
  18773. import { Observable } from "babylonjs/Misc/observable";
  18774. import { Nullable } from "babylonjs/types";
  18775. import { Scene } from "babylonjs/scene";
  18776. import { Matrix } from "babylonjs/Maths/math";
  18777. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18778. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18779. /**
  18780. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18781. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18782. */
  18783. export class Texture extends BaseTexture {
  18784. /** @hidden */
  18785. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18786. /** @hidden */
  18787. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18788. /** @hidden */
  18789. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18790. /** nearest is mag = nearest and min = nearest and mip = linear */
  18791. static readonly NEAREST_SAMPLINGMODE: number;
  18792. /** nearest is mag = nearest and min = nearest and mip = linear */
  18793. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18794. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18795. static readonly BILINEAR_SAMPLINGMODE: number;
  18796. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18797. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18798. /** Trilinear is mag = linear and min = linear and mip = linear */
  18799. static readonly TRILINEAR_SAMPLINGMODE: number;
  18800. /** Trilinear is mag = linear and min = linear and mip = linear */
  18801. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18802. /** mag = nearest and min = nearest and mip = nearest */
  18803. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18804. /** mag = nearest and min = linear and mip = nearest */
  18805. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18806. /** mag = nearest and min = linear and mip = linear */
  18807. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18808. /** mag = nearest and min = linear and mip = none */
  18809. static readonly NEAREST_LINEAR: number;
  18810. /** mag = nearest and min = nearest and mip = none */
  18811. static readonly NEAREST_NEAREST: number;
  18812. /** mag = linear and min = nearest and mip = nearest */
  18813. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18814. /** mag = linear and min = nearest and mip = linear */
  18815. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18816. /** mag = linear and min = linear and mip = none */
  18817. static readonly LINEAR_LINEAR: number;
  18818. /** mag = linear and min = nearest and mip = none */
  18819. static readonly LINEAR_NEAREST: number;
  18820. /** Explicit coordinates mode */
  18821. static readonly EXPLICIT_MODE: number;
  18822. /** Spherical coordinates mode */
  18823. static readonly SPHERICAL_MODE: number;
  18824. /** Planar coordinates mode */
  18825. static readonly PLANAR_MODE: number;
  18826. /** Cubic coordinates mode */
  18827. static readonly CUBIC_MODE: number;
  18828. /** Projection coordinates mode */
  18829. static readonly PROJECTION_MODE: number;
  18830. /** Inverse Cubic coordinates mode */
  18831. static readonly SKYBOX_MODE: number;
  18832. /** Inverse Cubic coordinates mode */
  18833. static readonly INVCUBIC_MODE: number;
  18834. /** Equirectangular coordinates mode */
  18835. static readonly EQUIRECTANGULAR_MODE: number;
  18836. /** Equirectangular Fixed coordinates mode */
  18837. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18838. /** Equirectangular Fixed Mirrored coordinates mode */
  18839. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18840. /** Texture is not repeating outside of 0..1 UVs */
  18841. static readonly CLAMP_ADDRESSMODE: number;
  18842. /** Texture is repeating outside of 0..1 UVs */
  18843. static readonly WRAP_ADDRESSMODE: number;
  18844. /** Texture is repeating and mirrored */
  18845. static readonly MIRROR_ADDRESSMODE: number;
  18846. /**
  18847. * 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
  18848. */
  18849. static UseSerializedUrlIfAny: boolean;
  18850. /**
  18851. * Define the url of the texture.
  18852. */
  18853. url: Nullable<string>;
  18854. /**
  18855. * Define an offset on the texture to offset the u coordinates of the UVs
  18856. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18857. */
  18858. uOffset: number;
  18859. /**
  18860. * Define an offset on the texture to offset the v coordinates of the UVs
  18861. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18862. */
  18863. vOffset: number;
  18864. /**
  18865. * Define an offset on the texture to scale the u coordinates of the UVs
  18866. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18867. */
  18868. uScale: number;
  18869. /**
  18870. * Define an offset on the texture to scale the v coordinates of the UVs
  18871. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18872. */
  18873. vScale: number;
  18874. /**
  18875. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18876. * @see http://doc.babylonjs.com/how_to/more_materials
  18877. */
  18878. uAng: number;
  18879. /**
  18880. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18881. * @see http://doc.babylonjs.com/how_to/more_materials
  18882. */
  18883. vAng: number;
  18884. /**
  18885. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18886. * @see http://doc.babylonjs.com/how_to/more_materials
  18887. */
  18888. wAng: number;
  18889. /**
  18890. * Defines the center of rotation (U)
  18891. */
  18892. uRotationCenter: number;
  18893. /**
  18894. * Defines the center of rotation (V)
  18895. */
  18896. vRotationCenter: number;
  18897. /**
  18898. * Defines the center of rotation (W)
  18899. */
  18900. wRotationCenter: number;
  18901. /**
  18902. * Are mip maps generated for this texture or not.
  18903. */
  18904. readonly noMipmap: boolean;
  18905. /**
  18906. * List of inspectable custom properties (used by the Inspector)
  18907. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18908. */
  18909. inspectableCustomProperties: Nullable<IInspectable[]>;
  18910. private _noMipmap;
  18911. /** @hidden */
  18912. _invertY: boolean;
  18913. private _rowGenerationMatrix;
  18914. private _cachedTextureMatrix;
  18915. private _projectionModeMatrix;
  18916. private _t0;
  18917. private _t1;
  18918. private _t2;
  18919. private _cachedUOffset;
  18920. private _cachedVOffset;
  18921. private _cachedUScale;
  18922. private _cachedVScale;
  18923. private _cachedUAng;
  18924. private _cachedVAng;
  18925. private _cachedWAng;
  18926. private _cachedProjectionMatrixId;
  18927. private _cachedCoordinatesMode;
  18928. /** @hidden */
  18929. protected _initialSamplingMode: number;
  18930. /** @hidden */
  18931. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18932. private _deleteBuffer;
  18933. protected _format: Nullable<number>;
  18934. private _delayedOnLoad;
  18935. private _delayedOnError;
  18936. /**
  18937. * Observable triggered once the texture has been loaded.
  18938. */
  18939. onLoadObservable: Observable<Texture>;
  18940. protected _isBlocking: boolean;
  18941. /**
  18942. * Is the texture preventing material to render while loading.
  18943. * If false, a default texture will be used instead of the loading one during the preparation step.
  18944. */
  18945. isBlocking: boolean;
  18946. /**
  18947. * Get the current sampling mode associated with the texture.
  18948. */
  18949. readonly samplingMode: number;
  18950. /**
  18951. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18952. */
  18953. readonly invertY: boolean;
  18954. /**
  18955. * Instantiates a new texture.
  18956. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18957. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18958. * @param url define the url of the picture to load as a texture
  18959. * @param scene define the scene the texture will belong to
  18960. * @param noMipmap define if the texture will require mip maps or not
  18961. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18962. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18963. * @param onLoad define a callback triggered when the texture has been loaded
  18964. * @param onError define a callback triggered when an error occurred during the loading session
  18965. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18966. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18967. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18968. */
  18969. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18970. /**
  18971. * Update the url (and optional buffer) of this texture if url was null during construction.
  18972. * @param url the url of the texture
  18973. * @param buffer the buffer of the texture (defaults to null)
  18974. * @param onLoad callback called when the texture is loaded (defaults to null)
  18975. */
  18976. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18977. /**
  18978. * Finish the loading sequence of a texture flagged as delayed load.
  18979. * @hidden
  18980. */
  18981. delayLoad(): void;
  18982. private _prepareRowForTextureGeneration;
  18983. /**
  18984. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18985. * @returns the transform matrix of the texture.
  18986. */
  18987. getTextureMatrix(): Matrix;
  18988. /**
  18989. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18990. * @returns The reflection texture transform
  18991. */
  18992. getReflectionTextureMatrix(): Matrix;
  18993. /**
  18994. * Clones the texture.
  18995. * @returns the cloned texture
  18996. */
  18997. clone(): Texture;
  18998. /**
  18999. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19000. * @returns The JSON representation of the texture
  19001. */
  19002. serialize(): any;
  19003. /**
  19004. * Get the current class name of the texture useful for serialization or dynamic coding.
  19005. * @returns "Texture"
  19006. */
  19007. getClassName(): string;
  19008. /**
  19009. * Dispose the texture and release its associated resources.
  19010. */
  19011. dispose(): void;
  19012. /**
  19013. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  19014. * @param parsedTexture Define the JSON representation of the texture
  19015. * @param scene Define the scene the parsed texture should be instantiated in
  19016. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  19017. * @returns The parsed texture if successful
  19018. */
  19019. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  19020. /**
  19021. * Creates a texture from its base 64 representation.
  19022. * @param data Define the base64 payload without the data: prefix
  19023. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19024. * @param scene Define the scene the texture should belong to
  19025. * @param noMipmap Forces the texture to not create mip map information if true
  19026. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19027. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19028. * @param onLoad define a callback triggered when the texture has been loaded
  19029. * @param onError define a callback triggered when an error occurred during the loading session
  19030. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19031. * @returns the created texture
  19032. */
  19033. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  19034. /**
  19035. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  19036. * @param data Define the base64 payload without the data: prefix
  19037. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19038. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19039. * @param scene Define the scene the texture should belong to
  19040. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19041. * @param noMipmap Forces the texture to not create mip map information if true
  19042. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19043. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19044. * @param onLoad define a callback triggered when the texture has been loaded
  19045. * @param onError define a callback triggered when an error occurred during the loading session
  19046. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19047. * @returns the created texture
  19048. */
  19049. 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;
  19050. }
  19051. }
  19052. declare module "babylonjs/PostProcesses/postProcessManager" {
  19053. import { Nullable } from "babylonjs/types";
  19054. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19055. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19056. import { Scene } from "babylonjs/scene";
  19057. /**
  19058. * PostProcessManager is used to manage one or more post processes or post process pipelines
  19059. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19060. */
  19061. export class PostProcessManager {
  19062. private _scene;
  19063. private _indexBuffer;
  19064. private _vertexBuffers;
  19065. /**
  19066. * Creates a new instance PostProcess
  19067. * @param scene The scene that the post process is associated with.
  19068. */
  19069. constructor(scene: Scene);
  19070. private _prepareBuffers;
  19071. private _buildIndexBuffer;
  19072. /**
  19073. * Rebuilds the vertex buffers of the manager.
  19074. * @hidden
  19075. */
  19076. _rebuild(): void;
  19077. /**
  19078. * Prepares a frame to be run through a post process.
  19079. * @param sourceTexture The input texture to the post procesess. (default: null)
  19080. * @param postProcesses An array of post processes to be run. (default: null)
  19081. * @returns True if the post processes were able to be run.
  19082. * @hidden
  19083. */
  19084. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  19085. /**
  19086. * Manually render a set of post processes to a texture.
  19087. * @param postProcesses An array of post processes to be run.
  19088. * @param targetTexture The target texture to render to.
  19089. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  19090. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  19091. * @param lodLevel defines which lod of the texture to render to
  19092. */
  19093. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  19094. /**
  19095. * Finalize the result of the output of the postprocesses.
  19096. * @param doNotPresent If true the result will not be displayed to the screen.
  19097. * @param targetTexture The target texture to render to.
  19098. * @param faceIndex The index of the face to bind the target texture to.
  19099. * @param postProcesses The array of post processes to render.
  19100. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  19101. * @hidden
  19102. */
  19103. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  19104. /**
  19105. * Disposes of the post process manager.
  19106. */
  19107. dispose(): void;
  19108. }
  19109. }
  19110. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  19111. import { Scene } from "babylonjs/scene";
  19112. import { ISceneComponent } from "babylonjs/sceneComponent";
  19113. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19114. module "babylonjs/abstractScene" {
  19115. interface AbstractScene {
  19116. /**
  19117. * The list of procedural textures added to the scene
  19118. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19119. */
  19120. proceduralTextures: Array<ProceduralTexture>;
  19121. }
  19122. }
  19123. /**
  19124. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  19125. * in a given scene.
  19126. */
  19127. export class ProceduralTextureSceneComponent implements ISceneComponent {
  19128. /**
  19129. * The component name helpfull to identify the component in the list of scene components.
  19130. */
  19131. readonly name: string;
  19132. /**
  19133. * The scene the component belongs to.
  19134. */
  19135. scene: Scene;
  19136. /**
  19137. * Creates a new instance of the component for the given scene
  19138. * @param scene Defines the scene to register the component in
  19139. */
  19140. constructor(scene: Scene);
  19141. /**
  19142. * Registers the component in a given scene
  19143. */
  19144. register(): void;
  19145. /**
  19146. * Rebuilds the elements related to this component in case of
  19147. * context lost for instance.
  19148. */
  19149. rebuild(): void;
  19150. /**
  19151. * Disposes the component and the associated ressources.
  19152. */
  19153. dispose(): void;
  19154. private _beforeClear;
  19155. }
  19156. }
  19157. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  19158. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19159. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  19160. module "babylonjs/Engines/engine" {
  19161. interface Engine {
  19162. /**
  19163. * Creates a new render target cube texture
  19164. * @param size defines the size of the texture
  19165. * @param options defines the options used to create the texture
  19166. * @returns a new render target cube texture stored in an InternalTexture
  19167. */
  19168. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  19169. }
  19170. }
  19171. }
  19172. declare module "babylonjs/Shaders/procedural.vertex" {
  19173. /** @hidden */
  19174. export var proceduralVertexShader: {
  19175. name: string;
  19176. shader: string;
  19177. };
  19178. }
  19179. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  19180. import { Observable } from "babylonjs/Misc/observable";
  19181. import { Nullable } from "babylonjs/types";
  19182. import { Scene } from "babylonjs/scene";
  19183. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  19184. import { Effect } from "babylonjs/Materials/effect";
  19185. import { Texture } from "babylonjs/Materials/Textures/texture";
  19186. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19187. import "babylonjs/Shaders/procedural.vertex";
  19188. /**
  19189. * 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.
  19190. * This is the base class of any Procedural texture and contains most of the shareable code.
  19191. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19192. */
  19193. export class ProceduralTexture extends Texture {
  19194. isCube: boolean;
  19195. /**
  19196. * Define if the texture is enabled or not (disabled texture will not render)
  19197. */
  19198. isEnabled: boolean;
  19199. /**
  19200. * Define if the texture must be cleared before rendering (default is true)
  19201. */
  19202. autoClear: boolean;
  19203. /**
  19204. * Callback called when the texture is generated
  19205. */
  19206. onGenerated: () => void;
  19207. /**
  19208. * Event raised when the texture is generated
  19209. */
  19210. onGeneratedObservable: Observable<ProceduralTexture>;
  19211. /** @hidden */
  19212. _generateMipMaps: boolean;
  19213. /** @hidden **/
  19214. _effect: Effect;
  19215. /** @hidden */
  19216. _textures: {
  19217. [key: string]: Texture;
  19218. };
  19219. private _size;
  19220. private _currentRefreshId;
  19221. private _refreshRate;
  19222. private _vertexBuffers;
  19223. private _indexBuffer;
  19224. private _uniforms;
  19225. private _samplers;
  19226. private _fragment;
  19227. private _floats;
  19228. private _ints;
  19229. private _floatsArrays;
  19230. private _colors3;
  19231. private _colors4;
  19232. private _vectors2;
  19233. private _vectors3;
  19234. private _matrices;
  19235. private _fallbackTexture;
  19236. private _fallbackTextureUsed;
  19237. private _engine;
  19238. private _cachedDefines;
  19239. private _contentUpdateId;
  19240. private _contentData;
  19241. /**
  19242. * Instantiates a new procedural texture.
  19243. * 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.
  19244. * This is the base class of any Procedural texture and contains most of the shareable code.
  19245. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19246. * @param name Define the name of the texture
  19247. * @param size Define the size of the texture to create
  19248. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  19249. * @param scene Define the scene the texture belongs to
  19250. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  19251. * @param generateMipMaps Define if the texture should creates mip maps or not
  19252. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  19253. */
  19254. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  19255. /**
  19256. * The effect that is created when initializing the post process.
  19257. * @returns The created effect corresponding the the postprocess.
  19258. */
  19259. getEffect(): Effect;
  19260. /**
  19261. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  19262. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  19263. */
  19264. getContent(): Nullable<ArrayBufferView>;
  19265. private _createIndexBuffer;
  19266. /** @hidden */
  19267. _rebuild(): void;
  19268. /**
  19269. * Resets the texture in order to recreate its associated resources.
  19270. * This can be called in case of context loss
  19271. */
  19272. reset(): void;
  19273. protected _getDefines(): string;
  19274. /**
  19275. * Is the texture ready to be used ? (rendered at least once)
  19276. * @returns true if ready, otherwise, false.
  19277. */
  19278. isReady(): boolean;
  19279. /**
  19280. * Resets the refresh counter of the texture and start bak from scratch.
  19281. * Could be useful to regenerate the texture if it is setup to render only once.
  19282. */
  19283. resetRefreshCounter(): void;
  19284. /**
  19285. * Set the fragment shader to use in order to render the texture.
  19286. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  19287. */
  19288. setFragment(fragment: any): void;
  19289. /**
  19290. * Define the refresh rate of the texture or the rendering frequency.
  19291. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19292. */
  19293. refreshRate: number;
  19294. /** @hidden */
  19295. _shouldRender(): boolean;
  19296. /**
  19297. * Get the size the texture is rendering at.
  19298. * @returns the size (texture is always squared)
  19299. */
  19300. getRenderSize(): number;
  19301. /**
  19302. * Resize the texture to new value.
  19303. * @param size Define the new size the texture should have
  19304. * @param generateMipMaps Define whether the new texture should create mip maps
  19305. */
  19306. resize(size: number, generateMipMaps: boolean): void;
  19307. private _checkUniform;
  19308. /**
  19309. * Set a texture in the shader program used to render.
  19310. * @param name Define the name of the uniform samplers as defined in the shader
  19311. * @param texture Define the texture to bind to this sampler
  19312. * @return the texture itself allowing "fluent" like uniform updates
  19313. */
  19314. setTexture(name: string, texture: Texture): ProceduralTexture;
  19315. /**
  19316. * Set a float in the shader.
  19317. * @param name Define the name of the uniform as defined in the shader
  19318. * @param value Define the value to give to the uniform
  19319. * @return the texture itself allowing "fluent" like uniform updates
  19320. */
  19321. setFloat(name: string, value: number): ProceduralTexture;
  19322. /**
  19323. * Set a int in the shader.
  19324. * @param name Define the name of the uniform as defined in the shader
  19325. * @param value Define the value to give to the uniform
  19326. * @return the texture itself allowing "fluent" like uniform updates
  19327. */
  19328. setInt(name: string, value: number): ProceduralTexture;
  19329. /**
  19330. * Set an array of floats in the shader.
  19331. * @param name Define the name of the uniform as defined in the shader
  19332. * @param value Define the value to give to the uniform
  19333. * @return the texture itself allowing "fluent" like uniform updates
  19334. */
  19335. setFloats(name: string, value: number[]): ProceduralTexture;
  19336. /**
  19337. * Set a vec3 in the shader from a Color3.
  19338. * @param name Define the name of the uniform as defined in the shader
  19339. * @param value Define the value to give to the uniform
  19340. * @return the texture itself allowing "fluent" like uniform updates
  19341. */
  19342. setColor3(name: string, value: Color3): ProceduralTexture;
  19343. /**
  19344. * Set a vec4 in the shader from a Color4.
  19345. * @param name Define the name of the uniform as defined in the shader
  19346. * @param value Define the value to give to the uniform
  19347. * @return the texture itself allowing "fluent" like uniform updates
  19348. */
  19349. setColor4(name: string, value: Color4): ProceduralTexture;
  19350. /**
  19351. * Set a vec2 in the shader from a Vector2.
  19352. * @param name Define the name of the uniform as defined in the shader
  19353. * @param value Define the value to give to the uniform
  19354. * @return the texture itself allowing "fluent" like uniform updates
  19355. */
  19356. setVector2(name: string, value: Vector2): ProceduralTexture;
  19357. /**
  19358. * Set a vec3 in the shader from a Vector3.
  19359. * @param name Define the name of the uniform as defined in the shader
  19360. * @param value Define the value to give to the uniform
  19361. * @return the texture itself allowing "fluent" like uniform updates
  19362. */
  19363. setVector3(name: string, value: Vector3): ProceduralTexture;
  19364. /**
  19365. * Set a mat4 in the shader from a MAtrix.
  19366. * @param name Define the name of the uniform as defined in the shader
  19367. * @param value Define the value to give to the uniform
  19368. * @return the texture itself allowing "fluent" like uniform updates
  19369. */
  19370. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19371. /**
  19372. * Render the texture to its associated render target.
  19373. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19374. */
  19375. render(useCameraPostProcess?: boolean): void;
  19376. /**
  19377. * Clone the texture.
  19378. * @returns the cloned texture
  19379. */
  19380. clone(): ProceduralTexture;
  19381. /**
  19382. * Dispose the texture and release its asoociated resources.
  19383. */
  19384. dispose(): void;
  19385. }
  19386. }
  19387. declare module "babylonjs/Particles/baseParticleSystem" {
  19388. import { Nullable } from "babylonjs/types";
  19389. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  19390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19391. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19392. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19393. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19394. import { Scene } from "babylonjs/scene";
  19395. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  19396. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19397. import { Texture } from "babylonjs/Materials/Textures/texture";
  19398. import { Animation } from "babylonjs/Animations/animation";
  19399. /**
  19400. * This represents the base class for particle system in Babylon.
  19401. * 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.
  19402. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19403. * @example https://doc.babylonjs.com/babylon101/particles
  19404. */
  19405. export class BaseParticleSystem {
  19406. /**
  19407. * Source color is added to the destination color without alpha affecting the result
  19408. */
  19409. static BLENDMODE_ONEONE: number;
  19410. /**
  19411. * Blend current color and particle color using particle’s alpha
  19412. */
  19413. static BLENDMODE_STANDARD: number;
  19414. /**
  19415. * Add current color and particle color multiplied by particle’s alpha
  19416. */
  19417. static BLENDMODE_ADD: number;
  19418. /**
  19419. * Multiply current color with particle color
  19420. */
  19421. static BLENDMODE_MULTIPLY: number;
  19422. /**
  19423. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19424. */
  19425. static BLENDMODE_MULTIPLYADD: number;
  19426. /**
  19427. * List of animations used by the particle system.
  19428. */
  19429. animations: Animation[];
  19430. /**
  19431. * The id of the Particle system.
  19432. */
  19433. id: string;
  19434. /**
  19435. * The friendly name of the Particle system.
  19436. */
  19437. name: string;
  19438. /**
  19439. * The rendering group used by the Particle system to chose when to render.
  19440. */
  19441. renderingGroupId: number;
  19442. /**
  19443. * The emitter represents the Mesh or position we are attaching the particle system to.
  19444. */
  19445. emitter: Nullable<AbstractMesh | Vector3>;
  19446. /**
  19447. * The maximum number of particles to emit per frame
  19448. */
  19449. emitRate: number;
  19450. /**
  19451. * If you want to launch only a few particles at once, that can be done, as well.
  19452. */
  19453. manualEmitCount: number;
  19454. /**
  19455. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19456. */
  19457. updateSpeed: number;
  19458. /**
  19459. * The amount of time the particle system is running (depends of the overall update speed).
  19460. */
  19461. targetStopDuration: number;
  19462. /**
  19463. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19464. */
  19465. disposeOnStop: boolean;
  19466. /**
  19467. * Minimum power of emitting particles.
  19468. */
  19469. minEmitPower: number;
  19470. /**
  19471. * Maximum power of emitting particles.
  19472. */
  19473. maxEmitPower: number;
  19474. /**
  19475. * Minimum life time of emitting particles.
  19476. */
  19477. minLifeTime: number;
  19478. /**
  19479. * Maximum life time of emitting particles.
  19480. */
  19481. maxLifeTime: number;
  19482. /**
  19483. * Minimum Size of emitting particles.
  19484. */
  19485. minSize: number;
  19486. /**
  19487. * Maximum Size of emitting particles.
  19488. */
  19489. maxSize: number;
  19490. /**
  19491. * Minimum scale of emitting particles on X axis.
  19492. */
  19493. minScaleX: number;
  19494. /**
  19495. * Maximum scale of emitting particles on X axis.
  19496. */
  19497. maxScaleX: number;
  19498. /**
  19499. * Minimum scale of emitting particles on Y axis.
  19500. */
  19501. minScaleY: number;
  19502. /**
  19503. * Maximum scale of emitting particles on Y axis.
  19504. */
  19505. maxScaleY: number;
  19506. /**
  19507. * Gets or sets the minimal initial rotation in radians.
  19508. */
  19509. minInitialRotation: number;
  19510. /**
  19511. * Gets or sets the maximal initial rotation in radians.
  19512. */
  19513. maxInitialRotation: number;
  19514. /**
  19515. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19516. */
  19517. minAngularSpeed: number;
  19518. /**
  19519. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19520. */
  19521. maxAngularSpeed: number;
  19522. /**
  19523. * The texture used to render each particle. (this can be a spritesheet)
  19524. */
  19525. particleTexture: Nullable<Texture>;
  19526. /**
  19527. * The layer mask we are rendering the particles through.
  19528. */
  19529. layerMask: number;
  19530. /**
  19531. * This can help using your own shader to render the particle system.
  19532. * The according effect will be created
  19533. */
  19534. customShader: any;
  19535. /**
  19536. * By default particle system starts as soon as they are created. This prevents the
  19537. * automatic start to happen and let you decide when to start emitting particles.
  19538. */
  19539. preventAutoStart: boolean;
  19540. private _noiseTexture;
  19541. /**
  19542. * Gets or sets a texture used to add random noise to particle positions
  19543. */
  19544. noiseTexture: Nullable<ProceduralTexture>;
  19545. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19546. noiseStrength: Vector3;
  19547. /**
  19548. * Callback triggered when the particle animation is ending.
  19549. */
  19550. onAnimationEnd: Nullable<() => void>;
  19551. /**
  19552. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19553. */
  19554. blendMode: number;
  19555. /**
  19556. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19557. * to override the particles.
  19558. */
  19559. forceDepthWrite: boolean;
  19560. /** 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 */
  19561. preWarmCycles: number;
  19562. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19563. preWarmStepOffset: number;
  19564. /**
  19565. * 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)
  19566. */
  19567. spriteCellChangeSpeed: number;
  19568. /**
  19569. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19570. */
  19571. startSpriteCellID: number;
  19572. /**
  19573. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19574. */
  19575. endSpriteCellID: number;
  19576. /**
  19577. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19578. */
  19579. spriteCellWidth: number;
  19580. /**
  19581. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19582. */
  19583. spriteCellHeight: number;
  19584. /**
  19585. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19586. */
  19587. spriteRandomStartCell: boolean;
  19588. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19589. translationPivot: Vector2;
  19590. /** @hidden */
  19591. protected _isAnimationSheetEnabled: boolean;
  19592. /**
  19593. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19594. */
  19595. beginAnimationOnStart: boolean;
  19596. /**
  19597. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19598. */
  19599. beginAnimationFrom: number;
  19600. /**
  19601. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19602. */
  19603. beginAnimationTo: number;
  19604. /**
  19605. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19606. */
  19607. beginAnimationLoop: boolean;
  19608. /**
  19609. * Gets or sets a world offset applied to all particles
  19610. */
  19611. worldOffset: Vector3;
  19612. /**
  19613. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19614. */
  19615. isAnimationSheetEnabled: boolean;
  19616. /**
  19617. * Get hosting scene
  19618. * @returns the scene
  19619. */
  19620. getScene(): Scene;
  19621. /**
  19622. * You can use gravity if you want to give an orientation to your particles.
  19623. */
  19624. gravity: Vector3;
  19625. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19626. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19627. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19628. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19629. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19630. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19631. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19632. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19633. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19634. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19635. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19636. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19637. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19638. /**
  19639. * Defines the delay in milliseconds before starting the system (0 by default)
  19640. */
  19641. startDelay: number;
  19642. /**
  19643. * Gets the current list of drag gradients.
  19644. * You must use addDragGradient and removeDragGradient to udpate this list
  19645. * @returns the list of drag gradients
  19646. */
  19647. getDragGradients(): Nullable<Array<FactorGradient>>;
  19648. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19649. limitVelocityDamping: number;
  19650. /**
  19651. * Gets the current list of limit velocity gradients.
  19652. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19653. * @returns the list of limit velocity gradients
  19654. */
  19655. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19656. /**
  19657. * Gets the current list of color gradients.
  19658. * You must use addColorGradient and removeColorGradient to udpate this list
  19659. * @returns the list of color gradients
  19660. */
  19661. getColorGradients(): Nullable<Array<ColorGradient>>;
  19662. /**
  19663. * Gets the current list of size gradients.
  19664. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19665. * @returns the list of size gradients
  19666. */
  19667. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19668. /**
  19669. * Gets the current list of color remap gradients.
  19670. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19671. * @returns the list of color remap gradients
  19672. */
  19673. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19674. /**
  19675. * Gets the current list of alpha remap gradients.
  19676. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19677. * @returns the list of alpha remap gradients
  19678. */
  19679. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19680. /**
  19681. * Gets the current list of life time gradients.
  19682. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19683. * @returns the list of life time gradients
  19684. */
  19685. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19686. /**
  19687. * Gets the current list of angular speed gradients.
  19688. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19689. * @returns the list of angular speed gradients
  19690. */
  19691. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19692. /**
  19693. * Gets the current list of velocity gradients.
  19694. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19695. * @returns the list of velocity gradients
  19696. */
  19697. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19698. /**
  19699. * Gets the current list of start size gradients.
  19700. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19701. * @returns the list of start size gradients
  19702. */
  19703. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19704. /**
  19705. * Gets the current list of emit rate gradients.
  19706. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19707. * @returns the list of emit rate gradients
  19708. */
  19709. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19710. /**
  19711. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19712. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19713. */
  19714. direction1: Vector3;
  19715. /**
  19716. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19717. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19718. */
  19719. direction2: Vector3;
  19720. /**
  19721. * 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.
  19722. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19723. */
  19724. minEmitBox: Vector3;
  19725. /**
  19726. * 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.
  19727. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19728. */
  19729. maxEmitBox: Vector3;
  19730. /**
  19731. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19732. */
  19733. color1: Color4;
  19734. /**
  19735. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19736. */
  19737. color2: Color4;
  19738. /**
  19739. * Color the particle will have at the end of its lifetime
  19740. */
  19741. colorDead: Color4;
  19742. /**
  19743. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19744. */
  19745. textureMask: Color4;
  19746. /**
  19747. * The particle emitter type defines the emitter used by the particle system.
  19748. * It can be for example box, sphere, or cone...
  19749. */
  19750. particleEmitterType: IParticleEmitterType;
  19751. /** @hidden */
  19752. _isSubEmitter: boolean;
  19753. /**
  19754. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19755. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19756. */
  19757. billboardMode: number;
  19758. protected _isBillboardBased: boolean;
  19759. /**
  19760. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19761. */
  19762. isBillboardBased: boolean;
  19763. /**
  19764. * The scene the particle system belongs to.
  19765. */
  19766. protected _scene: Scene;
  19767. /**
  19768. * Local cache of defines for image processing.
  19769. */
  19770. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19771. /**
  19772. * Default configuration related to image processing available in the standard Material.
  19773. */
  19774. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19775. /**
  19776. * Gets the image processing configuration used either in this material.
  19777. */
  19778. /**
  19779. * Sets the Default image processing configuration used either in the this material.
  19780. *
  19781. * If sets to null, the scene one is in use.
  19782. */
  19783. imageProcessingConfiguration: ImageProcessingConfiguration;
  19784. /**
  19785. * Attaches a new image processing configuration to the Standard Material.
  19786. * @param configuration
  19787. */
  19788. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19789. /** @hidden */
  19790. protected _reset(): void;
  19791. /** @hidden */
  19792. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19793. /**
  19794. * Instantiates a particle system.
  19795. * 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.
  19796. * @param name The name of the particle system
  19797. */
  19798. constructor(name: string);
  19799. /**
  19800. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19801. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19802. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19803. * @returns the emitter
  19804. */
  19805. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19806. /**
  19807. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19808. * @param radius The radius of the hemisphere to emit from
  19809. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19810. * @returns the emitter
  19811. */
  19812. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19813. /**
  19814. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19815. * @param radius The radius of the sphere to emit from
  19816. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19817. * @returns the emitter
  19818. */
  19819. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19820. /**
  19821. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19822. * @param radius The radius of the sphere to emit from
  19823. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19824. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19825. * @returns the emitter
  19826. */
  19827. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19828. /**
  19829. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19830. * @param radius The radius of the emission cylinder
  19831. * @param height The height of the emission cylinder
  19832. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19833. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19834. * @returns the emitter
  19835. */
  19836. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19837. /**
  19838. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19839. * @param radius The radius of the cylinder to emit from
  19840. * @param height The height of the emission cylinder
  19841. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19842. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19843. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19844. * @returns the emitter
  19845. */
  19846. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19847. /**
  19848. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19849. * @param radius The radius of the cone to emit from
  19850. * @param angle The base angle of the cone
  19851. * @returns the emitter
  19852. */
  19853. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19854. /**
  19855. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19856. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19857. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19858. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19859. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19860. * @returns the emitter
  19861. */
  19862. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19863. }
  19864. }
  19865. declare module "babylonjs/Particles/subEmitter" {
  19866. import { Scene } from "babylonjs/scene";
  19867. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  19868. /**
  19869. * Type of sub emitter
  19870. */
  19871. export enum SubEmitterType {
  19872. /**
  19873. * Attached to the particle over it's lifetime
  19874. */
  19875. ATTACHED = 0,
  19876. /**
  19877. * Created when the particle dies
  19878. */
  19879. END = 1
  19880. }
  19881. /**
  19882. * Sub emitter class used to emit particles from an existing particle
  19883. */
  19884. export class SubEmitter {
  19885. /**
  19886. * the particle system to be used by the sub emitter
  19887. */
  19888. particleSystem: ParticleSystem;
  19889. /**
  19890. * Type of the submitter (Default: END)
  19891. */
  19892. type: SubEmitterType;
  19893. /**
  19894. * 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)
  19895. * Note: This only is supported when using an emitter of type Mesh
  19896. */
  19897. inheritDirection: boolean;
  19898. /**
  19899. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19900. */
  19901. inheritedVelocityAmount: number;
  19902. /**
  19903. * Creates a sub emitter
  19904. * @param particleSystem the particle system to be used by the sub emitter
  19905. */
  19906. constructor(
  19907. /**
  19908. * the particle system to be used by the sub emitter
  19909. */
  19910. particleSystem: ParticleSystem);
  19911. /**
  19912. * Clones the sub emitter
  19913. * @returns the cloned sub emitter
  19914. */
  19915. clone(): SubEmitter;
  19916. /**
  19917. * Serialize current object to a JSON object
  19918. * @returns the serialized object
  19919. */
  19920. serialize(): any;
  19921. /** @hidden */
  19922. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  19923. /**
  19924. * Creates a new SubEmitter from a serialized JSON version
  19925. * @param serializationObject defines the JSON object to read from
  19926. * @param scene defines the hosting scene
  19927. * @param rootUrl defines the rootUrl for data loading
  19928. * @returns a new SubEmitter
  19929. */
  19930. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  19931. /** Release associated resources */
  19932. dispose(): void;
  19933. }
  19934. }
  19935. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  19936. /** @hidden */
  19937. export var imageProcessingDeclaration: {
  19938. name: string;
  19939. shader: string;
  19940. };
  19941. }
  19942. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  19943. /** @hidden */
  19944. export var imageProcessingFunctions: {
  19945. name: string;
  19946. shader: string;
  19947. };
  19948. }
  19949. declare module "babylonjs/Shaders/particles.fragment" {
  19950. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19951. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  19952. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19953. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  19954. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19955. /** @hidden */
  19956. export var particlesPixelShader: {
  19957. name: string;
  19958. shader: string;
  19959. };
  19960. }
  19961. declare module "babylonjs/Shaders/particles.vertex" {
  19962. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19963. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19964. /** @hidden */
  19965. export var particlesVertexShader: {
  19966. name: string;
  19967. shader: string;
  19968. };
  19969. }
  19970. declare module "babylonjs/Particles/particleSystem" {
  19971. import { Nullable } from "babylonjs/types";
  19972. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  19973. import { Observable } from "babylonjs/Misc/observable";
  19974. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  19975. import { Effect } from "babylonjs/Materials/effect";
  19976. import { Scene, IDisposable } from "babylonjs/scene";
  19977. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19978. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  19979. import { Particle } from "babylonjs/Particles/particle";
  19980. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  19981. import "babylonjs/Shaders/particles.fragment";
  19982. import "babylonjs/Shaders/particles.vertex";
  19983. /**
  19984. * This represents a particle system in Babylon.
  19985. * 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.
  19986. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19987. * @example https://doc.babylonjs.com/babylon101/particles
  19988. */
  19989. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19990. /**
  19991. * Billboard mode will only apply to Y axis
  19992. */
  19993. static readonly BILLBOARDMODE_Y: number;
  19994. /**
  19995. * Billboard mode will apply to all axes
  19996. */
  19997. static readonly BILLBOARDMODE_ALL: number;
  19998. /**
  19999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  20000. */
  20001. static readonly BILLBOARDMODE_STRETCHED: number;
  20002. /**
  20003. * This function can be defined to provide custom update for active particles.
  20004. * This function will be called instead of regular update (age, position, color, etc.).
  20005. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  20006. */
  20007. updateFunction: (particles: Particle[]) => void;
  20008. private _emitterWorldMatrix;
  20009. /**
  20010. * This function can be defined to specify initial direction for every new particle.
  20011. * It by default use the emitterType defined function
  20012. */
  20013. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  20014. /**
  20015. * This function can be defined to specify initial position for every new particle.
  20016. * It by default use the emitterType defined function
  20017. */
  20018. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  20019. /**
  20020. * @hidden
  20021. */
  20022. _inheritedVelocityOffset: Vector3;
  20023. /**
  20024. * An event triggered when the system is disposed
  20025. */
  20026. onDisposeObservable: Observable<ParticleSystem>;
  20027. private _onDisposeObserver;
  20028. /**
  20029. * Sets a callback that will be triggered when the system is disposed
  20030. */
  20031. onDispose: () => void;
  20032. private _particles;
  20033. private _epsilon;
  20034. private _capacity;
  20035. private _stockParticles;
  20036. private _newPartsExcess;
  20037. private _vertexData;
  20038. private _vertexBuffer;
  20039. private _vertexBuffers;
  20040. private _spriteBuffer;
  20041. private _indexBuffer;
  20042. private _effect;
  20043. private _customEffect;
  20044. private _cachedDefines;
  20045. private _scaledColorStep;
  20046. private _colorDiff;
  20047. private _scaledDirection;
  20048. private _scaledGravity;
  20049. private _currentRenderId;
  20050. private _alive;
  20051. private _useInstancing;
  20052. private _started;
  20053. private _stopped;
  20054. private _actualFrame;
  20055. private _scaledUpdateSpeed;
  20056. private _vertexBufferSize;
  20057. /** @hidden */
  20058. _currentEmitRateGradient: Nullable<FactorGradient>;
  20059. /** @hidden */
  20060. _currentEmitRate1: number;
  20061. /** @hidden */
  20062. _currentEmitRate2: number;
  20063. /** @hidden */
  20064. _currentStartSizeGradient: Nullable<FactorGradient>;
  20065. /** @hidden */
  20066. _currentStartSize1: number;
  20067. /** @hidden */
  20068. _currentStartSize2: number;
  20069. private readonly _rawTextureWidth;
  20070. private _rampGradientsTexture;
  20071. private _useRampGradients;
  20072. /** Gets or sets a boolean indicating that ramp gradients must be used
  20073. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20074. */
  20075. useRampGradients: boolean;
  20076. /**
  20077. * 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.
  20078. * 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: [])
  20079. */
  20080. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  20081. private _subEmitters;
  20082. /**
  20083. * @hidden
  20084. * If the particle systems emitter should be disposed when the particle system is disposed
  20085. */
  20086. _disposeEmitterOnDispose: boolean;
  20087. /**
  20088. * The current active Sub-systems, this property is used by the root particle system only.
  20089. */
  20090. activeSubSystems: Array<ParticleSystem>;
  20091. private _rootParticleSystem;
  20092. /**
  20093. * Gets the current list of active particles
  20094. */
  20095. readonly particles: Particle[];
  20096. /**
  20097. * Returns the string "ParticleSystem"
  20098. * @returns a string containing the class name
  20099. */
  20100. getClassName(): string;
  20101. /**
  20102. * Instantiates a particle system.
  20103. * 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.
  20104. * @param name The name of the particle system
  20105. * @param capacity The max number of particles alive at the same time
  20106. * @param scene The scene the particle system belongs to
  20107. * @param customEffect a custom effect used to change the way particles are rendered by default
  20108. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  20109. * @param epsilon Offset used to render the particles
  20110. */
  20111. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  20112. private _addFactorGradient;
  20113. private _removeFactorGradient;
  20114. /**
  20115. * Adds a new life time gradient
  20116. * @param gradient defines the gradient to use (between 0 and 1)
  20117. * @param factor defines the life time factor to affect to the specified gradient
  20118. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20119. * @returns the current particle system
  20120. */
  20121. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20122. /**
  20123. * Remove a specific life time gradient
  20124. * @param gradient defines the gradient to remove
  20125. * @returns the current particle system
  20126. */
  20127. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20128. /**
  20129. * Adds a new size gradient
  20130. * @param gradient defines the gradient to use (between 0 and 1)
  20131. * @param factor defines the size factor to affect to the specified gradient
  20132. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20133. * @returns the current particle system
  20134. */
  20135. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20136. /**
  20137. * Remove a specific size gradient
  20138. * @param gradient defines the gradient to remove
  20139. * @returns the current particle system
  20140. */
  20141. removeSizeGradient(gradient: number): IParticleSystem;
  20142. /**
  20143. * Adds a new color remap gradient
  20144. * @param gradient defines the gradient to use (between 0 and 1)
  20145. * @param min defines the color remap minimal range
  20146. * @param max defines the color remap maximal range
  20147. * @returns the current particle system
  20148. */
  20149. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20150. /**
  20151. * Remove a specific color remap gradient
  20152. * @param gradient defines the gradient to remove
  20153. * @returns the current particle system
  20154. */
  20155. removeColorRemapGradient(gradient: number): IParticleSystem;
  20156. /**
  20157. * Adds a new alpha remap gradient
  20158. * @param gradient defines the gradient to use (between 0 and 1)
  20159. * @param min defines the alpha remap minimal range
  20160. * @param max defines the alpha remap maximal range
  20161. * @returns the current particle system
  20162. */
  20163. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20164. /**
  20165. * Remove a specific alpha remap gradient
  20166. * @param gradient defines the gradient to remove
  20167. * @returns the current particle system
  20168. */
  20169. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  20170. /**
  20171. * Adds a new angular speed gradient
  20172. * @param gradient defines the gradient to use (between 0 and 1)
  20173. * @param factor defines the angular speed to affect to the specified gradient
  20174. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20175. * @returns the current particle system
  20176. */
  20177. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20178. /**
  20179. * Remove a specific angular speed gradient
  20180. * @param gradient defines the gradient to remove
  20181. * @returns the current particle system
  20182. */
  20183. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20184. /**
  20185. * Adds a new velocity gradient
  20186. * @param gradient defines the gradient to use (between 0 and 1)
  20187. * @param factor defines the velocity to affect to the specified gradient
  20188. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20189. * @returns the current particle system
  20190. */
  20191. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20192. /**
  20193. * Remove a specific velocity gradient
  20194. * @param gradient defines the gradient to remove
  20195. * @returns the current particle system
  20196. */
  20197. removeVelocityGradient(gradient: number): IParticleSystem;
  20198. /**
  20199. * Adds a new limit velocity gradient
  20200. * @param gradient defines the gradient to use (between 0 and 1)
  20201. * @param factor defines the limit velocity value to affect to the specified gradient
  20202. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20203. * @returns the current particle system
  20204. */
  20205. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20206. /**
  20207. * Remove a specific limit velocity gradient
  20208. * @param gradient defines the gradient to remove
  20209. * @returns the current particle system
  20210. */
  20211. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20212. /**
  20213. * Adds a new drag gradient
  20214. * @param gradient defines the gradient to use (between 0 and 1)
  20215. * @param factor defines the drag value to affect to the specified gradient
  20216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20217. * @returns the current particle system
  20218. */
  20219. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20220. /**
  20221. * Remove a specific drag gradient
  20222. * @param gradient defines the gradient to remove
  20223. * @returns the current particle system
  20224. */
  20225. removeDragGradient(gradient: number): IParticleSystem;
  20226. /**
  20227. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20228. * @param gradient defines the gradient to use (between 0 and 1)
  20229. * @param factor defines the emit rate value to affect to the specified gradient
  20230. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20231. * @returns the current particle system
  20232. */
  20233. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20234. /**
  20235. * Remove a specific emit rate gradient
  20236. * @param gradient defines the gradient to remove
  20237. * @returns the current particle system
  20238. */
  20239. removeEmitRateGradient(gradient: number): IParticleSystem;
  20240. /**
  20241. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20242. * @param gradient defines the gradient to use (between 0 and 1)
  20243. * @param factor defines the start size value to affect to the specified gradient
  20244. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20245. * @returns the current particle system
  20246. */
  20247. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20248. /**
  20249. * Remove a specific start size gradient
  20250. * @param gradient defines the gradient to remove
  20251. * @returns the current particle system
  20252. */
  20253. removeStartSizeGradient(gradient: number): IParticleSystem;
  20254. private _createRampGradientTexture;
  20255. /**
  20256. * Gets the current list of ramp gradients.
  20257. * You must use addRampGradient and removeRampGradient to udpate this list
  20258. * @returns the list of ramp gradients
  20259. */
  20260. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20261. /**
  20262. * Adds a new ramp gradient used to remap particle colors
  20263. * @param gradient defines the gradient to use (between 0 and 1)
  20264. * @param color defines the color to affect to the specified gradient
  20265. * @returns the current particle system
  20266. */
  20267. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  20268. /**
  20269. * Remove a specific ramp gradient
  20270. * @param gradient defines the gradient to remove
  20271. * @returns the current particle system
  20272. */
  20273. removeRampGradient(gradient: number): ParticleSystem;
  20274. /**
  20275. * Adds a new color gradient
  20276. * @param gradient defines the gradient to use (between 0 and 1)
  20277. * @param color1 defines the color to affect to the specified gradient
  20278. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20279. * @returns this particle system
  20280. */
  20281. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20282. /**
  20283. * Remove a specific color gradient
  20284. * @param gradient defines the gradient to remove
  20285. * @returns this particle system
  20286. */
  20287. removeColorGradient(gradient: number): IParticleSystem;
  20288. private _fetchR;
  20289. protected _reset(): void;
  20290. private _resetEffect;
  20291. private _createVertexBuffers;
  20292. private _createIndexBuffer;
  20293. /**
  20294. * Gets the maximum number of particles active at the same time.
  20295. * @returns The max number of active particles.
  20296. */
  20297. getCapacity(): number;
  20298. /**
  20299. * Gets whether there are still active particles in the system.
  20300. * @returns True if it is alive, otherwise false.
  20301. */
  20302. isAlive(): boolean;
  20303. /**
  20304. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20305. * @returns True if it has been started, otherwise false.
  20306. */
  20307. isStarted(): boolean;
  20308. private _prepareSubEmitterInternalArray;
  20309. /**
  20310. * Starts the particle system and begins to emit
  20311. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  20312. */
  20313. start(delay?: number): void;
  20314. /**
  20315. * Stops the particle system.
  20316. * @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.
  20317. */
  20318. stop(stopSubEmitters?: boolean): void;
  20319. /**
  20320. * Remove all active particles
  20321. */
  20322. reset(): void;
  20323. /**
  20324. * @hidden (for internal use only)
  20325. */
  20326. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20327. /**
  20328. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  20329. * Its lifetime will start back at 0.
  20330. */
  20331. recycleParticle: (particle: Particle) => void;
  20332. private _stopSubEmitters;
  20333. private _createParticle;
  20334. private _removeFromRoot;
  20335. private _emitFromParticle;
  20336. private _update;
  20337. /** @hidden */
  20338. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  20339. /** @hidden */
  20340. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  20341. /** @hidden */
  20342. private _getEffect;
  20343. /**
  20344. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20345. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  20346. */
  20347. animate(preWarmOnly?: boolean): void;
  20348. private _appendParticleVertices;
  20349. /**
  20350. * Rebuilds the particle system.
  20351. */
  20352. rebuild(): void;
  20353. /**
  20354. * Is this system ready to be used/rendered
  20355. * @return true if the system is ready
  20356. */
  20357. isReady(): boolean;
  20358. private _render;
  20359. /**
  20360. * Renders the particle system in its current state.
  20361. * @returns the current number of particles
  20362. */
  20363. render(): number;
  20364. /**
  20365. * Disposes the particle system and free the associated resources
  20366. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20367. */
  20368. dispose(disposeTexture?: boolean): void;
  20369. /**
  20370. * Clones the particle system.
  20371. * @param name The name of the cloned object
  20372. * @param newEmitter The new emitter to use
  20373. * @returns the cloned particle system
  20374. */
  20375. clone(name: string, newEmitter: any): ParticleSystem;
  20376. /**
  20377. * Serializes the particle system to a JSON object.
  20378. * @returns the JSON object
  20379. */
  20380. serialize(): any;
  20381. /** @hidden */
  20382. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20383. /** @hidden */
  20384. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20385. /**
  20386. * Parses a JSON object to create a particle system.
  20387. * @param parsedParticleSystem The JSON object to parse
  20388. * @param scene The scene to create the particle system in
  20389. * @param rootUrl The root url to use to load external dependencies like texture
  20390. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  20391. * @returns the Parsed particle system
  20392. */
  20393. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  20394. }
  20395. }
  20396. declare module "babylonjs/Particles/particle" {
  20397. import { Nullable } from "babylonjs/types";
  20398. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  20399. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  20400. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20401. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  20402. /**
  20403. * A particle represents one of the element emitted by a particle system.
  20404. * This is mainly define by its coordinates, direction, velocity and age.
  20405. */
  20406. export class Particle {
  20407. /**
  20408. * The particle system the particle belongs to.
  20409. */
  20410. particleSystem: ParticleSystem;
  20411. private static _Count;
  20412. /**
  20413. * Unique ID of the particle
  20414. */
  20415. id: number;
  20416. /**
  20417. * The world position of the particle in the scene.
  20418. */
  20419. position: Vector3;
  20420. /**
  20421. * The world direction of the particle in the scene.
  20422. */
  20423. direction: Vector3;
  20424. /**
  20425. * The color of the particle.
  20426. */
  20427. color: Color4;
  20428. /**
  20429. * The color change of the particle per step.
  20430. */
  20431. colorStep: Color4;
  20432. /**
  20433. * Defines how long will the life of the particle be.
  20434. */
  20435. lifeTime: number;
  20436. /**
  20437. * The current age of the particle.
  20438. */
  20439. age: number;
  20440. /**
  20441. * The current size of the particle.
  20442. */
  20443. size: number;
  20444. /**
  20445. * The current scale of the particle.
  20446. */
  20447. scale: Vector2;
  20448. /**
  20449. * The current angle of the particle.
  20450. */
  20451. angle: number;
  20452. /**
  20453. * Defines how fast is the angle changing.
  20454. */
  20455. angularSpeed: number;
  20456. /**
  20457. * Defines the cell index used by the particle to be rendered from a sprite.
  20458. */
  20459. cellIndex: number;
  20460. /**
  20461. * The information required to support color remapping
  20462. */
  20463. remapData: Vector4;
  20464. /** @hidden */
  20465. _randomCellOffset?: number;
  20466. /** @hidden */
  20467. _initialDirection: Nullable<Vector3>;
  20468. /** @hidden */
  20469. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20470. /** @hidden */
  20471. _initialStartSpriteCellID: number;
  20472. /** @hidden */
  20473. _initialEndSpriteCellID: number;
  20474. /** @hidden */
  20475. _currentColorGradient: Nullable<ColorGradient>;
  20476. /** @hidden */
  20477. _currentColor1: Color4;
  20478. /** @hidden */
  20479. _currentColor2: Color4;
  20480. /** @hidden */
  20481. _currentSizeGradient: Nullable<FactorGradient>;
  20482. /** @hidden */
  20483. _currentSize1: number;
  20484. /** @hidden */
  20485. _currentSize2: number;
  20486. /** @hidden */
  20487. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20488. /** @hidden */
  20489. _currentAngularSpeed1: number;
  20490. /** @hidden */
  20491. _currentAngularSpeed2: number;
  20492. /** @hidden */
  20493. _currentVelocityGradient: Nullable<FactorGradient>;
  20494. /** @hidden */
  20495. _currentVelocity1: number;
  20496. /** @hidden */
  20497. _currentVelocity2: number;
  20498. /** @hidden */
  20499. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20500. /** @hidden */
  20501. _currentLimitVelocity1: number;
  20502. /** @hidden */
  20503. _currentLimitVelocity2: number;
  20504. /** @hidden */
  20505. _currentDragGradient: Nullable<FactorGradient>;
  20506. /** @hidden */
  20507. _currentDrag1: number;
  20508. /** @hidden */
  20509. _currentDrag2: number;
  20510. /** @hidden */
  20511. _randomNoiseCoordinates1: Vector3;
  20512. /** @hidden */
  20513. _randomNoiseCoordinates2: Vector3;
  20514. /**
  20515. * Creates a new instance Particle
  20516. * @param particleSystem the particle system the particle belongs to
  20517. */
  20518. constructor(
  20519. /**
  20520. * The particle system the particle belongs to.
  20521. */
  20522. particleSystem: ParticleSystem);
  20523. private updateCellInfoFromSystem;
  20524. /**
  20525. * Defines how the sprite cell index is updated for the particle
  20526. */
  20527. updateCellIndex(): void;
  20528. /** @hidden */
  20529. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20530. /** @hidden */
  20531. _inheritParticleInfoToSubEmitters(): void;
  20532. /** @hidden */
  20533. _reset(): void;
  20534. /**
  20535. * Copy the properties of particle to another one.
  20536. * @param other the particle to copy the information to.
  20537. */
  20538. copyTo(other: Particle): void;
  20539. }
  20540. }
  20541. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  20542. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20543. import { Effect } from "babylonjs/Materials/effect";
  20544. import { Particle } from "babylonjs/Particles/particle";
  20545. /**
  20546. * Particle emitter represents a volume emitting particles.
  20547. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20548. */
  20549. export interface IParticleEmitterType {
  20550. /**
  20551. * Called by the particle System when the direction is computed for the created particle.
  20552. * @param worldMatrix is the world matrix of the particle system
  20553. * @param directionToUpdate is the direction vector to update with the result
  20554. * @param particle is the particle we are computed the direction for
  20555. */
  20556. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20557. /**
  20558. * Called by the particle System when the position is computed for the created particle.
  20559. * @param worldMatrix is the world matrix of the particle system
  20560. * @param positionToUpdate is the position vector to update with the result
  20561. * @param particle is the particle we are computed the position for
  20562. */
  20563. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20564. /**
  20565. * Clones the current emitter and returns a copy of it
  20566. * @returns the new emitter
  20567. */
  20568. clone(): IParticleEmitterType;
  20569. /**
  20570. * Called by the GPUParticleSystem to setup the update shader
  20571. * @param effect defines the update shader
  20572. */
  20573. applyToShader(effect: Effect): void;
  20574. /**
  20575. * Returns a string to use to update the GPU particles update shader
  20576. * @returns the effect defines string
  20577. */
  20578. getEffectDefines(): string;
  20579. /**
  20580. * Returns a string representing the class name
  20581. * @returns a string containing the class name
  20582. */
  20583. getClassName(): string;
  20584. /**
  20585. * Serializes the particle system to a JSON object.
  20586. * @returns the JSON object
  20587. */
  20588. serialize(): any;
  20589. /**
  20590. * Parse properties from a JSON object
  20591. * @param serializationObject defines the JSON object
  20592. */
  20593. parse(serializationObject: any): void;
  20594. }
  20595. }
  20596. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  20597. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20598. import { Effect } from "babylonjs/Materials/effect";
  20599. import { Particle } from "babylonjs/Particles/particle";
  20600. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20601. /**
  20602. * Particle emitter emitting particles from the inside of a box.
  20603. * It emits the particles randomly between 2 given directions.
  20604. */
  20605. export class BoxParticleEmitter implements IParticleEmitterType {
  20606. /**
  20607. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20608. */
  20609. direction1: Vector3;
  20610. /**
  20611. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20612. */
  20613. direction2: Vector3;
  20614. /**
  20615. * 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.
  20616. */
  20617. minEmitBox: Vector3;
  20618. /**
  20619. * 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.
  20620. */
  20621. maxEmitBox: Vector3;
  20622. /**
  20623. * Creates a new instance BoxParticleEmitter
  20624. */
  20625. constructor();
  20626. /**
  20627. * Called by the particle System when the direction is computed for the created particle.
  20628. * @param worldMatrix is the world matrix of the particle system
  20629. * @param directionToUpdate is the direction vector to update with the result
  20630. * @param particle is the particle we are computed the direction for
  20631. */
  20632. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20633. /**
  20634. * Called by the particle System when the position is computed for the created particle.
  20635. * @param worldMatrix is the world matrix of the particle system
  20636. * @param positionToUpdate is the position vector to update with the result
  20637. * @param particle is the particle we are computed the position for
  20638. */
  20639. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20640. /**
  20641. * Clones the current emitter and returns a copy of it
  20642. * @returns the new emitter
  20643. */
  20644. clone(): BoxParticleEmitter;
  20645. /**
  20646. * Called by the GPUParticleSystem to setup the update shader
  20647. * @param effect defines the update shader
  20648. */
  20649. applyToShader(effect: Effect): void;
  20650. /**
  20651. * Returns a string to use to update the GPU particles update shader
  20652. * @returns a string containng the defines string
  20653. */
  20654. getEffectDefines(): string;
  20655. /**
  20656. * Returns the string "BoxParticleEmitter"
  20657. * @returns a string containing the class name
  20658. */
  20659. getClassName(): string;
  20660. /**
  20661. * Serializes the particle system to a JSON object.
  20662. * @returns the JSON object
  20663. */
  20664. serialize(): any;
  20665. /**
  20666. * Parse properties from a JSON object
  20667. * @param serializationObject defines the JSON object
  20668. */
  20669. parse(serializationObject: any): void;
  20670. }
  20671. }
  20672. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  20673. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20674. import { Effect } from "babylonjs/Materials/effect";
  20675. import { Particle } from "babylonjs/Particles/particle";
  20676. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20677. /**
  20678. * Particle emitter emitting particles from the inside of a cone.
  20679. * It emits the particles alongside the cone volume from the base to the particle.
  20680. * The emission direction might be randomized.
  20681. */
  20682. export class ConeParticleEmitter implements IParticleEmitterType {
  20683. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20684. directionRandomizer: number;
  20685. private _radius;
  20686. private _angle;
  20687. private _height;
  20688. /**
  20689. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20690. */
  20691. radiusRange: number;
  20692. /**
  20693. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20694. */
  20695. heightRange: number;
  20696. /**
  20697. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20698. */
  20699. emitFromSpawnPointOnly: boolean;
  20700. /**
  20701. * Gets or sets the radius of the emission cone
  20702. */
  20703. radius: number;
  20704. /**
  20705. * Gets or sets the angle of the emission cone
  20706. */
  20707. angle: number;
  20708. private _buildHeight;
  20709. /**
  20710. * Creates a new instance ConeParticleEmitter
  20711. * @param radius the radius of the emission cone (1 by default)
  20712. * @param angle the cone base angle (PI by default)
  20713. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20714. */
  20715. constructor(radius?: number, angle?: number,
  20716. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20717. directionRandomizer?: number);
  20718. /**
  20719. * Called by the particle System when the direction is computed for the created particle.
  20720. * @param worldMatrix is the world matrix of the particle system
  20721. * @param directionToUpdate is the direction vector to update with the result
  20722. * @param particle is the particle we are computed the direction for
  20723. */
  20724. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20725. /**
  20726. * Called by the particle System when the position is computed for the created particle.
  20727. * @param worldMatrix is the world matrix of the particle system
  20728. * @param positionToUpdate is the position vector to update with the result
  20729. * @param particle is the particle we are computed the position for
  20730. */
  20731. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20732. /**
  20733. * Clones the current emitter and returns a copy of it
  20734. * @returns the new emitter
  20735. */
  20736. clone(): ConeParticleEmitter;
  20737. /**
  20738. * Called by the GPUParticleSystem to setup the update shader
  20739. * @param effect defines the update shader
  20740. */
  20741. applyToShader(effect: Effect): void;
  20742. /**
  20743. * Returns a string to use to update the GPU particles update shader
  20744. * @returns a string containng the defines string
  20745. */
  20746. getEffectDefines(): string;
  20747. /**
  20748. * Returns the string "ConeParticleEmitter"
  20749. * @returns a string containing the class name
  20750. */
  20751. getClassName(): string;
  20752. /**
  20753. * Serializes the particle system to a JSON object.
  20754. * @returns the JSON object
  20755. */
  20756. serialize(): any;
  20757. /**
  20758. * Parse properties from a JSON object
  20759. * @param serializationObject defines the JSON object
  20760. */
  20761. parse(serializationObject: any): void;
  20762. }
  20763. }
  20764. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  20765. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20766. import { Effect } from "babylonjs/Materials/effect";
  20767. import { Particle } from "babylonjs/Particles/particle";
  20768. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20769. /**
  20770. * Particle emitter emitting particles from the inside of a cylinder.
  20771. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20772. */
  20773. export class CylinderParticleEmitter implements IParticleEmitterType {
  20774. /**
  20775. * The radius of the emission cylinder.
  20776. */
  20777. radius: number;
  20778. /**
  20779. * The height of the emission cylinder.
  20780. */
  20781. height: number;
  20782. /**
  20783. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20784. */
  20785. radiusRange: number;
  20786. /**
  20787. * How much to randomize the particle direction [0-1].
  20788. */
  20789. directionRandomizer: number;
  20790. /**
  20791. * Creates a new instance CylinderParticleEmitter
  20792. * @param radius the radius of the emission cylinder (1 by default)
  20793. * @param height the height of the emission cylinder (1 by default)
  20794. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20795. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20796. */
  20797. constructor(
  20798. /**
  20799. * The radius of the emission cylinder.
  20800. */
  20801. radius?: number,
  20802. /**
  20803. * The height of the emission cylinder.
  20804. */
  20805. height?: number,
  20806. /**
  20807. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20808. */
  20809. radiusRange?: number,
  20810. /**
  20811. * How much to randomize the particle direction [0-1].
  20812. */
  20813. directionRandomizer?: number);
  20814. /**
  20815. * Called by the particle System when the direction is computed for the created particle.
  20816. * @param worldMatrix is the world matrix of the particle system
  20817. * @param directionToUpdate is the direction vector to update with the result
  20818. * @param particle is the particle we are computed the direction for
  20819. */
  20820. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20821. /**
  20822. * Called by the particle System when the position is computed for the created particle.
  20823. * @param worldMatrix is the world matrix of the particle system
  20824. * @param positionToUpdate is the position vector to update with the result
  20825. * @param particle is the particle we are computed the position for
  20826. */
  20827. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20828. /**
  20829. * Clones the current emitter and returns a copy of it
  20830. * @returns the new emitter
  20831. */
  20832. clone(): CylinderParticleEmitter;
  20833. /**
  20834. * Called by the GPUParticleSystem to setup the update shader
  20835. * @param effect defines the update shader
  20836. */
  20837. applyToShader(effect: Effect): void;
  20838. /**
  20839. * Returns a string to use to update the GPU particles update shader
  20840. * @returns a string containng the defines string
  20841. */
  20842. getEffectDefines(): string;
  20843. /**
  20844. * Returns the string "CylinderParticleEmitter"
  20845. * @returns a string containing the class name
  20846. */
  20847. getClassName(): string;
  20848. /**
  20849. * Serializes the particle system to a JSON object.
  20850. * @returns the JSON object
  20851. */
  20852. serialize(): any;
  20853. /**
  20854. * Parse properties from a JSON object
  20855. * @param serializationObject defines the JSON object
  20856. */
  20857. parse(serializationObject: any): void;
  20858. }
  20859. /**
  20860. * Particle emitter emitting particles from the inside of a cylinder.
  20861. * It emits the particles randomly between two vectors.
  20862. */
  20863. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20864. /**
  20865. * The min limit of the emission direction.
  20866. */
  20867. direction1: Vector3;
  20868. /**
  20869. * The max limit of the emission direction.
  20870. */
  20871. direction2: Vector3;
  20872. /**
  20873. * Creates a new instance CylinderDirectedParticleEmitter
  20874. * @param radius the radius of the emission cylinder (1 by default)
  20875. * @param height the height of the emission cylinder (1 by default)
  20876. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20877. * @param direction1 the min limit of the emission direction (up vector by default)
  20878. * @param direction2 the max limit of the emission direction (up vector by default)
  20879. */
  20880. constructor(radius?: number, height?: number, radiusRange?: number,
  20881. /**
  20882. * The min limit of the emission direction.
  20883. */
  20884. direction1?: Vector3,
  20885. /**
  20886. * The max limit of the emission direction.
  20887. */
  20888. direction2?: Vector3);
  20889. /**
  20890. * Called by the particle System when the direction is computed for the created particle.
  20891. * @param worldMatrix is the world matrix of the particle system
  20892. * @param directionToUpdate is the direction vector to update with the result
  20893. * @param particle is the particle we are computed the direction for
  20894. */
  20895. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20896. /**
  20897. * Clones the current emitter and returns a copy of it
  20898. * @returns the new emitter
  20899. */
  20900. clone(): CylinderDirectedParticleEmitter;
  20901. /**
  20902. * Called by the GPUParticleSystem to setup the update shader
  20903. * @param effect defines the update shader
  20904. */
  20905. applyToShader(effect: Effect): void;
  20906. /**
  20907. * Returns a string to use to update the GPU particles update shader
  20908. * @returns a string containng the defines string
  20909. */
  20910. getEffectDefines(): string;
  20911. /**
  20912. * Returns the string "CylinderDirectedParticleEmitter"
  20913. * @returns a string containing the class name
  20914. */
  20915. getClassName(): string;
  20916. /**
  20917. * Serializes the particle system to a JSON object.
  20918. * @returns the JSON object
  20919. */
  20920. serialize(): any;
  20921. /**
  20922. * Parse properties from a JSON object
  20923. * @param serializationObject defines the JSON object
  20924. */
  20925. parse(serializationObject: any): void;
  20926. }
  20927. }
  20928. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  20929. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20930. import { Effect } from "babylonjs/Materials/effect";
  20931. import { Particle } from "babylonjs/Particles/particle";
  20932. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20933. /**
  20934. * Particle emitter emitting particles from the inside of a hemisphere.
  20935. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  20936. */
  20937. export class HemisphericParticleEmitter implements IParticleEmitterType {
  20938. /**
  20939. * The radius of the emission hemisphere.
  20940. */
  20941. radius: number;
  20942. /**
  20943. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20944. */
  20945. radiusRange: number;
  20946. /**
  20947. * How much to randomize the particle direction [0-1].
  20948. */
  20949. directionRandomizer: number;
  20950. /**
  20951. * Creates a new instance HemisphericParticleEmitter
  20952. * @param radius the radius of the emission hemisphere (1 by default)
  20953. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20954. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20955. */
  20956. constructor(
  20957. /**
  20958. * The radius of the emission hemisphere.
  20959. */
  20960. radius?: number,
  20961. /**
  20962. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20963. */
  20964. radiusRange?: number,
  20965. /**
  20966. * How much to randomize the particle direction [0-1].
  20967. */
  20968. directionRandomizer?: number);
  20969. /**
  20970. * Called by the particle System when the direction is computed for the created particle.
  20971. * @param worldMatrix is the world matrix of the particle system
  20972. * @param directionToUpdate is the direction vector to update with the result
  20973. * @param particle is the particle we are computed the direction for
  20974. */
  20975. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20976. /**
  20977. * Called by the particle System when the position is computed for the created particle.
  20978. * @param worldMatrix is the world matrix of the particle system
  20979. * @param positionToUpdate is the position vector to update with the result
  20980. * @param particle is the particle we are computed the position for
  20981. */
  20982. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20983. /**
  20984. * Clones the current emitter and returns a copy of it
  20985. * @returns the new emitter
  20986. */
  20987. clone(): HemisphericParticleEmitter;
  20988. /**
  20989. * Called by the GPUParticleSystem to setup the update shader
  20990. * @param effect defines the update shader
  20991. */
  20992. applyToShader(effect: Effect): void;
  20993. /**
  20994. * Returns a string to use to update the GPU particles update shader
  20995. * @returns a string containng the defines string
  20996. */
  20997. getEffectDefines(): string;
  20998. /**
  20999. * Returns the string "HemisphericParticleEmitter"
  21000. * @returns a string containing the class name
  21001. */
  21002. getClassName(): string;
  21003. /**
  21004. * Serializes the particle system to a JSON object.
  21005. * @returns the JSON object
  21006. */
  21007. serialize(): any;
  21008. /**
  21009. * Parse properties from a JSON object
  21010. * @param serializationObject defines the JSON object
  21011. */
  21012. parse(serializationObject: any): void;
  21013. }
  21014. }
  21015. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  21016. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21017. import { Effect } from "babylonjs/Materials/effect";
  21018. import { Particle } from "babylonjs/Particles/particle";
  21019. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21020. /**
  21021. * Particle emitter emitting particles from a point.
  21022. * It emits the particles randomly between 2 given directions.
  21023. */
  21024. export class PointParticleEmitter implements IParticleEmitterType {
  21025. /**
  21026. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21027. */
  21028. direction1: Vector3;
  21029. /**
  21030. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21031. */
  21032. direction2: Vector3;
  21033. /**
  21034. * Creates a new instance PointParticleEmitter
  21035. */
  21036. constructor();
  21037. /**
  21038. * Called by the particle System when the direction is computed for the created particle.
  21039. * @param worldMatrix is the world matrix of the particle system
  21040. * @param directionToUpdate is the direction vector to update with the result
  21041. * @param particle is the particle we are computed the direction for
  21042. */
  21043. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21044. /**
  21045. * Called by the particle System when the position is computed for the created particle.
  21046. * @param worldMatrix is the world matrix of the particle system
  21047. * @param positionToUpdate is the position vector to update with the result
  21048. * @param particle is the particle we are computed the position for
  21049. */
  21050. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21051. /**
  21052. * Clones the current emitter and returns a copy of it
  21053. * @returns the new emitter
  21054. */
  21055. clone(): PointParticleEmitter;
  21056. /**
  21057. * Called by the GPUParticleSystem to setup the update shader
  21058. * @param effect defines the update shader
  21059. */
  21060. applyToShader(effect: Effect): void;
  21061. /**
  21062. * Returns a string to use to update the GPU particles update shader
  21063. * @returns a string containng the defines string
  21064. */
  21065. getEffectDefines(): string;
  21066. /**
  21067. * Returns the string "PointParticleEmitter"
  21068. * @returns a string containing the class name
  21069. */
  21070. getClassName(): string;
  21071. /**
  21072. * Serializes the particle system to a JSON object.
  21073. * @returns the JSON object
  21074. */
  21075. serialize(): any;
  21076. /**
  21077. * Parse properties from a JSON object
  21078. * @param serializationObject defines the JSON object
  21079. */
  21080. parse(serializationObject: any): void;
  21081. }
  21082. }
  21083. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  21084. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21085. import { Effect } from "babylonjs/Materials/effect";
  21086. import { Particle } from "babylonjs/Particles/particle";
  21087. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21088. /**
  21089. * Particle emitter emitting particles from the inside of a sphere.
  21090. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  21091. */
  21092. export class SphereParticleEmitter implements IParticleEmitterType {
  21093. /**
  21094. * The radius of the emission sphere.
  21095. */
  21096. radius: number;
  21097. /**
  21098. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21099. */
  21100. radiusRange: number;
  21101. /**
  21102. * How much to randomize the particle direction [0-1].
  21103. */
  21104. directionRandomizer: number;
  21105. /**
  21106. * Creates a new instance SphereParticleEmitter
  21107. * @param radius the radius of the emission sphere (1 by default)
  21108. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21109. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21110. */
  21111. constructor(
  21112. /**
  21113. * The radius of the emission sphere.
  21114. */
  21115. radius?: number,
  21116. /**
  21117. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21118. */
  21119. radiusRange?: number,
  21120. /**
  21121. * How much to randomize the particle direction [0-1].
  21122. */
  21123. directionRandomizer?: number);
  21124. /**
  21125. * Called by the particle System when the direction is computed for the created particle.
  21126. * @param worldMatrix is the world matrix of the particle system
  21127. * @param directionToUpdate is the direction vector to update with the result
  21128. * @param particle is the particle we are computed the direction for
  21129. */
  21130. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21131. /**
  21132. * Called by the particle System when the position is computed for the created particle.
  21133. * @param worldMatrix is the world matrix of the particle system
  21134. * @param positionToUpdate is the position vector to update with the result
  21135. * @param particle is the particle we are computed the position for
  21136. */
  21137. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21138. /**
  21139. * Clones the current emitter and returns a copy of it
  21140. * @returns the new emitter
  21141. */
  21142. clone(): SphereParticleEmitter;
  21143. /**
  21144. * Called by the GPUParticleSystem to setup the update shader
  21145. * @param effect defines the update shader
  21146. */
  21147. applyToShader(effect: Effect): void;
  21148. /**
  21149. * Returns a string to use to update the GPU particles update shader
  21150. * @returns a string containng the defines string
  21151. */
  21152. getEffectDefines(): string;
  21153. /**
  21154. * Returns the string "SphereParticleEmitter"
  21155. * @returns a string containing the class name
  21156. */
  21157. getClassName(): string;
  21158. /**
  21159. * Serializes the particle system to a JSON object.
  21160. * @returns the JSON object
  21161. */
  21162. serialize(): any;
  21163. /**
  21164. * Parse properties from a JSON object
  21165. * @param serializationObject defines the JSON object
  21166. */
  21167. parse(serializationObject: any): void;
  21168. }
  21169. /**
  21170. * Particle emitter emitting particles from the inside of a sphere.
  21171. * It emits the particles randomly between two vectors.
  21172. */
  21173. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  21174. /**
  21175. * The min limit of the emission direction.
  21176. */
  21177. direction1: Vector3;
  21178. /**
  21179. * The max limit of the emission direction.
  21180. */
  21181. direction2: Vector3;
  21182. /**
  21183. * Creates a new instance SphereDirectedParticleEmitter
  21184. * @param radius the radius of the emission sphere (1 by default)
  21185. * @param direction1 the min limit of the emission direction (up vector by default)
  21186. * @param direction2 the max limit of the emission direction (up vector by default)
  21187. */
  21188. constructor(radius?: number,
  21189. /**
  21190. * The min limit of the emission direction.
  21191. */
  21192. direction1?: Vector3,
  21193. /**
  21194. * The max limit of the emission direction.
  21195. */
  21196. direction2?: Vector3);
  21197. /**
  21198. * Called by the particle System when the direction is computed for the created particle.
  21199. * @param worldMatrix is the world matrix of the particle system
  21200. * @param directionToUpdate is the direction vector to update with the result
  21201. * @param particle is the particle we are computed the direction for
  21202. */
  21203. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21204. /**
  21205. * Clones the current emitter and returns a copy of it
  21206. * @returns the new emitter
  21207. */
  21208. clone(): SphereDirectedParticleEmitter;
  21209. /**
  21210. * Called by the GPUParticleSystem to setup the update shader
  21211. * @param effect defines the update shader
  21212. */
  21213. applyToShader(effect: Effect): void;
  21214. /**
  21215. * Returns a string to use to update the GPU particles update shader
  21216. * @returns a string containng the defines string
  21217. */
  21218. getEffectDefines(): string;
  21219. /**
  21220. * Returns the string "SphereDirectedParticleEmitter"
  21221. * @returns a string containing the class name
  21222. */
  21223. getClassName(): string;
  21224. /**
  21225. * Serializes the particle system to a JSON object.
  21226. * @returns the JSON object
  21227. */
  21228. serialize(): any;
  21229. /**
  21230. * Parse properties from a JSON object
  21231. * @param serializationObject defines the JSON object
  21232. */
  21233. parse(serializationObject: any): void;
  21234. }
  21235. }
  21236. declare module "babylonjs/Particles/EmitterTypes/index" {
  21237. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  21238. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  21239. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  21240. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  21241. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21242. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  21243. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  21244. }
  21245. declare module "babylonjs/Particles/IParticleSystem" {
  21246. import { Nullable } from "babylonjs/types";
  21247. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  21248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21249. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21250. import { Texture } from "babylonjs/Materials/Textures/texture";
  21251. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  21252. import { Scene } from "babylonjs/scene";
  21253. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  21254. import { Animation } from "babylonjs/Animations/animation";
  21255. /**
  21256. * Interface representing a particle system in Babylon.js.
  21257. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  21258. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  21259. */
  21260. export interface IParticleSystem {
  21261. /**
  21262. * List of animations used by the particle system.
  21263. */
  21264. animations: Animation[];
  21265. /**
  21266. * The id of the Particle system.
  21267. */
  21268. id: string;
  21269. /**
  21270. * The name of the Particle system.
  21271. */
  21272. name: string;
  21273. /**
  21274. * The emitter represents the Mesh or position we are attaching the particle system to.
  21275. */
  21276. emitter: Nullable<AbstractMesh | Vector3>;
  21277. /**
  21278. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  21279. */
  21280. isBillboardBased: boolean;
  21281. /**
  21282. * The rendering group used by the Particle system to chose when to render.
  21283. */
  21284. renderingGroupId: number;
  21285. /**
  21286. * The layer mask we are rendering the particles through.
  21287. */
  21288. layerMask: number;
  21289. /**
  21290. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  21291. */
  21292. updateSpeed: number;
  21293. /**
  21294. * The amount of time the particle system is running (depends of the overall update speed).
  21295. */
  21296. targetStopDuration: number;
  21297. /**
  21298. * The texture used to render each particle. (this can be a spritesheet)
  21299. */
  21300. particleTexture: Nullable<Texture>;
  21301. /**
  21302. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  21303. */
  21304. blendMode: number;
  21305. /**
  21306. * Minimum life time of emitting particles.
  21307. */
  21308. minLifeTime: number;
  21309. /**
  21310. * Maximum life time of emitting particles.
  21311. */
  21312. maxLifeTime: number;
  21313. /**
  21314. * Minimum Size of emitting particles.
  21315. */
  21316. minSize: number;
  21317. /**
  21318. * Maximum Size of emitting particles.
  21319. */
  21320. maxSize: number;
  21321. /**
  21322. * Minimum scale of emitting particles on X axis.
  21323. */
  21324. minScaleX: number;
  21325. /**
  21326. * Maximum scale of emitting particles on X axis.
  21327. */
  21328. maxScaleX: number;
  21329. /**
  21330. * Minimum scale of emitting particles on Y axis.
  21331. */
  21332. minScaleY: number;
  21333. /**
  21334. * Maximum scale of emitting particles on Y axis.
  21335. */
  21336. maxScaleY: number;
  21337. /**
  21338. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21339. */
  21340. color1: Color4;
  21341. /**
  21342. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21343. */
  21344. color2: Color4;
  21345. /**
  21346. * Color the particle will have at the end of its lifetime.
  21347. */
  21348. colorDead: Color4;
  21349. /**
  21350. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  21351. */
  21352. emitRate: number;
  21353. /**
  21354. * You can use gravity if you want to give an orientation to your particles.
  21355. */
  21356. gravity: Vector3;
  21357. /**
  21358. * Minimum power of emitting particles.
  21359. */
  21360. minEmitPower: number;
  21361. /**
  21362. * Maximum power of emitting particles.
  21363. */
  21364. maxEmitPower: number;
  21365. /**
  21366. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  21367. */
  21368. minAngularSpeed: number;
  21369. /**
  21370. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  21371. */
  21372. maxAngularSpeed: number;
  21373. /**
  21374. * Gets or sets the minimal initial rotation in radians.
  21375. */
  21376. minInitialRotation: number;
  21377. /**
  21378. * Gets or sets the maximal initial rotation in radians.
  21379. */
  21380. maxInitialRotation: number;
  21381. /**
  21382. * The particle emitter type defines the emitter used by the particle system.
  21383. * It can be for example box, sphere, or cone...
  21384. */
  21385. particleEmitterType: Nullable<IParticleEmitterType>;
  21386. /**
  21387. * Defines the delay in milliseconds before starting the system (0 by default)
  21388. */
  21389. startDelay: number;
  21390. /**
  21391. * 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
  21392. */
  21393. preWarmCycles: number;
  21394. /**
  21395. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  21396. */
  21397. preWarmStepOffset: number;
  21398. /**
  21399. * 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)
  21400. */
  21401. spriteCellChangeSpeed: number;
  21402. /**
  21403. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  21404. */
  21405. startSpriteCellID: number;
  21406. /**
  21407. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  21408. */
  21409. endSpriteCellID: number;
  21410. /**
  21411. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  21412. */
  21413. spriteCellWidth: number;
  21414. /**
  21415. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  21416. */
  21417. spriteCellHeight: number;
  21418. /**
  21419. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  21420. */
  21421. spriteRandomStartCell: boolean;
  21422. /**
  21423. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  21424. */
  21425. isAnimationSheetEnabled: boolean;
  21426. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  21427. translationPivot: Vector2;
  21428. /**
  21429. * Gets or sets a texture used to add random noise to particle positions
  21430. */
  21431. noiseTexture: Nullable<BaseTexture>;
  21432. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21433. noiseStrength: Vector3;
  21434. /**
  21435. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21436. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  21437. */
  21438. billboardMode: number;
  21439. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21440. limitVelocityDamping: number;
  21441. /**
  21442. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  21443. */
  21444. beginAnimationOnStart: boolean;
  21445. /**
  21446. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21447. */
  21448. beginAnimationFrom: number;
  21449. /**
  21450. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21451. */
  21452. beginAnimationTo: number;
  21453. /**
  21454. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21455. */
  21456. beginAnimationLoop: boolean;
  21457. /**
  21458. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21459. */
  21460. disposeOnStop: boolean;
  21461. /**
  21462. * Gets the maximum number of particles active at the same time.
  21463. * @returns The max number of active particles.
  21464. */
  21465. getCapacity(): number;
  21466. /**
  21467. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21468. * @returns True if it has been started, otherwise false.
  21469. */
  21470. isStarted(): boolean;
  21471. /**
  21472. * Animates the particle system for this frame.
  21473. */
  21474. animate(): void;
  21475. /**
  21476. * Renders the particle system in its current state.
  21477. * @returns the current number of particles
  21478. */
  21479. render(): number;
  21480. /**
  21481. * Dispose the particle system and frees its associated resources.
  21482. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21483. */
  21484. dispose(disposeTexture?: boolean): void;
  21485. /**
  21486. * Clones the particle system.
  21487. * @param name The name of the cloned object
  21488. * @param newEmitter The new emitter to use
  21489. * @returns the cloned particle system
  21490. */
  21491. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21492. /**
  21493. * Serializes the particle system to a JSON object.
  21494. * @returns the JSON object
  21495. */
  21496. serialize(): any;
  21497. /**
  21498. * Rebuild the particle system
  21499. */
  21500. rebuild(): void;
  21501. /**
  21502. * Starts the particle system and begins to emit
  21503. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21504. */
  21505. start(delay?: number): void;
  21506. /**
  21507. * Stops the particle system.
  21508. */
  21509. stop(): void;
  21510. /**
  21511. * Remove all active particles
  21512. */
  21513. reset(): void;
  21514. /**
  21515. * Is this system ready to be used/rendered
  21516. * @return true if the system is ready
  21517. */
  21518. isReady(): boolean;
  21519. /**
  21520. * Adds a new color gradient
  21521. * @param gradient defines the gradient to use (between 0 and 1)
  21522. * @param color1 defines the color to affect to the specified gradient
  21523. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21524. * @returns the current particle system
  21525. */
  21526. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21527. /**
  21528. * Remove a specific color gradient
  21529. * @param gradient defines the gradient to remove
  21530. * @returns the current particle system
  21531. */
  21532. removeColorGradient(gradient: number): IParticleSystem;
  21533. /**
  21534. * Adds a new size gradient
  21535. * @param gradient defines the gradient to use (between 0 and 1)
  21536. * @param factor defines the size factor to affect to the specified gradient
  21537. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21538. * @returns the current particle system
  21539. */
  21540. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21541. /**
  21542. * Remove a specific size gradient
  21543. * @param gradient defines the gradient to remove
  21544. * @returns the current particle system
  21545. */
  21546. removeSizeGradient(gradient: number): IParticleSystem;
  21547. /**
  21548. * Gets the current list of color gradients.
  21549. * You must use addColorGradient and removeColorGradient to udpate this list
  21550. * @returns the list of color gradients
  21551. */
  21552. getColorGradients(): Nullable<Array<ColorGradient>>;
  21553. /**
  21554. * Gets the current list of size gradients.
  21555. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21556. * @returns the list of size gradients
  21557. */
  21558. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21559. /**
  21560. * Gets the current list of angular speed gradients.
  21561. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21562. * @returns the list of angular speed gradients
  21563. */
  21564. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21565. /**
  21566. * Adds a new angular speed gradient
  21567. * @param gradient defines the gradient to use (between 0 and 1)
  21568. * @param factor defines the angular speed to affect to the specified gradient
  21569. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21570. * @returns the current particle system
  21571. */
  21572. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21573. /**
  21574. * Remove a specific angular speed gradient
  21575. * @param gradient defines the gradient to remove
  21576. * @returns the current particle system
  21577. */
  21578. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21579. /**
  21580. * Gets the current list of velocity gradients.
  21581. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21582. * @returns the list of velocity gradients
  21583. */
  21584. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21585. /**
  21586. * Adds a new velocity gradient
  21587. * @param gradient defines the gradient to use (between 0 and 1)
  21588. * @param factor defines the velocity to affect to the specified gradient
  21589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21590. * @returns the current particle system
  21591. */
  21592. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21593. /**
  21594. * Remove a specific velocity gradient
  21595. * @param gradient defines the gradient to remove
  21596. * @returns the current particle system
  21597. */
  21598. removeVelocityGradient(gradient: number): IParticleSystem;
  21599. /**
  21600. * Gets the current list of limit velocity gradients.
  21601. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21602. * @returns the list of limit velocity gradients
  21603. */
  21604. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21605. /**
  21606. * Adds a new limit velocity gradient
  21607. * @param gradient defines the gradient to use (between 0 and 1)
  21608. * @param factor defines the limit velocity to affect to the specified gradient
  21609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21610. * @returns the current particle system
  21611. */
  21612. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21613. /**
  21614. * Remove a specific limit velocity gradient
  21615. * @param gradient defines the gradient to remove
  21616. * @returns the current particle system
  21617. */
  21618. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21619. /**
  21620. * Adds a new drag gradient
  21621. * @param gradient defines the gradient to use (between 0 and 1)
  21622. * @param factor defines the drag to affect to the specified gradient
  21623. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21624. * @returns the current particle system
  21625. */
  21626. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21627. /**
  21628. * Remove a specific drag gradient
  21629. * @param gradient defines the gradient to remove
  21630. * @returns the current particle system
  21631. */
  21632. removeDragGradient(gradient: number): IParticleSystem;
  21633. /**
  21634. * Gets the current list of drag gradients.
  21635. * You must use addDragGradient and removeDragGradient to udpate this list
  21636. * @returns the list of drag gradients
  21637. */
  21638. getDragGradients(): Nullable<Array<FactorGradient>>;
  21639. /**
  21640. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21641. * @param gradient defines the gradient to use (between 0 and 1)
  21642. * @param factor defines the emit rate to affect to the specified gradient
  21643. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21644. * @returns the current particle system
  21645. */
  21646. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21647. /**
  21648. * Remove a specific emit rate gradient
  21649. * @param gradient defines the gradient to remove
  21650. * @returns the current particle system
  21651. */
  21652. removeEmitRateGradient(gradient: number): IParticleSystem;
  21653. /**
  21654. * Gets the current list of emit rate gradients.
  21655. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21656. * @returns the list of emit rate gradients
  21657. */
  21658. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21659. /**
  21660. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21661. * @param gradient defines the gradient to use (between 0 and 1)
  21662. * @param factor defines the start size to affect to the specified gradient
  21663. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21664. * @returns the current particle system
  21665. */
  21666. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21667. /**
  21668. * Remove a specific start size gradient
  21669. * @param gradient defines the gradient to remove
  21670. * @returns the current particle system
  21671. */
  21672. removeStartSizeGradient(gradient: number): IParticleSystem;
  21673. /**
  21674. * Gets the current list of start size gradients.
  21675. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21676. * @returns the list of start size gradients
  21677. */
  21678. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21679. /**
  21680. * Adds a new life time gradient
  21681. * @param gradient defines the gradient to use (between 0 and 1)
  21682. * @param factor defines the life time factor to affect to the specified gradient
  21683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21684. * @returns the current particle system
  21685. */
  21686. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21687. /**
  21688. * Remove a specific life time gradient
  21689. * @param gradient defines the gradient to remove
  21690. * @returns the current particle system
  21691. */
  21692. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21693. /**
  21694. * Gets the current list of life time gradients.
  21695. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21696. * @returns the list of life time gradients
  21697. */
  21698. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21699. /**
  21700. * Gets the current list of color gradients.
  21701. * You must use addColorGradient and removeColorGradient to udpate this list
  21702. * @returns the list of color gradients
  21703. */
  21704. getColorGradients(): Nullable<Array<ColorGradient>>;
  21705. /**
  21706. * Adds a new ramp gradient used to remap particle colors
  21707. * @param gradient defines the gradient to use (between 0 and 1)
  21708. * @param color defines the color to affect to the specified gradient
  21709. * @returns the current particle system
  21710. */
  21711. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21712. /**
  21713. * Gets the current list of ramp gradients.
  21714. * You must use addRampGradient and removeRampGradient to udpate this list
  21715. * @returns the list of ramp gradients
  21716. */
  21717. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21718. /** Gets or sets a boolean indicating that ramp gradients must be used
  21719. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21720. */
  21721. useRampGradients: boolean;
  21722. /**
  21723. * Adds a new color remap gradient
  21724. * @param gradient defines the gradient to use (between 0 and 1)
  21725. * @param min defines the color remap minimal range
  21726. * @param max defines the color remap maximal range
  21727. * @returns the current particle system
  21728. */
  21729. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21730. /**
  21731. * Gets the current list of color remap gradients.
  21732. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21733. * @returns the list of color remap gradients
  21734. */
  21735. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21736. /**
  21737. * Adds a new alpha remap gradient
  21738. * @param gradient defines the gradient to use (between 0 and 1)
  21739. * @param min defines the alpha remap minimal range
  21740. * @param max defines the alpha remap maximal range
  21741. * @returns the current particle system
  21742. */
  21743. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21744. /**
  21745. * Gets the current list of alpha remap gradients.
  21746. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21747. * @returns the list of alpha remap gradients
  21748. */
  21749. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21750. /**
  21751. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21752. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21753. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21754. * @returns the emitter
  21755. */
  21756. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21757. /**
  21758. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21759. * @param radius The radius of the hemisphere to emit from
  21760. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21761. * @returns the emitter
  21762. */
  21763. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21764. /**
  21765. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21766. * @param radius The radius of the sphere to emit from
  21767. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21768. * @returns the emitter
  21769. */
  21770. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21771. /**
  21772. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21773. * @param radius The radius of the sphere to emit from
  21774. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21775. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21776. * @returns the emitter
  21777. */
  21778. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21779. /**
  21780. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21781. * @param radius The radius of the emission cylinder
  21782. * @param height The height of the emission cylinder
  21783. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21784. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21785. * @returns the emitter
  21786. */
  21787. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21788. /**
  21789. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21790. * @param radius The radius of the cylinder to emit from
  21791. * @param height The height of the emission cylinder
  21792. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21793. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21794. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21795. * @returns the emitter
  21796. */
  21797. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21798. /**
  21799. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21800. * @param radius The radius of the cone to emit from
  21801. * @param angle The base angle of the cone
  21802. * @returns the emitter
  21803. */
  21804. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21805. /**
  21806. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21807. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21808. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21809. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21810. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21811. * @returns the emitter
  21812. */
  21813. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21814. /**
  21815. * Get hosting scene
  21816. * @returns the scene
  21817. */
  21818. getScene(): Scene;
  21819. }
  21820. }
  21821. declare module "babylonjs/Shaders/line.fragment" {
  21822. /** @hidden */
  21823. export var linePixelShader: {
  21824. name: string;
  21825. shader: string;
  21826. };
  21827. }
  21828. declare module "babylonjs/Shaders/line.vertex" {
  21829. /** @hidden */
  21830. export var lineVertexShader: {
  21831. name: string;
  21832. shader: string;
  21833. };
  21834. }
  21835. declare module "babylonjs/Rendering/edgesRenderer" {
  21836. import { Nullable } from "babylonjs/types";
  21837. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21839. import { Vector3 } from "babylonjs/Maths/math";
  21840. import { IDisposable } from "babylonjs/scene";
  21841. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  21842. import "babylonjs/Shaders/line.fragment";
  21843. import "babylonjs/Shaders/line.vertex";
  21844. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21845. module "babylonjs/Meshes/abstractMesh" {
  21846. interface AbstractMesh {
  21847. /**
  21848. * Gets the edgesRenderer associated with the mesh
  21849. */
  21850. edgesRenderer: Nullable<EdgesRenderer>;
  21851. }
  21852. }
  21853. module "babylonjs/Meshes/linesMesh" {
  21854. interface LinesMesh {
  21855. /**
  21856. * Enables the edge rendering mode on the mesh.
  21857. * This mode makes the mesh edges visible
  21858. * @param epsilon defines the maximal distance between two angles to detect a face
  21859. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21860. * @returns the currentAbstractMesh
  21861. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21862. */
  21863. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21864. }
  21865. }
  21866. module "babylonjs/Meshes/linesMesh" {
  21867. interface InstancedLinesMesh {
  21868. /**
  21869. * Enables the edge rendering mode on the mesh.
  21870. * This mode makes the mesh edges visible
  21871. * @param epsilon defines the maximal distance between two angles to detect a face
  21872. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21873. * @returns the current InstancedLinesMesh
  21874. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21875. */
  21876. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21877. }
  21878. }
  21879. /**
  21880. * Defines the minimum contract an Edges renderer should follow.
  21881. */
  21882. export interface IEdgesRenderer extends IDisposable {
  21883. /**
  21884. * Gets or sets a boolean indicating if the edgesRenderer is active
  21885. */
  21886. isEnabled: boolean;
  21887. /**
  21888. * Renders the edges of the attached mesh,
  21889. */
  21890. render(): void;
  21891. /**
  21892. * Checks wether or not the edges renderer is ready to render.
  21893. * @return true if ready, otherwise false.
  21894. */
  21895. isReady(): boolean;
  21896. }
  21897. /**
  21898. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21899. */
  21900. export class EdgesRenderer implements IEdgesRenderer {
  21901. /**
  21902. * Define the size of the edges with an orthographic camera
  21903. */
  21904. edgesWidthScalerForOrthographic: number;
  21905. /**
  21906. * Define the size of the edges with a perspective camera
  21907. */
  21908. edgesWidthScalerForPerspective: number;
  21909. protected _source: AbstractMesh;
  21910. protected _linesPositions: number[];
  21911. protected _linesNormals: number[];
  21912. protected _linesIndices: number[];
  21913. protected _epsilon: number;
  21914. protected _indicesCount: number;
  21915. protected _lineShader: ShaderMaterial;
  21916. protected _ib: DataBuffer;
  21917. protected _buffers: {
  21918. [key: string]: Nullable<VertexBuffer>;
  21919. };
  21920. protected _checkVerticesInsteadOfIndices: boolean;
  21921. private _meshRebuildObserver;
  21922. private _meshDisposeObserver;
  21923. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  21924. isEnabled: boolean;
  21925. /**
  21926. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  21927. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  21928. * @param source Mesh used to create edges
  21929. * @param epsilon sum of angles in adjacency to check for edge
  21930. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  21931. * @param generateEdgesLines - should generate Lines or only prepare resources.
  21932. */
  21933. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  21934. protected _prepareRessources(): void;
  21935. /** @hidden */
  21936. _rebuild(): void;
  21937. /**
  21938. * Releases the required resources for the edges renderer
  21939. */
  21940. dispose(): void;
  21941. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  21942. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  21943. /**
  21944. * Checks if the pair of p0 and p1 is en edge
  21945. * @param faceIndex
  21946. * @param edge
  21947. * @param faceNormals
  21948. * @param p0
  21949. * @param p1
  21950. * @private
  21951. */
  21952. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  21953. /**
  21954. * push line into the position, normal and index buffer
  21955. * @protected
  21956. */
  21957. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  21958. /**
  21959. * Generates lines edges from adjacencjes
  21960. * @private
  21961. */
  21962. _generateEdgesLines(): void;
  21963. /**
  21964. * Checks wether or not the edges renderer is ready to render.
  21965. * @return true if ready, otherwise false.
  21966. */
  21967. isReady(): boolean;
  21968. /**
  21969. * Renders the edges of the attached mesh,
  21970. */
  21971. render(): void;
  21972. }
  21973. /**
  21974. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  21975. */
  21976. export class LineEdgesRenderer extends EdgesRenderer {
  21977. /**
  21978. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  21979. * @param source LineMesh used to generate edges
  21980. * @param epsilon not important (specified angle for edge detection)
  21981. * @param checkVerticesInsteadOfIndices not important for LineMesh
  21982. */
  21983. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  21984. /**
  21985. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  21986. */
  21987. _generateEdgesLines(): void;
  21988. }
  21989. }
  21990. declare module "babylonjs/Rendering/renderingGroup" {
  21991. import { SmartArray } from "babylonjs/Misc/smartArray";
  21992. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21994. import { Nullable } from "babylonjs/types";
  21995. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  21996. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  21997. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  21998. import { Material } from "babylonjs/Materials/material";
  21999. import { Scene } from "babylonjs/scene";
  22000. /**
  22001. * This represents the object necessary to create a rendering group.
  22002. * This is exclusively used and created by the rendering manager.
  22003. * To modify the behavior, you use the available helpers in your scene or meshes.
  22004. * @hidden
  22005. */
  22006. export class RenderingGroup {
  22007. index: number;
  22008. private static _zeroVector;
  22009. private _scene;
  22010. private _opaqueSubMeshes;
  22011. private _transparentSubMeshes;
  22012. private _alphaTestSubMeshes;
  22013. private _depthOnlySubMeshes;
  22014. private _particleSystems;
  22015. private _spriteManagers;
  22016. private _opaqueSortCompareFn;
  22017. private _alphaTestSortCompareFn;
  22018. private _transparentSortCompareFn;
  22019. private _renderOpaque;
  22020. private _renderAlphaTest;
  22021. private _renderTransparent;
  22022. /** @hidden */
  22023. _edgesRenderers: SmartArray<IEdgesRenderer>;
  22024. onBeforeTransparentRendering: () => void;
  22025. /**
  22026. * Set the opaque sort comparison function.
  22027. * If null the sub meshes will be render in the order they were created
  22028. */
  22029. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22030. /**
  22031. * Set the alpha test sort comparison function.
  22032. * If null the sub meshes will be render in the order they were created
  22033. */
  22034. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22035. /**
  22036. * Set the transparent sort comparison function.
  22037. * If null the sub meshes will be render in the order they were created
  22038. */
  22039. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22040. /**
  22041. * Creates a new rendering group.
  22042. * @param index The rendering group index
  22043. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  22044. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  22045. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  22046. */
  22047. 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>);
  22048. /**
  22049. * Render all the sub meshes contained in the group.
  22050. * @param customRenderFunction Used to override the default render behaviour of the group.
  22051. * @returns true if rendered some submeshes.
  22052. */
  22053. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  22054. /**
  22055. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  22056. * @param subMeshes The submeshes to render
  22057. */
  22058. private renderOpaqueSorted;
  22059. /**
  22060. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  22061. * @param subMeshes The submeshes to render
  22062. */
  22063. private renderAlphaTestSorted;
  22064. /**
  22065. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  22066. * @param subMeshes The submeshes to render
  22067. */
  22068. private renderTransparentSorted;
  22069. /**
  22070. * Renders the submeshes in a specified order.
  22071. * @param subMeshes The submeshes to sort before render
  22072. * @param sortCompareFn The comparison function use to sort
  22073. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  22074. * @param transparent Specifies to activate blending if true
  22075. */
  22076. private static renderSorted;
  22077. /**
  22078. * Renders the submeshes in the order they were dispatched (no sort applied).
  22079. * @param subMeshes The submeshes to render
  22080. */
  22081. private static renderUnsorted;
  22082. /**
  22083. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22084. * are rendered back to front if in the same alpha index.
  22085. *
  22086. * @param a The first submesh
  22087. * @param b The second submesh
  22088. * @returns The result of the comparison
  22089. */
  22090. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  22091. /**
  22092. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22093. * are rendered back to front.
  22094. *
  22095. * @param a The first submesh
  22096. * @param b The second submesh
  22097. * @returns The result of the comparison
  22098. */
  22099. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  22100. /**
  22101. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22102. * are rendered front to back (prevent overdraw).
  22103. *
  22104. * @param a The first submesh
  22105. * @param b The second submesh
  22106. * @returns The result of the comparison
  22107. */
  22108. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  22109. /**
  22110. * Resets the different lists of submeshes to prepare a new frame.
  22111. */
  22112. prepare(): void;
  22113. dispose(): void;
  22114. /**
  22115. * Inserts the submesh in its correct queue depending on its material.
  22116. * @param subMesh The submesh to dispatch
  22117. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22118. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22119. */
  22120. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22121. dispatchSprites(spriteManager: ISpriteManager): void;
  22122. dispatchParticles(particleSystem: IParticleSystem): void;
  22123. private _renderParticles;
  22124. private _renderSprites;
  22125. }
  22126. }
  22127. declare module "babylonjs/Rendering/renderingManager" {
  22128. import { Nullable } from "babylonjs/types";
  22129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22130. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22131. import { SmartArray } from "babylonjs/Misc/smartArray";
  22132. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22133. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22134. import { Material } from "babylonjs/Materials/material";
  22135. import { Scene } from "babylonjs/scene";
  22136. import { Camera } from "babylonjs/Cameras/camera";
  22137. /**
  22138. * Interface describing the different options available in the rendering manager
  22139. * regarding Auto Clear between groups.
  22140. */
  22141. export interface IRenderingManagerAutoClearSetup {
  22142. /**
  22143. * Defines whether or not autoclear is enable.
  22144. */
  22145. autoClear: boolean;
  22146. /**
  22147. * Defines whether or not to autoclear the depth buffer.
  22148. */
  22149. depth: boolean;
  22150. /**
  22151. * Defines whether or not to autoclear the stencil buffer.
  22152. */
  22153. stencil: boolean;
  22154. }
  22155. /**
  22156. * This class is used by the onRenderingGroupObservable
  22157. */
  22158. export class RenderingGroupInfo {
  22159. /**
  22160. * The Scene that being rendered
  22161. */
  22162. scene: Scene;
  22163. /**
  22164. * The camera currently used for the rendering pass
  22165. */
  22166. camera: Nullable<Camera>;
  22167. /**
  22168. * The ID of the renderingGroup being processed
  22169. */
  22170. renderingGroupId: number;
  22171. }
  22172. /**
  22173. * This is the manager responsible of all the rendering for meshes sprites and particles.
  22174. * It is enable to manage the different groups as well as the different necessary sort functions.
  22175. * This should not be used directly aside of the few static configurations
  22176. */
  22177. export class RenderingManager {
  22178. /**
  22179. * The max id used for rendering groups (not included)
  22180. */
  22181. static MAX_RENDERINGGROUPS: number;
  22182. /**
  22183. * The min id used for rendering groups (included)
  22184. */
  22185. static MIN_RENDERINGGROUPS: number;
  22186. /**
  22187. * Used to globally prevent autoclearing scenes.
  22188. */
  22189. static AUTOCLEAR: boolean;
  22190. /**
  22191. * @hidden
  22192. */
  22193. _useSceneAutoClearSetup: boolean;
  22194. private _scene;
  22195. private _renderingGroups;
  22196. private _depthStencilBufferAlreadyCleaned;
  22197. private _autoClearDepthStencil;
  22198. private _customOpaqueSortCompareFn;
  22199. private _customAlphaTestSortCompareFn;
  22200. private _customTransparentSortCompareFn;
  22201. private _renderingGroupInfo;
  22202. /**
  22203. * Instantiates a new rendering group for a particular scene
  22204. * @param scene Defines the scene the groups belongs to
  22205. */
  22206. constructor(scene: Scene);
  22207. private _clearDepthStencilBuffer;
  22208. /**
  22209. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  22210. * @hidden
  22211. */
  22212. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  22213. /**
  22214. * Resets the different information of the group to prepare a new frame
  22215. * @hidden
  22216. */
  22217. reset(): void;
  22218. /**
  22219. * Dispose and release the group and its associated resources.
  22220. * @hidden
  22221. */
  22222. dispose(): void;
  22223. /**
  22224. * Clear the info related to rendering groups preventing retention points during dispose.
  22225. */
  22226. freeRenderingGroups(): void;
  22227. private _prepareRenderingGroup;
  22228. /**
  22229. * Add a sprite manager to the rendering manager in order to render it this frame.
  22230. * @param spriteManager Define the sprite manager to render
  22231. */
  22232. dispatchSprites(spriteManager: ISpriteManager): void;
  22233. /**
  22234. * Add a particle system to the rendering manager in order to render it this frame.
  22235. * @param particleSystem Define the particle system to render
  22236. */
  22237. dispatchParticles(particleSystem: IParticleSystem): void;
  22238. /**
  22239. * Add a submesh to the manager in order to render it this frame
  22240. * @param subMesh The submesh to dispatch
  22241. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22242. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22243. */
  22244. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22245. /**
  22246. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22247. * This allowed control for front to back rendering or reversly depending of the special needs.
  22248. *
  22249. * @param renderingGroupId The rendering group id corresponding to its index
  22250. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22251. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22252. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22253. */
  22254. 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;
  22255. /**
  22256. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22257. *
  22258. * @param renderingGroupId The rendering group id corresponding to its index
  22259. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22260. * @param depth Automatically clears depth between groups if true and autoClear is true.
  22261. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  22262. */
  22263. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  22264. /**
  22265. * Gets the current auto clear configuration for one rendering group of the rendering
  22266. * manager.
  22267. * @param index the rendering group index to get the information for
  22268. * @returns The auto clear setup for the requested rendering group
  22269. */
  22270. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  22271. }
  22272. }
  22273. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  22274. import { Observable } from "babylonjs/Misc/observable";
  22275. import { SmartArray } from "babylonjs/Misc/smartArray";
  22276. import { Nullable } from "babylonjs/types";
  22277. import { Camera } from "babylonjs/Cameras/camera";
  22278. import { Scene } from "babylonjs/scene";
  22279. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  22280. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  22281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22282. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22283. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22284. import { Texture } from "babylonjs/Materials/Textures/texture";
  22285. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  22286. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  22287. import "babylonjs/Engines/Extensions/engine.renderTarget";
  22288. import { Engine } from "babylonjs/Engines/engine";
  22289. /**
  22290. * This Helps creating a texture that will be created from a camera in your scene.
  22291. * It is basically a dynamic texture that could be used to create special effects for instance.
  22292. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  22293. */
  22294. export class RenderTargetTexture extends Texture {
  22295. isCube: boolean;
  22296. /**
  22297. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  22298. */
  22299. static readonly REFRESHRATE_RENDER_ONCE: number;
  22300. /**
  22301. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  22302. */
  22303. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  22304. /**
  22305. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  22306. * the central point of your effect and can save a lot of performances.
  22307. */
  22308. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  22309. /**
  22310. * Use this predicate to dynamically define the list of mesh you want to render.
  22311. * If set, the renderList property will be overwritten.
  22312. */
  22313. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  22314. private _renderList;
  22315. /**
  22316. * Use this list to define the list of mesh you want to render.
  22317. */
  22318. renderList: Nullable<Array<AbstractMesh>>;
  22319. private _hookArray;
  22320. /**
  22321. * Define if particles should be rendered in your texture.
  22322. */
  22323. renderParticles: boolean;
  22324. /**
  22325. * Define if sprites should be rendered in your texture.
  22326. */
  22327. renderSprites: boolean;
  22328. /**
  22329. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  22330. */
  22331. coordinatesMode: number;
  22332. /**
  22333. * Define the camera used to render the texture.
  22334. */
  22335. activeCamera: Nullable<Camera>;
  22336. /**
  22337. * Override the render function of the texture with your own one.
  22338. */
  22339. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  22340. /**
  22341. * Define if camera post processes should be use while rendering the texture.
  22342. */
  22343. useCameraPostProcesses: boolean;
  22344. /**
  22345. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  22346. */
  22347. ignoreCameraViewport: boolean;
  22348. private _postProcessManager;
  22349. private _postProcesses;
  22350. private _resizeObserver;
  22351. /**
  22352. * An event triggered when the texture is unbind.
  22353. */
  22354. onBeforeBindObservable: Observable<RenderTargetTexture>;
  22355. /**
  22356. * An event triggered when the texture is unbind.
  22357. */
  22358. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  22359. private _onAfterUnbindObserver;
  22360. /**
  22361. * Set a after unbind callback in the texture.
  22362. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  22363. */
  22364. onAfterUnbind: () => void;
  22365. /**
  22366. * An event triggered before rendering the texture
  22367. */
  22368. onBeforeRenderObservable: Observable<number>;
  22369. private _onBeforeRenderObserver;
  22370. /**
  22371. * Set a before render callback in the texture.
  22372. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  22373. */
  22374. onBeforeRender: (faceIndex: number) => void;
  22375. /**
  22376. * An event triggered after rendering the texture
  22377. */
  22378. onAfterRenderObservable: Observable<number>;
  22379. private _onAfterRenderObserver;
  22380. /**
  22381. * Set a after render callback in the texture.
  22382. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  22383. */
  22384. onAfterRender: (faceIndex: number) => void;
  22385. /**
  22386. * An event triggered after the texture clear
  22387. */
  22388. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  22389. private _onClearObserver;
  22390. /**
  22391. * Set a clear callback in the texture.
  22392. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  22393. */
  22394. onClear: (Engine: Engine) => void;
  22395. /**
  22396. * Define the clear color of the Render Target if it should be different from the scene.
  22397. */
  22398. clearColor: Color4;
  22399. protected _size: number | {
  22400. width: number;
  22401. height: number;
  22402. };
  22403. protected _initialSizeParameter: number | {
  22404. width: number;
  22405. height: number;
  22406. } | {
  22407. ratio: number;
  22408. };
  22409. protected _sizeRatio: Nullable<number>;
  22410. /** @hidden */
  22411. _generateMipMaps: boolean;
  22412. protected _renderingManager: RenderingManager;
  22413. /** @hidden */
  22414. _waitingRenderList: string[];
  22415. protected _doNotChangeAspectRatio: boolean;
  22416. protected _currentRefreshId: number;
  22417. protected _refreshRate: number;
  22418. protected _textureMatrix: Matrix;
  22419. protected _samples: number;
  22420. protected _renderTargetOptions: RenderTargetCreationOptions;
  22421. /**
  22422. * Gets render target creation options that were used.
  22423. */
  22424. readonly renderTargetOptions: RenderTargetCreationOptions;
  22425. protected _engine: Engine;
  22426. protected _onRatioRescale(): void;
  22427. /**
  22428. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  22429. * It must define where the camera used to render the texture is set
  22430. */
  22431. boundingBoxPosition: Vector3;
  22432. private _boundingBoxSize;
  22433. /**
  22434. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  22435. * When defined, the cubemap will switch to local mode
  22436. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  22437. * @example https://www.babylonjs-playground.com/#RNASML
  22438. */
  22439. boundingBoxSize: Vector3;
  22440. /**
  22441. * In case the RTT has been created with a depth texture, get the associated
  22442. * depth texture.
  22443. * Otherwise, return null.
  22444. */
  22445. depthStencilTexture: Nullable<InternalTexture>;
  22446. /**
  22447. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  22448. * or used a shadow, depth texture...
  22449. * @param name The friendly name of the texture
  22450. * @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)
  22451. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  22452. * @param generateMipMaps True if mip maps need to be generated after render.
  22453. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  22454. * @param type The type of the buffer in the RTT (int, half float, float...)
  22455. * @param isCube True if a cube texture needs to be created
  22456. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  22457. * @param generateDepthBuffer True to generate a depth buffer
  22458. * @param generateStencilBuffer True to generate a stencil buffer
  22459. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  22460. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  22461. * @param delayAllocation if the texture allocation should be delayed (default: false)
  22462. */
  22463. constructor(name: string, size: number | {
  22464. width: number;
  22465. height: number;
  22466. } | {
  22467. ratio: number;
  22468. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  22469. /**
  22470. * Creates a depth stencil texture.
  22471. * This is only available in WebGL 2 or with the depth texture extension available.
  22472. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  22473. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  22474. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  22475. */
  22476. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  22477. private _processSizeParameter;
  22478. /**
  22479. * Define the number of samples to use in case of MSAA.
  22480. * It defaults to one meaning no MSAA has been enabled.
  22481. */
  22482. samples: number;
  22483. /**
  22484. * Resets the refresh counter of the texture and start bak from scratch.
  22485. * Could be useful to regenerate the texture if it is setup to render only once.
  22486. */
  22487. resetRefreshCounter(): void;
  22488. /**
  22489. * Define the refresh rate of the texture or the rendering frequency.
  22490. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  22491. */
  22492. refreshRate: number;
  22493. /**
  22494. * Adds a post process to the render target rendering passes.
  22495. * @param postProcess define the post process to add
  22496. */
  22497. addPostProcess(postProcess: PostProcess): void;
  22498. /**
  22499. * Clear all the post processes attached to the render target
  22500. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22501. */
  22502. clearPostProcesses(dispose?: boolean): void;
  22503. /**
  22504. * Remove one of the post process from the list of attached post processes to the texture
  22505. * @param postProcess define the post process to remove from the list
  22506. */
  22507. removePostProcess(postProcess: PostProcess): void;
  22508. /** @hidden */
  22509. _shouldRender(): boolean;
  22510. /**
  22511. * Gets the actual render size of the texture.
  22512. * @returns the width of the render size
  22513. */
  22514. getRenderSize(): number;
  22515. /**
  22516. * Gets the actual render width of the texture.
  22517. * @returns the width of the render size
  22518. */
  22519. getRenderWidth(): number;
  22520. /**
  22521. * Gets the actual render height of the texture.
  22522. * @returns the height of the render size
  22523. */
  22524. getRenderHeight(): number;
  22525. /**
  22526. * Get if the texture can be rescaled or not.
  22527. */
  22528. readonly canRescale: boolean;
  22529. /**
  22530. * Resize the texture using a ratio.
  22531. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22532. */
  22533. scale(ratio: number): void;
  22534. /**
  22535. * Get the texture reflection matrix used to rotate/transform the reflection.
  22536. * @returns the reflection matrix
  22537. */
  22538. getReflectionTextureMatrix(): Matrix;
  22539. /**
  22540. * Resize the texture to a new desired size.
  22541. * Be carrefull as it will recreate all the data in the new texture.
  22542. * @param size Define the new size. It can be:
  22543. * - a number for squared texture,
  22544. * - an object containing { width: number, height: number }
  22545. * - or an object containing a ratio { ratio: number }
  22546. */
  22547. resize(size: number | {
  22548. width: number;
  22549. height: number;
  22550. } | {
  22551. ratio: number;
  22552. }): void;
  22553. /**
  22554. * Renders all the objects from the render list into the texture.
  22555. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22556. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22557. */
  22558. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22559. private _bestReflectionRenderTargetDimension;
  22560. /**
  22561. * @hidden
  22562. * @param faceIndex face index to bind to if this is a cubetexture
  22563. */
  22564. _bindFrameBuffer(faceIndex?: number): void;
  22565. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22566. private renderToTarget;
  22567. /**
  22568. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22569. * This allowed control for front to back rendering or reversly depending of the special needs.
  22570. *
  22571. * @param renderingGroupId The rendering group id corresponding to its index
  22572. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22573. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22574. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22575. */
  22576. 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;
  22577. /**
  22578. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22579. *
  22580. * @param renderingGroupId The rendering group id corresponding to its index
  22581. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22582. */
  22583. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22584. /**
  22585. * Clones the texture.
  22586. * @returns the cloned texture
  22587. */
  22588. clone(): RenderTargetTexture;
  22589. /**
  22590. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22591. * @returns The JSON representation of the texture
  22592. */
  22593. serialize(): any;
  22594. /**
  22595. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22596. */
  22597. disposeFramebufferObjects(): void;
  22598. /**
  22599. * Dispose the texture and release its associated resources.
  22600. */
  22601. dispose(): void;
  22602. /** @hidden */
  22603. _rebuild(): void;
  22604. /**
  22605. * Clear the info related to rendering groups preventing retention point in material dispose.
  22606. */
  22607. freeRenderingGroups(): void;
  22608. /**
  22609. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22610. * @returns the view count
  22611. */
  22612. getViewCount(): number;
  22613. }
  22614. }
  22615. declare module "babylonjs/Materials/material" {
  22616. import { IAnimatable } from "babylonjs/Misc/tools";
  22617. import { SmartArray } from "babylonjs/Misc/smartArray";
  22618. import { Observable } from "babylonjs/Misc/observable";
  22619. import { Nullable } from "babylonjs/types";
  22620. import { Scene } from "babylonjs/scene";
  22621. import { Matrix } from "babylonjs/Maths/math";
  22622. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22624. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22625. import { Effect } from "babylonjs/Materials/effect";
  22626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22627. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22628. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22629. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22630. import { Mesh } from "babylonjs/Meshes/mesh";
  22631. import { Animation } from "babylonjs/Animations/animation";
  22632. /**
  22633. * Base class for the main features of a material in Babylon.js
  22634. */
  22635. export class Material implements IAnimatable {
  22636. /**
  22637. * Returns the triangle fill mode
  22638. */
  22639. static readonly TriangleFillMode: number;
  22640. /**
  22641. * Returns the wireframe mode
  22642. */
  22643. static readonly WireFrameFillMode: number;
  22644. /**
  22645. * Returns the point fill mode
  22646. */
  22647. static readonly PointFillMode: number;
  22648. /**
  22649. * Returns the point list draw mode
  22650. */
  22651. static readonly PointListDrawMode: number;
  22652. /**
  22653. * Returns the line list draw mode
  22654. */
  22655. static readonly LineListDrawMode: number;
  22656. /**
  22657. * Returns the line loop draw mode
  22658. */
  22659. static readonly LineLoopDrawMode: number;
  22660. /**
  22661. * Returns the line strip draw mode
  22662. */
  22663. static readonly LineStripDrawMode: number;
  22664. /**
  22665. * Returns the triangle strip draw mode
  22666. */
  22667. static readonly TriangleStripDrawMode: number;
  22668. /**
  22669. * Returns the triangle fan draw mode
  22670. */
  22671. static readonly TriangleFanDrawMode: number;
  22672. /**
  22673. * Stores the clock-wise side orientation
  22674. */
  22675. static readonly ClockWiseSideOrientation: number;
  22676. /**
  22677. * Stores the counter clock-wise side orientation
  22678. */
  22679. static readonly CounterClockWiseSideOrientation: number;
  22680. /**
  22681. * The dirty texture flag value
  22682. */
  22683. static readonly TextureDirtyFlag: number;
  22684. /**
  22685. * The dirty light flag value
  22686. */
  22687. static readonly LightDirtyFlag: number;
  22688. /**
  22689. * The dirty fresnel flag value
  22690. */
  22691. static readonly FresnelDirtyFlag: number;
  22692. /**
  22693. * The dirty attribute flag value
  22694. */
  22695. static readonly AttributesDirtyFlag: number;
  22696. /**
  22697. * The dirty misc flag value
  22698. */
  22699. static readonly MiscDirtyFlag: number;
  22700. /**
  22701. * The all dirty flag value
  22702. */
  22703. static readonly AllDirtyFlag: number;
  22704. /**
  22705. * The ID of the material
  22706. */
  22707. id: string;
  22708. /**
  22709. * Gets or sets the unique id of the material
  22710. */
  22711. uniqueId: number;
  22712. /**
  22713. * The name of the material
  22714. */
  22715. name: string;
  22716. /**
  22717. * Gets or sets user defined metadata
  22718. */
  22719. metadata: any;
  22720. /**
  22721. * For internal use only. Please do not use.
  22722. */
  22723. reservedDataStore: any;
  22724. /**
  22725. * Specifies if the ready state should be checked on each call
  22726. */
  22727. checkReadyOnEveryCall: boolean;
  22728. /**
  22729. * Specifies if the ready state should be checked once
  22730. */
  22731. checkReadyOnlyOnce: boolean;
  22732. /**
  22733. * The state of the material
  22734. */
  22735. state: string;
  22736. /**
  22737. * The alpha value of the material
  22738. */
  22739. protected _alpha: number;
  22740. /**
  22741. * List of inspectable custom properties (used by the Inspector)
  22742. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22743. */
  22744. inspectableCustomProperties: IInspectable[];
  22745. /**
  22746. * Sets the alpha value of the material
  22747. */
  22748. /**
  22749. * Gets the alpha value of the material
  22750. */
  22751. alpha: number;
  22752. /**
  22753. * Specifies if back face culling is enabled
  22754. */
  22755. protected _backFaceCulling: boolean;
  22756. /**
  22757. * Sets the back-face culling state
  22758. */
  22759. /**
  22760. * Gets the back-face culling state
  22761. */
  22762. backFaceCulling: boolean;
  22763. /**
  22764. * Stores the value for side orientation
  22765. */
  22766. sideOrientation: number;
  22767. /**
  22768. * Callback triggered when the material is compiled
  22769. */
  22770. onCompiled: Nullable<(effect: Effect) => void>;
  22771. /**
  22772. * Callback triggered when an error occurs
  22773. */
  22774. onError: Nullable<(effect: Effect, errors: string) => void>;
  22775. /**
  22776. * Callback triggered to get the render target textures
  22777. */
  22778. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22779. /**
  22780. * Gets a boolean indicating that current material needs to register RTT
  22781. */
  22782. readonly hasRenderTargetTextures: boolean;
  22783. /**
  22784. * Specifies if the material should be serialized
  22785. */
  22786. doNotSerialize: boolean;
  22787. /**
  22788. * @hidden
  22789. */
  22790. _storeEffectOnSubMeshes: boolean;
  22791. /**
  22792. * Stores the animations for the material
  22793. */
  22794. animations: Nullable<Array<Animation>>;
  22795. /**
  22796. * An event triggered when the material is disposed
  22797. */
  22798. onDisposeObservable: Observable<Material>;
  22799. /**
  22800. * An observer which watches for dispose events
  22801. */
  22802. private _onDisposeObserver;
  22803. private _onUnBindObservable;
  22804. /**
  22805. * Called during a dispose event
  22806. */
  22807. onDispose: () => void;
  22808. private _onBindObservable;
  22809. /**
  22810. * An event triggered when the material is bound
  22811. */
  22812. readonly onBindObservable: Observable<AbstractMesh>;
  22813. /**
  22814. * An observer which watches for bind events
  22815. */
  22816. private _onBindObserver;
  22817. /**
  22818. * Called during a bind event
  22819. */
  22820. onBind: (Mesh: AbstractMesh) => void;
  22821. /**
  22822. * An event triggered when the material is unbound
  22823. */
  22824. readonly onUnBindObservable: Observable<Material>;
  22825. /**
  22826. * Stores the value of the alpha mode
  22827. */
  22828. private _alphaMode;
  22829. /**
  22830. * Sets the value of the alpha mode.
  22831. *
  22832. * | Value | Type | Description |
  22833. * | --- | --- | --- |
  22834. * | 0 | ALPHA_DISABLE | |
  22835. * | 1 | ALPHA_ADD | |
  22836. * | 2 | ALPHA_COMBINE | |
  22837. * | 3 | ALPHA_SUBTRACT | |
  22838. * | 4 | ALPHA_MULTIPLY | |
  22839. * | 5 | ALPHA_MAXIMIZED | |
  22840. * | 6 | ALPHA_ONEONE | |
  22841. * | 7 | ALPHA_PREMULTIPLIED | |
  22842. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22843. * | 9 | ALPHA_INTERPOLATE | |
  22844. * | 10 | ALPHA_SCREENMODE | |
  22845. *
  22846. */
  22847. /**
  22848. * Gets the value of the alpha mode
  22849. */
  22850. alphaMode: number;
  22851. /**
  22852. * Stores the state of the need depth pre-pass value
  22853. */
  22854. private _needDepthPrePass;
  22855. /**
  22856. * Sets the need depth pre-pass value
  22857. */
  22858. /**
  22859. * Gets the depth pre-pass value
  22860. */
  22861. needDepthPrePass: boolean;
  22862. /**
  22863. * Specifies if depth writing should be disabled
  22864. */
  22865. disableDepthWrite: boolean;
  22866. /**
  22867. * Specifies if depth writing should be forced
  22868. */
  22869. forceDepthWrite: boolean;
  22870. /**
  22871. * Specifies if there should be a separate pass for culling
  22872. */
  22873. separateCullingPass: boolean;
  22874. /**
  22875. * Stores the state specifing if fog should be enabled
  22876. */
  22877. private _fogEnabled;
  22878. /**
  22879. * Sets the state for enabling fog
  22880. */
  22881. /**
  22882. * Gets the value of the fog enabled state
  22883. */
  22884. fogEnabled: boolean;
  22885. /**
  22886. * Stores the size of points
  22887. */
  22888. pointSize: number;
  22889. /**
  22890. * Stores the z offset value
  22891. */
  22892. zOffset: number;
  22893. /**
  22894. * Gets a value specifying if wireframe mode is enabled
  22895. */
  22896. /**
  22897. * Sets the state of wireframe mode
  22898. */
  22899. wireframe: boolean;
  22900. /**
  22901. * Gets the value specifying if point clouds are enabled
  22902. */
  22903. /**
  22904. * Sets the state of point cloud mode
  22905. */
  22906. pointsCloud: boolean;
  22907. /**
  22908. * Gets the material fill mode
  22909. */
  22910. /**
  22911. * Sets the material fill mode
  22912. */
  22913. fillMode: number;
  22914. /**
  22915. * @hidden
  22916. * Stores the effects for the material
  22917. */
  22918. _effect: Nullable<Effect>;
  22919. /**
  22920. * @hidden
  22921. * Specifies if the material was previously ready
  22922. */
  22923. _wasPreviouslyReady: boolean;
  22924. /**
  22925. * Specifies if uniform buffers should be used
  22926. */
  22927. private _useUBO;
  22928. /**
  22929. * Stores a reference to the scene
  22930. */
  22931. private _scene;
  22932. /**
  22933. * Stores the fill mode state
  22934. */
  22935. private _fillMode;
  22936. /**
  22937. * Specifies if the depth write state should be cached
  22938. */
  22939. private _cachedDepthWriteState;
  22940. /**
  22941. * Stores the uniform buffer
  22942. */
  22943. protected _uniformBuffer: UniformBuffer;
  22944. /** @hidden */
  22945. _indexInSceneMaterialArray: number;
  22946. /** @hidden */
  22947. meshMap: Nullable<{
  22948. [id: string]: AbstractMesh | undefined;
  22949. }>;
  22950. /**
  22951. * Creates a material instance
  22952. * @param name defines the name of the material
  22953. * @param scene defines the scene to reference
  22954. * @param doNotAdd specifies if the material should be added to the scene
  22955. */
  22956. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22957. /**
  22958. * Returns a string representation of the current material
  22959. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22960. * @returns a string with material information
  22961. */
  22962. toString(fullDetails?: boolean): string;
  22963. /**
  22964. * Gets the class name of the material
  22965. * @returns a string with the class name of the material
  22966. */
  22967. getClassName(): string;
  22968. /**
  22969. * Specifies if updates for the material been locked
  22970. */
  22971. readonly isFrozen: boolean;
  22972. /**
  22973. * Locks updates for the material
  22974. */
  22975. freeze(): void;
  22976. /**
  22977. * Unlocks updates for the material
  22978. */
  22979. unfreeze(): void;
  22980. /**
  22981. * Specifies if the material is ready to be used
  22982. * @param mesh defines the mesh to check
  22983. * @param useInstances specifies if instances should be used
  22984. * @returns a boolean indicating if the material is ready to be used
  22985. */
  22986. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22987. /**
  22988. * Specifies that the submesh is ready to be used
  22989. * @param mesh defines the mesh to check
  22990. * @param subMesh defines which submesh to check
  22991. * @param useInstances specifies that instances should be used
  22992. * @returns a boolean indicating that the submesh is ready or not
  22993. */
  22994. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22995. /**
  22996. * Returns the material effect
  22997. * @returns the effect associated with the material
  22998. */
  22999. getEffect(): Nullable<Effect>;
  23000. /**
  23001. * Returns the current scene
  23002. * @returns a Scene
  23003. */
  23004. getScene(): Scene;
  23005. /**
  23006. * Specifies if the material will require alpha blending
  23007. * @returns a boolean specifying if alpha blending is needed
  23008. */
  23009. needAlphaBlending(): boolean;
  23010. /**
  23011. * Specifies if the mesh will require alpha blending
  23012. * @param mesh defines the mesh to check
  23013. * @returns a boolean specifying if alpha blending is needed for the mesh
  23014. */
  23015. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23016. /**
  23017. * Specifies if this material should be rendered in alpha test mode
  23018. * @returns a boolean specifying if an alpha test is needed.
  23019. */
  23020. needAlphaTesting(): boolean;
  23021. /**
  23022. * Gets the texture used for the alpha test
  23023. * @returns the texture to use for alpha testing
  23024. */
  23025. getAlphaTestTexture(): Nullable<BaseTexture>;
  23026. /**
  23027. * Marks the material to indicate that it needs to be re-calculated
  23028. */
  23029. markDirty(): void;
  23030. /** @hidden */
  23031. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23032. /**
  23033. * Binds the material to the mesh
  23034. * @param world defines the world transformation matrix
  23035. * @param mesh defines the mesh to bind the material to
  23036. */
  23037. bind(world: Matrix, mesh?: Mesh): void;
  23038. /**
  23039. * Binds the submesh to the material
  23040. * @param world defines the world transformation matrix
  23041. * @param mesh defines the mesh containing the submesh
  23042. * @param subMesh defines the submesh to bind the material to
  23043. */
  23044. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23045. /**
  23046. * Binds the world matrix to the material
  23047. * @param world defines the world transformation matrix
  23048. */
  23049. bindOnlyWorldMatrix(world: Matrix): void;
  23050. /**
  23051. * Binds the scene's uniform buffer to the effect.
  23052. * @param effect defines the effect to bind to the scene uniform buffer
  23053. * @param sceneUbo defines the uniform buffer storing scene data
  23054. */
  23055. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23056. /**
  23057. * Binds the view matrix to the effect
  23058. * @param effect defines the effect to bind the view matrix to
  23059. */
  23060. bindView(effect: Effect): void;
  23061. /**
  23062. * Binds the view projection matrix to the effect
  23063. * @param effect defines the effect to bind the view projection matrix to
  23064. */
  23065. bindViewProjection(effect: Effect): void;
  23066. /**
  23067. * Specifies if material alpha testing should be turned on for the mesh
  23068. * @param mesh defines the mesh to check
  23069. */
  23070. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23071. /**
  23072. * Processes to execute after binding the material to a mesh
  23073. * @param mesh defines the rendered mesh
  23074. */
  23075. protected _afterBind(mesh?: Mesh): void;
  23076. /**
  23077. * Unbinds the material from the mesh
  23078. */
  23079. unbind(): void;
  23080. /**
  23081. * Gets the active textures from the material
  23082. * @returns an array of textures
  23083. */
  23084. getActiveTextures(): BaseTexture[];
  23085. /**
  23086. * Specifies if the material uses a texture
  23087. * @param texture defines the texture to check against the material
  23088. * @returns a boolean specifying if the material uses the texture
  23089. */
  23090. hasTexture(texture: BaseTexture): boolean;
  23091. /**
  23092. * Makes a duplicate of the material, and gives it a new name
  23093. * @param name defines the new name for the duplicated material
  23094. * @returns the cloned material
  23095. */
  23096. clone(name: string): Nullable<Material>;
  23097. /**
  23098. * Gets the meshes bound to the material
  23099. * @returns an array of meshes bound to the material
  23100. */
  23101. getBindedMeshes(): AbstractMesh[];
  23102. /**
  23103. * Force shader compilation
  23104. * @param mesh defines the mesh associated with this material
  23105. * @param onCompiled defines a function to execute once the material is compiled
  23106. * @param options defines the options to configure the compilation
  23107. */
  23108. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23109. clipPlane: boolean;
  23110. }>): void;
  23111. /**
  23112. * Force shader compilation
  23113. * @param mesh defines the mesh that will use this material
  23114. * @param options defines additional options for compiling the shaders
  23115. * @returns a promise that resolves when the compilation completes
  23116. */
  23117. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23118. clipPlane: boolean;
  23119. }>): Promise<void>;
  23120. private static readonly _AllDirtyCallBack;
  23121. private static readonly _ImageProcessingDirtyCallBack;
  23122. private static readonly _TextureDirtyCallBack;
  23123. private static readonly _FresnelDirtyCallBack;
  23124. private static readonly _MiscDirtyCallBack;
  23125. private static readonly _LightsDirtyCallBack;
  23126. private static readonly _AttributeDirtyCallBack;
  23127. private static _FresnelAndMiscDirtyCallBack;
  23128. private static _TextureAndMiscDirtyCallBack;
  23129. private static readonly _DirtyCallbackArray;
  23130. private static readonly _RunDirtyCallBacks;
  23131. /**
  23132. * Marks a define in the material to indicate that it needs to be re-computed
  23133. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23134. */
  23135. markAsDirty(flag: number): void;
  23136. /**
  23137. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23138. * @param func defines a function which checks material defines against the submeshes
  23139. */
  23140. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23141. /**
  23142. * Indicates that we need to re-calculated for all submeshes
  23143. */
  23144. protected _markAllSubMeshesAsAllDirty(): void;
  23145. /**
  23146. * Indicates that image processing needs to be re-calculated for all submeshes
  23147. */
  23148. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23149. /**
  23150. * Indicates that textures need to be re-calculated for all submeshes
  23151. */
  23152. protected _markAllSubMeshesAsTexturesDirty(): void;
  23153. /**
  23154. * Indicates that fresnel needs to be re-calculated for all submeshes
  23155. */
  23156. protected _markAllSubMeshesAsFresnelDirty(): void;
  23157. /**
  23158. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23159. */
  23160. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23161. /**
  23162. * Indicates that lights need to be re-calculated for all submeshes
  23163. */
  23164. protected _markAllSubMeshesAsLightsDirty(): void;
  23165. /**
  23166. * Indicates that attributes need to be re-calculated for all submeshes
  23167. */
  23168. protected _markAllSubMeshesAsAttributesDirty(): void;
  23169. /**
  23170. * Indicates that misc needs to be re-calculated for all submeshes
  23171. */
  23172. protected _markAllSubMeshesAsMiscDirty(): void;
  23173. /**
  23174. * Indicates that textures and misc need to be re-calculated for all submeshes
  23175. */
  23176. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23177. /**
  23178. * Disposes the material
  23179. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23180. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23181. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23182. */
  23183. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23184. /** @hidden */
  23185. private releaseVertexArrayObject;
  23186. /**
  23187. * Serializes this material
  23188. * @returns the serialized material object
  23189. */
  23190. serialize(): any;
  23191. /**
  23192. * Creates a material from parsed material data
  23193. * @param parsedMaterial defines parsed material data
  23194. * @param scene defines the hosting scene
  23195. * @param rootUrl defines the root URL to use to load textures
  23196. * @returns a new material
  23197. */
  23198. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23199. }
  23200. }
  23201. declare module "babylonjs/Meshes/subMesh" {
  23202. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23203. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23204. import { Engine } from "babylonjs/Engines/engine";
  23205. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23206. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23207. import { Effect } from "babylonjs/Materials/effect";
  23208. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23209. import { Collider } from "babylonjs/Collisions/collider";
  23210. import { Material } from "babylonjs/Materials/material";
  23211. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23213. import { Mesh } from "babylonjs/Meshes/mesh";
  23214. import { Ray } from "babylonjs/Culling/ray";
  23215. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23216. /**
  23217. * Base class for submeshes
  23218. */
  23219. export class BaseSubMesh {
  23220. /** @hidden */
  23221. _materialDefines: Nullable<MaterialDefines>;
  23222. /** @hidden */
  23223. _materialEffect: Nullable<Effect>;
  23224. /**
  23225. * Gets associated effect
  23226. */
  23227. readonly effect: Nullable<Effect>;
  23228. /**
  23229. * Sets associated effect (effect used to render this submesh)
  23230. * @param effect defines the effect to associate with
  23231. * @param defines defines the set of defines used to compile this effect
  23232. */
  23233. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23234. }
  23235. /**
  23236. * Defines a subdivision inside a mesh
  23237. */
  23238. export class SubMesh extends BaseSubMesh implements ICullable {
  23239. /** the material index to use */
  23240. materialIndex: number;
  23241. /** vertex index start */
  23242. verticesStart: number;
  23243. /** vertices count */
  23244. verticesCount: number;
  23245. /** index start */
  23246. indexStart: number;
  23247. /** indices count */
  23248. indexCount: number;
  23249. /** @hidden */
  23250. _linesIndexCount: number;
  23251. private _mesh;
  23252. private _renderingMesh;
  23253. private _boundingInfo;
  23254. private _linesIndexBuffer;
  23255. /** @hidden */
  23256. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23257. /** @hidden */
  23258. _trianglePlanes: Plane[];
  23259. /** @hidden */
  23260. _lastColliderTransformMatrix: Nullable<Matrix>;
  23261. /** @hidden */
  23262. _renderId: number;
  23263. /** @hidden */
  23264. _alphaIndex: number;
  23265. /** @hidden */
  23266. _distanceToCamera: number;
  23267. /** @hidden */
  23268. _id: number;
  23269. private _currentMaterial;
  23270. /**
  23271. * Add a new submesh to a mesh
  23272. * @param materialIndex defines the material index to use
  23273. * @param verticesStart defines vertex index start
  23274. * @param verticesCount defines vertices count
  23275. * @param indexStart defines index start
  23276. * @param indexCount defines indices count
  23277. * @param mesh defines the parent mesh
  23278. * @param renderingMesh defines an optional rendering mesh
  23279. * @param createBoundingBox defines if bounding box should be created for this submesh
  23280. * @returns the new submesh
  23281. */
  23282. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23283. /**
  23284. * Creates a new submesh
  23285. * @param materialIndex defines the material index to use
  23286. * @param verticesStart defines vertex index start
  23287. * @param verticesCount defines vertices count
  23288. * @param indexStart defines index start
  23289. * @param indexCount defines indices count
  23290. * @param mesh defines the parent mesh
  23291. * @param renderingMesh defines an optional rendering mesh
  23292. * @param createBoundingBox defines if bounding box should be created for this submesh
  23293. */
  23294. constructor(
  23295. /** the material index to use */
  23296. materialIndex: number,
  23297. /** vertex index start */
  23298. verticesStart: number,
  23299. /** vertices count */
  23300. verticesCount: number,
  23301. /** index start */
  23302. indexStart: number,
  23303. /** indices count */
  23304. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23305. /**
  23306. * Returns true if this submesh covers the entire parent mesh
  23307. * @ignorenaming
  23308. */
  23309. readonly IsGlobal: boolean;
  23310. /**
  23311. * Returns the submesh BoudingInfo object
  23312. * @returns current bounding info (or mesh's one if the submesh is global)
  23313. */
  23314. getBoundingInfo(): BoundingInfo;
  23315. /**
  23316. * Sets the submesh BoundingInfo
  23317. * @param boundingInfo defines the new bounding info to use
  23318. * @returns the SubMesh
  23319. */
  23320. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23321. /**
  23322. * Returns the mesh of the current submesh
  23323. * @return the parent mesh
  23324. */
  23325. getMesh(): AbstractMesh;
  23326. /**
  23327. * Returns the rendering mesh of the submesh
  23328. * @returns the rendering mesh (could be different from parent mesh)
  23329. */
  23330. getRenderingMesh(): Mesh;
  23331. /**
  23332. * Returns the submesh material
  23333. * @returns null or the current material
  23334. */
  23335. getMaterial(): Nullable<Material>;
  23336. /**
  23337. * Sets a new updated BoundingInfo object to the submesh
  23338. * @param data defines an optional position array to use to determine the bounding info
  23339. * @returns the SubMesh
  23340. */
  23341. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23342. /** @hidden */
  23343. _checkCollision(collider: Collider): boolean;
  23344. /**
  23345. * Updates the submesh BoundingInfo
  23346. * @param world defines the world matrix to use to update the bounding info
  23347. * @returns the submesh
  23348. */
  23349. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23350. /**
  23351. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23352. * @param frustumPlanes defines the frustum planes
  23353. * @returns true if the submesh is intersecting with the frustum
  23354. */
  23355. isInFrustum(frustumPlanes: Plane[]): boolean;
  23356. /**
  23357. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23358. * @param frustumPlanes defines the frustum planes
  23359. * @returns true if the submesh is inside the frustum
  23360. */
  23361. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23362. /**
  23363. * Renders the submesh
  23364. * @param enableAlphaMode defines if alpha needs to be used
  23365. * @returns the submesh
  23366. */
  23367. render(enableAlphaMode: boolean): SubMesh;
  23368. /**
  23369. * @hidden
  23370. */
  23371. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23372. /**
  23373. * Checks if the submesh intersects with a ray
  23374. * @param ray defines the ray to test
  23375. * @returns true is the passed ray intersects the submesh bounding box
  23376. */
  23377. canIntersects(ray: Ray): boolean;
  23378. /**
  23379. * Intersects current submesh with a ray
  23380. * @param ray defines the ray to test
  23381. * @param positions defines mesh's positions array
  23382. * @param indices defines mesh's indices array
  23383. * @param fastCheck defines if only bounding info should be used
  23384. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23385. * @returns intersection info or null if no intersection
  23386. */
  23387. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23388. /** @hidden */
  23389. private _intersectLines;
  23390. /** @hidden */
  23391. private _intersectUnIndexedLines;
  23392. /** @hidden */
  23393. private _intersectTriangles;
  23394. /** @hidden */
  23395. private _intersectUnIndexedTriangles;
  23396. /** @hidden */
  23397. _rebuild(): void;
  23398. /**
  23399. * Creates a new submesh from the passed mesh
  23400. * @param newMesh defines the new hosting mesh
  23401. * @param newRenderingMesh defines an optional rendering mesh
  23402. * @returns the new submesh
  23403. */
  23404. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23405. /**
  23406. * Release associated resources
  23407. */
  23408. dispose(): void;
  23409. /**
  23410. * Gets the class name
  23411. * @returns the string "SubMesh".
  23412. */
  23413. getClassName(): string;
  23414. /**
  23415. * Creates a new submesh from indices data
  23416. * @param materialIndex the index of the main mesh material
  23417. * @param startIndex the index where to start the copy in the mesh indices array
  23418. * @param indexCount the number of indices to copy then from the startIndex
  23419. * @param mesh the main mesh to create the submesh from
  23420. * @param renderingMesh the optional rendering mesh
  23421. * @returns a new submesh
  23422. */
  23423. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23424. }
  23425. }
  23426. declare module "babylonjs/Meshes/geometry" {
  23427. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23428. import { Scene } from "babylonjs/scene";
  23429. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23430. import { Engine } from "babylonjs/Engines/engine";
  23431. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23432. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23433. import { Effect } from "babylonjs/Materials/effect";
  23434. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23435. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23436. import { Mesh } from "babylonjs/Meshes/mesh";
  23437. /**
  23438. * Class used to store geometry data (vertex buffers + index buffer)
  23439. */
  23440. export class Geometry implements IGetSetVerticesData {
  23441. /**
  23442. * Gets or sets the ID of the geometry
  23443. */
  23444. id: string;
  23445. /**
  23446. * Gets or sets the unique ID of the geometry
  23447. */
  23448. uniqueId: number;
  23449. /**
  23450. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23451. */
  23452. delayLoadState: number;
  23453. /**
  23454. * Gets the file containing the data to load when running in delay load state
  23455. */
  23456. delayLoadingFile: Nullable<string>;
  23457. /**
  23458. * Callback called when the geometry is updated
  23459. */
  23460. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23461. private _scene;
  23462. private _engine;
  23463. private _meshes;
  23464. private _totalVertices;
  23465. /** @hidden */
  23466. _indices: IndicesArray;
  23467. /** @hidden */
  23468. _vertexBuffers: {
  23469. [key: string]: VertexBuffer;
  23470. };
  23471. private _isDisposed;
  23472. private _extend;
  23473. private _boundingBias;
  23474. /** @hidden */
  23475. _delayInfo: Array<string>;
  23476. private _indexBuffer;
  23477. private _indexBufferIsUpdatable;
  23478. /** @hidden */
  23479. _boundingInfo: Nullable<BoundingInfo>;
  23480. /** @hidden */
  23481. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23482. /** @hidden */
  23483. _softwareSkinningFrameId: number;
  23484. private _vertexArrayObjects;
  23485. private _updatable;
  23486. /** @hidden */
  23487. _positions: Nullable<Vector3[]>;
  23488. /**
  23489. * 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
  23490. */
  23491. /**
  23492. * 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
  23493. */
  23494. boundingBias: Vector2;
  23495. /**
  23496. * Static function used to attach a new empty geometry to a mesh
  23497. * @param mesh defines the mesh to attach the geometry to
  23498. * @returns the new Geometry
  23499. */
  23500. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23501. /**
  23502. * Creates a new geometry
  23503. * @param id defines the unique ID
  23504. * @param scene defines the hosting scene
  23505. * @param vertexData defines the VertexData used to get geometry data
  23506. * @param updatable defines if geometry must be updatable (false by default)
  23507. * @param mesh defines the mesh that will be associated with the geometry
  23508. */
  23509. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23510. /**
  23511. * Gets the current extend of the geometry
  23512. */
  23513. readonly extend: {
  23514. minimum: Vector3;
  23515. maximum: Vector3;
  23516. };
  23517. /**
  23518. * Gets the hosting scene
  23519. * @returns the hosting Scene
  23520. */
  23521. getScene(): Scene;
  23522. /**
  23523. * Gets the hosting engine
  23524. * @returns the hosting Engine
  23525. */
  23526. getEngine(): Engine;
  23527. /**
  23528. * Defines if the geometry is ready to use
  23529. * @returns true if the geometry is ready to be used
  23530. */
  23531. isReady(): boolean;
  23532. /**
  23533. * Gets a value indicating that the geometry should not be serialized
  23534. */
  23535. readonly doNotSerialize: boolean;
  23536. /** @hidden */
  23537. _rebuild(): void;
  23538. /**
  23539. * Affects all geometry data in one call
  23540. * @param vertexData defines the geometry data
  23541. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23542. */
  23543. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23544. /**
  23545. * Set specific vertex data
  23546. * @param kind defines the data kind (Position, normal, etc...)
  23547. * @param data defines the vertex data to use
  23548. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23549. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23550. */
  23551. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23552. /**
  23553. * Removes a specific vertex data
  23554. * @param kind defines the data kind (Position, normal, etc...)
  23555. */
  23556. removeVerticesData(kind: string): void;
  23557. /**
  23558. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23559. * @param buffer defines the vertex buffer to use
  23560. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23561. */
  23562. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23563. /**
  23564. * Update a specific vertex buffer
  23565. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23566. * It will do nothing if the buffer is not updatable
  23567. * @param kind defines the data kind (Position, normal, etc...)
  23568. * @param data defines the data to use
  23569. * @param offset defines the offset in the target buffer where to store the data
  23570. * @param useBytes set to true if the offset is in bytes
  23571. */
  23572. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23573. /**
  23574. * Update a specific vertex buffer
  23575. * This function will create a new buffer if the current one is not updatable
  23576. * @param kind defines the data kind (Position, normal, etc...)
  23577. * @param data defines the data to use
  23578. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23579. */
  23580. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23581. private _updateBoundingInfo;
  23582. /** @hidden */
  23583. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23584. /**
  23585. * Gets total number of vertices
  23586. * @returns the total number of vertices
  23587. */
  23588. getTotalVertices(): number;
  23589. /**
  23590. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23591. * @param kind defines the data kind (Position, normal, etc...)
  23592. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23593. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23594. * @returns a float array containing vertex data
  23595. */
  23596. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23597. /**
  23598. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23599. * @param kind defines the data kind (Position, normal, etc...)
  23600. * @returns true if the vertex buffer with the specified kind is updatable
  23601. */
  23602. isVertexBufferUpdatable(kind: string): boolean;
  23603. /**
  23604. * Gets a specific vertex buffer
  23605. * @param kind defines the data kind (Position, normal, etc...)
  23606. * @returns a VertexBuffer
  23607. */
  23608. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23609. /**
  23610. * Returns all vertex buffers
  23611. * @return an object holding all vertex buffers indexed by kind
  23612. */
  23613. getVertexBuffers(): Nullable<{
  23614. [key: string]: VertexBuffer;
  23615. }>;
  23616. /**
  23617. * Gets a boolean indicating if specific vertex buffer is present
  23618. * @param kind defines the data kind (Position, normal, etc...)
  23619. * @returns true if data is present
  23620. */
  23621. isVerticesDataPresent(kind: string): boolean;
  23622. /**
  23623. * Gets a list of all attached data kinds (Position, normal, etc...)
  23624. * @returns a list of string containing all kinds
  23625. */
  23626. getVerticesDataKinds(): string[];
  23627. /**
  23628. * Update index buffer
  23629. * @param indices defines the indices to store in the index buffer
  23630. * @param offset defines the offset in the target buffer where to store the data
  23631. * @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)
  23632. */
  23633. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23634. /**
  23635. * Creates a new index buffer
  23636. * @param indices defines the indices to store in the index buffer
  23637. * @param totalVertices defines the total number of vertices (could be null)
  23638. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23639. */
  23640. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23641. /**
  23642. * Return the total number of indices
  23643. * @returns the total number of indices
  23644. */
  23645. getTotalIndices(): number;
  23646. /**
  23647. * Gets the index buffer array
  23648. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23649. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23650. * @returns the index buffer array
  23651. */
  23652. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23653. /**
  23654. * Gets the index buffer
  23655. * @return the index buffer
  23656. */
  23657. getIndexBuffer(): Nullable<DataBuffer>;
  23658. /** @hidden */
  23659. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23660. /**
  23661. * Release the associated resources for a specific mesh
  23662. * @param mesh defines the source mesh
  23663. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23664. */
  23665. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23666. /**
  23667. * Apply current geometry to a given mesh
  23668. * @param mesh defines the mesh to apply geometry to
  23669. */
  23670. applyToMesh(mesh: Mesh): void;
  23671. private _updateExtend;
  23672. private _applyToMesh;
  23673. private notifyUpdate;
  23674. /**
  23675. * Load the geometry if it was flagged as delay loaded
  23676. * @param scene defines the hosting scene
  23677. * @param onLoaded defines a callback called when the geometry is loaded
  23678. */
  23679. load(scene: Scene, onLoaded?: () => void): void;
  23680. private _queueLoad;
  23681. /**
  23682. * Invert the geometry to move from a right handed system to a left handed one.
  23683. */
  23684. toLeftHanded(): void;
  23685. /** @hidden */
  23686. _resetPointsArrayCache(): void;
  23687. /** @hidden */
  23688. _generatePointsArray(): boolean;
  23689. /**
  23690. * Gets a value indicating if the geometry is disposed
  23691. * @returns true if the geometry was disposed
  23692. */
  23693. isDisposed(): boolean;
  23694. private _disposeVertexArrayObjects;
  23695. /**
  23696. * Free all associated resources
  23697. */
  23698. dispose(): void;
  23699. /**
  23700. * Clone the current geometry into a new geometry
  23701. * @param id defines the unique ID of the new geometry
  23702. * @returns a new geometry object
  23703. */
  23704. copy(id: string): Geometry;
  23705. /**
  23706. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23707. * @return a JSON representation of the current geometry data (without the vertices data)
  23708. */
  23709. serialize(): any;
  23710. private toNumberArray;
  23711. /**
  23712. * Serialize all vertices data into a JSON oject
  23713. * @returns a JSON representation of the current geometry data
  23714. */
  23715. serializeVerticeData(): any;
  23716. /**
  23717. * Extracts a clone of a mesh geometry
  23718. * @param mesh defines the source mesh
  23719. * @param id defines the unique ID of the new geometry object
  23720. * @returns the new geometry object
  23721. */
  23722. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23723. /**
  23724. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23725. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23726. * Be aware Math.random() could cause collisions, but:
  23727. * "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"
  23728. * @returns a string containing a new GUID
  23729. */
  23730. static RandomId(): string;
  23731. /** @hidden */
  23732. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23733. private static _CleanMatricesWeights;
  23734. /**
  23735. * Create a new geometry from persisted data (Using .babylon file format)
  23736. * @param parsedVertexData defines the persisted data
  23737. * @param scene defines the hosting scene
  23738. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23739. * @returns the new geometry object
  23740. */
  23741. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23742. }
  23743. }
  23744. declare module "babylonjs/Meshes/mesh.vertexData" {
  23745. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23746. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23747. import { Geometry } from "babylonjs/Meshes/geometry";
  23748. import { Mesh } from "babylonjs/Meshes/mesh";
  23749. /**
  23750. * Define an interface for all classes that will get and set the data on vertices
  23751. */
  23752. export interface IGetSetVerticesData {
  23753. /**
  23754. * Gets a boolean indicating if specific vertex data is present
  23755. * @param kind defines the vertex data kind to use
  23756. * @returns true is data kind is present
  23757. */
  23758. isVerticesDataPresent(kind: string): boolean;
  23759. /**
  23760. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23761. * @param kind defines the data kind (Position, normal, etc...)
  23762. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23763. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23764. * @returns a float array containing vertex data
  23765. */
  23766. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23767. /**
  23768. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23769. * @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.
  23770. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23771. * @returns the indices array or an empty array if the mesh has no geometry
  23772. */
  23773. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23774. /**
  23775. * Set specific vertex data
  23776. * @param kind defines the data kind (Position, normal, etc...)
  23777. * @param data defines the vertex data to use
  23778. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23779. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23780. */
  23781. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23782. /**
  23783. * Update a specific associated vertex buffer
  23784. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23785. * - VertexBuffer.PositionKind
  23786. * - VertexBuffer.UVKind
  23787. * - VertexBuffer.UV2Kind
  23788. * - VertexBuffer.UV3Kind
  23789. * - VertexBuffer.UV4Kind
  23790. * - VertexBuffer.UV5Kind
  23791. * - VertexBuffer.UV6Kind
  23792. * - VertexBuffer.ColorKind
  23793. * - VertexBuffer.MatricesIndicesKind
  23794. * - VertexBuffer.MatricesIndicesExtraKind
  23795. * - VertexBuffer.MatricesWeightsKind
  23796. * - VertexBuffer.MatricesWeightsExtraKind
  23797. * @param data defines the data source
  23798. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23799. * @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)
  23800. */
  23801. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23802. /**
  23803. * Creates a new index buffer
  23804. * @param indices defines the indices to store in the index buffer
  23805. * @param totalVertices defines the total number of vertices (could be null)
  23806. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23807. */
  23808. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23809. }
  23810. /**
  23811. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23812. */
  23813. export class VertexData {
  23814. /**
  23815. * Mesh side orientation : usually the external or front surface
  23816. */
  23817. static readonly FRONTSIDE: number;
  23818. /**
  23819. * Mesh side orientation : usually the internal or back surface
  23820. */
  23821. static readonly BACKSIDE: number;
  23822. /**
  23823. * Mesh side orientation : both internal and external or front and back surfaces
  23824. */
  23825. static readonly DOUBLESIDE: number;
  23826. /**
  23827. * Mesh side orientation : by default, `FRONTSIDE`
  23828. */
  23829. static readonly DEFAULTSIDE: number;
  23830. /**
  23831. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23832. */
  23833. positions: Nullable<FloatArray>;
  23834. /**
  23835. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23836. */
  23837. normals: Nullable<FloatArray>;
  23838. /**
  23839. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23840. */
  23841. tangents: Nullable<FloatArray>;
  23842. /**
  23843. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23844. */
  23845. uvs: Nullable<FloatArray>;
  23846. /**
  23847. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23848. */
  23849. uvs2: Nullable<FloatArray>;
  23850. /**
  23851. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23852. */
  23853. uvs3: Nullable<FloatArray>;
  23854. /**
  23855. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23856. */
  23857. uvs4: Nullable<FloatArray>;
  23858. /**
  23859. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23860. */
  23861. uvs5: Nullable<FloatArray>;
  23862. /**
  23863. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23864. */
  23865. uvs6: Nullable<FloatArray>;
  23866. /**
  23867. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23868. */
  23869. colors: Nullable<FloatArray>;
  23870. /**
  23871. * 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).
  23872. */
  23873. matricesIndices: Nullable<FloatArray>;
  23874. /**
  23875. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23876. */
  23877. matricesWeights: Nullable<FloatArray>;
  23878. /**
  23879. * An array extending the number of possible indices
  23880. */
  23881. matricesIndicesExtra: Nullable<FloatArray>;
  23882. /**
  23883. * An array extending the number of possible weights when the number of indices is extended
  23884. */
  23885. matricesWeightsExtra: Nullable<FloatArray>;
  23886. /**
  23887. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23888. */
  23889. indices: Nullable<IndicesArray>;
  23890. /**
  23891. * Uses the passed data array to set the set the values for the specified kind of data
  23892. * @param data a linear array of floating numbers
  23893. * @param kind the type of data that is being set, eg positions, colors etc
  23894. */
  23895. set(data: FloatArray, kind: string): void;
  23896. /**
  23897. * Associates the vertexData to the passed Mesh.
  23898. * Sets it as updatable or not (default `false`)
  23899. * @param mesh the mesh the vertexData is applied to
  23900. * @param updatable when used and having the value true allows new data to update the vertexData
  23901. * @returns the VertexData
  23902. */
  23903. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23904. /**
  23905. * Associates the vertexData to the passed Geometry.
  23906. * Sets it as updatable or not (default `false`)
  23907. * @param geometry the geometry the vertexData is applied to
  23908. * @param updatable when used and having the value true allows new data to update the vertexData
  23909. * @returns VertexData
  23910. */
  23911. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23912. /**
  23913. * Updates the associated mesh
  23914. * @param mesh the mesh to be updated
  23915. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23916. * @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
  23917. * @returns VertexData
  23918. */
  23919. updateMesh(mesh: Mesh): VertexData;
  23920. /**
  23921. * Updates the associated geometry
  23922. * @param geometry the geometry to be updated
  23923. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23924. * @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
  23925. * @returns VertexData.
  23926. */
  23927. updateGeometry(geometry: Geometry): VertexData;
  23928. private _applyTo;
  23929. private _update;
  23930. /**
  23931. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23932. * @param matrix the transforming matrix
  23933. * @returns the VertexData
  23934. */
  23935. transform(matrix: Matrix): VertexData;
  23936. /**
  23937. * Merges the passed VertexData into the current one
  23938. * @param other the VertexData to be merged into the current one
  23939. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23940. * @returns the modified VertexData
  23941. */
  23942. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23943. private _mergeElement;
  23944. private _validate;
  23945. /**
  23946. * Serializes the VertexData
  23947. * @returns a serialized object
  23948. */
  23949. serialize(): any;
  23950. /**
  23951. * Extracts the vertexData from a mesh
  23952. * @param mesh the mesh from which to extract the VertexData
  23953. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23954. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23955. * @returns the object VertexData associated to the passed mesh
  23956. */
  23957. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23958. /**
  23959. * Extracts the vertexData from the geometry
  23960. * @param geometry the geometry from which to extract the VertexData
  23961. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23962. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23963. * @returns the object VertexData associated to the passed mesh
  23964. */
  23965. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23966. private static _ExtractFrom;
  23967. /**
  23968. * Creates the VertexData for a Ribbon
  23969. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23970. * * pathArray array of paths, each of which an array of successive Vector3
  23971. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23972. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23973. * * 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
  23974. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23975. * * 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)
  23976. * * 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)
  23977. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23978. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23979. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23980. * @returns the VertexData of the ribbon
  23981. */
  23982. static CreateRibbon(options: {
  23983. pathArray: Vector3[][];
  23984. closeArray?: boolean;
  23985. closePath?: boolean;
  23986. offset?: number;
  23987. sideOrientation?: number;
  23988. frontUVs?: Vector4;
  23989. backUVs?: Vector4;
  23990. invertUV?: boolean;
  23991. uvs?: Vector2[];
  23992. colors?: Color4[];
  23993. }): VertexData;
  23994. /**
  23995. * Creates the VertexData for a box
  23996. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23997. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23998. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23999. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  24000. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  24001. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24002. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24003. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24004. * * 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)
  24005. * * 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)
  24006. * @returns the VertexData of the box
  24007. */
  24008. static CreateBox(options: {
  24009. size?: number;
  24010. width?: number;
  24011. height?: number;
  24012. depth?: number;
  24013. faceUV?: Vector4[];
  24014. faceColors?: Color4[];
  24015. sideOrientation?: number;
  24016. frontUVs?: Vector4;
  24017. backUVs?: Vector4;
  24018. }): VertexData;
  24019. /**
  24020. * Creates the VertexData for a tiled box
  24021. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24022. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24023. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24024. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24025. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24026. * @returns the VertexData of the box
  24027. */
  24028. static CreateTiledBox(options: {
  24029. pattern?: number;
  24030. width?: number;
  24031. height?: number;
  24032. depth?: number;
  24033. tileSize?: number;
  24034. tileWidth?: number;
  24035. tileHeight?: number;
  24036. alignHorizontal?: number;
  24037. alignVertical?: number;
  24038. faceUV?: Vector4[];
  24039. faceColors?: Color4[];
  24040. sideOrientation?: number;
  24041. }): VertexData;
  24042. /**
  24043. * Creates the VertexData for a tiled plane
  24044. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24045. * * pattern a limited pattern arrangement depending on the number
  24046. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24047. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24048. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24049. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24050. * * 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)
  24051. * * 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)
  24052. * @returns the VertexData of the tiled plane
  24053. */
  24054. static CreateTiledPlane(options: {
  24055. pattern?: number;
  24056. tileSize?: number;
  24057. tileWidth?: number;
  24058. tileHeight?: number;
  24059. size?: number;
  24060. width?: number;
  24061. height?: number;
  24062. alignHorizontal?: number;
  24063. alignVertical?: number;
  24064. sideOrientation?: number;
  24065. frontUVs?: Vector4;
  24066. backUVs?: Vector4;
  24067. }): VertexData;
  24068. /**
  24069. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24070. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24071. * * segments sets the number of horizontal strips optional, default 32
  24072. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24073. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24074. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24075. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24076. * * 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
  24077. * * 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
  24078. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24079. * * 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)
  24080. * * 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)
  24081. * @returns the VertexData of the ellipsoid
  24082. */
  24083. static CreateSphere(options: {
  24084. segments?: number;
  24085. diameter?: number;
  24086. diameterX?: number;
  24087. diameterY?: number;
  24088. diameterZ?: number;
  24089. arc?: number;
  24090. slice?: number;
  24091. sideOrientation?: number;
  24092. frontUVs?: Vector4;
  24093. backUVs?: Vector4;
  24094. }): VertexData;
  24095. /**
  24096. * Creates the VertexData for a cylinder, cone or prism
  24097. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24098. * * height sets the height (y direction) of the cylinder, optional, default 2
  24099. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24100. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24101. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24102. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24103. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24104. * * 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
  24105. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24106. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24107. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24108. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24109. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24110. * * 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)
  24111. * * 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)
  24112. * @returns the VertexData of the cylinder, cone or prism
  24113. */
  24114. static CreateCylinder(options: {
  24115. height?: number;
  24116. diameterTop?: number;
  24117. diameterBottom?: number;
  24118. diameter?: number;
  24119. tessellation?: number;
  24120. subdivisions?: number;
  24121. arc?: number;
  24122. faceColors?: Color4[];
  24123. faceUV?: Vector4[];
  24124. hasRings?: boolean;
  24125. enclose?: boolean;
  24126. sideOrientation?: number;
  24127. frontUVs?: Vector4;
  24128. backUVs?: Vector4;
  24129. }): VertexData;
  24130. /**
  24131. * Creates the VertexData for a torus
  24132. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24133. * * diameter the diameter of the torus, optional default 1
  24134. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24135. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24136. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24137. * * 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)
  24138. * * 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)
  24139. * @returns the VertexData of the torus
  24140. */
  24141. static CreateTorus(options: {
  24142. diameter?: number;
  24143. thickness?: number;
  24144. tessellation?: number;
  24145. sideOrientation?: number;
  24146. frontUVs?: Vector4;
  24147. backUVs?: Vector4;
  24148. }): VertexData;
  24149. /**
  24150. * Creates the VertexData of the LineSystem
  24151. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24152. * - lines an array of lines, each line being an array of successive Vector3
  24153. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24154. * @returns the VertexData of the LineSystem
  24155. */
  24156. static CreateLineSystem(options: {
  24157. lines: Vector3[][];
  24158. colors?: Nullable<Color4[][]>;
  24159. }): VertexData;
  24160. /**
  24161. * Create the VertexData for a DashedLines
  24162. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24163. * - points an array successive Vector3
  24164. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24165. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24166. * - dashNb the intended total number of dashes, optional, default 200
  24167. * @returns the VertexData for the DashedLines
  24168. */
  24169. static CreateDashedLines(options: {
  24170. points: Vector3[];
  24171. dashSize?: number;
  24172. gapSize?: number;
  24173. dashNb?: number;
  24174. }): VertexData;
  24175. /**
  24176. * Creates the VertexData for a Ground
  24177. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24178. * - width the width (x direction) of the ground, optional, default 1
  24179. * - height the height (z direction) of the ground, optional, default 1
  24180. * - subdivisions the number of subdivisions per side, optional, default 1
  24181. * @returns the VertexData of the Ground
  24182. */
  24183. static CreateGround(options: {
  24184. width?: number;
  24185. height?: number;
  24186. subdivisions?: number;
  24187. subdivisionsX?: number;
  24188. subdivisionsY?: number;
  24189. }): VertexData;
  24190. /**
  24191. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24192. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24193. * * xmin the ground minimum X coordinate, optional, default -1
  24194. * * zmin the ground minimum Z coordinate, optional, default -1
  24195. * * xmax the ground maximum X coordinate, optional, default 1
  24196. * * zmax the ground maximum Z coordinate, optional, default 1
  24197. * * 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}
  24198. * * 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}
  24199. * @returns the VertexData of the TiledGround
  24200. */
  24201. static CreateTiledGround(options: {
  24202. xmin: number;
  24203. zmin: number;
  24204. xmax: number;
  24205. zmax: number;
  24206. subdivisions?: {
  24207. w: number;
  24208. h: number;
  24209. };
  24210. precision?: {
  24211. w: number;
  24212. h: number;
  24213. };
  24214. }): VertexData;
  24215. /**
  24216. * Creates the VertexData of the Ground designed from a heightmap
  24217. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24218. * * width the width (x direction) of the ground
  24219. * * height the height (z direction) of the ground
  24220. * * subdivisions the number of subdivisions per side
  24221. * * minHeight the minimum altitude on the ground, optional, default 0
  24222. * * maxHeight the maximum altitude on the ground, optional default 1
  24223. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24224. * * buffer the array holding the image color data
  24225. * * bufferWidth the width of image
  24226. * * bufferHeight the height of image
  24227. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24228. * @returns the VertexData of the Ground designed from a heightmap
  24229. */
  24230. static CreateGroundFromHeightMap(options: {
  24231. width: number;
  24232. height: number;
  24233. subdivisions: number;
  24234. minHeight: number;
  24235. maxHeight: number;
  24236. colorFilter: Color3;
  24237. buffer: Uint8Array;
  24238. bufferWidth: number;
  24239. bufferHeight: number;
  24240. alphaFilter: number;
  24241. }): VertexData;
  24242. /**
  24243. * Creates the VertexData for a Plane
  24244. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24245. * * size sets the width and height of the plane to the value of size, optional default 1
  24246. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24247. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24248. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24249. * * 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)
  24250. * * 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)
  24251. * @returns the VertexData of the box
  24252. */
  24253. static CreatePlane(options: {
  24254. size?: number;
  24255. width?: number;
  24256. height?: number;
  24257. sideOrientation?: number;
  24258. frontUVs?: Vector4;
  24259. backUVs?: Vector4;
  24260. }): VertexData;
  24261. /**
  24262. * Creates the VertexData of the Disc or regular Polygon
  24263. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24264. * * radius the radius of the disc, optional default 0.5
  24265. * * tessellation the number of polygon sides, optional, default 64
  24266. * * 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
  24267. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24268. * * 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)
  24269. * * 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)
  24270. * @returns the VertexData of the box
  24271. */
  24272. static CreateDisc(options: {
  24273. radius?: number;
  24274. tessellation?: number;
  24275. arc?: number;
  24276. sideOrientation?: number;
  24277. frontUVs?: Vector4;
  24278. backUVs?: Vector4;
  24279. }): VertexData;
  24280. /**
  24281. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24282. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24283. * @param polygon a mesh built from polygonTriangulation.build()
  24284. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24285. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24286. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24287. * @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)
  24288. * @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)
  24289. * @returns the VertexData of the Polygon
  24290. */
  24291. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24292. /**
  24293. * Creates the VertexData of the IcoSphere
  24294. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24295. * * radius the radius of the IcoSphere, optional default 1
  24296. * * radiusX allows stretching in the x direction, optional, default radius
  24297. * * radiusY allows stretching in the y direction, optional, default radius
  24298. * * radiusZ allows stretching in the z direction, optional, default radius
  24299. * * flat when true creates a flat shaded mesh, optional, default true
  24300. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24301. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24302. * * 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)
  24303. * * 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)
  24304. * @returns the VertexData of the IcoSphere
  24305. */
  24306. static CreateIcoSphere(options: {
  24307. radius?: number;
  24308. radiusX?: number;
  24309. radiusY?: number;
  24310. radiusZ?: number;
  24311. flat?: boolean;
  24312. subdivisions?: number;
  24313. sideOrientation?: number;
  24314. frontUVs?: Vector4;
  24315. backUVs?: Vector4;
  24316. }): VertexData;
  24317. /**
  24318. * Creates the VertexData for a Polyhedron
  24319. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24320. * * type provided types are:
  24321. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24322. * * 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)
  24323. * * size the size of the IcoSphere, optional default 1
  24324. * * sizeX allows stretching in the x direction, optional, default size
  24325. * * sizeY allows stretching in the y direction, optional, default size
  24326. * * sizeZ allows stretching in the z direction, optional, default size
  24327. * * 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
  24328. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24329. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24330. * * flat when true creates a flat shaded mesh, optional, default true
  24331. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24332. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24333. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  24334. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  24335. * @returns the VertexData of the Polyhedron
  24336. */
  24337. static CreatePolyhedron(options: {
  24338. type?: number;
  24339. size?: number;
  24340. sizeX?: number;
  24341. sizeY?: number;
  24342. sizeZ?: number;
  24343. custom?: any;
  24344. faceUV?: Vector4[];
  24345. faceColors?: Color4[];
  24346. flat?: boolean;
  24347. sideOrientation?: number;
  24348. frontUVs?: Vector4;
  24349. backUVs?: Vector4;
  24350. }): VertexData;
  24351. /**
  24352. * Creates the VertexData for a TorusKnot
  24353. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24354. * * radius the radius of the torus knot, optional, default 2
  24355. * * tube the thickness of the tube, optional, default 0.5
  24356. * * radialSegments the number of sides on each tube segments, optional, default 32
  24357. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24358. * * p the number of windings around the z axis, optional, default 2
  24359. * * q the number of windings around the x axis, optional, default 3
  24360. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24361. * * 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)
  24362. * * 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)
  24363. * @returns the VertexData of the Torus Knot
  24364. */
  24365. static CreateTorusKnot(options: {
  24366. radius?: number;
  24367. tube?: number;
  24368. radialSegments?: number;
  24369. tubularSegments?: number;
  24370. p?: number;
  24371. q?: number;
  24372. sideOrientation?: number;
  24373. frontUVs?: Vector4;
  24374. backUVs?: Vector4;
  24375. }): VertexData;
  24376. /**
  24377. * Compute normals for given positions and indices
  24378. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24379. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24380. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24381. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24382. * * facetNormals : optional array of facet normals (vector3)
  24383. * * facetPositions : optional array of facet positions (vector3)
  24384. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24385. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24386. * * bInfo : optional bounding info, required for facetPartitioning computation
  24387. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24388. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24389. * * useRightHandedSystem: optional boolean to for right handed system computation
  24390. * * depthSort : optional boolean to enable the facet depth sort computation
  24391. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24392. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24393. */
  24394. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24395. facetNormals?: any;
  24396. facetPositions?: any;
  24397. facetPartitioning?: any;
  24398. ratio?: number;
  24399. bInfo?: any;
  24400. bbSize?: Vector3;
  24401. subDiv?: any;
  24402. useRightHandedSystem?: boolean;
  24403. depthSort?: boolean;
  24404. distanceTo?: Vector3;
  24405. depthSortedFacets?: any;
  24406. }): void;
  24407. /** @hidden */
  24408. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24409. /**
  24410. * Applies VertexData created from the imported parameters to the geometry
  24411. * @param parsedVertexData the parsed data from an imported file
  24412. * @param geometry the geometry to apply the VertexData to
  24413. */
  24414. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24415. }
  24416. }
  24417. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24418. import { Nullable } from "babylonjs/types";
  24419. import { Scene } from "babylonjs/scene";
  24420. import { Vector4 } from "babylonjs/Maths/math";
  24421. import { Mesh } from "babylonjs/Meshes/mesh";
  24422. /**
  24423. * Class containing static functions to help procedurally build meshes
  24424. */
  24425. export class DiscBuilder {
  24426. /**
  24427. * Creates a plane polygonal mesh. By default, this is a disc
  24428. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24429. * * 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
  24430. * * 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
  24431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24434. * @param name defines the name of the mesh
  24435. * @param options defines the options used to create the mesh
  24436. * @param scene defines the hosting scene
  24437. * @returns the plane polygonal mesh
  24438. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24439. */
  24440. static CreateDisc(name: string, options: {
  24441. radius?: number;
  24442. tessellation?: number;
  24443. arc?: number;
  24444. updatable?: boolean;
  24445. sideOrientation?: number;
  24446. frontUVs?: Vector4;
  24447. backUVs?: Vector4;
  24448. }, scene?: Nullable<Scene>): Mesh;
  24449. }
  24450. }
  24451. declare module "babylonjs/Particles/solidParticleSystem" {
  24452. import { Vector3 } from "babylonjs/Maths/math";
  24453. import { Mesh } from "babylonjs/Meshes/mesh";
  24454. import { Scene, IDisposable } from "babylonjs/scene";
  24455. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24456. /**
  24457. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24458. *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.
  24459. * The SPS is also a particle system. It provides some methods to manage the particles.
  24460. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24461. *
  24462. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24463. */
  24464. export class SolidParticleSystem implements IDisposable {
  24465. /**
  24466. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24467. * Example : var p = SPS.particles[i];
  24468. */
  24469. particles: SolidParticle[];
  24470. /**
  24471. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24472. */
  24473. nbParticles: number;
  24474. /**
  24475. * If the particles must ever face the camera (default false). Useful for planar particles.
  24476. */
  24477. billboard: boolean;
  24478. /**
  24479. * Recompute normals when adding a shape
  24480. */
  24481. recomputeNormals: boolean;
  24482. /**
  24483. * This a counter ofr your own usage. It's not set by any SPS functions.
  24484. */
  24485. counter: number;
  24486. /**
  24487. * The SPS name. This name is also given to the underlying mesh.
  24488. */
  24489. name: string;
  24490. /**
  24491. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24492. */
  24493. mesh: Mesh;
  24494. /**
  24495. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24496. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24497. */
  24498. vars: any;
  24499. /**
  24500. * This array is populated when the SPS is set as 'pickable'.
  24501. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24502. * Each element of this array is an object `{idx: int, faceId: int}`.
  24503. * `idx` is the picked particle index in the `SPS.particles` array
  24504. * `faceId` is the picked face index counted within this particle.
  24505. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24506. */
  24507. pickedParticles: {
  24508. idx: number;
  24509. faceId: number;
  24510. }[];
  24511. /**
  24512. * This array is populated when `enableDepthSort` is set to true.
  24513. * Each element of this array is an instance of the class DepthSortedParticle.
  24514. */
  24515. depthSortedParticles: DepthSortedParticle[];
  24516. /**
  24517. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24518. * @hidden
  24519. */
  24520. _bSphereOnly: boolean;
  24521. /**
  24522. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24523. * @hidden
  24524. */
  24525. _bSphereRadiusFactor: number;
  24526. private _scene;
  24527. private _positions;
  24528. private _indices;
  24529. private _normals;
  24530. private _colors;
  24531. private _uvs;
  24532. private _indices32;
  24533. private _positions32;
  24534. private _normals32;
  24535. private _fixedNormal32;
  24536. private _colors32;
  24537. private _uvs32;
  24538. private _index;
  24539. private _updatable;
  24540. private _pickable;
  24541. private _isVisibilityBoxLocked;
  24542. private _alwaysVisible;
  24543. private _depthSort;
  24544. private _shapeCounter;
  24545. private _copy;
  24546. private _color;
  24547. private _computeParticleColor;
  24548. private _computeParticleTexture;
  24549. private _computeParticleRotation;
  24550. private _computeParticleVertex;
  24551. private _computeBoundingBox;
  24552. private _depthSortParticles;
  24553. private _camera;
  24554. private _mustUnrotateFixedNormals;
  24555. private _particlesIntersect;
  24556. private _needs32Bits;
  24557. /**
  24558. * Creates a SPS (Solid Particle System) object.
  24559. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24560. * @param scene (Scene) is the scene in which the SPS is added.
  24561. * @param options defines the options of the sps e.g.
  24562. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24563. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24564. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24565. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24566. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24567. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24568. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24569. */
  24570. constructor(name: string, scene: Scene, options?: {
  24571. updatable?: boolean;
  24572. isPickable?: boolean;
  24573. enableDepthSort?: boolean;
  24574. particleIntersection?: boolean;
  24575. boundingSphereOnly?: boolean;
  24576. bSphereRadiusFactor?: number;
  24577. });
  24578. /**
  24579. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24580. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24581. * @returns the created mesh
  24582. */
  24583. buildMesh(): Mesh;
  24584. /**
  24585. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24586. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24587. * Thus the particles generated from `digest()` have their property `position` set yet.
  24588. * @param mesh ( Mesh ) is the mesh to be digested
  24589. * @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
  24590. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24591. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24592. * @returns the current SPS
  24593. */
  24594. digest(mesh: Mesh, options?: {
  24595. facetNb?: number;
  24596. number?: number;
  24597. delta?: number;
  24598. }): SolidParticleSystem;
  24599. private _unrotateFixedNormals;
  24600. private _resetCopy;
  24601. private _meshBuilder;
  24602. private _posToShape;
  24603. private _uvsToShapeUV;
  24604. private _addParticle;
  24605. /**
  24606. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24607. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24608. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24609. * @param nb (positive integer) the number of particles to be created from this model
  24610. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24611. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24612. * @returns the number of shapes in the system
  24613. */
  24614. addShape(mesh: Mesh, nb: number, options?: {
  24615. positionFunction?: any;
  24616. vertexFunction?: any;
  24617. }): number;
  24618. private _rebuildParticle;
  24619. /**
  24620. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24621. * @returns the SPS.
  24622. */
  24623. rebuildMesh(): SolidParticleSystem;
  24624. /**
  24625. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24626. * This method calls `updateParticle()` for each particle of the SPS.
  24627. * For an animated SPS, it is usually called within the render loop.
  24628. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24629. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24630. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24631. * @returns the SPS.
  24632. */
  24633. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24634. /**
  24635. * Disposes the SPS.
  24636. */
  24637. dispose(): void;
  24638. /**
  24639. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24640. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24641. * @returns the SPS.
  24642. */
  24643. refreshVisibleSize(): SolidParticleSystem;
  24644. /**
  24645. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24646. * @param size the size (float) of the visibility box
  24647. * note : this doesn't lock the SPS mesh bounding box.
  24648. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24649. */
  24650. setVisibilityBox(size: number): void;
  24651. /**
  24652. * Gets whether the SPS as always visible or not
  24653. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24654. */
  24655. /**
  24656. * Sets the SPS as always visible or not
  24657. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24658. */
  24659. isAlwaysVisible: boolean;
  24660. /**
  24661. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24662. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24663. */
  24664. /**
  24665. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24666. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24667. */
  24668. isVisibilityBoxLocked: boolean;
  24669. /**
  24670. * Tells to `setParticles()` to compute the particle rotations or not.
  24671. * Default value : true. The SPS is faster when it's set to false.
  24672. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24673. */
  24674. /**
  24675. * Gets if `setParticles()` computes the particle rotations or not.
  24676. * Default value : true. The SPS is faster when it's set to false.
  24677. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24678. */
  24679. computeParticleRotation: boolean;
  24680. /**
  24681. * Tells to `setParticles()` to compute the particle colors or not.
  24682. * Default value : true. The SPS is faster when it's set to false.
  24683. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24684. */
  24685. /**
  24686. * Gets if `setParticles()` computes the particle colors or not.
  24687. * Default value : true. The SPS is faster when it's set to false.
  24688. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24689. */
  24690. computeParticleColor: boolean;
  24691. /**
  24692. * Gets if `setParticles()` computes the particle textures or not.
  24693. * Default value : true. The SPS is faster when it's set to false.
  24694. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24695. */
  24696. computeParticleTexture: boolean;
  24697. /**
  24698. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24699. * Default value : false. The SPS is faster when it's set to false.
  24700. * Note : the particle custom vertex positions aren't stored values.
  24701. */
  24702. /**
  24703. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24704. * Default value : false. The SPS is faster when it's set to false.
  24705. * Note : the particle custom vertex positions aren't stored values.
  24706. */
  24707. computeParticleVertex: boolean;
  24708. /**
  24709. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24710. */
  24711. /**
  24712. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24713. */
  24714. computeBoundingBox: boolean;
  24715. /**
  24716. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24717. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24718. * Default : `true`
  24719. */
  24720. /**
  24721. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24722. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24723. * Default : `true`
  24724. */
  24725. depthSortParticles: boolean;
  24726. /**
  24727. * This function does nothing. It may be overwritten to set all the particle first values.
  24728. * The SPS doesn't call this function, you may have to call it by your own.
  24729. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24730. */
  24731. initParticles(): void;
  24732. /**
  24733. * This function does nothing. It may be overwritten to recycle a particle.
  24734. * The SPS doesn't call this function, you may have to call it by your own.
  24735. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24736. * @param particle The particle to recycle
  24737. * @returns the recycled particle
  24738. */
  24739. recycleParticle(particle: SolidParticle): SolidParticle;
  24740. /**
  24741. * Updates a particle : this function should be overwritten by the user.
  24742. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24743. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24744. * @example : just set a particle position or velocity and recycle conditions
  24745. * @param particle The particle to update
  24746. * @returns the updated particle
  24747. */
  24748. updateParticle(particle: SolidParticle): SolidParticle;
  24749. /**
  24750. * Updates a vertex of a particle : it can be overwritten by the user.
  24751. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24752. * @param particle the current particle
  24753. * @param vertex the current index of the current particle
  24754. * @param pt the index of the current vertex in the particle shape
  24755. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24756. * @example : just set a vertex particle position
  24757. * @returns the updated vertex
  24758. */
  24759. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24760. /**
  24761. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24762. * This does nothing and may be overwritten by the user.
  24763. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24764. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24765. * @param update the boolean update value actually passed to setParticles()
  24766. */
  24767. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24768. /**
  24769. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24770. * This will be passed three parameters.
  24771. * This does nothing and may be overwritten by the user.
  24772. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24773. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24774. * @param update the boolean update value actually passed to setParticles()
  24775. */
  24776. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24777. }
  24778. }
  24779. declare module "babylonjs/Particles/solidParticle" {
  24780. import { Nullable } from "babylonjs/types";
  24781. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24782. import { Mesh } from "babylonjs/Meshes/mesh";
  24783. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24784. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24785. /**
  24786. * Represents one particle of a solid particle system.
  24787. */
  24788. export class SolidParticle {
  24789. /**
  24790. * particle global index
  24791. */
  24792. idx: number;
  24793. /**
  24794. * The color of the particle
  24795. */
  24796. color: Nullable<Color4>;
  24797. /**
  24798. * The world space position of the particle.
  24799. */
  24800. position: Vector3;
  24801. /**
  24802. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24803. */
  24804. rotation: Vector3;
  24805. /**
  24806. * The world space rotation quaternion of the particle.
  24807. */
  24808. rotationQuaternion: Nullable<Quaternion>;
  24809. /**
  24810. * The scaling of the particle.
  24811. */
  24812. scaling: Vector3;
  24813. /**
  24814. * The uvs of the particle.
  24815. */
  24816. uvs: Vector4;
  24817. /**
  24818. * The current speed of the particle.
  24819. */
  24820. velocity: Vector3;
  24821. /**
  24822. * The pivot point in the particle local space.
  24823. */
  24824. pivot: Vector3;
  24825. /**
  24826. * Must the particle be translated from its pivot point in its local space ?
  24827. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24828. * Default : false
  24829. */
  24830. translateFromPivot: boolean;
  24831. /**
  24832. * Is the particle active or not ?
  24833. */
  24834. alive: boolean;
  24835. /**
  24836. * Is the particle visible or not ?
  24837. */
  24838. isVisible: boolean;
  24839. /**
  24840. * Index of this particle in the global "positions" array (Internal use)
  24841. * @hidden
  24842. */
  24843. _pos: number;
  24844. /**
  24845. * @hidden Index of this particle in the global "indices" array (Internal use)
  24846. */
  24847. _ind: number;
  24848. /**
  24849. * @hidden ModelShape of this particle (Internal use)
  24850. */
  24851. _model: ModelShape;
  24852. /**
  24853. * ModelShape id of this particle
  24854. */
  24855. shapeId: number;
  24856. /**
  24857. * Index of the particle in its shape id (Internal use)
  24858. */
  24859. idxInShape: number;
  24860. /**
  24861. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24862. */
  24863. _modelBoundingInfo: BoundingInfo;
  24864. /**
  24865. * @hidden Particle BoundingInfo object (Internal use)
  24866. */
  24867. _boundingInfo: BoundingInfo;
  24868. /**
  24869. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24870. */
  24871. _sps: SolidParticleSystem;
  24872. /**
  24873. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24874. */
  24875. _stillInvisible: boolean;
  24876. /**
  24877. * @hidden Last computed particle rotation matrix
  24878. */
  24879. _rotationMatrix: number[];
  24880. /**
  24881. * Parent particle Id, if any.
  24882. * Default null.
  24883. */
  24884. parentId: Nullable<number>;
  24885. /**
  24886. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24887. * The possible values are :
  24888. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24889. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24890. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24891. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24892. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24893. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24894. * */
  24895. cullingStrategy: number;
  24896. /**
  24897. * @hidden Internal global position in the SPS.
  24898. */
  24899. _globalPosition: Vector3;
  24900. /**
  24901. * Creates a Solid Particle object.
  24902. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24903. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24904. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24905. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24906. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24907. * @param shapeId (integer) is the model shape identifier in the SPS.
  24908. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24909. * @param sps defines the sps it is associated to
  24910. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24911. */
  24912. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24913. /**
  24914. * Legacy support, changed scale to scaling
  24915. */
  24916. /**
  24917. * Legacy support, changed scale to scaling
  24918. */
  24919. scale: Vector3;
  24920. /**
  24921. * Legacy support, changed quaternion to rotationQuaternion
  24922. */
  24923. /**
  24924. * Legacy support, changed quaternion to rotationQuaternion
  24925. */
  24926. quaternion: Nullable<Quaternion>;
  24927. /**
  24928. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24929. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24930. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24931. * @returns true if it intersects
  24932. */
  24933. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24934. /**
  24935. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24936. * A particle is in the frustum if its bounding box intersects the frustum
  24937. * @param frustumPlanes defines the frustum to test
  24938. * @returns true if the particle is in the frustum planes
  24939. */
  24940. isInFrustum(frustumPlanes: Plane[]): boolean;
  24941. /**
  24942. * get the rotation matrix of the particle
  24943. * @hidden
  24944. */
  24945. getRotationMatrix(m: Matrix): void;
  24946. }
  24947. /**
  24948. * Represents the shape of the model used by one particle of a solid particle system.
  24949. * SPS internal tool, don't use it manually.
  24950. */
  24951. export class ModelShape {
  24952. /**
  24953. * The shape id
  24954. * @hidden
  24955. */
  24956. shapeID: number;
  24957. /**
  24958. * flat array of model positions (internal use)
  24959. * @hidden
  24960. */
  24961. _shape: Vector3[];
  24962. /**
  24963. * flat array of model UVs (internal use)
  24964. * @hidden
  24965. */
  24966. _shapeUV: number[];
  24967. /**
  24968. * length of the shape in the model indices array (internal use)
  24969. * @hidden
  24970. */
  24971. _indicesLength: number;
  24972. /**
  24973. * Custom position function (internal use)
  24974. * @hidden
  24975. */
  24976. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24977. /**
  24978. * Custom vertex function (internal use)
  24979. * @hidden
  24980. */
  24981. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24982. /**
  24983. * 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.
  24984. * SPS internal tool, don't use it manually.
  24985. * @hidden
  24986. */
  24987. 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>);
  24988. }
  24989. /**
  24990. * Represents a Depth Sorted Particle in the solid particle system.
  24991. */
  24992. export class DepthSortedParticle {
  24993. /**
  24994. * Index of the particle in the "indices" array
  24995. */
  24996. ind: number;
  24997. /**
  24998. * Length of the particle shape in the "indices" array
  24999. */
  25000. indicesLength: number;
  25001. /**
  25002. * Squared distance from the particle to the camera
  25003. */
  25004. sqDistance: number;
  25005. }
  25006. }
  25007. declare module "babylonjs/Collisions/meshCollisionData" {
  25008. import { Collider } from "babylonjs/Collisions/collider";
  25009. import { Vector3 } from "babylonjs/Maths/math";
  25010. import { Nullable } from "babylonjs/types";
  25011. import { Observer } from "babylonjs/Misc/observable";
  25012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25013. /**
  25014. * @hidden
  25015. */
  25016. export class _MeshCollisionData {
  25017. _checkCollisions: boolean;
  25018. _collisionMask: number;
  25019. _collisionGroup: number;
  25020. _collider: Nullable<Collider>;
  25021. _oldPositionForCollisions: Vector3;
  25022. _diffPositionForCollisions: Vector3;
  25023. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25024. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25025. }
  25026. }
  25027. declare module "babylonjs/Meshes/abstractMesh" {
  25028. import { Observable } from "babylonjs/Misc/observable";
  25029. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25030. import { Camera } from "babylonjs/Cameras/camera";
  25031. import { Scene, IDisposable } from "babylonjs/scene";
  25032. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25033. import { Node } from "babylonjs/node";
  25034. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25035. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25036. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25037. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25038. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25039. import { Material } from "babylonjs/Materials/material";
  25040. import { Light } from "babylonjs/Lights/light";
  25041. import { Skeleton } from "babylonjs/Bones/skeleton";
  25042. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25043. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25044. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25045. import { Ray } from "babylonjs/Culling/ray";
  25046. import { Collider } from "babylonjs/Collisions/collider";
  25047. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25048. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25049. /** @hidden */
  25050. class _FacetDataStorage {
  25051. facetPositions: Vector3[];
  25052. facetNormals: Vector3[];
  25053. facetPartitioning: number[][];
  25054. facetNb: number;
  25055. partitioningSubdivisions: number;
  25056. partitioningBBoxRatio: number;
  25057. facetDataEnabled: boolean;
  25058. facetParameters: any;
  25059. bbSize: Vector3;
  25060. subDiv: {
  25061. max: number;
  25062. X: number;
  25063. Y: number;
  25064. Z: number;
  25065. };
  25066. facetDepthSort: boolean;
  25067. facetDepthSortEnabled: boolean;
  25068. depthSortedIndices: IndicesArray;
  25069. depthSortedFacets: {
  25070. ind: number;
  25071. sqDistance: number;
  25072. }[];
  25073. facetDepthSortFunction: (f1: {
  25074. ind: number;
  25075. sqDistance: number;
  25076. }, f2: {
  25077. ind: number;
  25078. sqDistance: number;
  25079. }) => number;
  25080. facetDepthSortFrom: Vector3;
  25081. facetDepthSortOrigin: Vector3;
  25082. invertedMatrix: Matrix;
  25083. }
  25084. /**
  25085. * @hidden
  25086. **/
  25087. class _InternalAbstractMeshDataInfo {
  25088. _hasVertexAlpha: boolean;
  25089. _useVertexColors: boolean;
  25090. _numBoneInfluencers: number;
  25091. _applyFog: boolean;
  25092. _receiveShadows: boolean;
  25093. _facetData: _FacetDataStorage;
  25094. _visibility: number;
  25095. _skeleton: Nullable<Skeleton>;
  25096. _layerMask: number;
  25097. _computeBonesUsingShaders: boolean;
  25098. _isActive: boolean;
  25099. _onlyForInstances: boolean;
  25100. _isActiveIntermediate: boolean;
  25101. _onlyForInstancesIntermediate: boolean;
  25102. }
  25103. /**
  25104. * Class used to store all common mesh properties
  25105. */
  25106. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25107. /** No occlusion */
  25108. static OCCLUSION_TYPE_NONE: number;
  25109. /** Occlusion set to optimisitic */
  25110. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25111. /** Occlusion set to strict */
  25112. static OCCLUSION_TYPE_STRICT: number;
  25113. /** Use an accurante occlusion algorithm */
  25114. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25115. /** Use a conservative occlusion algorithm */
  25116. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25117. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25118. * Test order :
  25119. * Is the bounding sphere outside the frustum ?
  25120. * If not, are the bounding box vertices outside the frustum ?
  25121. * It not, then the cullable object is in the frustum.
  25122. */
  25123. static readonly CULLINGSTRATEGY_STANDARD: number;
  25124. /** Culling strategy : Bounding Sphere Only.
  25125. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25126. * It's also less accurate than the standard because some not visible objects can still be selected.
  25127. * Test : is the bounding sphere outside the frustum ?
  25128. * If not, then the cullable object is in the frustum.
  25129. */
  25130. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25131. /** Culling strategy : Optimistic Inclusion.
  25132. * This in an inclusion test first, then the standard exclusion test.
  25133. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25134. * 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.
  25135. * Anyway, it's as accurate as the standard strategy.
  25136. * Test :
  25137. * Is the cullable object bounding sphere center in the frustum ?
  25138. * If not, apply the default culling strategy.
  25139. */
  25140. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25141. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25142. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25143. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25144. * 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.
  25145. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25146. * Test :
  25147. * Is the cullable object bounding sphere center in the frustum ?
  25148. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25149. */
  25150. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25151. /**
  25152. * No billboard
  25153. */
  25154. static readonly BILLBOARDMODE_NONE: number;
  25155. /** Billboard on X axis */
  25156. static readonly BILLBOARDMODE_X: number;
  25157. /** Billboard on Y axis */
  25158. static readonly BILLBOARDMODE_Y: number;
  25159. /** Billboard on Z axis */
  25160. static readonly BILLBOARDMODE_Z: number;
  25161. /** Billboard on all axes */
  25162. static readonly BILLBOARDMODE_ALL: number;
  25163. /** @hidden */
  25164. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25165. /**
  25166. * The culling strategy to use to check whether the mesh must be rendered or not.
  25167. * This value can be changed at any time and will be used on the next render mesh selection.
  25168. * The possible values are :
  25169. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25170. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25171. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25172. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25173. * Please read each static variable documentation to get details about the culling process.
  25174. * */
  25175. cullingStrategy: number;
  25176. /**
  25177. * Gets the number of facets in the mesh
  25178. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25179. */
  25180. readonly facetNb: number;
  25181. /**
  25182. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25184. */
  25185. partitioningSubdivisions: number;
  25186. /**
  25187. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25188. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25189. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25190. */
  25191. partitioningBBoxRatio: number;
  25192. /**
  25193. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25194. * Works only for updatable meshes.
  25195. * Doesn't work with multi-materials
  25196. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25197. */
  25198. mustDepthSortFacets: boolean;
  25199. /**
  25200. * The location (Vector3) where the facet depth sort must be computed from.
  25201. * By default, the active camera position.
  25202. * Used only when facet depth sort is enabled
  25203. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25204. */
  25205. facetDepthSortFrom: Vector3;
  25206. /**
  25207. * gets a boolean indicating if facetData is enabled
  25208. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25209. */
  25210. readonly isFacetDataEnabled: boolean;
  25211. /** @hidden */
  25212. _updateNonUniformScalingState(value: boolean): boolean;
  25213. /**
  25214. * An event triggered when this mesh collides with another one
  25215. */
  25216. onCollideObservable: Observable<AbstractMesh>;
  25217. /** Set a function to call when this mesh collides with another one */
  25218. onCollide: () => void;
  25219. /**
  25220. * An event triggered when the collision's position changes
  25221. */
  25222. onCollisionPositionChangeObservable: Observable<Vector3>;
  25223. /** Set a function to call when the collision's position changes */
  25224. onCollisionPositionChange: () => void;
  25225. /**
  25226. * An event triggered when material is changed
  25227. */
  25228. onMaterialChangedObservable: Observable<AbstractMesh>;
  25229. /**
  25230. * Gets or sets the orientation for POV movement & rotation
  25231. */
  25232. definedFacingForward: boolean;
  25233. /** @hidden */
  25234. _occlusionQuery: Nullable<WebGLQuery>;
  25235. /** @hidden */
  25236. _renderingGroup: Nullable<RenderingGroup>;
  25237. /**
  25238. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25239. */
  25240. /**
  25241. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25242. */
  25243. visibility: number;
  25244. /** Gets or sets the alpha index used to sort transparent meshes
  25245. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25246. */
  25247. alphaIndex: number;
  25248. /**
  25249. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25250. */
  25251. isVisible: boolean;
  25252. /**
  25253. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25254. */
  25255. isPickable: boolean;
  25256. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25257. showSubMeshesBoundingBox: boolean;
  25258. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25259. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25260. */
  25261. isBlocker: boolean;
  25262. /**
  25263. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25264. */
  25265. enablePointerMoveEvents: boolean;
  25266. /**
  25267. * Specifies the rendering group id for this mesh (0 by default)
  25268. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25269. */
  25270. renderingGroupId: number;
  25271. private _material;
  25272. /** Gets or sets current material */
  25273. material: Nullable<Material>;
  25274. /**
  25275. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25276. * @see http://doc.babylonjs.com/babylon101/shadows
  25277. */
  25278. receiveShadows: boolean;
  25279. /** Defines color to use when rendering outline */
  25280. outlineColor: Color3;
  25281. /** Define width to use when rendering outline */
  25282. outlineWidth: number;
  25283. /** Defines color to use when rendering overlay */
  25284. overlayColor: Color3;
  25285. /** Defines alpha to use when rendering overlay */
  25286. overlayAlpha: number;
  25287. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25288. hasVertexAlpha: boolean;
  25289. /** 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) */
  25290. useVertexColors: boolean;
  25291. /**
  25292. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25293. */
  25294. computeBonesUsingShaders: boolean;
  25295. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25296. numBoneInfluencers: number;
  25297. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25298. applyFog: boolean;
  25299. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25300. useOctreeForRenderingSelection: boolean;
  25301. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25302. useOctreeForPicking: boolean;
  25303. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25304. useOctreeForCollisions: boolean;
  25305. /**
  25306. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25307. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25308. */
  25309. layerMask: number;
  25310. /**
  25311. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25312. */
  25313. alwaysSelectAsActiveMesh: boolean;
  25314. /**
  25315. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25316. */
  25317. doNotSyncBoundingInfo: boolean;
  25318. /**
  25319. * Gets or sets the current action manager
  25320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25321. */
  25322. actionManager: Nullable<AbstractActionManager>;
  25323. private _meshCollisionData;
  25324. /**
  25325. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25326. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25327. */
  25328. ellipsoid: Vector3;
  25329. /**
  25330. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25331. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25332. */
  25333. ellipsoidOffset: Vector3;
  25334. /**
  25335. * Gets or sets a collision mask used to mask collisions (default is -1).
  25336. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25337. */
  25338. collisionMask: number;
  25339. /**
  25340. * Gets or sets the current collision group mask (-1 by default).
  25341. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25342. */
  25343. collisionGroup: number;
  25344. /**
  25345. * Defines edge width used when edgesRenderer is enabled
  25346. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25347. */
  25348. edgesWidth: number;
  25349. /**
  25350. * Defines edge color used when edgesRenderer is enabled
  25351. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25352. */
  25353. edgesColor: Color4;
  25354. /** @hidden */
  25355. _edgesRenderer: Nullable<IEdgesRenderer>;
  25356. /** @hidden */
  25357. _masterMesh: Nullable<AbstractMesh>;
  25358. /** @hidden */
  25359. _boundingInfo: Nullable<BoundingInfo>;
  25360. /** @hidden */
  25361. _renderId: number;
  25362. /**
  25363. * Gets or sets the list of subMeshes
  25364. * @see http://doc.babylonjs.com/how_to/multi_materials
  25365. */
  25366. subMeshes: SubMesh[];
  25367. /** @hidden */
  25368. _intersectionsInProgress: AbstractMesh[];
  25369. /** @hidden */
  25370. _unIndexed: boolean;
  25371. /** @hidden */
  25372. _lightSources: Light[];
  25373. /** Gets the list of lights affecting that mesh */
  25374. readonly lightSources: Light[];
  25375. /** @hidden */
  25376. readonly _positions: Nullable<Vector3[]>;
  25377. /** @hidden */
  25378. _waitingData: {
  25379. lods: Nullable<any>;
  25380. actions: Nullable<any>;
  25381. freezeWorldMatrix: Nullable<boolean>;
  25382. };
  25383. /** @hidden */
  25384. _bonesTransformMatrices: Nullable<Float32Array>;
  25385. /**
  25386. * Gets or sets a skeleton to apply skining transformations
  25387. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25388. */
  25389. skeleton: Nullable<Skeleton>;
  25390. /**
  25391. * An event triggered when the mesh is rebuilt.
  25392. */
  25393. onRebuildObservable: Observable<AbstractMesh>;
  25394. /**
  25395. * Creates a new AbstractMesh
  25396. * @param name defines the name of the mesh
  25397. * @param scene defines the hosting scene
  25398. */
  25399. constructor(name: string, scene?: Nullable<Scene>);
  25400. /**
  25401. * Returns the string "AbstractMesh"
  25402. * @returns "AbstractMesh"
  25403. */
  25404. getClassName(): string;
  25405. /**
  25406. * Gets a string representation of the current mesh
  25407. * @param fullDetails defines a boolean indicating if full details must be included
  25408. * @returns a string representation of the current mesh
  25409. */
  25410. toString(fullDetails?: boolean): string;
  25411. /**
  25412. * @hidden
  25413. */
  25414. protected _getEffectiveParent(): Nullable<Node>;
  25415. /** @hidden */
  25416. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25417. /** @hidden */
  25418. _rebuild(): void;
  25419. /** @hidden */
  25420. _resyncLightSources(): void;
  25421. /** @hidden */
  25422. _resyncLighSource(light: Light): void;
  25423. /** @hidden */
  25424. _unBindEffect(): void;
  25425. /** @hidden */
  25426. _removeLightSource(light: Light): void;
  25427. private _markSubMeshesAsDirty;
  25428. /** @hidden */
  25429. _markSubMeshesAsLightDirty(): void;
  25430. /** @hidden */
  25431. _markSubMeshesAsAttributesDirty(): void;
  25432. /** @hidden */
  25433. _markSubMeshesAsMiscDirty(): void;
  25434. /**
  25435. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25436. */
  25437. scaling: Vector3;
  25438. /**
  25439. * Returns true if the mesh is blocked. Implemented by child classes
  25440. */
  25441. readonly isBlocked: boolean;
  25442. /**
  25443. * Returns the mesh itself by default. Implemented by child classes
  25444. * @param camera defines the camera to use to pick the right LOD level
  25445. * @returns the currentAbstractMesh
  25446. */
  25447. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25448. /**
  25449. * Returns 0 by default. Implemented by child classes
  25450. * @returns an integer
  25451. */
  25452. getTotalVertices(): number;
  25453. /**
  25454. * Returns a positive integer : the total number of indices in this mesh geometry.
  25455. * @returns the numner of indices or zero if the mesh has no geometry.
  25456. */
  25457. getTotalIndices(): number;
  25458. /**
  25459. * Returns null by default. Implemented by child classes
  25460. * @returns null
  25461. */
  25462. getIndices(): Nullable<IndicesArray>;
  25463. /**
  25464. * Returns the array of the requested vertex data kind. Implemented by child classes
  25465. * @param kind defines the vertex data kind to use
  25466. * @returns null
  25467. */
  25468. getVerticesData(kind: string): Nullable<FloatArray>;
  25469. /**
  25470. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25471. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25472. * Note that a new underlying VertexBuffer object is created each call.
  25473. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25474. * @param kind defines vertex data kind:
  25475. * * VertexBuffer.PositionKind
  25476. * * VertexBuffer.UVKind
  25477. * * VertexBuffer.UV2Kind
  25478. * * VertexBuffer.UV3Kind
  25479. * * VertexBuffer.UV4Kind
  25480. * * VertexBuffer.UV5Kind
  25481. * * VertexBuffer.UV6Kind
  25482. * * VertexBuffer.ColorKind
  25483. * * VertexBuffer.MatricesIndicesKind
  25484. * * VertexBuffer.MatricesIndicesExtraKind
  25485. * * VertexBuffer.MatricesWeightsKind
  25486. * * VertexBuffer.MatricesWeightsExtraKind
  25487. * @param data defines the data source
  25488. * @param updatable defines if the data must be flagged as updatable (or static)
  25489. * @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
  25490. * @returns the current mesh
  25491. */
  25492. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25493. /**
  25494. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25495. * If the mesh has no geometry, it is simply returned as it is.
  25496. * @param kind defines vertex data kind:
  25497. * * VertexBuffer.PositionKind
  25498. * * VertexBuffer.UVKind
  25499. * * VertexBuffer.UV2Kind
  25500. * * VertexBuffer.UV3Kind
  25501. * * VertexBuffer.UV4Kind
  25502. * * VertexBuffer.UV5Kind
  25503. * * VertexBuffer.UV6Kind
  25504. * * VertexBuffer.ColorKind
  25505. * * VertexBuffer.MatricesIndicesKind
  25506. * * VertexBuffer.MatricesIndicesExtraKind
  25507. * * VertexBuffer.MatricesWeightsKind
  25508. * * VertexBuffer.MatricesWeightsExtraKind
  25509. * @param data defines the data source
  25510. * @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
  25511. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25512. * @returns the current mesh
  25513. */
  25514. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25515. /**
  25516. * Sets the mesh indices,
  25517. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25518. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25519. * @param totalVertices Defines the total number of vertices
  25520. * @returns the current mesh
  25521. */
  25522. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25523. /**
  25524. * Gets a boolean indicating if specific vertex data is present
  25525. * @param kind defines the vertex data kind to use
  25526. * @returns true is data kind is present
  25527. */
  25528. isVerticesDataPresent(kind: string): boolean;
  25529. /**
  25530. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25531. * @returns a BoundingInfo
  25532. */
  25533. getBoundingInfo(): BoundingInfo;
  25534. /**
  25535. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25536. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25537. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25538. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25539. * @returns the current mesh
  25540. */
  25541. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25542. /**
  25543. * Overwrite the current bounding info
  25544. * @param boundingInfo defines the new bounding info
  25545. * @returns the current mesh
  25546. */
  25547. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25548. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25549. readonly useBones: boolean;
  25550. /** @hidden */
  25551. _preActivate(): void;
  25552. /** @hidden */
  25553. _preActivateForIntermediateRendering(renderId: number): void;
  25554. /** @hidden */
  25555. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25556. /** @hidden */
  25557. _postActivate(): void;
  25558. /** @hidden */
  25559. _freeze(): void;
  25560. /** @hidden */
  25561. _unFreeze(): void;
  25562. /**
  25563. * Gets the current world matrix
  25564. * @returns a Matrix
  25565. */
  25566. getWorldMatrix(): Matrix;
  25567. /** @hidden */
  25568. _getWorldMatrixDeterminant(): number;
  25569. /**
  25570. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25571. */
  25572. readonly isAnInstance: boolean;
  25573. /**
  25574. * Perform relative position change from the point of view of behind the front of the mesh.
  25575. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25576. * Supports definition of mesh facing forward or backward
  25577. * @param amountRight defines the distance on the right axis
  25578. * @param amountUp defines the distance on the up axis
  25579. * @param amountForward defines the distance on the forward axis
  25580. * @returns the current mesh
  25581. */
  25582. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25583. /**
  25584. * Calculate relative position change from the point of view of behind the front of the mesh.
  25585. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25586. * Supports definition of mesh facing forward or backward
  25587. * @param amountRight defines the distance on the right axis
  25588. * @param amountUp defines the distance on the up axis
  25589. * @param amountForward defines the distance on the forward axis
  25590. * @returns the new displacement vector
  25591. */
  25592. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25593. /**
  25594. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25595. * Supports definition of mesh facing forward or backward
  25596. * @param flipBack defines the flip
  25597. * @param twirlClockwise defines the twirl
  25598. * @param tiltRight defines the tilt
  25599. * @returns the current mesh
  25600. */
  25601. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25602. /**
  25603. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25604. * Supports definition of mesh facing forward or backward.
  25605. * @param flipBack defines the flip
  25606. * @param twirlClockwise defines the twirl
  25607. * @param tiltRight defines the tilt
  25608. * @returns the new rotation vector
  25609. */
  25610. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25611. /**
  25612. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25613. * This means the mesh underlying bounding box and sphere are recomputed.
  25614. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25615. * @returns the current mesh
  25616. */
  25617. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25618. /** @hidden */
  25619. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25620. /** @hidden */
  25621. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25622. /** @hidden */
  25623. _updateBoundingInfo(): AbstractMesh;
  25624. /** @hidden */
  25625. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25626. /** @hidden */
  25627. protected _afterComputeWorldMatrix(): void;
  25628. /** @hidden */
  25629. readonly _effectiveMesh: AbstractMesh;
  25630. /**
  25631. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25632. * A mesh is in the frustum if its bounding box intersects the frustum
  25633. * @param frustumPlanes defines the frustum to test
  25634. * @returns true if the mesh is in the frustum planes
  25635. */
  25636. isInFrustum(frustumPlanes: Plane[]): boolean;
  25637. /**
  25638. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25639. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25640. * @param frustumPlanes defines the frustum to test
  25641. * @returns true if the mesh is completely in the frustum planes
  25642. */
  25643. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25644. /**
  25645. * True if the mesh intersects another mesh or a SolidParticle object
  25646. * @param mesh defines a target mesh or SolidParticle to test
  25647. * @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)
  25648. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25649. * @returns true if there is an intersection
  25650. */
  25651. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25652. /**
  25653. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25654. * @param point defines the point to test
  25655. * @returns true if there is an intersection
  25656. */
  25657. intersectsPoint(point: Vector3): boolean;
  25658. /**
  25659. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25660. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25661. */
  25662. checkCollisions: boolean;
  25663. /**
  25664. * Gets Collider object used to compute collisions (not physics)
  25665. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25666. */
  25667. readonly collider: Nullable<Collider>;
  25668. /**
  25669. * Move the mesh using collision engine
  25670. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25671. * @param displacement defines the requested displacement vector
  25672. * @returns the current mesh
  25673. */
  25674. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25675. private _onCollisionPositionChange;
  25676. /** @hidden */
  25677. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25678. /** @hidden */
  25679. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25680. /** @hidden */
  25681. _checkCollision(collider: Collider): AbstractMesh;
  25682. /** @hidden */
  25683. _generatePointsArray(): boolean;
  25684. /**
  25685. * Checks if the passed Ray intersects with the mesh
  25686. * @param ray defines the ray to use
  25687. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25688. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25689. * @returns the picking info
  25690. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25691. */
  25692. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25693. /**
  25694. * Clones the current mesh
  25695. * @param name defines the mesh name
  25696. * @param newParent defines the new mesh parent
  25697. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25698. * @returns the new mesh
  25699. */
  25700. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25701. /**
  25702. * Disposes all the submeshes of the current meshnp
  25703. * @returns the current mesh
  25704. */
  25705. releaseSubMeshes(): AbstractMesh;
  25706. /**
  25707. * Releases resources associated with this abstract mesh.
  25708. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25709. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25710. */
  25711. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25712. /**
  25713. * Adds the passed mesh as a child to the current mesh
  25714. * @param mesh defines the child mesh
  25715. * @returns the current mesh
  25716. */
  25717. addChild(mesh: AbstractMesh): AbstractMesh;
  25718. /**
  25719. * Removes the passed mesh from the current mesh children list
  25720. * @param mesh defines the child mesh
  25721. * @returns the current mesh
  25722. */
  25723. removeChild(mesh: AbstractMesh): AbstractMesh;
  25724. /** @hidden */
  25725. private _initFacetData;
  25726. /**
  25727. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25728. * This method can be called within the render loop.
  25729. * 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
  25730. * @returns the current mesh
  25731. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25732. */
  25733. updateFacetData(): AbstractMesh;
  25734. /**
  25735. * Returns the facetLocalNormals array.
  25736. * The normals are expressed in the mesh local spac
  25737. * @returns an array of Vector3
  25738. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25739. */
  25740. getFacetLocalNormals(): Vector3[];
  25741. /**
  25742. * Returns the facetLocalPositions array.
  25743. * The facet positions are expressed in the mesh local space
  25744. * @returns an array of Vector3
  25745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25746. */
  25747. getFacetLocalPositions(): Vector3[];
  25748. /**
  25749. * Returns the facetLocalPartioning array
  25750. * @returns an array of array of numbers
  25751. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25752. */
  25753. getFacetLocalPartitioning(): number[][];
  25754. /**
  25755. * Returns the i-th facet position in the world system.
  25756. * This method allocates a new Vector3 per call
  25757. * @param i defines the facet index
  25758. * @returns a new Vector3
  25759. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25760. */
  25761. getFacetPosition(i: number): Vector3;
  25762. /**
  25763. * Sets the reference Vector3 with the i-th facet position in the world system
  25764. * @param i defines the facet index
  25765. * @param ref defines the target vector
  25766. * @returns the current mesh
  25767. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25768. */
  25769. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25770. /**
  25771. * Returns the i-th facet normal in the world system.
  25772. * This method allocates a new Vector3 per call
  25773. * @param i defines the facet index
  25774. * @returns a new Vector3
  25775. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25776. */
  25777. getFacetNormal(i: number): Vector3;
  25778. /**
  25779. * Sets the reference Vector3 with the i-th facet normal in the world system
  25780. * @param i defines the facet index
  25781. * @param ref defines the target vector
  25782. * @returns the current mesh
  25783. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25784. */
  25785. getFacetNormalToRef(i: number, ref: Vector3): this;
  25786. /**
  25787. * 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)
  25788. * @param x defines x coordinate
  25789. * @param y defines y coordinate
  25790. * @param z defines z coordinate
  25791. * @returns the array of facet indexes
  25792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25793. */
  25794. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25795. /**
  25796. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25797. * @param projected sets as the (x,y,z) world projection on the facet
  25798. * @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
  25799. * @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
  25800. * @param x defines x coordinate
  25801. * @param y defines y coordinate
  25802. * @param z defines z coordinate
  25803. * @returns the face index if found (or null instead)
  25804. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25805. */
  25806. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25807. /**
  25808. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25809. * @param projected sets as the (x,y,z) local projection on the facet
  25810. * @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
  25811. * @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
  25812. * @param x defines x coordinate
  25813. * @param y defines y coordinate
  25814. * @param z defines z coordinate
  25815. * @returns the face index if found (or null instead)
  25816. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25817. */
  25818. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25819. /**
  25820. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25821. * @returns the parameters
  25822. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25823. */
  25824. getFacetDataParameters(): any;
  25825. /**
  25826. * Disables the feature FacetData and frees the related memory
  25827. * @returns the current mesh
  25828. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25829. */
  25830. disableFacetData(): AbstractMesh;
  25831. /**
  25832. * Updates the AbstractMesh indices array
  25833. * @param indices defines the data source
  25834. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25835. * @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)
  25836. * @returns the current mesh
  25837. */
  25838. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25839. /**
  25840. * Creates new normals data for the mesh
  25841. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25842. * @returns the current mesh
  25843. */
  25844. createNormals(updatable: boolean): AbstractMesh;
  25845. /**
  25846. * Align the mesh with a normal
  25847. * @param normal defines the normal to use
  25848. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25849. * @returns the current mesh
  25850. */
  25851. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25852. /** @hidden */
  25853. _checkOcclusionQuery(): boolean;
  25854. /**
  25855. * Disables the mesh edge rendering mode
  25856. * @returns the currentAbstractMesh
  25857. */
  25858. disableEdgesRendering(): AbstractMesh;
  25859. /**
  25860. * Enables the edge rendering mode on the mesh.
  25861. * This mode makes the mesh edges visible
  25862. * @param epsilon defines the maximal distance between two angles to detect a face
  25863. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25864. * @returns the currentAbstractMesh
  25865. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25866. */
  25867. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25868. }
  25869. }
  25870. declare module "babylonjs/Actions/actionEvent" {
  25871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25872. import { Nullable } from "babylonjs/types";
  25873. import { Sprite } from "babylonjs/Sprites/sprite";
  25874. import { Scene } from "babylonjs/scene";
  25875. import { Vector2 } from "babylonjs/Maths/math";
  25876. /**
  25877. * Interface used to define ActionEvent
  25878. */
  25879. export interface IActionEvent {
  25880. /** The mesh or sprite that triggered the action */
  25881. source: any;
  25882. /** The X mouse cursor position at the time of the event */
  25883. pointerX: number;
  25884. /** The Y mouse cursor position at the time of the event */
  25885. pointerY: number;
  25886. /** The mesh that is currently pointed at (can be null) */
  25887. meshUnderPointer: Nullable<AbstractMesh>;
  25888. /** the original (browser) event that triggered the ActionEvent */
  25889. sourceEvent?: any;
  25890. /** additional data for the event */
  25891. additionalData?: any;
  25892. }
  25893. /**
  25894. * ActionEvent is the event being sent when an action is triggered.
  25895. */
  25896. export class ActionEvent implements IActionEvent {
  25897. /** The mesh or sprite that triggered the action */
  25898. source: any;
  25899. /** The X mouse cursor position at the time of the event */
  25900. pointerX: number;
  25901. /** The Y mouse cursor position at the time of the event */
  25902. pointerY: number;
  25903. /** The mesh that is currently pointed at (can be null) */
  25904. meshUnderPointer: Nullable<AbstractMesh>;
  25905. /** the original (browser) event that triggered the ActionEvent */
  25906. sourceEvent?: any;
  25907. /** additional data for the event */
  25908. additionalData?: any;
  25909. /**
  25910. * Creates a new ActionEvent
  25911. * @param source The mesh or sprite that triggered the action
  25912. * @param pointerX The X mouse cursor position at the time of the event
  25913. * @param pointerY The Y mouse cursor position at the time of the event
  25914. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25915. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25916. * @param additionalData additional data for the event
  25917. */
  25918. constructor(
  25919. /** The mesh or sprite that triggered the action */
  25920. source: any,
  25921. /** The X mouse cursor position at the time of the event */
  25922. pointerX: number,
  25923. /** The Y mouse cursor position at the time of the event */
  25924. pointerY: number,
  25925. /** The mesh that is currently pointed at (can be null) */
  25926. meshUnderPointer: Nullable<AbstractMesh>,
  25927. /** the original (browser) event that triggered the ActionEvent */
  25928. sourceEvent?: any,
  25929. /** additional data for the event */
  25930. additionalData?: any);
  25931. /**
  25932. * Helper function to auto-create an ActionEvent from a source mesh.
  25933. * @param source The source mesh that triggered the event
  25934. * @param evt The original (browser) event
  25935. * @param additionalData additional data for the event
  25936. * @returns the new ActionEvent
  25937. */
  25938. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25939. /**
  25940. * Helper function to auto-create an ActionEvent from a source sprite
  25941. * @param source The source sprite that triggered the event
  25942. * @param scene Scene associated with the sprite
  25943. * @param evt The original (browser) event
  25944. * @param additionalData additional data for the event
  25945. * @returns the new ActionEvent
  25946. */
  25947. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25948. /**
  25949. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25950. * @param scene the scene where the event occurred
  25951. * @param evt The original (browser) event
  25952. * @returns the new ActionEvent
  25953. */
  25954. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25955. /**
  25956. * Helper function to auto-create an ActionEvent from a primitive
  25957. * @param prim defines the target primitive
  25958. * @param pointerPos defines the pointer position
  25959. * @param evt The original (browser) event
  25960. * @param additionalData additional data for the event
  25961. * @returns the new ActionEvent
  25962. */
  25963. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25964. }
  25965. }
  25966. declare module "babylonjs/Actions/abstractActionManager" {
  25967. import { IDisposable } from "babylonjs/scene";
  25968. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25969. import { IAction } from "babylonjs/Actions/action";
  25970. import { Nullable } from "babylonjs/types";
  25971. /**
  25972. * Abstract class used to decouple action Manager from scene and meshes.
  25973. * Do not instantiate.
  25974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25975. */
  25976. export abstract class AbstractActionManager implements IDisposable {
  25977. /** Gets the list of active triggers */
  25978. static Triggers: {
  25979. [key: string]: number;
  25980. };
  25981. /** Gets the cursor to use when hovering items */
  25982. hoverCursor: string;
  25983. /** Gets the list of actions */
  25984. actions: IAction[];
  25985. /**
  25986. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25987. */
  25988. isRecursive: boolean;
  25989. /**
  25990. * Releases all associated resources
  25991. */
  25992. abstract dispose(): void;
  25993. /**
  25994. * Does this action manager has pointer triggers
  25995. */
  25996. abstract readonly hasPointerTriggers: boolean;
  25997. /**
  25998. * Does this action manager has pick triggers
  25999. */
  26000. abstract readonly hasPickTriggers: boolean;
  26001. /**
  26002. * Process a specific trigger
  26003. * @param trigger defines the trigger to process
  26004. * @param evt defines the event details to be processed
  26005. */
  26006. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26007. /**
  26008. * Does this action manager handles actions of any of the given triggers
  26009. * @param triggers defines the triggers to be tested
  26010. * @return a boolean indicating whether one (or more) of the triggers is handled
  26011. */
  26012. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26013. /**
  26014. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26015. * speed.
  26016. * @param triggerA defines the trigger to be tested
  26017. * @param triggerB defines the trigger to be tested
  26018. * @return a boolean indicating whether one (or more) of the triggers is handled
  26019. */
  26020. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26021. /**
  26022. * Does this action manager handles actions of a given trigger
  26023. * @param trigger defines the trigger to be tested
  26024. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26025. * @return whether the trigger is handled
  26026. */
  26027. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26028. /**
  26029. * Serialize this manager to a JSON object
  26030. * @param name defines the property name to store this manager
  26031. * @returns a JSON representation of this manager
  26032. */
  26033. abstract serialize(name: string): any;
  26034. /**
  26035. * Registers an action to this action manager
  26036. * @param action defines the action to be registered
  26037. * @return the action amended (prepared) after registration
  26038. */
  26039. abstract registerAction(action: IAction): Nullable<IAction>;
  26040. /**
  26041. * Unregisters an action to this action manager
  26042. * @param action defines the action to be unregistered
  26043. * @return a boolean indicating whether the action has been unregistered
  26044. */
  26045. abstract unregisterAction(action: IAction): Boolean;
  26046. /**
  26047. * Does exist one action manager with at least one trigger
  26048. **/
  26049. static readonly HasTriggers: boolean;
  26050. /**
  26051. * Does exist one action manager with at least one pick trigger
  26052. **/
  26053. static readonly HasPickTriggers: boolean;
  26054. /**
  26055. * Does exist one action manager that handles actions of a given trigger
  26056. * @param trigger defines the trigger to be tested
  26057. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26058. **/
  26059. static HasSpecificTrigger(trigger: number): boolean;
  26060. }
  26061. }
  26062. declare module "babylonjs/node" {
  26063. import { Scene } from "babylonjs/scene";
  26064. import { Nullable } from "babylonjs/types";
  26065. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26066. import { Engine } from "babylonjs/Engines/engine";
  26067. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26068. import { Observable } from "babylonjs/Misc/observable";
  26069. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26070. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26071. import { Animatable } from "babylonjs/Animations/animatable";
  26072. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26073. import { Animation } from "babylonjs/Animations/animation";
  26074. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26076. /**
  26077. * Defines how a node can be built from a string name.
  26078. */
  26079. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26080. /**
  26081. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26082. */
  26083. export class Node implements IBehaviorAware<Node> {
  26084. /** @hidden */
  26085. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26086. private static _NodeConstructors;
  26087. /**
  26088. * Add a new node constructor
  26089. * @param type defines the type name of the node to construct
  26090. * @param constructorFunc defines the constructor function
  26091. */
  26092. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26093. /**
  26094. * Returns a node constructor based on type name
  26095. * @param type defines the type name
  26096. * @param name defines the new node name
  26097. * @param scene defines the hosting scene
  26098. * @param options defines optional options to transmit to constructors
  26099. * @returns the new constructor or null
  26100. */
  26101. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26102. /**
  26103. * Gets or sets the name of the node
  26104. */
  26105. name: string;
  26106. /**
  26107. * Gets or sets the id of the node
  26108. */
  26109. id: string;
  26110. /**
  26111. * Gets or sets the unique id of the node
  26112. */
  26113. uniqueId: number;
  26114. /**
  26115. * Gets or sets a string used to store user defined state for the node
  26116. */
  26117. state: string;
  26118. /**
  26119. * Gets or sets an object used to store user defined information for the node
  26120. */
  26121. metadata: any;
  26122. /**
  26123. * For internal use only. Please do not use.
  26124. */
  26125. reservedDataStore: any;
  26126. /**
  26127. * List of inspectable custom properties (used by the Inspector)
  26128. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26129. */
  26130. inspectableCustomProperties: IInspectable[];
  26131. /**
  26132. * Gets or sets a boolean used to define if the node must be serialized
  26133. */
  26134. doNotSerialize: boolean;
  26135. /** @hidden */
  26136. _isDisposed: boolean;
  26137. /**
  26138. * Gets a list of Animations associated with the node
  26139. */
  26140. animations: import("babylonjs/Animations/animation").Animation[];
  26141. protected _ranges: {
  26142. [name: string]: Nullable<AnimationRange>;
  26143. };
  26144. /**
  26145. * Callback raised when the node is ready to be used
  26146. */
  26147. onReady: Nullable<(node: Node) => void>;
  26148. private _isEnabled;
  26149. private _isParentEnabled;
  26150. private _isReady;
  26151. /** @hidden */
  26152. _currentRenderId: number;
  26153. private _parentUpdateId;
  26154. /** @hidden */
  26155. _childUpdateId: number;
  26156. /** @hidden */
  26157. _waitingParentId: Nullable<string>;
  26158. /** @hidden */
  26159. _scene: Scene;
  26160. /** @hidden */
  26161. _cache: any;
  26162. private _parentNode;
  26163. private _children;
  26164. /** @hidden */
  26165. _worldMatrix: Matrix;
  26166. /** @hidden */
  26167. _worldMatrixDeterminant: number;
  26168. /** @hidden */
  26169. _worldMatrixDeterminantIsDirty: boolean;
  26170. /** @hidden */
  26171. private _sceneRootNodesIndex;
  26172. /**
  26173. * Gets a boolean indicating if the node has been disposed
  26174. * @returns true if the node was disposed
  26175. */
  26176. isDisposed(): boolean;
  26177. /**
  26178. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26179. * @see https://doc.babylonjs.com/how_to/parenting
  26180. */
  26181. parent: Nullable<Node>;
  26182. private addToSceneRootNodes;
  26183. private removeFromSceneRootNodes;
  26184. private _animationPropertiesOverride;
  26185. /**
  26186. * Gets or sets the animation properties override
  26187. */
  26188. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26189. /**
  26190. * Gets a string idenfifying the name of the class
  26191. * @returns "Node" string
  26192. */
  26193. getClassName(): string;
  26194. /** @hidden */
  26195. readonly _isNode: boolean;
  26196. /**
  26197. * An event triggered when the mesh is disposed
  26198. */
  26199. onDisposeObservable: Observable<Node>;
  26200. private _onDisposeObserver;
  26201. /**
  26202. * Sets a callback that will be raised when the node will be disposed
  26203. */
  26204. onDispose: () => void;
  26205. /**
  26206. * Creates a new Node
  26207. * @param name the name and id to be given to this node
  26208. * @param scene the scene this node will be added to
  26209. * @param addToRootNodes the node will be added to scene.rootNodes
  26210. */
  26211. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26212. /**
  26213. * Gets the scene of the node
  26214. * @returns a scene
  26215. */
  26216. getScene(): Scene;
  26217. /**
  26218. * Gets the engine of the node
  26219. * @returns a Engine
  26220. */
  26221. getEngine(): Engine;
  26222. private _behaviors;
  26223. /**
  26224. * Attach a behavior to the node
  26225. * @see http://doc.babylonjs.com/features/behaviour
  26226. * @param behavior defines the behavior to attach
  26227. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26228. * @returns the current Node
  26229. */
  26230. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26231. /**
  26232. * Remove an attached behavior
  26233. * @see http://doc.babylonjs.com/features/behaviour
  26234. * @param behavior defines the behavior to attach
  26235. * @returns the current Node
  26236. */
  26237. removeBehavior(behavior: Behavior<Node>): Node;
  26238. /**
  26239. * Gets the list of attached behaviors
  26240. * @see http://doc.babylonjs.com/features/behaviour
  26241. */
  26242. readonly behaviors: Behavior<Node>[];
  26243. /**
  26244. * Gets an attached behavior by name
  26245. * @param name defines the name of the behavior to look for
  26246. * @see http://doc.babylonjs.com/features/behaviour
  26247. * @returns null if behavior was not found else the requested behavior
  26248. */
  26249. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26250. /**
  26251. * Returns the latest update of the World matrix
  26252. * @returns a Matrix
  26253. */
  26254. getWorldMatrix(): Matrix;
  26255. /** @hidden */
  26256. _getWorldMatrixDeterminant(): number;
  26257. /**
  26258. * Returns directly the latest state of the mesh World matrix.
  26259. * A Matrix is returned.
  26260. */
  26261. readonly worldMatrixFromCache: Matrix;
  26262. /** @hidden */
  26263. _initCache(): void;
  26264. /** @hidden */
  26265. updateCache(force?: boolean): void;
  26266. /** @hidden */
  26267. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26268. /** @hidden */
  26269. _updateCache(ignoreParentClass?: boolean): void;
  26270. /** @hidden */
  26271. _isSynchronized(): boolean;
  26272. /** @hidden */
  26273. _markSyncedWithParent(): void;
  26274. /** @hidden */
  26275. isSynchronizedWithParent(): boolean;
  26276. /** @hidden */
  26277. isSynchronized(): boolean;
  26278. /**
  26279. * Is this node ready to be used/rendered
  26280. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26281. * @return true if the node is ready
  26282. */
  26283. isReady(completeCheck?: boolean): boolean;
  26284. /**
  26285. * Is this node enabled?
  26286. * 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
  26287. * @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
  26288. * @return whether this node (and its parent) is enabled
  26289. */
  26290. isEnabled(checkAncestors?: boolean): boolean;
  26291. /** @hidden */
  26292. protected _syncParentEnabledState(): void;
  26293. /**
  26294. * Set the enabled state of this node
  26295. * @param value defines the new enabled state
  26296. */
  26297. setEnabled(value: boolean): void;
  26298. /**
  26299. * Is this node a descendant of the given node?
  26300. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26301. * @param ancestor defines the parent node to inspect
  26302. * @returns a boolean indicating if this node is a descendant of the given node
  26303. */
  26304. isDescendantOf(ancestor: Node): boolean;
  26305. /** @hidden */
  26306. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26307. /**
  26308. * Will return all nodes that have this node as ascendant
  26309. * @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
  26310. * @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
  26311. * @return all children nodes of all types
  26312. */
  26313. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26314. /**
  26315. * Get all child-meshes of this node
  26316. * @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)
  26317. * @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
  26318. * @returns an array of AbstractMesh
  26319. */
  26320. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26321. /**
  26322. * Get all direct children of this node
  26323. * @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
  26324. * @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)
  26325. * @returns an array of Node
  26326. */
  26327. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26328. /** @hidden */
  26329. _setReady(state: boolean): void;
  26330. /**
  26331. * Get an animation by name
  26332. * @param name defines the name of the animation to look for
  26333. * @returns null if not found else the requested animation
  26334. */
  26335. getAnimationByName(name: string): Nullable<Animation>;
  26336. /**
  26337. * Creates an animation range for this node
  26338. * @param name defines the name of the range
  26339. * @param from defines the starting key
  26340. * @param to defines the end key
  26341. */
  26342. createAnimationRange(name: string, from: number, to: number): void;
  26343. /**
  26344. * Delete a specific animation range
  26345. * @param name defines the name of the range to delete
  26346. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26347. */
  26348. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26349. /**
  26350. * Get an animation range by name
  26351. * @param name defines the name of the animation range to look for
  26352. * @returns null if not found else the requested animation range
  26353. */
  26354. getAnimationRange(name: string): Nullable<AnimationRange>;
  26355. /**
  26356. * Gets the list of all animation ranges defined on this node
  26357. * @returns an array
  26358. */
  26359. getAnimationRanges(): Nullable<AnimationRange>[];
  26360. /**
  26361. * Will start the animation sequence
  26362. * @param name defines the range frames for animation sequence
  26363. * @param loop defines if the animation should loop (false by default)
  26364. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26365. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26366. * @returns the object created for this animation. If range does not exist, it will return null
  26367. */
  26368. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26369. /**
  26370. * Serialize animation ranges into a JSON compatible object
  26371. * @returns serialization object
  26372. */
  26373. serializeAnimationRanges(): any;
  26374. /**
  26375. * Computes the world matrix of the node
  26376. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26377. * @returns the world matrix
  26378. */
  26379. computeWorldMatrix(force?: boolean): Matrix;
  26380. /**
  26381. * Releases resources associated with this node.
  26382. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26383. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26384. */
  26385. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26386. /**
  26387. * Parse animation range data from a serialization object and store them into a given node
  26388. * @param node defines where to store the animation ranges
  26389. * @param parsedNode defines the serialization object to read data from
  26390. * @param scene defines the hosting scene
  26391. */
  26392. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26393. /**
  26394. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26395. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26396. * @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
  26397. * @returns the new bounding vectors
  26398. */
  26399. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26400. min: Vector3;
  26401. max: Vector3;
  26402. };
  26403. }
  26404. }
  26405. declare module "babylonjs/Animations/animation" {
  26406. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26407. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26408. import { Nullable } from "babylonjs/types";
  26409. import { Scene } from "babylonjs/scene";
  26410. import { IAnimatable } from "babylonjs/Misc/tools";
  26411. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26412. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26413. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26414. import { Node } from "babylonjs/node";
  26415. import { Animatable } from "babylonjs/Animations/animatable";
  26416. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26417. /**
  26418. * @hidden
  26419. */
  26420. export class _IAnimationState {
  26421. key: number;
  26422. repeatCount: number;
  26423. workValue?: any;
  26424. loopMode?: number;
  26425. offsetValue?: any;
  26426. highLimitValue?: any;
  26427. }
  26428. /**
  26429. * Class used to store any kind of animation
  26430. */
  26431. export class Animation {
  26432. /**Name of the animation */
  26433. name: string;
  26434. /**Property to animate */
  26435. targetProperty: string;
  26436. /**The frames per second of the animation */
  26437. framePerSecond: number;
  26438. /**The data type of the animation */
  26439. dataType: number;
  26440. /**The loop mode of the animation */
  26441. loopMode?: number | undefined;
  26442. /**Specifies if blending should be enabled */
  26443. enableBlending?: boolean | undefined;
  26444. /**
  26445. * Use matrix interpolation instead of using direct key value when animating matrices
  26446. */
  26447. static AllowMatricesInterpolation: boolean;
  26448. /**
  26449. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26450. */
  26451. static AllowMatrixDecomposeForInterpolation: boolean;
  26452. /**
  26453. * Stores the key frames of the animation
  26454. */
  26455. private _keys;
  26456. /**
  26457. * Stores the easing function of the animation
  26458. */
  26459. private _easingFunction;
  26460. /**
  26461. * @hidden Internal use only
  26462. */
  26463. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26464. /**
  26465. * The set of event that will be linked to this animation
  26466. */
  26467. private _events;
  26468. /**
  26469. * Stores an array of target property paths
  26470. */
  26471. targetPropertyPath: string[];
  26472. /**
  26473. * Stores the blending speed of the animation
  26474. */
  26475. blendingSpeed: number;
  26476. /**
  26477. * Stores the animation ranges for the animation
  26478. */
  26479. private _ranges;
  26480. /**
  26481. * @hidden Internal use
  26482. */
  26483. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26484. /**
  26485. * Sets up an animation
  26486. * @param property The property to animate
  26487. * @param animationType The animation type to apply
  26488. * @param framePerSecond The frames per second of the animation
  26489. * @param easingFunction The easing function used in the animation
  26490. * @returns The created animation
  26491. */
  26492. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26493. /**
  26494. * Create and start an animation on a node
  26495. * @param name defines the name of the global animation that will be run on all nodes
  26496. * @param node defines the root node where the animation will take place
  26497. * @param targetProperty defines property to animate
  26498. * @param framePerSecond defines the number of frame per second yo use
  26499. * @param totalFrame defines the number of frames in total
  26500. * @param from defines the initial value
  26501. * @param to defines the final value
  26502. * @param loopMode defines which loop mode you want to use (off by default)
  26503. * @param easingFunction defines the easing function to use (linear by default)
  26504. * @param onAnimationEnd defines the callback to call when animation end
  26505. * @returns the animatable created for this animation
  26506. */
  26507. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26508. /**
  26509. * Create and start an animation on a node and its descendants
  26510. * @param name defines the name of the global animation that will be run on all nodes
  26511. * @param node defines the root node where the animation will take place
  26512. * @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
  26513. * @param targetProperty defines property to animate
  26514. * @param framePerSecond defines the number of frame per second to use
  26515. * @param totalFrame defines the number of frames in total
  26516. * @param from defines the initial value
  26517. * @param to defines the final value
  26518. * @param loopMode defines which loop mode you want to use (off by default)
  26519. * @param easingFunction defines the easing function to use (linear by default)
  26520. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26521. * @returns the list of animatables created for all nodes
  26522. * @example https://www.babylonjs-playground.com/#MH0VLI
  26523. */
  26524. 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[]>;
  26525. /**
  26526. * Creates a new animation, merges it with the existing animations and starts it
  26527. * @param name Name of the animation
  26528. * @param node Node which contains the scene that begins the animations
  26529. * @param targetProperty Specifies which property to animate
  26530. * @param framePerSecond The frames per second of the animation
  26531. * @param totalFrame The total number of frames
  26532. * @param from The frame at the beginning of the animation
  26533. * @param to The frame at the end of the animation
  26534. * @param loopMode Specifies the loop mode of the animation
  26535. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26536. * @param onAnimationEnd Callback to run once the animation is complete
  26537. * @returns Nullable animation
  26538. */
  26539. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26540. /**
  26541. * Transition property of an host to the target Value
  26542. * @param property The property to transition
  26543. * @param targetValue The target Value of the property
  26544. * @param host The object where the property to animate belongs
  26545. * @param scene Scene used to run the animation
  26546. * @param frameRate Framerate (in frame/s) to use
  26547. * @param transition The transition type we want to use
  26548. * @param duration The duration of the animation, in milliseconds
  26549. * @param onAnimationEnd Callback trigger at the end of the animation
  26550. * @returns Nullable animation
  26551. */
  26552. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26553. /**
  26554. * Return the array of runtime animations currently using this animation
  26555. */
  26556. readonly runtimeAnimations: RuntimeAnimation[];
  26557. /**
  26558. * Specifies if any of the runtime animations are currently running
  26559. */
  26560. readonly hasRunningRuntimeAnimations: boolean;
  26561. /**
  26562. * Initializes the animation
  26563. * @param name Name of the animation
  26564. * @param targetProperty Property to animate
  26565. * @param framePerSecond The frames per second of the animation
  26566. * @param dataType The data type of the animation
  26567. * @param loopMode The loop mode of the animation
  26568. * @param enableBlending Specifies if blending should be enabled
  26569. */
  26570. constructor(
  26571. /**Name of the animation */
  26572. name: string,
  26573. /**Property to animate */
  26574. targetProperty: string,
  26575. /**The frames per second of the animation */
  26576. framePerSecond: number,
  26577. /**The data type of the animation */
  26578. dataType: number,
  26579. /**The loop mode of the animation */
  26580. loopMode?: number | undefined,
  26581. /**Specifies if blending should be enabled */
  26582. enableBlending?: boolean | undefined);
  26583. /**
  26584. * Converts the animation to a string
  26585. * @param fullDetails support for multiple levels of logging within scene loading
  26586. * @returns String form of the animation
  26587. */
  26588. toString(fullDetails?: boolean): string;
  26589. /**
  26590. * Add an event to this animation
  26591. * @param event Event to add
  26592. */
  26593. addEvent(event: AnimationEvent): void;
  26594. /**
  26595. * Remove all events found at the given frame
  26596. * @param frame The frame to remove events from
  26597. */
  26598. removeEvents(frame: number): void;
  26599. /**
  26600. * Retrieves all the events from the animation
  26601. * @returns Events from the animation
  26602. */
  26603. getEvents(): AnimationEvent[];
  26604. /**
  26605. * Creates an animation range
  26606. * @param name Name of the animation range
  26607. * @param from Starting frame of the animation range
  26608. * @param to Ending frame of the animation
  26609. */
  26610. createRange(name: string, from: number, to: number): void;
  26611. /**
  26612. * Deletes an animation range by name
  26613. * @param name Name of the animation range to delete
  26614. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26615. */
  26616. deleteRange(name: string, deleteFrames?: boolean): void;
  26617. /**
  26618. * Gets the animation range by name, or null if not defined
  26619. * @param name Name of the animation range
  26620. * @returns Nullable animation range
  26621. */
  26622. getRange(name: string): Nullable<AnimationRange>;
  26623. /**
  26624. * Gets the key frames from the animation
  26625. * @returns The key frames of the animation
  26626. */
  26627. getKeys(): Array<IAnimationKey>;
  26628. /**
  26629. * Gets the highest frame rate of the animation
  26630. * @returns Highest frame rate of the animation
  26631. */
  26632. getHighestFrame(): number;
  26633. /**
  26634. * Gets the easing function of the animation
  26635. * @returns Easing function of the animation
  26636. */
  26637. getEasingFunction(): IEasingFunction;
  26638. /**
  26639. * Sets the easing function of the animation
  26640. * @param easingFunction A custom mathematical formula for animation
  26641. */
  26642. setEasingFunction(easingFunction: EasingFunction): void;
  26643. /**
  26644. * Interpolates a scalar linearly
  26645. * @param startValue Start value of the animation curve
  26646. * @param endValue End value of the animation curve
  26647. * @param gradient Scalar amount to interpolate
  26648. * @returns Interpolated scalar value
  26649. */
  26650. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26651. /**
  26652. * Interpolates a scalar cubically
  26653. * @param startValue Start value of the animation curve
  26654. * @param outTangent End tangent of the animation
  26655. * @param endValue End value of the animation curve
  26656. * @param inTangent Start tangent of the animation curve
  26657. * @param gradient Scalar amount to interpolate
  26658. * @returns Interpolated scalar value
  26659. */
  26660. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26661. /**
  26662. * Interpolates a quaternion using a spherical linear interpolation
  26663. * @param startValue Start value of the animation curve
  26664. * @param endValue End value of the animation curve
  26665. * @param gradient Scalar amount to interpolate
  26666. * @returns Interpolated quaternion value
  26667. */
  26668. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26669. /**
  26670. * Interpolates a quaternion cubically
  26671. * @param startValue Start value of the animation curve
  26672. * @param outTangent End tangent of the animation curve
  26673. * @param endValue End value of the animation curve
  26674. * @param inTangent Start tangent of the animation curve
  26675. * @param gradient Scalar amount to interpolate
  26676. * @returns Interpolated quaternion value
  26677. */
  26678. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26679. /**
  26680. * Interpolates a Vector3 linearl
  26681. * @param startValue Start value of the animation curve
  26682. * @param endValue End value of the animation curve
  26683. * @param gradient Scalar amount to interpolate
  26684. * @returns Interpolated scalar value
  26685. */
  26686. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26687. /**
  26688. * Interpolates a Vector3 cubically
  26689. * @param startValue Start value of the animation curve
  26690. * @param outTangent End tangent of the animation
  26691. * @param endValue End value of the animation curve
  26692. * @param inTangent Start tangent of the animation curve
  26693. * @param gradient Scalar amount to interpolate
  26694. * @returns InterpolatedVector3 value
  26695. */
  26696. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26697. /**
  26698. * Interpolates a Vector2 linearly
  26699. * @param startValue Start value of the animation curve
  26700. * @param endValue End value of the animation curve
  26701. * @param gradient Scalar amount to interpolate
  26702. * @returns Interpolated Vector2 value
  26703. */
  26704. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26705. /**
  26706. * Interpolates a Vector2 cubically
  26707. * @param startValue Start value of the animation curve
  26708. * @param outTangent End tangent of the animation
  26709. * @param endValue End value of the animation curve
  26710. * @param inTangent Start tangent of the animation curve
  26711. * @param gradient Scalar amount to interpolate
  26712. * @returns Interpolated Vector2 value
  26713. */
  26714. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26715. /**
  26716. * Interpolates a size linearly
  26717. * @param startValue Start value of the animation curve
  26718. * @param endValue End value of the animation curve
  26719. * @param gradient Scalar amount to interpolate
  26720. * @returns Interpolated Size value
  26721. */
  26722. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26723. /**
  26724. * Interpolates a Color3 linearly
  26725. * @param startValue Start value of the animation curve
  26726. * @param endValue End value of the animation curve
  26727. * @param gradient Scalar amount to interpolate
  26728. * @returns Interpolated Color3 value
  26729. */
  26730. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26731. /**
  26732. * @hidden Internal use only
  26733. */
  26734. _getKeyValue(value: any): any;
  26735. /**
  26736. * @hidden Internal use only
  26737. */
  26738. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26739. /**
  26740. * Defines the function to use to interpolate matrices
  26741. * @param startValue defines the start matrix
  26742. * @param endValue defines the end matrix
  26743. * @param gradient defines the gradient between both matrices
  26744. * @param result defines an optional target matrix where to store the interpolation
  26745. * @returns the interpolated matrix
  26746. */
  26747. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26748. /**
  26749. * Makes a copy of the animation
  26750. * @returns Cloned animation
  26751. */
  26752. clone(): Animation;
  26753. /**
  26754. * Sets the key frames of the animation
  26755. * @param values The animation key frames to set
  26756. */
  26757. setKeys(values: Array<IAnimationKey>): void;
  26758. /**
  26759. * Serializes the animation to an object
  26760. * @returns Serialized object
  26761. */
  26762. serialize(): any;
  26763. /**
  26764. * Float animation type
  26765. */
  26766. private static _ANIMATIONTYPE_FLOAT;
  26767. /**
  26768. * Vector3 animation type
  26769. */
  26770. private static _ANIMATIONTYPE_VECTOR3;
  26771. /**
  26772. * Quaternion animation type
  26773. */
  26774. private static _ANIMATIONTYPE_QUATERNION;
  26775. /**
  26776. * Matrix animation type
  26777. */
  26778. private static _ANIMATIONTYPE_MATRIX;
  26779. /**
  26780. * Color3 animation type
  26781. */
  26782. private static _ANIMATIONTYPE_COLOR3;
  26783. /**
  26784. * Vector2 animation type
  26785. */
  26786. private static _ANIMATIONTYPE_VECTOR2;
  26787. /**
  26788. * Size animation type
  26789. */
  26790. private static _ANIMATIONTYPE_SIZE;
  26791. /**
  26792. * Relative Loop Mode
  26793. */
  26794. private static _ANIMATIONLOOPMODE_RELATIVE;
  26795. /**
  26796. * Cycle Loop Mode
  26797. */
  26798. private static _ANIMATIONLOOPMODE_CYCLE;
  26799. /**
  26800. * Constant Loop Mode
  26801. */
  26802. private static _ANIMATIONLOOPMODE_CONSTANT;
  26803. /**
  26804. * Get the float animation type
  26805. */
  26806. static readonly ANIMATIONTYPE_FLOAT: number;
  26807. /**
  26808. * Get the Vector3 animation type
  26809. */
  26810. static readonly ANIMATIONTYPE_VECTOR3: number;
  26811. /**
  26812. * Get the Vector2 animation type
  26813. */
  26814. static readonly ANIMATIONTYPE_VECTOR2: number;
  26815. /**
  26816. * Get the Size animation type
  26817. */
  26818. static readonly ANIMATIONTYPE_SIZE: number;
  26819. /**
  26820. * Get the Quaternion animation type
  26821. */
  26822. static readonly ANIMATIONTYPE_QUATERNION: number;
  26823. /**
  26824. * Get the Matrix animation type
  26825. */
  26826. static readonly ANIMATIONTYPE_MATRIX: number;
  26827. /**
  26828. * Get the Color3 animation type
  26829. */
  26830. static readonly ANIMATIONTYPE_COLOR3: number;
  26831. /**
  26832. * Get the Relative Loop Mode
  26833. */
  26834. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26835. /**
  26836. * Get the Cycle Loop Mode
  26837. */
  26838. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26839. /**
  26840. * Get the Constant Loop Mode
  26841. */
  26842. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26843. /** @hidden */
  26844. static _UniversalLerp(left: any, right: any, amount: number): any;
  26845. /**
  26846. * Parses an animation object and creates an animation
  26847. * @param parsedAnimation Parsed animation object
  26848. * @returns Animation object
  26849. */
  26850. static Parse(parsedAnimation: any): Animation;
  26851. /**
  26852. * Appends the serialized animations from the source animations
  26853. * @param source Source containing the animations
  26854. * @param destination Target to store the animations
  26855. */
  26856. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26857. }
  26858. }
  26859. declare module "babylonjs/Materials/Textures/baseTexture" {
  26860. import { Observable } from "babylonjs/Misc/observable";
  26861. import { IAnimatable } from "babylonjs/Misc/tools";
  26862. import { Nullable } from "babylonjs/types";
  26863. import { Scene } from "babylonjs/scene";
  26864. import { Matrix, ISize } from "babylonjs/Maths/math";
  26865. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26866. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26867. /**
  26868. * Base class of all the textures in babylon.
  26869. * It groups all the common properties the materials, post process, lights... might need
  26870. * in order to make a correct use of the texture.
  26871. */
  26872. export class BaseTexture implements IAnimatable {
  26873. /**
  26874. * Default anisotropic filtering level for the application.
  26875. * It is set to 4 as a good tradeoff between perf and quality.
  26876. */
  26877. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26878. /**
  26879. * Gets or sets the unique id of the texture
  26880. */
  26881. uniqueId: number;
  26882. /**
  26883. * Define the name of the texture.
  26884. */
  26885. name: string;
  26886. /**
  26887. * Gets or sets an object used to store user defined information.
  26888. */
  26889. metadata: any;
  26890. /**
  26891. * For internal use only. Please do not use.
  26892. */
  26893. reservedDataStore: any;
  26894. private _hasAlpha;
  26895. /**
  26896. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26897. */
  26898. hasAlpha: boolean;
  26899. /**
  26900. * Defines if the alpha value should be determined via the rgb values.
  26901. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26902. */
  26903. getAlphaFromRGB: boolean;
  26904. /**
  26905. * Intensity or strength of the texture.
  26906. * It is commonly used by materials to fine tune the intensity of the texture
  26907. */
  26908. level: number;
  26909. /**
  26910. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26911. * This is part of the texture as textures usually maps to one uv set.
  26912. */
  26913. coordinatesIndex: number;
  26914. private _coordinatesMode;
  26915. /**
  26916. * How a texture is mapped.
  26917. *
  26918. * | Value | Type | Description |
  26919. * | ----- | ----------------------------------- | ----------- |
  26920. * | 0 | EXPLICIT_MODE | |
  26921. * | 1 | SPHERICAL_MODE | |
  26922. * | 2 | PLANAR_MODE | |
  26923. * | 3 | CUBIC_MODE | |
  26924. * | 4 | PROJECTION_MODE | |
  26925. * | 5 | SKYBOX_MODE | |
  26926. * | 6 | INVCUBIC_MODE | |
  26927. * | 7 | EQUIRECTANGULAR_MODE | |
  26928. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26929. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26930. */
  26931. coordinatesMode: number;
  26932. /**
  26933. * | Value | Type | Description |
  26934. * | ----- | ------------------ | ----------- |
  26935. * | 0 | CLAMP_ADDRESSMODE | |
  26936. * | 1 | WRAP_ADDRESSMODE | |
  26937. * | 2 | MIRROR_ADDRESSMODE | |
  26938. */
  26939. wrapU: number;
  26940. /**
  26941. * | Value | Type | Description |
  26942. * | ----- | ------------------ | ----------- |
  26943. * | 0 | CLAMP_ADDRESSMODE | |
  26944. * | 1 | WRAP_ADDRESSMODE | |
  26945. * | 2 | MIRROR_ADDRESSMODE | |
  26946. */
  26947. wrapV: number;
  26948. /**
  26949. * | Value | Type | Description |
  26950. * | ----- | ------------------ | ----------- |
  26951. * | 0 | CLAMP_ADDRESSMODE | |
  26952. * | 1 | WRAP_ADDRESSMODE | |
  26953. * | 2 | MIRROR_ADDRESSMODE | |
  26954. */
  26955. wrapR: number;
  26956. /**
  26957. * With compliant hardware and browser (supporting anisotropic filtering)
  26958. * this defines the level of anisotropic filtering in the texture.
  26959. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26960. */
  26961. anisotropicFilteringLevel: number;
  26962. /**
  26963. * Define if the texture is a cube texture or if false a 2d texture.
  26964. */
  26965. isCube: boolean;
  26966. /**
  26967. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26968. */
  26969. is3D: boolean;
  26970. /**
  26971. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26972. * HDR texture are usually stored in linear space.
  26973. * This only impacts the PBR and Background materials
  26974. */
  26975. gammaSpace: boolean;
  26976. /**
  26977. * Gets whether or not the texture contains RGBD data.
  26978. */
  26979. readonly isRGBD: boolean;
  26980. /**
  26981. * Is Z inverted in the texture (useful in a cube texture).
  26982. */
  26983. invertZ: boolean;
  26984. /**
  26985. * Are mip maps generated for this texture or not.
  26986. */
  26987. readonly noMipmap: boolean;
  26988. /**
  26989. * @hidden
  26990. */
  26991. lodLevelInAlpha: boolean;
  26992. /**
  26993. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26994. */
  26995. lodGenerationOffset: number;
  26996. /**
  26997. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26998. */
  26999. lodGenerationScale: number;
  27000. /**
  27001. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27002. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27003. * average roughness values.
  27004. */
  27005. linearSpecularLOD: boolean;
  27006. /**
  27007. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27008. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27009. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27010. */
  27011. irradianceTexture: Nullable<BaseTexture>;
  27012. /**
  27013. * Define if the texture is a render target.
  27014. */
  27015. isRenderTarget: boolean;
  27016. /**
  27017. * Define the unique id of the texture in the scene.
  27018. */
  27019. readonly uid: string;
  27020. /**
  27021. * Return a string representation of the texture.
  27022. * @returns the texture as a string
  27023. */
  27024. toString(): string;
  27025. /**
  27026. * Get the class name of the texture.
  27027. * @returns "BaseTexture"
  27028. */
  27029. getClassName(): string;
  27030. /**
  27031. * Define the list of animation attached to the texture.
  27032. */
  27033. animations: import("babylonjs/Animations/animation").Animation[];
  27034. /**
  27035. * An event triggered when the texture is disposed.
  27036. */
  27037. onDisposeObservable: Observable<BaseTexture>;
  27038. private _onDisposeObserver;
  27039. /**
  27040. * Callback triggered when the texture has been disposed.
  27041. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27042. */
  27043. onDispose: () => void;
  27044. /**
  27045. * Define the current state of the loading sequence when in delayed load mode.
  27046. */
  27047. delayLoadState: number;
  27048. private _scene;
  27049. /** @hidden */
  27050. _texture: Nullable<InternalTexture>;
  27051. private _uid;
  27052. /**
  27053. * Define if the texture is preventinga material to render or not.
  27054. * If not and the texture is not ready, the engine will use a default black texture instead.
  27055. */
  27056. readonly isBlocking: boolean;
  27057. /**
  27058. * Instantiates a new BaseTexture.
  27059. * Base class of all the textures in babylon.
  27060. * It groups all the common properties the materials, post process, lights... might need
  27061. * in order to make a correct use of the texture.
  27062. * @param scene Define the scene the texture blongs to
  27063. */
  27064. constructor(scene: Nullable<Scene>);
  27065. /**
  27066. * Get the scene the texture belongs to.
  27067. * @returns the scene or null if undefined
  27068. */
  27069. getScene(): Nullable<Scene>;
  27070. /**
  27071. * Get the texture transform matrix used to offset tile the texture for istance.
  27072. * @returns the transformation matrix
  27073. */
  27074. getTextureMatrix(): Matrix;
  27075. /**
  27076. * Get the texture reflection matrix used to rotate/transform the reflection.
  27077. * @returns the reflection matrix
  27078. */
  27079. getReflectionTextureMatrix(): Matrix;
  27080. /**
  27081. * Get the underlying lower level texture from Babylon.
  27082. * @returns the insternal texture
  27083. */
  27084. getInternalTexture(): Nullable<InternalTexture>;
  27085. /**
  27086. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27087. * @returns true if ready or not blocking
  27088. */
  27089. isReadyOrNotBlocking(): boolean;
  27090. /**
  27091. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27092. * @returns true if fully ready
  27093. */
  27094. isReady(): boolean;
  27095. private _cachedSize;
  27096. /**
  27097. * Get the size of the texture.
  27098. * @returns the texture size.
  27099. */
  27100. getSize(): ISize;
  27101. /**
  27102. * Get the base size of the texture.
  27103. * It can be different from the size if the texture has been resized for POT for instance
  27104. * @returns the base size
  27105. */
  27106. getBaseSize(): ISize;
  27107. /**
  27108. * Update the sampling mode of the texture.
  27109. * Default is Trilinear mode.
  27110. *
  27111. * | Value | Type | Description |
  27112. * | ----- | ------------------ | ----------- |
  27113. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27114. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27115. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27116. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27117. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27118. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27119. * | 7 | NEAREST_LINEAR | |
  27120. * | 8 | NEAREST_NEAREST | |
  27121. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27122. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27123. * | 11 | LINEAR_LINEAR | |
  27124. * | 12 | LINEAR_NEAREST | |
  27125. *
  27126. * > _mag_: magnification filter (close to the viewer)
  27127. * > _min_: minification filter (far from the viewer)
  27128. * > _mip_: filter used between mip map levels
  27129. *@param samplingMode Define the new sampling mode of the texture
  27130. */
  27131. updateSamplingMode(samplingMode: number): void;
  27132. /**
  27133. * Scales the texture if is `canRescale()`
  27134. * @param ratio the resize factor we want to use to rescale
  27135. */
  27136. scale(ratio: number): void;
  27137. /**
  27138. * Get if the texture can rescale.
  27139. */
  27140. readonly canRescale: boolean;
  27141. /** @hidden */
  27142. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27143. /** @hidden */
  27144. _rebuild(): void;
  27145. /**
  27146. * Triggers the load sequence in delayed load mode.
  27147. */
  27148. delayLoad(): void;
  27149. /**
  27150. * Clones the texture.
  27151. * @returns the cloned texture
  27152. */
  27153. clone(): Nullable<BaseTexture>;
  27154. /**
  27155. * Get the texture underlying type (INT, FLOAT...)
  27156. */
  27157. readonly textureType: number;
  27158. /**
  27159. * Get the texture underlying format (RGB, RGBA...)
  27160. */
  27161. readonly textureFormat: number;
  27162. /**
  27163. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27164. * This will returns an RGBA array buffer containing either in values (0-255) or
  27165. * float values (0-1) depending of the underlying buffer type.
  27166. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27167. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27168. * @param buffer defines a user defined buffer to fill with data (can be null)
  27169. * @returns The Array buffer containing the pixels data.
  27170. */
  27171. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27172. /**
  27173. * Release and destroy the underlying lower level texture aka internalTexture.
  27174. */
  27175. releaseInternalTexture(): void;
  27176. /**
  27177. * Get the polynomial representation of the texture data.
  27178. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27179. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27180. */
  27181. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27182. /** @hidden */
  27183. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27184. /** @hidden */
  27185. readonly _lodTextureMid: Nullable<BaseTexture>;
  27186. /** @hidden */
  27187. readonly _lodTextureLow: Nullable<BaseTexture>;
  27188. /**
  27189. * Dispose the texture and release its associated resources.
  27190. */
  27191. dispose(): void;
  27192. /**
  27193. * Serialize the texture into a JSON representation that can be parsed later on.
  27194. * @returns the JSON representation of the texture
  27195. */
  27196. serialize(): any;
  27197. /**
  27198. * Helper function to be called back once a list of texture contains only ready textures.
  27199. * @param textures Define the list of textures to wait for
  27200. * @param callback Define the callback triggered once the entire list will be ready
  27201. */
  27202. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27203. }
  27204. }
  27205. declare module "babylonjs/Materials/uniformBuffer" {
  27206. import { Nullable, FloatArray } from "babylonjs/types";
  27207. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27208. import { Engine } from "babylonjs/Engines/engine";
  27209. import { Effect } from "babylonjs/Materials/effect";
  27210. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27211. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27212. /**
  27213. * Uniform buffer objects.
  27214. *
  27215. * Handles blocks of uniform on the GPU.
  27216. *
  27217. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27218. *
  27219. * For more information, please refer to :
  27220. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27221. */
  27222. export class UniformBuffer {
  27223. private _engine;
  27224. private _buffer;
  27225. private _data;
  27226. private _bufferData;
  27227. private _dynamic?;
  27228. private _uniformLocations;
  27229. private _uniformSizes;
  27230. private _uniformLocationPointer;
  27231. private _needSync;
  27232. private _noUBO;
  27233. private _currentEffect;
  27234. private static _MAX_UNIFORM_SIZE;
  27235. private static _tempBuffer;
  27236. /**
  27237. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27238. * This is dynamic to allow compat with webgl 1 and 2.
  27239. * You will need to pass the name of the uniform as well as the value.
  27240. */
  27241. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27242. /**
  27243. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27244. * This is dynamic to allow compat with webgl 1 and 2.
  27245. * You will need to pass the name of the uniform as well as the value.
  27246. */
  27247. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27248. /**
  27249. * Lambda to Update a single float in a uniform buffer.
  27250. * This is dynamic to allow compat with webgl 1 and 2.
  27251. * You will need to pass the name of the uniform as well as the value.
  27252. */
  27253. updateFloat: (name: string, x: number) => void;
  27254. /**
  27255. * Lambda to Update a vec2 of float in a uniform buffer.
  27256. * This is dynamic to allow compat with webgl 1 and 2.
  27257. * You will need to pass the name of the uniform as well as the value.
  27258. */
  27259. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27260. /**
  27261. * Lambda to Update a vec3 of float in a uniform buffer.
  27262. * This is dynamic to allow compat with webgl 1 and 2.
  27263. * You will need to pass the name of the uniform as well as the value.
  27264. */
  27265. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27266. /**
  27267. * Lambda to Update a vec4 of float in a uniform buffer.
  27268. * This is dynamic to allow compat with webgl 1 and 2.
  27269. * You will need to pass the name of the uniform as well as the value.
  27270. */
  27271. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27272. /**
  27273. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27274. * This is dynamic to allow compat with webgl 1 and 2.
  27275. * You will need to pass the name of the uniform as well as the value.
  27276. */
  27277. updateMatrix: (name: string, mat: Matrix) => void;
  27278. /**
  27279. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27280. * This is dynamic to allow compat with webgl 1 and 2.
  27281. * You will need to pass the name of the uniform as well as the value.
  27282. */
  27283. updateVector3: (name: string, vector: Vector3) => void;
  27284. /**
  27285. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27286. * This is dynamic to allow compat with webgl 1 and 2.
  27287. * You will need to pass the name of the uniform as well as the value.
  27288. */
  27289. updateVector4: (name: string, vector: Vector4) => void;
  27290. /**
  27291. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27292. * This is dynamic to allow compat with webgl 1 and 2.
  27293. * You will need to pass the name of the uniform as well as the value.
  27294. */
  27295. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27296. /**
  27297. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27298. * This is dynamic to allow compat with webgl 1 and 2.
  27299. * You will need to pass the name of the uniform as well as the value.
  27300. */
  27301. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27302. /**
  27303. * Instantiates a new Uniform buffer objects.
  27304. *
  27305. * Handles blocks of uniform on the GPU.
  27306. *
  27307. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27308. *
  27309. * For more information, please refer to :
  27310. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27311. * @param engine Define the engine the buffer is associated with
  27312. * @param data Define the data contained in the buffer
  27313. * @param dynamic Define if the buffer is updatable
  27314. */
  27315. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27316. /**
  27317. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27318. * or just falling back on setUniformXXX calls.
  27319. */
  27320. readonly useUbo: boolean;
  27321. /**
  27322. * Indicates if the WebGL underlying uniform buffer is in sync
  27323. * with the javascript cache data.
  27324. */
  27325. readonly isSync: boolean;
  27326. /**
  27327. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27328. * Also, a dynamic UniformBuffer will disable cache verification and always
  27329. * update the underlying WebGL uniform buffer to the GPU.
  27330. * @returns if Dynamic, otherwise false
  27331. */
  27332. isDynamic(): boolean;
  27333. /**
  27334. * The data cache on JS side.
  27335. * @returns the underlying data as a float array
  27336. */
  27337. getData(): Float32Array;
  27338. /**
  27339. * The underlying WebGL Uniform buffer.
  27340. * @returns the webgl buffer
  27341. */
  27342. getBuffer(): Nullable<DataBuffer>;
  27343. /**
  27344. * std140 layout specifies how to align data within an UBO structure.
  27345. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27346. * for specs.
  27347. */
  27348. private _fillAlignment;
  27349. /**
  27350. * Adds an uniform in the buffer.
  27351. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27352. * for the layout to be correct !
  27353. * @param name Name of the uniform, as used in the uniform block in the shader.
  27354. * @param size Data size, or data directly.
  27355. */
  27356. addUniform(name: string, size: number | number[]): void;
  27357. /**
  27358. * Adds a Matrix 4x4 to the uniform buffer.
  27359. * @param name Name of the uniform, as used in the uniform block in the shader.
  27360. * @param mat A 4x4 matrix.
  27361. */
  27362. addMatrix(name: string, mat: Matrix): void;
  27363. /**
  27364. * Adds a vec2 to the uniform buffer.
  27365. * @param name Name of the uniform, as used in the uniform block in the shader.
  27366. * @param x Define the x component value of the vec2
  27367. * @param y Define the y component value of the vec2
  27368. */
  27369. addFloat2(name: string, x: number, y: number): void;
  27370. /**
  27371. * Adds a vec3 to the uniform buffer.
  27372. * @param name Name of the uniform, as used in the uniform block in the shader.
  27373. * @param x Define the x component value of the vec3
  27374. * @param y Define the y component value of the vec3
  27375. * @param z Define the z component value of the vec3
  27376. */
  27377. addFloat3(name: string, x: number, y: number, z: number): void;
  27378. /**
  27379. * Adds a vec3 to the uniform buffer.
  27380. * @param name Name of the uniform, as used in the uniform block in the shader.
  27381. * @param color Define the vec3 from a Color
  27382. */
  27383. addColor3(name: string, color: Color3): void;
  27384. /**
  27385. * Adds a vec4 to the uniform buffer.
  27386. * @param name Name of the uniform, as used in the uniform block in the shader.
  27387. * @param color Define the rgb components from a Color
  27388. * @param alpha Define the a component of the vec4
  27389. */
  27390. addColor4(name: string, color: Color3, alpha: number): void;
  27391. /**
  27392. * Adds a vec3 to the uniform buffer.
  27393. * @param name Name of the uniform, as used in the uniform block in the shader.
  27394. * @param vector Define the vec3 components from a Vector
  27395. */
  27396. addVector3(name: string, vector: Vector3): void;
  27397. /**
  27398. * Adds a Matrix 3x3 to the uniform buffer.
  27399. * @param name Name of the uniform, as used in the uniform block in the shader.
  27400. */
  27401. addMatrix3x3(name: string): void;
  27402. /**
  27403. * Adds a Matrix 2x2 to the uniform buffer.
  27404. * @param name Name of the uniform, as used in the uniform block in the shader.
  27405. */
  27406. addMatrix2x2(name: string): void;
  27407. /**
  27408. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27409. */
  27410. create(): void;
  27411. /** @hidden */
  27412. _rebuild(): void;
  27413. /**
  27414. * Updates the WebGL Uniform Buffer on the GPU.
  27415. * If the `dynamic` flag is set to true, no cache comparison is done.
  27416. * Otherwise, the buffer will be updated only if the cache differs.
  27417. */
  27418. update(): void;
  27419. /**
  27420. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27421. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27422. * @param data Define the flattened data
  27423. * @param size Define the size of the data.
  27424. */
  27425. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27426. private _updateMatrix3x3ForUniform;
  27427. private _updateMatrix3x3ForEffect;
  27428. private _updateMatrix2x2ForEffect;
  27429. private _updateMatrix2x2ForUniform;
  27430. private _updateFloatForEffect;
  27431. private _updateFloatForUniform;
  27432. private _updateFloat2ForEffect;
  27433. private _updateFloat2ForUniform;
  27434. private _updateFloat3ForEffect;
  27435. private _updateFloat3ForUniform;
  27436. private _updateFloat4ForEffect;
  27437. private _updateFloat4ForUniform;
  27438. private _updateMatrixForEffect;
  27439. private _updateMatrixForUniform;
  27440. private _updateVector3ForEffect;
  27441. private _updateVector3ForUniform;
  27442. private _updateVector4ForEffect;
  27443. private _updateVector4ForUniform;
  27444. private _updateColor3ForEffect;
  27445. private _updateColor3ForUniform;
  27446. private _updateColor4ForEffect;
  27447. private _updateColor4ForUniform;
  27448. /**
  27449. * Sets a sampler uniform on the effect.
  27450. * @param name Define the name of the sampler.
  27451. * @param texture Define the texture to set in the sampler
  27452. */
  27453. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27454. /**
  27455. * Directly updates the value of the uniform in the cache AND on the GPU.
  27456. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27457. * @param data Define the flattened data
  27458. */
  27459. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27460. /**
  27461. * Binds this uniform buffer to an effect.
  27462. * @param effect Define the effect to bind the buffer to
  27463. * @param name Name of the uniform block in the shader.
  27464. */
  27465. bindToEffect(effect: Effect, name: string): void;
  27466. /**
  27467. * Disposes the uniform buffer.
  27468. */
  27469. dispose(): void;
  27470. }
  27471. }
  27472. declare module "babylonjs/Audio/analyser" {
  27473. import { Scene } from "babylonjs/scene";
  27474. /**
  27475. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27477. */
  27478. export class Analyser {
  27479. /**
  27480. * Gets or sets the smoothing
  27481. * @ignorenaming
  27482. */
  27483. SMOOTHING: number;
  27484. /**
  27485. * Gets or sets the FFT table size
  27486. * @ignorenaming
  27487. */
  27488. FFT_SIZE: number;
  27489. /**
  27490. * Gets or sets the bar graph amplitude
  27491. * @ignorenaming
  27492. */
  27493. BARGRAPHAMPLITUDE: number;
  27494. /**
  27495. * Gets or sets the position of the debug canvas
  27496. * @ignorenaming
  27497. */
  27498. DEBUGCANVASPOS: {
  27499. x: number;
  27500. y: number;
  27501. };
  27502. /**
  27503. * Gets or sets the debug canvas size
  27504. * @ignorenaming
  27505. */
  27506. DEBUGCANVASSIZE: {
  27507. width: number;
  27508. height: number;
  27509. };
  27510. private _byteFreqs;
  27511. private _byteTime;
  27512. private _floatFreqs;
  27513. private _webAudioAnalyser;
  27514. private _debugCanvas;
  27515. private _debugCanvasContext;
  27516. private _scene;
  27517. private _registerFunc;
  27518. private _audioEngine;
  27519. /**
  27520. * Creates a new analyser
  27521. * @param scene defines hosting scene
  27522. */
  27523. constructor(scene: Scene);
  27524. /**
  27525. * Get the number of data values you will have to play with for the visualization
  27526. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27527. * @returns a number
  27528. */
  27529. getFrequencyBinCount(): number;
  27530. /**
  27531. * Gets the current frequency data as a byte array
  27532. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27533. * @returns a Uint8Array
  27534. */
  27535. getByteFrequencyData(): Uint8Array;
  27536. /**
  27537. * Gets the current waveform as a byte array
  27538. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27539. * @returns a Uint8Array
  27540. */
  27541. getByteTimeDomainData(): Uint8Array;
  27542. /**
  27543. * Gets the current frequency data as a float array
  27544. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27545. * @returns a Float32Array
  27546. */
  27547. getFloatFrequencyData(): Float32Array;
  27548. /**
  27549. * Renders the debug canvas
  27550. */
  27551. drawDebugCanvas(): void;
  27552. /**
  27553. * Stops rendering the debug canvas and removes it
  27554. */
  27555. stopDebugCanvas(): void;
  27556. /**
  27557. * Connects two audio nodes
  27558. * @param inputAudioNode defines first node to connect
  27559. * @param outputAudioNode defines second node to connect
  27560. */
  27561. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27562. /**
  27563. * Releases all associated resources
  27564. */
  27565. dispose(): void;
  27566. }
  27567. }
  27568. declare module "babylonjs/Audio/audioEngine" {
  27569. import { IDisposable } from "babylonjs/scene";
  27570. import { Analyser } from "babylonjs/Audio/analyser";
  27571. import { Nullable } from "babylonjs/types";
  27572. import { Observable } from "babylonjs/Misc/observable";
  27573. /**
  27574. * This represents an audio engine and it is responsible
  27575. * to play, synchronize and analyse sounds throughout the application.
  27576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27577. */
  27578. export interface IAudioEngine extends IDisposable {
  27579. /**
  27580. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27581. */
  27582. readonly canUseWebAudio: boolean;
  27583. /**
  27584. * Gets the current AudioContext if available.
  27585. */
  27586. readonly audioContext: Nullable<AudioContext>;
  27587. /**
  27588. * The master gain node defines the global audio volume of your audio engine.
  27589. */
  27590. readonly masterGain: GainNode;
  27591. /**
  27592. * Gets whether or not mp3 are supported by your browser.
  27593. */
  27594. readonly isMP3supported: boolean;
  27595. /**
  27596. * Gets whether or not ogg are supported by your browser.
  27597. */
  27598. readonly isOGGsupported: boolean;
  27599. /**
  27600. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27601. * @ignoreNaming
  27602. */
  27603. WarnedWebAudioUnsupported: boolean;
  27604. /**
  27605. * Defines if the audio engine relies on a custom unlocked button.
  27606. * In this case, the embedded button will not be displayed.
  27607. */
  27608. useCustomUnlockedButton: boolean;
  27609. /**
  27610. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27611. */
  27612. readonly unlocked: boolean;
  27613. /**
  27614. * Event raised when audio has been unlocked on the browser.
  27615. */
  27616. onAudioUnlockedObservable: Observable<AudioEngine>;
  27617. /**
  27618. * Event raised when audio has been locked on the browser.
  27619. */
  27620. onAudioLockedObservable: Observable<AudioEngine>;
  27621. /**
  27622. * Flags the audio engine in Locked state.
  27623. * This happens due to new browser policies preventing audio to autoplay.
  27624. */
  27625. lock(): void;
  27626. /**
  27627. * Unlocks the audio engine once a user action has been done on the dom.
  27628. * This is helpful to resume play once browser policies have been satisfied.
  27629. */
  27630. unlock(): void;
  27631. }
  27632. /**
  27633. * This represents the default audio engine used in babylon.
  27634. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27636. */
  27637. export class AudioEngine implements IAudioEngine {
  27638. private _audioContext;
  27639. private _audioContextInitialized;
  27640. private _muteButton;
  27641. private _hostElement;
  27642. /**
  27643. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27644. */
  27645. canUseWebAudio: boolean;
  27646. /**
  27647. * The master gain node defines the global audio volume of your audio engine.
  27648. */
  27649. masterGain: GainNode;
  27650. /**
  27651. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27652. * @ignoreNaming
  27653. */
  27654. WarnedWebAudioUnsupported: boolean;
  27655. /**
  27656. * Gets whether or not mp3 are supported by your browser.
  27657. */
  27658. isMP3supported: boolean;
  27659. /**
  27660. * Gets whether or not ogg are supported by your browser.
  27661. */
  27662. isOGGsupported: boolean;
  27663. /**
  27664. * Gets whether audio has been unlocked on the device.
  27665. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27666. * a user interaction has happened.
  27667. */
  27668. unlocked: boolean;
  27669. /**
  27670. * Defines if the audio engine relies on a custom unlocked button.
  27671. * In this case, the embedded button will not be displayed.
  27672. */
  27673. useCustomUnlockedButton: boolean;
  27674. /**
  27675. * Event raised when audio has been unlocked on the browser.
  27676. */
  27677. onAudioUnlockedObservable: Observable<AudioEngine>;
  27678. /**
  27679. * Event raised when audio has been locked on the browser.
  27680. */
  27681. onAudioLockedObservable: Observable<AudioEngine>;
  27682. /**
  27683. * Gets the current AudioContext if available.
  27684. */
  27685. readonly audioContext: Nullable<AudioContext>;
  27686. private _connectedAnalyser;
  27687. /**
  27688. * Instantiates a new audio engine.
  27689. *
  27690. * There should be only one per page as some browsers restrict the number
  27691. * of audio contexts you can create.
  27692. * @param hostElement defines the host element where to display the mute icon if necessary
  27693. */
  27694. constructor(hostElement?: Nullable<HTMLElement>);
  27695. /**
  27696. * Flags the audio engine in Locked state.
  27697. * This happens due to new browser policies preventing audio to autoplay.
  27698. */
  27699. lock(): void;
  27700. /**
  27701. * Unlocks the audio engine once a user action has been done on the dom.
  27702. * This is helpful to resume play once browser policies have been satisfied.
  27703. */
  27704. unlock(): void;
  27705. private _resumeAudioContext;
  27706. private _initializeAudioContext;
  27707. private _tryToRun;
  27708. private _triggerRunningState;
  27709. private _triggerSuspendedState;
  27710. private _displayMuteButton;
  27711. private _moveButtonToTopLeft;
  27712. private _onResize;
  27713. private _hideMuteButton;
  27714. /**
  27715. * Destroy and release the resources associated with the audio ccontext.
  27716. */
  27717. dispose(): void;
  27718. /**
  27719. * Gets the global volume sets on the master gain.
  27720. * @returns the global volume if set or -1 otherwise
  27721. */
  27722. getGlobalVolume(): number;
  27723. /**
  27724. * Sets the global volume of your experience (sets on the master gain).
  27725. * @param newVolume Defines the new global volume of the application
  27726. */
  27727. setGlobalVolume(newVolume: number): void;
  27728. /**
  27729. * Connect the audio engine to an audio analyser allowing some amazing
  27730. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27732. * @param analyser The analyser to connect to the engine
  27733. */
  27734. connectToAnalyser(analyser: Analyser): void;
  27735. }
  27736. }
  27737. declare module "babylonjs/Loading/loadingScreen" {
  27738. /**
  27739. * Interface used to present a loading screen while loading a scene
  27740. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27741. */
  27742. export interface ILoadingScreen {
  27743. /**
  27744. * Function called to display the loading screen
  27745. */
  27746. displayLoadingUI: () => void;
  27747. /**
  27748. * Function called to hide the loading screen
  27749. */
  27750. hideLoadingUI: () => void;
  27751. /**
  27752. * Gets or sets the color to use for the background
  27753. */
  27754. loadingUIBackgroundColor: string;
  27755. /**
  27756. * Gets or sets the text to display while loading
  27757. */
  27758. loadingUIText: string;
  27759. }
  27760. /**
  27761. * Class used for the default loading screen
  27762. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27763. */
  27764. export class DefaultLoadingScreen implements ILoadingScreen {
  27765. private _renderingCanvas;
  27766. private _loadingText;
  27767. private _loadingDivBackgroundColor;
  27768. private _loadingDiv;
  27769. private _loadingTextDiv;
  27770. /** Gets or sets the logo url to use for the default loading screen */
  27771. static DefaultLogoUrl: string;
  27772. /** Gets or sets the spinner url to use for the default loading screen */
  27773. static DefaultSpinnerUrl: string;
  27774. /**
  27775. * Creates a new default loading screen
  27776. * @param _renderingCanvas defines the canvas used to render the scene
  27777. * @param _loadingText defines the default text to display
  27778. * @param _loadingDivBackgroundColor defines the default background color
  27779. */
  27780. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27781. /**
  27782. * Function called to display the loading screen
  27783. */
  27784. displayLoadingUI(): void;
  27785. /**
  27786. * Function called to hide the loading screen
  27787. */
  27788. hideLoadingUI(): void;
  27789. /**
  27790. * Gets or sets the text to display while loading
  27791. */
  27792. loadingUIText: string;
  27793. /**
  27794. * Gets or sets the color to use for the background
  27795. */
  27796. loadingUIBackgroundColor: string;
  27797. private _resizeLoadingUI;
  27798. }
  27799. }
  27800. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27801. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27802. import { Engine } from "babylonjs/Engines/engine";
  27803. import { Nullable } from "babylonjs/types";
  27804. /** @hidden */
  27805. export class WebGLPipelineContext implements IPipelineContext {
  27806. engine: Engine;
  27807. program: Nullable<WebGLProgram>;
  27808. context?: WebGLRenderingContext;
  27809. vertexShader?: WebGLShader;
  27810. fragmentShader?: WebGLShader;
  27811. isParallelCompiled: boolean;
  27812. onCompiled?: () => void;
  27813. transformFeedback?: WebGLTransformFeedback | null;
  27814. readonly isAsync: boolean;
  27815. readonly isReady: boolean;
  27816. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27817. }
  27818. }
  27819. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27820. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27821. /** @hidden */
  27822. export class WebGLDataBuffer extends DataBuffer {
  27823. private _buffer;
  27824. constructor(resource: WebGLBuffer);
  27825. readonly underlyingResource: any;
  27826. }
  27827. }
  27828. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27829. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27830. /** @hidden */
  27831. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27832. attributeProcessor(attribute: string): string;
  27833. varyingProcessor(varying: string, isFragment: boolean): string;
  27834. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27835. }
  27836. }
  27837. declare module "babylonjs/Materials/Textures/videoTexture" {
  27838. import { Observable } from "babylonjs/Misc/observable";
  27839. import { Nullable } from "babylonjs/types";
  27840. import { Scene } from "babylonjs/scene";
  27841. import { Texture } from "babylonjs/Materials/Textures/texture";
  27842. /**
  27843. * Settings for finer control over video usage
  27844. */
  27845. export interface VideoTextureSettings {
  27846. /**
  27847. * Applies `autoplay` to video, if specified
  27848. */
  27849. autoPlay?: boolean;
  27850. /**
  27851. * Applies `loop` to video, if specified
  27852. */
  27853. loop?: boolean;
  27854. /**
  27855. * Automatically updates internal texture from video at every frame in the render loop
  27856. */
  27857. autoUpdateTexture: boolean;
  27858. /**
  27859. * Image src displayed during the video loading or until the user interacts with the video.
  27860. */
  27861. poster?: string;
  27862. }
  27863. /**
  27864. * If you want to display a video in your scene, this is the special texture for that.
  27865. * This special texture works similar to other textures, with the exception of a few parameters.
  27866. * @see https://doc.babylonjs.com/how_to/video_texture
  27867. */
  27868. export class VideoTexture extends Texture {
  27869. /**
  27870. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27871. */
  27872. readonly autoUpdateTexture: boolean;
  27873. /**
  27874. * The video instance used by the texture internally
  27875. */
  27876. readonly video: HTMLVideoElement;
  27877. private _onUserActionRequestedObservable;
  27878. /**
  27879. * Event triggerd when a dom action is required by the user to play the video.
  27880. * This happens due to recent changes in browser policies preventing video to auto start.
  27881. */
  27882. readonly onUserActionRequestedObservable: Observable<Texture>;
  27883. private _generateMipMaps;
  27884. private _engine;
  27885. private _stillImageCaptured;
  27886. private _displayingPosterTexture;
  27887. private _settings;
  27888. private _createInternalTextureOnEvent;
  27889. /**
  27890. * Creates a video texture.
  27891. * If you want to display a video in your scene, this is the special texture for that.
  27892. * This special texture works similar to other textures, with the exception of a few parameters.
  27893. * @see https://doc.babylonjs.com/how_to/video_texture
  27894. * @param name optional name, will detect from video source, if not defined
  27895. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27896. * @param scene is obviously the current scene.
  27897. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27898. * @param invertY is false by default but can be used to invert video on Y axis
  27899. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27900. * @param settings allows finer control over video usage
  27901. */
  27902. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27903. private _getName;
  27904. private _getVideo;
  27905. private _createInternalTexture;
  27906. private reset;
  27907. /**
  27908. * @hidden Internal method to initiate `update`.
  27909. */
  27910. _rebuild(): void;
  27911. /**
  27912. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27913. */
  27914. update(): void;
  27915. /**
  27916. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27917. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27918. */
  27919. updateTexture(isVisible: boolean): void;
  27920. protected _updateInternalTexture: () => void;
  27921. /**
  27922. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27923. * @param url New url.
  27924. */
  27925. updateURL(url: string): void;
  27926. /**
  27927. * Dispose the texture and release its associated resources.
  27928. */
  27929. dispose(): void;
  27930. /**
  27931. * Creates a video texture straight from a stream.
  27932. * @param scene Define the scene the texture should be created in
  27933. * @param stream Define the stream the texture should be created from
  27934. * @returns The created video texture as a promise
  27935. */
  27936. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27937. /**
  27938. * Creates a video texture straight from your WebCam video feed.
  27939. * @param scene Define the scene the texture should be created in
  27940. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27941. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27942. * @returns The created video texture as a promise
  27943. */
  27944. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27945. minWidth: number;
  27946. maxWidth: number;
  27947. minHeight: number;
  27948. maxHeight: number;
  27949. deviceId: string;
  27950. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27951. /**
  27952. * Creates a video texture straight from your WebCam video feed.
  27953. * @param scene Define the scene the texture should be created in
  27954. * @param onReady Define a callback to triggered once the texture will be ready
  27955. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27956. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27957. */
  27958. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27959. minWidth: number;
  27960. maxWidth: number;
  27961. minHeight: number;
  27962. maxHeight: number;
  27963. deviceId: string;
  27964. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27965. }
  27966. }
  27967. declare module "babylonjs/Engines/engine" {
  27968. import { Observable } from "babylonjs/Misc/observable";
  27969. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27970. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27971. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27972. import { Camera } from "babylonjs/Cameras/camera";
  27973. import { Scene } from "babylonjs/scene";
  27974. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27975. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27976. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27977. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27978. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27979. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27980. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27981. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27982. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27983. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27984. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27985. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27986. import { WebRequest } from "babylonjs/Misc/webRequest";
  27987. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27988. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27989. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27990. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27991. import { Material } from "babylonjs/Materials/material";
  27992. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27993. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27994. /**
  27995. * Interface for attribute information associated with buffer instanciation
  27996. */
  27997. export class InstancingAttributeInfo {
  27998. /**
  27999. * Index/offset of the attribute in the vertex shader
  28000. */
  28001. index: number;
  28002. /**
  28003. * size of the attribute, 1, 2, 3 or 4
  28004. */
  28005. attributeSize: number;
  28006. /**
  28007. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28008. * default is FLOAT
  28009. */
  28010. attribyteType: number;
  28011. /**
  28012. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28013. */
  28014. normalized: boolean;
  28015. /**
  28016. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28017. */
  28018. offset: number;
  28019. /**
  28020. * Name of the GLSL attribute, for debugging purpose only
  28021. */
  28022. attributeName: string;
  28023. }
  28024. /**
  28025. * Define options used to create a depth texture
  28026. */
  28027. export class DepthTextureCreationOptions {
  28028. /** Specifies whether or not a stencil should be allocated in the texture */
  28029. generateStencil?: boolean;
  28030. /** Specifies whether or not bilinear filtering is enable on the texture */
  28031. bilinearFiltering?: boolean;
  28032. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28033. comparisonFunction?: number;
  28034. /** Specifies if the created texture is a cube texture */
  28035. isCube?: boolean;
  28036. }
  28037. /**
  28038. * Class used to describe the capabilities of the engine relatively to the current browser
  28039. */
  28040. export class EngineCapabilities {
  28041. /** Maximum textures units per fragment shader */
  28042. maxTexturesImageUnits: number;
  28043. /** Maximum texture units per vertex shader */
  28044. maxVertexTextureImageUnits: number;
  28045. /** Maximum textures units in the entire pipeline */
  28046. maxCombinedTexturesImageUnits: number;
  28047. /** Maximum texture size */
  28048. maxTextureSize: number;
  28049. /** Maximum cube texture size */
  28050. maxCubemapTextureSize: number;
  28051. /** Maximum render texture size */
  28052. maxRenderTextureSize: number;
  28053. /** Maximum number of vertex attributes */
  28054. maxVertexAttribs: number;
  28055. /** Maximum number of varyings */
  28056. maxVaryingVectors: number;
  28057. /** Maximum number of uniforms per vertex shader */
  28058. maxVertexUniformVectors: number;
  28059. /** Maximum number of uniforms per fragment shader */
  28060. maxFragmentUniformVectors: number;
  28061. /** Defines if standard derivates (dx/dy) are supported */
  28062. standardDerivatives: boolean;
  28063. /** Defines if s3tc texture compression is supported */
  28064. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28065. /** Defines if pvrtc texture compression is supported */
  28066. pvrtc: any;
  28067. /** Defines if etc1 texture compression is supported */
  28068. etc1: any;
  28069. /** Defines if etc2 texture compression is supported */
  28070. etc2: any;
  28071. /** Defines if astc texture compression is supported */
  28072. astc: any;
  28073. /** Defines if float textures are supported */
  28074. textureFloat: boolean;
  28075. /** Defines if vertex array objects are supported */
  28076. vertexArrayObject: boolean;
  28077. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28078. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28079. /** Gets the maximum level of anisotropy supported */
  28080. maxAnisotropy: number;
  28081. /** Defines if instancing is supported */
  28082. instancedArrays: boolean;
  28083. /** Defines if 32 bits indices are supported */
  28084. uintIndices: boolean;
  28085. /** Defines if high precision shaders are supported */
  28086. highPrecisionShaderSupported: boolean;
  28087. /** Defines if depth reading in the fragment shader is supported */
  28088. fragmentDepthSupported: boolean;
  28089. /** Defines if float texture linear filtering is supported*/
  28090. textureFloatLinearFiltering: boolean;
  28091. /** Defines if rendering to float textures is supported */
  28092. textureFloatRender: boolean;
  28093. /** Defines if half float textures are supported*/
  28094. textureHalfFloat: boolean;
  28095. /** Defines if half float texture linear filtering is supported*/
  28096. textureHalfFloatLinearFiltering: boolean;
  28097. /** Defines if rendering to half float textures is supported */
  28098. textureHalfFloatRender: boolean;
  28099. /** Defines if textureLOD shader command is supported */
  28100. textureLOD: boolean;
  28101. /** Defines if draw buffers extension is supported */
  28102. drawBuffersExtension: boolean;
  28103. /** Defines if depth textures are supported */
  28104. depthTextureExtension: boolean;
  28105. /** Defines if float color buffer are supported */
  28106. colorBufferFloat: boolean;
  28107. /** Gets disjoint timer query extension (null if not supported) */
  28108. timerQuery: EXT_disjoint_timer_query;
  28109. /** Defines if timestamp can be used with timer query */
  28110. canUseTimestampForTimerQuery: boolean;
  28111. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28112. multiview: any;
  28113. /** Function used to let the system compiles shaders in background */
  28114. parallelShaderCompile: {
  28115. COMPLETION_STATUS_KHR: number;
  28116. };
  28117. }
  28118. /** Interface defining initialization parameters for Engine class */
  28119. export interface EngineOptions extends WebGLContextAttributes {
  28120. /**
  28121. * Defines if the engine should no exceed a specified device ratio
  28122. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28123. */
  28124. limitDeviceRatio?: number;
  28125. /**
  28126. * Defines if webvr should be enabled automatically
  28127. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28128. */
  28129. autoEnableWebVR?: boolean;
  28130. /**
  28131. * Defines if webgl2 should be turned off even if supported
  28132. * @see http://doc.babylonjs.com/features/webgl2
  28133. */
  28134. disableWebGL2Support?: boolean;
  28135. /**
  28136. * Defines if webaudio should be initialized as well
  28137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28138. */
  28139. audioEngine?: boolean;
  28140. /**
  28141. * Defines if animations should run using a deterministic lock step
  28142. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28143. */
  28144. deterministicLockstep?: boolean;
  28145. /** Defines the maximum steps to use with deterministic lock step mode */
  28146. lockstepMaxSteps?: number;
  28147. /**
  28148. * Defines that engine should ignore context lost events
  28149. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28150. */
  28151. doNotHandleContextLost?: boolean;
  28152. /**
  28153. * Defines that engine should ignore modifying touch action attribute and style
  28154. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28155. */
  28156. doNotHandleTouchAction?: boolean;
  28157. /**
  28158. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28159. */
  28160. useHighPrecisionFloats?: boolean;
  28161. }
  28162. /**
  28163. * Defines the interface used by display changed events
  28164. */
  28165. export interface IDisplayChangedEventArgs {
  28166. /** Gets the vrDisplay object (if any) */
  28167. vrDisplay: Nullable<any>;
  28168. /** Gets a boolean indicating if webVR is supported */
  28169. vrSupported: boolean;
  28170. }
  28171. /**
  28172. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28173. */
  28174. export class Engine {
  28175. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28176. static ExceptionList: ({
  28177. key: string;
  28178. capture: string;
  28179. captureConstraint: number;
  28180. targets: string[];
  28181. } | {
  28182. key: string;
  28183. capture: null;
  28184. captureConstraint: null;
  28185. targets: string[];
  28186. })[];
  28187. /** Gets the list of created engines */
  28188. static readonly Instances: Engine[];
  28189. /**
  28190. * Gets the latest created engine
  28191. */
  28192. static readonly LastCreatedEngine: Nullable<Engine>;
  28193. /**
  28194. * Gets the latest created scene
  28195. */
  28196. static readonly LastCreatedScene: Nullable<Scene>;
  28197. /**
  28198. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28199. * @param flag defines which part of the materials must be marked as dirty
  28200. * @param predicate defines a predicate used to filter which materials should be affected
  28201. */
  28202. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28203. /** @hidden */
  28204. static _TextureLoaders: IInternalTextureLoader[];
  28205. /** Defines that alpha blending is disabled */
  28206. static readonly ALPHA_DISABLE: number;
  28207. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28208. static readonly ALPHA_ADD: number;
  28209. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28210. static readonly ALPHA_COMBINE: number;
  28211. /** Defines that alpha blending to DEST - SRC * DEST */
  28212. static readonly ALPHA_SUBTRACT: number;
  28213. /** Defines that alpha blending to SRC * DEST */
  28214. static readonly ALPHA_MULTIPLY: number;
  28215. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28216. static readonly ALPHA_MAXIMIZED: number;
  28217. /** Defines that alpha blending to SRC + DEST */
  28218. static readonly ALPHA_ONEONE: number;
  28219. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28220. static readonly ALPHA_PREMULTIPLIED: number;
  28221. /**
  28222. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28223. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28224. */
  28225. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28226. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28227. static readonly ALPHA_INTERPOLATE: number;
  28228. /**
  28229. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28230. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28231. */
  28232. static readonly ALPHA_SCREENMODE: number;
  28233. /** Defines that the ressource is not delayed*/
  28234. static readonly DELAYLOADSTATE_NONE: number;
  28235. /** Defines that the ressource was successfully delay loaded */
  28236. static readonly DELAYLOADSTATE_LOADED: number;
  28237. /** Defines that the ressource is currently delay loading */
  28238. static readonly DELAYLOADSTATE_LOADING: number;
  28239. /** Defines that the ressource is delayed and has not started loading */
  28240. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28241. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28242. static readonly NEVER: number;
  28243. /** 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 */
  28244. static readonly ALWAYS: number;
  28245. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28246. static readonly LESS: number;
  28247. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28248. static readonly EQUAL: number;
  28249. /** 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 */
  28250. static readonly LEQUAL: number;
  28251. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28252. static readonly GREATER: number;
  28253. /** 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 */
  28254. static readonly GEQUAL: number;
  28255. /** 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 */
  28256. static readonly NOTEQUAL: number;
  28257. /** Passed to stencilOperation to specify that stencil value must be kept */
  28258. static readonly KEEP: number;
  28259. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28260. static readonly REPLACE: number;
  28261. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28262. static readonly INCR: number;
  28263. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28264. static readonly DECR: number;
  28265. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28266. static readonly INVERT: number;
  28267. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28268. static readonly INCR_WRAP: number;
  28269. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28270. static readonly DECR_WRAP: number;
  28271. /** Texture is not repeating outside of 0..1 UVs */
  28272. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28273. /** Texture is repeating outside of 0..1 UVs */
  28274. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28275. /** Texture is repeating and mirrored */
  28276. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28277. /** ALPHA */
  28278. static readonly TEXTUREFORMAT_ALPHA: number;
  28279. /** LUMINANCE */
  28280. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28281. /** LUMINANCE_ALPHA */
  28282. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28283. /** RGB */
  28284. static readonly TEXTUREFORMAT_RGB: number;
  28285. /** RGBA */
  28286. static readonly TEXTUREFORMAT_RGBA: number;
  28287. /** RED */
  28288. static readonly TEXTUREFORMAT_RED: number;
  28289. /** RED (2nd reference) */
  28290. static readonly TEXTUREFORMAT_R: number;
  28291. /** RG */
  28292. static readonly TEXTUREFORMAT_RG: number;
  28293. /** RED_INTEGER */
  28294. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28295. /** RED_INTEGER (2nd reference) */
  28296. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28297. /** RG_INTEGER */
  28298. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28299. /** RGB_INTEGER */
  28300. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28301. /** RGBA_INTEGER */
  28302. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28303. /** UNSIGNED_BYTE */
  28304. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28305. /** UNSIGNED_BYTE (2nd reference) */
  28306. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28307. /** FLOAT */
  28308. static readonly TEXTURETYPE_FLOAT: number;
  28309. /** HALF_FLOAT */
  28310. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28311. /** BYTE */
  28312. static readonly TEXTURETYPE_BYTE: number;
  28313. /** SHORT */
  28314. static readonly TEXTURETYPE_SHORT: number;
  28315. /** UNSIGNED_SHORT */
  28316. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28317. /** INT */
  28318. static readonly TEXTURETYPE_INT: number;
  28319. /** UNSIGNED_INT */
  28320. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28321. /** UNSIGNED_SHORT_4_4_4_4 */
  28322. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28323. /** UNSIGNED_SHORT_5_5_5_1 */
  28324. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28325. /** UNSIGNED_SHORT_5_6_5 */
  28326. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28327. /** UNSIGNED_INT_2_10_10_10_REV */
  28328. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28329. /** UNSIGNED_INT_24_8 */
  28330. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28331. /** UNSIGNED_INT_10F_11F_11F_REV */
  28332. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28333. /** UNSIGNED_INT_5_9_9_9_REV */
  28334. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28335. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28336. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28337. /** nearest is mag = nearest and min = nearest and mip = linear */
  28338. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28339. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28340. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28341. /** Trilinear is mag = linear and min = linear and mip = linear */
  28342. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28343. /** nearest is mag = nearest and min = nearest and mip = linear */
  28344. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28345. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28346. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28347. /** Trilinear is mag = linear and min = linear and mip = linear */
  28348. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28349. /** mag = nearest and min = nearest and mip = nearest */
  28350. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28351. /** mag = nearest and min = linear and mip = nearest */
  28352. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28353. /** mag = nearest and min = linear and mip = linear */
  28354. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28355. /** mag = nearest and min = linear and mip = none */
  28356. static readonly TEXTURE_NEAREST_LINEAR: number;
  28357. /** mag = nearest and min = nearest and mip = none */
  28358. static readonly TEXTURE_NEAREST_NEAREST: number;
  28359. /** mag = linear and min = nearest and mip = nearest */
  28360. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28361. /** mag = linear and min = nearest and mip = linear */
  28362. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28363. /** mag = linear and min = linear and mip = none */
  28364. static readonly TEXTURE_LINEAR_LINEAR: number;
  28365. /** mag = linear and min = nearest and mip = none */
  28366. static readonly TEXTURE_LINEAR_NEAREST: number;
  28367. /** Explicit coordinates mode */
  28368. static readonly TEXTURE_EXPLICIT_MODE: number;
  28369. /** Spherical coordinates mode */
  28370. static readonly TEXTURE_SPHERICAL_MODE: number;
  28371. /** Planar coordinates mode */
  28372. static readonly TEXTURE_PLANAR_MODE: number;
  28373. /** Cubic coordinates mode */
  28374. static readonly TEXTURE_CUBIC_MODE: number;
  28375. /** Projection coordinates mode */
  28376. static readonly TEXTURE_PROJECTION_MODE: number;
  28377. /** Skybox coordinates mode */
  28378. static readonly TEXTURE_SKYBOX_MODE: number;
  28379. /** Inverse Cubic coordinates mode */
  28380. static readonly TEXTURE_INVCUBIC_MODE: number;
  28381. /** Equirectangular coordinates mode */
  28382. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28383. /** Equirectangular Fixed coordinates mode */
  28384. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28385. /** Equirectangular Fixed Mirrored coordinates mode */
  28386. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28387. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28388. static readonly SCALEMODE_FLOOR: number;
  28389. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28390. static readonly SCALEMODE_NEAREST: number;
  28391. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28392. static readonly SCALEMODE_CEILING: number;
  28393. /**
  28394. * Returns the current npm package of the sdk
  28395. */
  28396. static readonly NpmPackage: string;
  28397. /**
  28398. * Returns the current version of the framework
  28399. */
  28400. static readonly Version: string;
  28401. /**
  28402. * Returns a string describing the current engine
  28403. */
  28404. readonly description: string;
  28405. /**
  28406. * Gets or sets the epsilon value used by collision engine
  28407. */
  28408. static CollisionsEpsilon: number;
  28409. /**
  28410. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28411. */
  28412. static ShadersRepository: string;
  28413. /**
  28414. * Method called to create the default loading screen.
  28415. * This can be overriden in your own app.
  28416. * @param canvas The rendering canvas element
  28417. * @returns The loading screen
  28418. */
  28419. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28420. /**
  28421. * Method called to create the default rescale post process on each engine.
  28422. */
  28423. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28424. /** @hidden */
  28425. _shaderProcessor: IShaderProcessor;
  28426. /**
  28427. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28428. */
  28429. forcePOTTextures: boolean;
  28430. /**
  28431. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28432. */
  28433. isFullscreen: boolean;
  28434. /**
  28435. * Gets a boolean indicating if the pointer is currently locked
  28436. */
  28437. isPointerLock: boolean;
  28438. /**
  28439. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28440. */
  28441. cullBackFaces: boolean;
  28442. /**
  28443. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28444. */
  28445. renderEvenInBackground: boolean;
  28446. /**
  28447. * Gets or sets a boolean indicating that cache can be kept between frames
  28448. */
  28449. preventCacheWipeBetweenFrames: boolean;
  28450. /**
  28451. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28452. **/
  28453. enableOfflineSupport: boolean;
  28454. /**
  28455. * 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)
  28456. **/
  28457. disableManifestCheck: boolean;
  28458. /**
  28459. * Gets the list of created scenes
  28460. */
  28461. scenes: Scene[];
  28462. /**
  28463. * Event raised when a new scene is created
  28464. */
  28465. onNewSceneAddedObservable: Observable<Scene>;
  28466. /**
  28467. * Gets the list of created postprocesses
  28468. */
  28469. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28470. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28471. validateShaderPrograms: boolean;
  28472. /**
  28473. * Observable event triggered each time the rendering canvas is resized
  28474. */
  28475. onResizeObservable: Observable<Engine>;
  28476. /**
  28477. * Observable event triggered each time the canvas loses focus
  28478. */
  28479. onCanvasBlurObservable: Observable<Engine>;
  28480. /**
  28481. * Observable event triggered each time the canvas gains focus
  28482. */
  28483. onCanvasFocusObservable: Observable<Engine>;
  28484. /**
  28485. * Observable event triggered each time the canvas receives pointerout event
  28486. */
  28487. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28488. /**
  28489. * Observable event triggered before each texture is initialized
  28490. */
  28491. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28492. /**
  28493. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28494. */
  28495. disableUniformBuffers: boolean;
  28496. /** @hidden */
  28497. _uniformBuffers: UniformBuffer[];
  28498. /**
  28499. * Gets a boolean indicating that the engine supports uniform buffers
  28500. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28501. */
  28502. readonly supportsUniformBuffers: boolean;
  28503. /**
  28504. * Observable raised when the engine begins a new frame
  28505. */
  28506. onBeginFrameObservable: Observable<Engine>;
  28507. /**
  28508. * If set, will be used to request the next animation frame for the render loop
  28509. */
  28510. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28511. /**
  28512. * Observable raised when the engine ends the current frame
  28513. */
  28514. onEndFrameObservable: Observable<Engine>;
  28515. /**
  28516. * Observable raised when the engine is about to compile a shader
  28517. */
  28518. onBeforeShaderCompilationObservable: Observable<Engine>;
  28519. /**
  28520. * Observable raised when the engine has jsut compiled a shader
  28521. */
  28522. onAfterShaderCompilationObservable: Observable<Engine>;
  28523. /** @hidden */
  28524. _gl: WebGLRenderingContext;
  28525. private _renderingCanvas;
  28526. private _windowIsBackground;
  28527. private _webGLVersion;
  28528. protected _highPrecisionShadersAllowed: boolean;
  28529. /** @hidden */
  28530. readonly _shouldUseHighPrecisionShader: boolean;
  28531. /**
  28532. * Gets a boolean indicating that only power of 2 textures are supported
  28533. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28534. */
  28535. readonly needPOTTextures: boolean;
  28536. /** @hidden */
  28537. _badOS: boolean;
  28538. /** @hidden */
  28539. _badDesktopOS: boolean;
  28540. /**
  28541. * Gets the audio engine
  28542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28543. * @ignorenaming
  28544. */
  28545. static audioEngine: IAudioEngine;
  28546. /**
  28547. * Default AudioEngine factory responsible of creating the Audio Engine.
  28548. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28549. */
  28550. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28551. /**
  28552. * Default offline support factory responsible of creating a tool used to store data locally.
  28553. * By default, this will create a Database object if the workload has been embedded.
  28554. */
  28555. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28556. private _onFocus;
  28557. private _onBlur;
  28558. private _onCanvasPointerOut;
  28559. private _onCanvasBlur;
  28560. private _onCanvasFocus;
  28561. private _onFullscreenChange;
  28562. private _onPointerLockChange;
  28563. private _hardwareScalingLevel;
  28564. /** @hidden */
  28565. _caps: EngineCapabilities;
  28566. private _pointerLockRequested;
  28567. private _isStencilEnable;
  28568. private _colorWrite;
  28569. private _loadingScreen;
  28570. /** @hidden */
  28571. _drawCalls: PerfCounter;
  28572. private _glVersion;
  28573. private _glRenderer;
  28574. private _glVendor;
  28575. private _videoTextureSupported;
  28576. private _renderingQueueLaunched;
  28577. private _activeRenderLoops;
  28578. private _deterministicLockstep;
  28579. private _lockstepMaxSteps;
  28580. /**
  28581. * Observable signaled when a context lost event is raised
  28582. */
  28583. onContextLostObservable: Observable<Engine>;
  28584. /**
  28585. * Observable signaled when a context restored event is raised
  28586. */
  28587. onContextRestoredObservable: Observable<Engine>;
  28588. private _onContextLost;
  28589. private _onContextRestored;
  28590. private _contextWasLost;
  28591. /** @hidden */
  28592. _doNotHandleContextLost: boolean;
  28593. /**
  28594. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28596. */
  28597. doNotHandleContextLost: boolean;
  28598. private _performanceMonitor;
  28599. private _fps;
  28600. private _deltaTime;
  28601. /**
  28602. * Turn this value on if you want to pause FPS computation when in background
  28603. */
  28604. disablePerformanceMonitorInBackground: boolean;
  28605. /**
  28606. * Gets the performance monitor attached to this engine
  28607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28608. */
  28609. readonly performanceMonitor: PerformanceMonitor;
  28610. /**
  28611. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28612. */
  28613. disableVertexArrayObjects: boolean;
  28614. /** @hidden */
  28615. protected _depthCullingState: _DepthCullingState;
  28616. /** @hidden */
  28617. protected _stencilState: _StencilState;
  28618. /** @hidden */
  28619. protected _alphaState: _AlphaState;
  28620. /** @hidden */
  28621. protected _alphaMode: number;
  28622. /** @hidden */
  28623. _internalTexturesCache: InternalTexture[];
  28624. /** @hidden */
  28625. protected _activeChannel: number;
  28626. private _currentTextureChannel;
  28627. /** @hidden */
  28628. protected _boundTexturesCache: {
  28629. [key: string]: Nullable<InternalTexture>;
  28630. };
  28631. /** @hidden */
  28632. protected _currentEffect: Nullable<Effect>;
  28633. /** @hidden */
  28634. protected _currentProgram: Nullable<WebGLProgram>;
  28635. private _compiledEffects;
  28636. private _vertexAttribArraysEnabled;
  28637. /** @hidden */
  28638. protected _cachedViewport: Nullable<Viewport>;
  28639. private _cachedVertexArrayObject;
  28640. /** @hidden */
  28641. protected _cachedVertexBuffers: any;
  28642. /** @hidden */
  28643. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28644. /** @hidden */
  28645. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28646. /** @hidden */
  28647. _currentRenderTarget: Nullable<InternalTexture>;
  28648. private _uintIndicesCurrentlySet;
  28649. private _currentBoundBuffer;
  28650. /** @hidden */
  28651. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28652. private _currentBufferPointers;
  28653. private _currentInstanceLocations;
  28654. private _currentInstanceBuffers;
  28655. private _textureUnits;
  28656. /** @hidden */
  28657. _workingCanvas: Nullable<HTMLCanvasElement>;
  28658. /** @hidden */
  28659. _workingContext: Nullable<CanvasRenderingContext2D>;
  28660. private _rescalePostProcess;
  28661. private _dummyFramebuffer;
  28662. private _externalData;
  28663. /** @hidden */
  28664. _bindedRenderFunction: any;
  28665. private _vaoRecordInProgress;
  28666. private _mustWipeVertexAttributes;
  28667. private _emptyTexture;
  28668. private _emptyCubeTexture;
  28669. private _emptyTexture3D;
  28670. /** @hidden */
  28671. _frameHandler: number;
  28672. private _nextFreeTextureSlots;
  28673. private _maxSimultaneousTextures;
  28674. private _activeRequests;
  28675. private _texturesSupported;
  28676. /** @hidden */
  28677. _textureFormatInUse: Nullable<string>;
  28678. /**
  28679. * Gets the list of texture formats supported
  28680. */
  28681. readonly texturesSupported: Array<string>;
  28682. /**
  28683. * Gets the list of texture formats in use
  28684. */
  28685. readonly textureFormatInUse: Nullable<string>;
  28686. /**
  28687. * Gets the current viewport
  28688. */
  28689. readonly currentViewport: Nullable<Viewport>;
  28690. /**
  28691. * Gets the default empty texture
  28692. */
  28693. readonly emptyTexture: InternalTexture;
  28694. /**
  28695. * Gets the default empty 3D texture
  28696. */
  28697. readonly emptyTexture3D: InternalTexture;
  28698. /**
  28699. * Gets the default empty cube texture
  28700. */
  28701. readonly emptyCubeTexture: InternalTexture;
  28702. /**
  28703. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28704. */
  28705. readonly premultipliedAlpha: boolean;
  28706. /**
  28707. * Creates a new engine
  28708. * @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
  28709. * @param antialias defines enable antialiasing (default: false)
  28710. * @param options defines further options to be sent to the getContext() function
  28711. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28712. */
  28713. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28714. /**
  28715. * Initializes a webVR display and starts listening to display change events
  28716. * The onVRDisplayChangedObservable will be notified upon these changes
  28717. * @returns The onVRDisplayChangedObservable
  28718. */
  28719. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28720. /** @hidden */
  28721. _prepareVRComponent(): void;
  28722. /** @hidden */
  28723. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28724. /** @hidden */
  28725. _submitVRFrame(): void;
  28726. /**
  28727. * Call this function to leave webVR mode
  28728. * Will do nothing if webVR is not supported or if there is no webVR device
  28729. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28730. */
  28731. disableVR(): void;
  28732. /**
  28733. * Gets a boolean indicating that the system is in VR mode and is presenting
  28734. * @returns true if VR mode is engaged
  28735. */
  28736. isVRPresenting(): boolean;
  28737. /** @hidden */
  28738. _requestVRFrame(): void;
  28739. private _disableTouchAction;
  28740. private _rebuildInternalTextures;
  28741. private _rebuildEffects;
  28742. /**
  28743. * Gets a boolean indicating if all created effects are ready
  28744. * @returns true if all effects are ready
  28745. */
  28746. areAllEffectsReady(): boolean;
  28747. private _rebuildBuffers;
  28748. private _initGLContext;
  28749. /**
  28750. * Gets version of the current webGL context
  28751. */
  28752. readonly webGLVersion: number;
  28753. /**
  28754. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28755. */
  28756. readonly isStencilEnable: boolean;
  28757. /** @hidden */
  28758. _prepareWorkingCanvas(): void;
  28759. /**
  28760. * Reset the texture cache to empty state
  28761. */
  28762. resetTextureCache(): void;
  28763. /**
  28764. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28765. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28766. * @returns true if engine is in deterministic lock step mode
  28767. */
  28768. isDeterministicLockStep(): boolean;
  28769. /**
  28770. * Gets the max steps when engine is running in deterministic lock step
  28771. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28772. * @returns the max steps
  28773. */
  28774. getLockstepMaxSteps(): number;
  28775. /**
  28776. * Gets an object containing information about the current webGL context
  28777. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28778. */
  28779. getGlInfo(): {
  28780. vendor: string;
  28781. renderer: string;
  28782. version: string;
  28783. };
  28784. /**
  28785. * Gets current aspect ratio
  28786. * @param camera defines the camera to use to get the aspect ratio
  28787. * @param useScreen defines if screen size must be used (or the current render target if any)
  28788. * @returns a number defining the aspect ratio
  28789. */
  28790. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28791. /**
  28792. * Gets current screen aspect ratio
  28793. * @returns a number defining the aspect ratio
  28794. */
  28795. getScreenAspectRatio(): number;
  28796. /**
  28797. * Gets the current render width
  28798. * @param useScreen defines if screen size must be used (or the current render target if any)
  28799. * @returns a number defining the current render width
  28800. */
  28801. getRenderWidth(useScreen?: boolean): number;
  28802. /**
  28803. * Gets the current render height
  28804. * @param useScreen defines if screen size must be used (or the current render target if any)
  28805. * @returns a number defining the current render height
  28806. */
  28807. getRenderHeight(useScreen?: boolean): number;
  28808. /**
  28809. * Gets the HTML canvas attached with the current webGL context
  28810. * @returns a HTML canvas
  28811. */
  28812. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28813. /**
  28814. * Gets the client rect of the HTML canvas attached with the current webGL context
  28815. * @returns a client rectanglee
  28816. */
  28817. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28818. /**
  28819. * Defines the hardware scaling level.
  28820. * By default the hardware scaling level is computed from the window device ratio.
  28821. * 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.
  28822. * @param level defines the level to use
  28823. */
  28824. setHardwareScalingLevel(level: number): void;
  28825. /**
  28826. * Gets the current hardware scaling level.
  28827. * By default the hardware scaling level is computed from the window device ratio.
  28828. * 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.
  28829. * @returns a number indicating the current hardware scaling level
  28830. */
  28831. getHardwareScalingLevel(): number;
  28832. /**
  28833. * Gets the list of loaded textures
  28834. * @returns an array containing all loaded textures
  28835. */
  28836. getLoadedTexturesCache(): InternalTexture[];
  28837. /**
  28838. * Gets the object containing all engine capabilities
  28839. * @returns the EngineCapabilities object
  28840. */
  28841. getCaps(): EngineCapabilities;
  28842. /**
  28843. * Gets the current depth function
  28844. * @returns a number defining the depth function
  28845. */
  28846. getDepthFunction(): Nullable<number>;
  28847. /**
  28848. * Sets the current depth function
  28849. * @param depthFunc defines the function to use
  28850. */
  28851. setDepthFunction(depthFunc: number): void;
  28852. /**
  28853. * Sets the current depth function to GREATER
  28854. */
  28855. setDepthFunctionToGreater(): void;
  28856. /**
  28857. * Sets the current depth function to GEQUAL
  28858. */
  28859. setDepthFunctionToGreaterOrEqual(): void;
  28860. /**
  28861. * Sets the current depth function to LESS
  28862. */
  28863. setDepthFunctionToLess(): void;
  28864. private _cachedStencilBuffer;
  28865. private _cachedStencilFunction;
  28866. private _cachedStencilMask;
  28867. private _cachedStencilOperationPass;
  28868. private _cachedStencilOperationFail;
  28869. private _cachedStencilOperationDepthFail;
  28870. private _cachedStencilReference;
  28871. /**
  28872. * Caches the the state of the stencil buffer
  28873. */
  28874. cacheStencilState(): void;
  28875. /**
  28876. * Restores the state of the stencil buffer
  28877. */
  28878. restoreStencilState(): void;
  28879. /**
  28880. * Sets the current depth function to LEQUAL
  28881. */
  28882. setDepthFunctionToLessOrEqual(): void;
  28883. /**
  28884. * Gets a boolean indicating if stencil buffer is enabled
  28885. * @returns the current stencil buffer state
  28886. */
  28887. getStencilBuffer(): boolean;
  28888. /**
  28889. * Enable or disable the stencil buffer
  28890. * @param enable defines if the stencil buffer must be enabled or disabled
  28891. */
  28892. setStencilBuffer(enable: boolean): void;
  28893. /**
  28894. * Gets the current stencil mask
  28895. * @returns a number defining the new stencil mask to use
  28896. */
  28897. getStencilMask(): number;
  28898. /**
  28899. * Sets the current stencil mask
  28900. * @param mask defines the new stencil mask to use
  28901. */
  28902. setStencilMask(mask: number): void;
  28903. /**
  28904. * Gets the current stencil function
  28905. * @returns a number defining the stencil function to use
  28906. */
  28907. getStencilFunction(): number;
  28908. /**
  28909. * Gets the current stencil reference value
  28910. * @returns a number defining the stencil reference value to use
  28911. */
  28912. getStencilFunctionReference(): number;
  28913. /**
  28914. * Gets the current stencil mask
  28915. * @returns a number defining the stencil mask to use
  28916. */
  28917. getStencilFunctionMask(): number;
  28918. /**
  28919. * Sets the current stencil function
  28920. * @param stencilFunc defines the new stencil function to use
  28921. */
  28922. setStencilFunction(stencilFunc: number): void;
  28923. /**
  28924. * Sets the current stencil reference
  28925. * @param reference defines the new stencil reference to use
  28926. */
  28927. setStencilFunctionReference(reference: number): void;
  28928. /**
  28929. * Sets the current stencil mask
  28930. * @param mask defines the new stencil mask to use
  28931. */
  28932. setStencilFunctionMask(mask: number): void;
  28933. /**
  28934. * Gets the current stencil operation when stencil fails
  28935. * @returns a number defining stencil operation to use when stencil fails
  28936. */
  28937. getStencilOperationFail(): number;
  28938. /**
  28939. * Gets the current stencil operation when depth fails
  28940. * @returns a number defining stencil operation to use when depth fails
  28941. */
  28942. getStencilOperationDepthFail(): number;
  28943. /**
  28944. * Gets the current stencil operation when stencil passes
  28945. * @returns a number defining stencil operation to use when stencil passes
  28946. */
  28947. getStencilOperationPass(): number;
  28948. /**
  28949. * Sets the stencil operation to use when stencil fails
  28950. * @param operation defines the stencil operation to use when stencil fails
  28951. */
  28952. setStencilOperationFail(operation: number): void;
  28953. /**
  28954. * Sets the stencil operation to use when depth fails
  28955. * @param operation defines the stencil operation to use when depth fails
  28956. */
  28957. setStencilOperationDepthFail(operation: number): void;
  28958. /**
  28959. * Sets the stencil operation to use when stencil passes
  28960. * @param operation defines the stencil operation to use when stencil passes
  28961. */
  28962. setStencilOperationPass(operation: number): void;
  28963. /**
  28964. * Sets a boolean indicating if the dithering state is enabled or disabled
  28965. * @param value defines the dithering state
  28966. */
  28967. setDitheringState(value: boolean): void;
  28968. /**
  28969. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28970. * @param value defines the rasterizer state
  28971. */
  28972. setRasterizerState(value: boolean): void;
  28973. /**
  28974. * stop executing a render loop function and remove it from the execution array
  28975. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28976. */
  28977. stopRenderLoop(renderFunction?: () => void): void;
  28978. /** @hidden */
  28979. _renderLoop(): void;
  28980. /**
  28981. * Register and execute a render loop. The engine can have more than one render function
  28982. * @param renderFunction defines the function to continuously execute
  28983. */
  28984. runRenderLoop(renderFunction: () => void): void;
  28985. /**
  28986. * Toggle full screen mode
  28987. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28988. */
  28989. switchFullscreen(requestPointerLock: boolean): void;
  28990. /**
  28991. * Enters full screen mode
  28992. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28993. */
  28994. enterFullscreen(requestPointerLock: boolean): void;
  28995. /**
  28996. * Exits full screen mode
  28997. */
  28998. exitFullscreen(): void;
  28999. /**
  29000. * Enters Pointerlock mode
  29001. */
  29002. enterPointerlock(): void;
  29003. /**
  29004. * Exits Pointerlock mode
  29005. */
  29006. exitPointerlock(): void;
  29007. /**
  29008. * Clear the current render buffer or the current render target (if any is set up)
  29009. * @param color defines the color to use
  29010. * @param backBuffer defines if the back buffer must be cleared
  29011. * @param depth defines if the depth buffer must be cleared
  29012. * @param stencil defines if the stencil buffer must be cleared
  29013. */
  29014. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29015. /**
  29016. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29017. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29018. * @param y defines the y-coordinate of the corner of the clear rectangle
  29019. * @param width defines the width of the clear rectangle
  29020. * @param height defines the height of the clear rectangle
  29021. * @param clearColor defines the clear color
  29022. */
  29023. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  29024. /**
  29025. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29026. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29027. * @param y defines the y-coordinate of the corner of the clear rectangle
  29028. * @param width defines the width of the clear rectangle
  29029. * @param height defines the height of the clear rectangle
  29030. */
  29031. enableScissor(x: number, y: number, width: number, height: number): void;
  29032. /**
  29033. * Disable previously set scissor test rectangle
  29034. */
  29035. disableScissor(): void;
  29036. private _viewportCached;
  29037. /** @hidden */
  29038. _viewport(x: number, y: number, width: number, height: number): void;
  29039. /**
  29040. * Set the WebGL's viewport
  29041. * @param viewport defines the viewport element to be used
  29042. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29043. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29044. */
  29045. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29046. /**
  29047. * Directly set the WebGL Viewport
  29048. * @param x defines the x coordinate of the viewport (in screen space)
  29049. * @param y defines the y coordinate of the viewport (in screen space)
  29050. * @param width defines the width of the viewport (in screen space)
  29051. * @param height defines the height of the viewport (in screen space)
  29052. * @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
  29053. */
  29054. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29055. /**
  29056. * Begin a new frame
  29057. */
  29058. beginFrame(): void;
  29059. /**
  29060. * Enf the current frame
  29061. */
  29062. endFrame(): void;
  29063. /**
  29064. * Resize the view according to the canvas' size
  29065. */
  29066. resize(): void;
  29067. /**
  29068. * Force a specific size of the canvas
  29069. * @param width defines the new canvas' width
  29070. * @param height defines the new canvas' height
  29071. */
  29072. setSize(width: number, height: number): void;
  29073. /**
  29074. * Binds the frame buffer to the specified texture.
  29075. * @param texture The texture to render to or null for the default canvas
  29076. * @param faceIndex The face of the texture to render to in case of cube texture
  29077. * @param requiredWidth The width of the target to render to
  29078. * @param requiredHeight The height of the target to render to
  29079. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29080. * @param depthStencilTexture The depth stencil texture to use to render
  29081. * @param lodLevel defines le lod level to bind to the frame buffer
  29082. */
  29083. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29084. /** @hidden */
  29085. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29086. /**
  29087. * Unbind the current render target texture from the webGL context
  29088. * @param texture defines the render target texture to unbind
  29089. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29090. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29091. */
  29092. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29093. /**
  29094. * Force the mipmap generation for the given render target texture
  29095. * @param texture defines the render target texture to use
  29096. */
  29097. generateMipMapsForCubemap(texture: InternalTexture): void;
  29098. /**
  29099. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29100. */
  29101. flushFramebuffer(): void;
  29102. /**
  29103. * Unbind the current render target and bind the default framebuffer
  29104. */
  29105. restoreDefaultFramebuffer(): void;
  29106. /**
  29107. * Create an uniform buffer
  29108. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29109. * @param elements defines the content of the uniform buffer
  29110. * @returns the webGL uniform buffer
  29111. */
  29112. createUniformBuffer(elements: FloatArray): DataBuffer;
  29113. /**
  29114. * Create a dynamic uniform buffer
  29115. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29116. * @param elements defines the content of the uniform buffer
  29117. * @returns the webGL uniform buffer
  29118. */
  29119. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29120. /**
  29121. * Update an existing uniform buffer
  29122. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29123. * @param uniformBuffer defines the target uniform buffer
  29124. * @param elements defines the content to update
  29125. * @param offset defines the offset in the uniform buffer where update should start
  29126. * @param count defines the size of the data to update
  29127. */
  29128. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29129. private _resetVertexBufferBinding;
  29130. /**
  29131. * Creates a vertex buffer
  29132. * @param data the data for the vertex buffer
  29133. * @returns the new WebGL static buffer
  29134. */
  29135. createVertexBuffer(data: DataArray): DataBuffer;
  29136. /**
  29137. * Creates a dynamic vertex buffer
  29138. * @param data the data for the dynamic vertex buffer
  29139. * @returns the new WebGL dynamic buffer
  29140. */
  29141. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29142. /**
  29143. * Update a dynamic index buffer
  29144. * @param indexBuffer defines the target index buffer
  29145. * @param indices defines the data to update
  29146. * @param offset defines the offset in the target index buffer where update should start
  29147. */
  29148. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29149. /**
  29150. * Updates a dynamic vertex buffer.
  29151. * @param vertexBuffer the vertex buffer to update
  29152. * @param data the data used to update the vertex buffer
  29153. * @param byteOffset the byte offset of the data
  29154. * @param byteLength the byte length of the data
  29155. */
  29156. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29157. private _resetIndexBufferBinding;
  29158. /**
  29159. * Creates a new index buffer
  29160. * @param indices defines the content of the index buffer
  29161. * @param updatable defines if the index buffer must be updatable
  29162. * @returns a new webGL buffer
  29163. */
  29164. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29165. /**
  29166. * Bind a webGL buffer to the webGL context
  29167. * @param buffer defines the buffer to bind
  29168. */
  29169. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29170. /**
  29171. * Bind an uniform buffer to the current webGL context
  29172. * @param buffer defines the buffer to bind
  29173. */
  29174. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29175. /**
  29176. * Bind a buffer to the current webGL context at a given location
  29177. * @param buffer defines the buffer to bind
  29178. * @param location defines the index where to bind the buffer
  29179. */
  29180. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29181. /**
  29182. * Bind a specific block at a given index in a specific shader program
  29183. * @param pipelineContext defines the pipeline context to use
  29184. * @param blockName defines the block name
  29185. * @param index defines the index where to bind the block
  29186. */
  29187. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29188. private bindIndexBuffer;
  29189. private bindBuffer;
  29190. /**
  29191. * update the bound buffer with the given data
  29192. * @param data defines the data to update
  29193. */
  29194. updateArrayBuffer(data: Float32Array): void;
  29195. private _vertexAttribPointer;
  29196. private _bindIndexBufferWithCache;
  29197. private _bindVertexBuffersAttributes;
  29198. /**
  29199. * Records a vertex array object
  29200. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29201. * @param vertexBuffers defines the list of vertex buffers to store
  29202. * @param indexBuffer defines the index buffer to store
  29203. * @param effect defines the effect to store
  29204. * @returns the new vertex array object
  29205. */
  29206. recordVertexArrayObject(vertexBuffers: {
  29207. [key: string]: VertexBuffer;
  29208. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29209. /**
  29210. * Bind a specific vertex array object
  29211. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29212. * @param vertexArrayObject defines the vertex array object to bind
  29213. * @param indexBuffer defines the index buffer to bind
  29214. */
  29215. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29216. /**
  29217. * Bind webGl buffers directly to the webGL context
  29218. * @param vertexBuffer defines the vertex buffer to bind
  29219. * @param indexBuffer defines the index buffer to bind
  29220. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29221. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29222. * @param effect defines the effect associated with the vertex buffer
  29223. */
  29224. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29225. private _unbindVertexArrayObject;
  29226. /**
  29227. * Bind a list of vertex buffers to the webGL context
  29228. * @param vertexBuffers defines the list of vertex buffers to bind
  29229. * @param indexBuffer defines the index buffer to bind
  29230. * @param effect defines the effect associated with the vertex buffers
  29231. */
  29232. bindBuffers(vertexBuffers: {
  29233. [key: string]: Nullable<VertexBuffer>;
  29234. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29235. /**
  29236. * Unbind all instance attributes
  29237. */
  29238. unbindInstanceAttributes(): void;
  29239. /**
  29240. * Release and free the memory of a vertex array object
  29241. * @param vao defines the vertex array object to delete
  29242. */
  29243. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29244. /** @hidden */
  29245. _releaseBuffer(buffer: DataBuffer): boolean;
  29246. /**
  29247. * Creates a webGL buffer to use with instanciation
  29248. * @param capacity defines the size of the buffer
  29249. * @returns the webGL buffer
  29250. */
  29251. createInstancesBuffer(capacity: number): DataBuffer;
  29252. /**
  29253. * Delete a webGL buffer used with instanciation
  29254. * @param buffer defines the webGL buffer to delete
  29255. */
  29256. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29257. /**
  29258. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29259. * @param instancesBuffer defines the webGL buffer to update and bind
  29260. * @param data defines the data to store in the buffer
  29261. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29262. */
  29263. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29264. /**
  29265. * Apply all cached states (depth, culling, stencil and alpha)
  29266. */
  29267. applyStates(): void;
  29268. /**
  29269. * Send a draw order
  29270. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29271. * @param indexStart defines the starting index
  29272. * @param indexCount defines the number of index to draw
  29273. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29274. */
  29275. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29276. /**
  29277. * Draw a list of points
  29278. * @param verticesStart defines the index of first vertex to draw
  29279. * @param verticesCount defines the count of vertices to draw
  29280. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29281. */
  29282. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29283. /**
  29284. * Draw a list of unindexed primitives
  29285. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29286. * @param verticesStart defines the index of first vertex to draw
  29287. * @param verticesCount defines the count of vertices to draw
  29288. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29289. */
  29290. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29291. /**
  29292. * Draw a list of indexed primitives
  29293. * @param fillMode defines the primitive to use
  29294. * @param indexStart defines the starting index
  29295. * @param indexCount defines the number of index to draw
  29296. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29297. */
  29298. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29299. /**
  29300. * Draw a list of unindexed primitives
  29301. * @param fillMode defines the primitive to use
  29302. * @param verticesStart defines the index of first vertex to draw
  29303. * @param verticesCount defines the count of vertices to draw
  29304. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29305. */
  29306. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29307. private _drawMode;
  29308. /** @hidden */
  29309. _releaseEffect(effect: Effect): void;
  29310. /** @hidden */
  29311. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29312. /**
  29313. * Create a new effect (used to store vertex/fragment shaders)
  29314. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29315. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29316. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29317. * @param samplers defines an array of string used to represent textures
  29318. * @param defines defines the string containing the defines to use to compile the shaders
  29319. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29320. * @param onCompiled defines a function to call when the effect creation is successful
  29321. * @param onError defines a function to call when the effect creation has failed
  29322. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29323. * @returns the new Effect
  29324. */
  29325. 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;
  29326. private _compileShader;
  29327. private _compileRawShader;
  29328. /**
  29329. * Directly creates a webGL program
  29330. * @param pipelineContext defines the pipeline context to attach to
  29331. * @param vertexCode defines the vertex shader code to use
  29332. * @param fragmentCode defines the fragment shader code to use
  29333. * @param context defines the webGL context to use (if not set, the current one will be used)
  29334. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29335. * @returns the new webGL program
  29336. */
  29337. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29338. /**
  29339. * Creates a webGL program
  29340. * @param pipelineContext defines the pipeline context to attach to
  29341. * @param vertexCode defines the vertex shader code to use
  29342. * @param fragmentCode defines the fragment shader code to use
  29343. * @param defines defines the string containing the defines to use to compile the shaders
  29344. * @param context defines the webGL context to use (if not set, the current one will be used)
  29345. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29346. * @returns the new webGL program
  29347. */
  29348. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29349. /**
  29350. * Creates a new pipeline context
  29351. * @returns the new pipeline
  29352. */
  29353. createPipelineContext(): WebGLPipelineContext;
  29354. private _createShaderProgram;
  29355. private _finalizePipelineContext;
  29356. /** @hidden */
  29357. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29358. /** @hidden */
  29359. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29360. /** @hidden */
  29361. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29362. /**
  29363. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29364. * @param pipelineContext defines the pipeline context to use
  29365. * @param uniformsNames defines the list of uniform names
  29366. * @returns an array of webGL uniform locations
  29367. */
  29368. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29369. /**
  29370. * Gets the lsit of active attributes for a given webGL program
  29371. * @param pipelineContext defines the pipeline context to use
  29372. * @param attributesNames defines the list of attribute names to get
  29373. * @returns an array of indices indicating the offset of each attribute
  29374. */
  29375. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29376. /**
  29377. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29378. * @param effect defines the effect to activate
  29379. */
  29380. enableEffect(effect: Nullable<Effect>): void;
  29381. /**
  29382. * Set the value of an uniform to an array of int32
  29383. * @param uniform defines the webGL uniform location where to store the value
  29384. * @param array defines the array of int32 to store
  29385. */
  29386. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29387. /**
  29388. * Set the value of an uniform to an array of int32 (stored as vec2)
  29389. * @param uniform defines the webGL uniform location where to store the value
  29390. * @param array defines the array of int32 to store
  29391. */
  29392. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29393. /**
  29394. * Set the value of an uniform to an array of int32 (stored as vec3)
  29395. * @param uniform defines the webGL uniform location where to store the value
  29396. * @param array defines the array of int32 to store
  29397. */
  29398. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29399. /**
  29400. * Set the value of an uniform to an array of int32 (stored as vec4)
  29401. * @param uniform defines the webGL uniform location where to store the value
  29402. * @param array defines the array of int32 to store
  29403. */
  29404. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29405. /**
  29406. * Set the value of an uniform to an array of float32
  29407. * @param uniform defines the webGL uniform location where to store the value
  29408. * @param array defines the array of float32 to store
  29409. */
  29410. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29411. /**
  29412. * Set the value of an uniform to an array of float32 (stored as vec2)
  29413. * @param uniform defines the webGL uniform location where to store the value
  29414. * @param array defines the array of float32 to store
  29415. */
  29416. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29417. /**
  29418. * Set the value of an uniform to an array of float32 (stored as vec3)
  29419. * @param uniform defines the webGL uniform location where to store the value
  29420. * @param array defines the array of float32 to store
  29421. */
  29422. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29423. /**
  29424. * Set the value of an uniform to an array of float32 (stored as vec4)
  29425. * @param uniform defines the webGL uniform location where to store the value
  29426. * @param array defines the array of float32 to store
  29427. */
  29428. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29429. /**
  29430. * Set the value of an uniform to an array of number
  29431. * @param uniform defines the webGL uniform location where to store the value
  29432. * @param array defines the array of number to store
  29433. */
  29434. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29435. /**
  29436. * Set the value of an uniform to an array of number (stored as vec2)
  29437. * @param uniform defines the webGL uniform location where to store the value
  29438. * @param array defines the array of number to store
  29439. */
  29440. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29441. /**
  29442. * Set the value of an uniform to an array of number (stored as vec3)
  29443. * @param uniform defines the webGL uniform location where to store the value
  29444. * @param array defines the array of number to store
  29445. */
  29446. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29447. /**
  29448. * Set the value of an uniform to an array of number (stored as vec4)
  29449. * @param uniform defines the webGL uniform location where to store the value
  29450. * @param array defines the array of number to store
  29451. */
  29452. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29453. /**
  29454. * Set the value of an uniform to an array of float32 (stored as matrices)
  29455. * @param uniform defines the webGL uniform location where to store the value
  29456. * @param matrices defines the array of float32 to store
  29457. */
  29458. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29459. /**
  29460. * Set the value of an uniform to a matrix
  29461. * @param uniform defines the webGL uniform location where to store the value
  29462. * @param matrix defines the matrix to store
  29463. */
  29464. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29465. /**
  29466. * Set the value of an uniform to a matrix (3x3)
  29467. * @param uniform defines the webGL uniform location where to store the value
  29468. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29469. */
  29470. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29471. /**
  29472. * Set the value of an uniform to a matrix (2x2)
  29473. * @param uniform defines the webGL uniform location where to store the value
  29474. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29475. */
  29476. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29477. /**
  29478. * Set the value of an uniform to a number (int)
  29479. * @param uniform defines the webGL uniform location where to store the value
  29480. * @param value defines the int number to store
  29481. */
  29482. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29483. /**
  29484. * Set the value of an uniform to a number (float)
  29485. * @param uniform defines the webGL uniform location where to store the value
  29486. * @param value defines the float number to store
  29487. */
  29488. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29489. /**
  29490. * Set the value of an uniform to a vec2
  29491. * @param uniform defines the webGL uniform location where to store the value
  29492. * @param x defines the 1st component of the value
  29493. * @param y defines the 2nd component of the value
  29494. */
  29495. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29496. /**
  29497. * Set the value of an uniform to a vec3
  29498. * @param uniform defines the webGL uniform location where to store the value
  29499. * @param x defines the 1st component of the value
  29500. * @param y defines the 2nd component of the value
  29501. * @param z defines the 3rd component of the value
  29502. */
  29503. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29504. /**
  29505. * Set the value of an uniform to a boolean
  29506. * @param uniform defines the webGL uniform location where to store the value
  29507. * @param bool defines the boolean to store
  29508. */
  29509. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29510. /**
  29511. * Set the value of an uniform to a vec4
  29512. * @param uniform defines the webGL uniform location where to store the value
  29513. * @param x defines the 1st component of the value
  29514. * @param y defines the 2nd component of the value
  29515. * @param z defines the 3rd component of the value
  29516. * @param w defines the 4th component of the value
  29517. */
  29518. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29519. /**
  29520. * Set the value of an uniform to a Color3
  29521. * @param uniform defines the webGL uniform location where to store the value
  29522. * @param color3 defines the color to store
  29523. */
  29524. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29525. /**
  29526. * Set the value of an uniform to a Color3 and an alpha value
  29527. * @param uniform defines the webGL uniform location where to store the value
  29528. * @param color3 defines the color to store
  29529. * @param alpha defines the alpha component to store
  29530. */
  29531. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29532. /**
  29533. * Sets a Color4 on a uniform variable
  29534. * @param uniform defines the uniform location
  29535. * @param color4 defines the value to be set
  29536. */
  29537. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29538. /**
  29539. * Set various states to the webGL context
  29540. * @param culling defines backface culling state
  29541. * @param zOffset defines the value to apply to zOffset (0 by default)
  29542. * @param force defines if states must be applied even if cache is up to date
  29543. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29544. */
  29545. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29546. /**
  29547. * Set the z offset to apply to current rendering
  29548. * @param value defines the offset to apply
  29549. */
  29550. setZOffset(value: number): void;
  29551. /**
  29552. * Gets the current value of the zOffset
  29553. * @returns the current zOffset state
  29554. */
  29555. getZOffset(): number;
  29556. /**
  29557. * Enable or disable depth buffering
  29558. * @param enable defines the state to set
  29559. */
  29560. setDepthBuffer(enable: boolean): void;
  29561. /**
  29562. * Gets a boolean indicating if depth writing is enabled
  29563. * @returns the current depth writing state
  29564. */
  29565. getDepthWrite(): boolean;
  29566. /**
  29567. * Enable or disable depth writing
  29568. * @param enable defines the state to set
  29569. */
  29570. setDepthWrite(enable: boolean): void;
  29571. /**
  29572. * Enable or disable color writing
  29573. * @param enable defines the state to set
  29574. */
  29575. setColorWrite(enable: boolean): void;
  29576. /**
  29577. * Gets a boolean indicating if color writing is enabled
  29578. * @returns the current color writing state
  29579. */
  29580. getColorWrite(): boolean;
  29581. /**
  29582. * Sets alpha constants used by some alpha blending modes
  29583. * @param r defines the red component
  29584. * @param g defines the green component
  29585. * @param b defines the blue component
  29586. * @param a defines the alpha component
  29587. */
  29588. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29589. /**
  29590. * Sets the current alpha mode
  29591. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29592. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29593. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29594. */
  29595. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29596. /**
  29597. * Gets the current alpha mode
  29598. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29599. * @returns the current alpha mode
  29600. */
  29601. getAlphaMode(): number;
  29602. /**
  29603. * Clears the list of texture accessible through engine.
  29604. * This can help preventing texture load conflict due to name collision.
  29605. */
  29606. clearInternalTexturesCache(): void;
  29607. /**
  29608. * Force the entire cache to be cleared
  29609. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29610. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29611. */
  29612. wipeCaches(bruteForce?: boolean): void;
  29613. /**
  29614. * Set the compressed texture format to use, based on the formats you have, and the formats
  29615. * supported by the hardware / browser.
  29616. *
  29617. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29618. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29619. * to API arguments needed to compressed textures. This puts the burden on the container
  29620. * generator to house the arcane code for determining these for current & future formats.
  29621. *
  29622. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29623. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29624. *
  29625. * Note: The result of this call is not taken into account when a texture is base64.
  29626. *
  29627. * @param formatsAvailable defines the list of those format families you have created
  29628. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29629. *
  29630. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29631. * @returns The extension selected.
  29632. */
  29633. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29634. /** @hidden */
  29635. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29636. min: number;
  29637. mag: number;
  29638. };
  29639. /** @hidden */
  29640. _createTexture(): WebGLTexture;
  29641. /**
  29642. * Usually called from Texture.ts.
  29643. * Passed information to create a WebGLTexture
  29644. * @param urlArg defines a value which contains one of the following:
  29645. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29646. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29647. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29648. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29649. * @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)
  29650. * @param scene needed for loading to the correct scene
  29651. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29652. * @param onLoad optional callback to be called upon successful completion
  29653. * @param onError optional callback to be called upon failure
  29654. * @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
  29655. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29656. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29657. * @param forcedExtension defines the extension to use to pick the right loader
  29658. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29659. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29660. */
  29661. 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;
  29662. /**
  29663. * @hidden
  29664. * Rescales a texture
  29665. * @param source input texutre
  29666. * @param destination destination texture
  29667. * @param scene scene to use to render the resize
  29668. * @param internalFormat format to use when resizing
  29669. * @param onComplete callback to be called when resize has completed
  29670. */
  29671. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29672. private _unpackFlipYCached;
  29673. /**
  29674. * In case you are sharing the context with other applications, it might
  29675. * be interested to not cache the unpack flip y state to ensure a consistent
  29676. * value would be set.
  29677. */
  29678. enableUnpackFlipYCached: boolean;
  29679. /** @hidden */
  29680. _unpackFlipY(value: boolean): void;
  29681. /** @hidden */
  29682. _getUnpackAlignement(): number;
  29683. /**
  29684. * Creates a dynamic texture
  29685. * @param width defines the width of the texture
  29686. * @param height defines the height of the texture
  29687. * @param generateMipMaps defines if the engine should generate the mip levels
  29688. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29689. * @returns the dynamic texture inside an InternalTexture
  29690. */
  29691. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29692. /**
  29693. * Update the sampling mode of a given texture
  29694. * @param samplingMode defines the required sampling mode
  29695. * @param texture defines the texture to update
  29696. */
  29697. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29698. /**
  29699. * Update the content of a dynamic texture
  29700. * @param texture defines the texture to update
  29701. * @param canvas defines the canvas containing the source
  29702. * @param invertY defines if data must be stored with Y axis inverted
  29703. * @param premulAlpha defines if alpha is stored as premultiplied
  29704. * @param format defines the format of the data
  29705. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29706. */
  29707. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29708. /**
  29709. * Update a video texture
  29710. * @param texture defines the texture to update
  29711. * @param video defines the video element to use
  29712. * @param invertY defines if data must be stored with Y axis inverted
  29713. */
  29714. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29715. /**
  29716. * Updates a depth texture Comparison Mode and Function.
  29717. * If the comparison Function is equal to 0, the mode will be set to none.
  29718. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29719. * @param texture The texture to set the comparison function for
  29720. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29721. */
  29722. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29723. /** @hidden */
  29724. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29725. width: number;
  29726. height: number;
  29727. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29728. /**
  29729. * Creates a depth stencil texture.
  29730. * This is only available in WebGL 2 or with the depth texture extension available.
  29731. * @param size The size of face edge in the texture.
  29732. * @param options The options defining the texture.
  29733. * @returns The texture
  29734. */
  29735. createDepthStencilTexture(size: number | {
  29736. width: number;
  29737. height: number;
  29738. }, options: DepthTextureCreationOptions): InternalTexture;
  29739. /**
  29740. * Creates a depth stencil texture.
  29741. * This is only available in WebGL 2 or with the depth texture extension available.
  29742. * @param size The size of face edge in the texture.
  29743. * @param options The options defining the texture.
  29744. * @returns The texture
  29745. */
  29746. private _createDepthStencilTexture;
  29747. /**
  29748. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29749. * @param renderTarget The render target to set the frame buffer for
  29750. */
  29751. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29752. /**
  29753. * Creates a new render target texture
  29754. * @param size defines the size of the texture
  29755. * @param options defines the options used to create the texture
  29756. * @returns a new render target texture stored in an InternalTexture
  29757. */
  29758. createRenderTargetTexture(size: number | {
  29759. width: number;
  29760. height: number;
  29761. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29762. /** @hidden */
  29763. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29764. /**
  29765. * Updates the sample count of a render target texture
  29766. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29767. * @param texture defines the texture to update
  29768. * @param samples defines the sample count to set
  29769. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29770. */
  29771. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29772. /** @hidden */
  29773. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29774. /** @hidden */
  29775. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29776. /** @hidden */
  29777. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29778. /** @hidden */
  29779. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29780. /**
  29781. * @hidden
  29782. */
  29783. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29784. private _prepareWebGLTextureContinuation;
  29785. private _prepareWebGLTexture;
  29786. /** @hidden */
  29787. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29788. /** @hidden */
  29789. _releaseFramebufferObjects(texture: InternalTexture): void;
  29790. /** @hidden */
  29791. _releaseTexture(texture: InternalTexture): void;
  29792. private setProgram;
  29793. private _boundUniforms;
  29794. /**
  29795. * Binds an effect to the webGL context
  29796. * @param effect defines the effect to bind
  29797. */
  29798. bindSamplers(effect: Effect): void;
  29799. private _activateCurrentTexture;
  29800. /** @hidden */
  29801. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29802. /** @hidden */
  29803. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29804. /**
  29805. * Sets a texture to the webGL context from a postprocess
  29806. * @param channel defines the channel to use
  29807. * @param postProcess defines the source postprocess
  29808. */
  29809. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29810. /**
  29811. * Binds the output of the passed in post process to the texture channel specified
  29812. * @param channel The channel the texture should be bound to
  29813. * @param postProcess The post process which's output should be bound
  29814. */
  29815. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29816. /**
  29817. * Unbind all textures from the webGL context
  29818. */
  29819. unbindAllTextures(): void;
  29820. /**
  29821. * Sets a texture to the according uniform.
  29822. * @param channel The texture channel
  29823. * @param uniform The uniform to set
  29824. * @param texture The texture to apply
  29825. */
  29826. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29827. /**
  29828. * Sets a depth stencil texture from a render target to the according uniform.
  29829. * @param channel The texture channel
  29830. * @param uniform The uniform to set
  29831. * @param texture The render target texture containing the depth stencil texture to apply
  29832. */
  29833. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29834. private _bindSamplerUniformToChannel;
  29835. private _getTextureWrapMode;
  29836. private _setTexture;
  29837. /**
  29838. * Sets an array of texture to the webGL context
  29839. * @param channel defines the channel where the texture array must be set
  29840. * @param uniform defines the associated uniform location
  29841. * @param textures defines the array of textures to bind
  29842. */
  29843. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29844. /** @hidden */
  29845. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29846. private _setTextureParameterFloat;
  29847. private _setTextureParameterInteger;
  29848. /**
  29849. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29850. * @param x defines the x coordinate of the rectangle where pixels must be read
  29851. * @param y defines the y coordinate of the rectangle where pixels must be read
  29852. * @param width defines the width of the rectangle where pixels must be read
  29853. * @param height defines the height of the rectangle where pixels must be read
  29854. * @returns a Uint8Array containing RGBA colors
  29855. */
  29856. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29857. /**
  29858. * Add an externaly attached data from its key.
  29859. * This method call will fail and return false, if such key already exists.
  29860. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29861. * @param key the unique key that identifies the data
  29862. * @param data the data object to associate to the key for this Engine instance
  29863. * @return true if no such key were already present and the data was added successfully, false otherwise
  29864. */
  29865. addExternalData<T>(key: string, data: T): boolean;
  29866. /**
  29867. * Get an externaly attached data from its key
  29868. * @param key the unique key that identifies the data
  29869. * @return the associated data, if present (can be null), or undefined if not present
  29870. */
  29871. getExternalData<T>(key: string): T;
  29872. /**
  29873. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29874. * @param key the unique key that identifies the data
  29875. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29876. * @return the associated data, can be null if the factory returned null.
  29877. */
  29878. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29879. /**
  29880. * Remove an externaly attached data from the Engine instance
  29881. * @param key the unique key that identifies the data
  29882. * @return true if the data was successfully removed, false if it doesn't exist
  29883. */
  29884. removeExternalData(key: string): boolean;
  29885. /**
  29886. * Unbind all vertex attributes from the webGL context
  29887. */
  29888. unbindAllAttributes(): void;
  29889. /**
  29890. * 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
  29891. */
  29892. releaseEffects(): void;
  29893. /**
  29894. * Dispose and release all associated resources
  29895. */
  29896. dispose(): void;
  29897. /**
  29898. * Display the loading screen
  29899. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29900. */
  29901. displayLoadingUI(): void;
  29902. /**
  29903. * Hide the loading screen
  29904. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29905. */
  29906. hideLoadingUI(): void;
  29907. /**
  29908. * Gets the current loading screen object
  29909. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29910. */
  29911. /**
  29912. * Sets the current loading screen object
  29913. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29914. */
  29915. loadingScreen: ILoadingScreen;
  29916. /**
  29917. * Sets the current loading screen text
  29918. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29919. */
  29920. loadingUIText: string;
  29921. /**
  29922. * Sets the current loading screen background color
  29923. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29924. */
  29925. loadingUIBackgroundColor: string;
  29926. /**
  29927. * Attach a new callback raised when context lost event is fired
  29928. * @param callback defines the callback to call
  29929. */
  29930. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29931. /**
  29932. * Attach a new callback raised when context restored event is fired
  29933. * @param callback defines the callback to call
  29934. */
  29935. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29936. /**
  29937. * Gets the source code of the vertex shader associated with a specific webGL program
  29938. * @param program defines the program to use
  29939. * @returns a string containing the source code of the vertex shader associated with the program
  29940. */
  29941. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29942. /**
  29943. * Gets the source code of the fragment shader associated with a specific webGL program
  29944. * @param program defines the program to use
  29945. * @returns a string containing the source code of the fragment shader associated with the program
  29946. */
  29947. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29948. /**
  29949. * Get the current error code of the webGL context
  29950. * @returns the error code
  29951. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29952. */
  29953. getError(): number;
  29954. /**
  29955. * Gets the current framerate
  29956. * @returns a number representing the framerate
  29957. */
  29958. getFps(): number;
  29959. /**
  29960. * Gets the time spent between current and previous frame
  29961. * @returns a number representing the delta time in ms
  29962. */
  29963. getDeltaTime(): number;
  29964. private _measureFps;
  29965. /** @hidden */
  29966. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29967. private _canRenderToFloatFramebuffer;
  29968. private _canRenderToHalfFloatFramebuffer;
  29969. private _canRenderToFramebuffer;
  29970. /** @hidden */
  29971. _getWebGLTextureType(type: number): number;
  29972. /** @hidden */
  29973. _getInternalFormat(format: number): number;
  29974. /** @hidden */
  29975. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29976. /** @hidden */
  29977. _getRGBAMultiSampleBufferFormat(type: number): number;
  29978. /** @hidden */
  29979. _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;
  29980. /** @hidden */
  29981. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29982. /**
  29983. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29984. * @returns true if the engine can be created
  29985. * @ignorenaming
  29986. */
  29987. static isSupported(): boolean;
  29988. }
  29989. }
  29990. declare module "babylonjs/Materials/effect" {
  29991. import { Observable } from "babylonjs/Misc/observable";
  29992. import { Nullable } from "babylonjs/types";
  29993. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29994. import { IDisposable } from "babylonjs/scene";
  29995. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29996. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29997. import { Engine } from "babylonjs/Engines/engine";
  29998. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29999. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30000. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30001. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30003. /**
  30004. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  30005. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  30006. */
  30007. export class EffectFallbacks {
  30008. private _defines;
  30009. private _currentRank;
  30010. private _maxRank;
  30011. private _mesh;
  30012. /**
  30013. * Removes the fallback from the bound mesh.
  30014. */
  30015. unBindMesh(): void;
  30016. /**
  30017. * Adds a fallback on the specified property.
  30018. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30019. * @param define The name of the define in the shader
  30020. */
  30021. addFallback(rank: number, define: string): void;
  30022. /**
  30023. * Sets the mesh to use CPU skinning when needing to fallback.
  30024. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30025. * @param mesh The mesh to use the fallbacks.
  30026. */
  30027. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30028. /**
  30029. * Checks to see if more fallbacks are still availible.
  30030. */
  30031. readonly isMoreFallbacks: boolean;
  30032. /**
  30033. * Removes the defines that should be removed when falling back.
  30034. * @param currentDefines defines the current define statements for the shader.
  30035. * @param effect defines the current effect we try to compile
  30036. * @returns The resulting defines with defines of the current rank removed.
  30037. */
  30038. reduce(currentDefines: string, effect: Effect): string;
  30039. }
  30040. /**
  30041. * Options to be used when creating an effect.
  30042. */
  30043. export class EffectCreationOptions {
  30044. /**
  30045. * Atrributes that will be used in the shader.
  30046. */
  30047. attributes: string[];
  30048. /**
  30049. * Uniform varible names that will be set in the shader.
  30050. */
  30051. uniformsNames: string[];
  30052. /**
  30053. * Uniform buffer varible names that will be set in the shader.
  30054. */
  30055. uniformBuffersNames: string[];
  30056. /**
  30057. * Sampler texture variable names that will be set in the shader.
  30058. */
  30059. samplers: string[];
  30060. /**
  30061. * Define statements that will be set in the shader.
  30062. */
  30063. defines: any;
  30064. /**
  30065. * Possible fallbacks for this effect to improve performance when needed.
  30066. */
  30067. fallbacks: Nullable<EffectFallbacks>;
  30068. /**
  30069. * Callback that will be called when the shader is compiled.
  30070. */
  30071. onCompiled: Nullable<(effect: Effect) => void>;
  30072. /**
  30073. * Callback that will be called if an error occurs during shader compilation.
  30074. */
  30075. onError: Nullable<(effect: Effect, errors: string) => void>;
  30076. /**
  30077. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30078. */
  30079. indexParameters: any;
  30080. /**
  30081. * Max number of lights that can be used in the shader.
  30082. */
  30083. maxSimultaneousLights: number;
  30084. /**
  30085. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30086. */
  30087. transformFeedbackVaryings: Nullable<string[]>;
  30088. }
  30089. /**
  30090. * Effect containing vertex and fragment shader that can be executed on an object.
  30091. */
  30092. export class Effect implements IDisposable {
  30093. /**
  30094. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30095. */
  30096. static ShadersRepository: string;
  30097. /**
  30098. * Name of the effect.
  30099. */
  30100. name: any;
  30101. /**
  30102. * String container all the define statements that should be set on the shader.
  30103. */
  30104. defines: string;
  30105. /**
  30106. * Callback that will be called when the shader is compiled.
  30107. */
  30108. onCompiled: Nullable<(effect: Effect) => void>;
  30109. /**
  30110. * Callback that will be called if an error occurs during shader compilation.
  30111. */
  30112. onError: Nullable<(effect: Effect, errors: string) => void>;
  30113. /**
  30114. * Callback that will be called when effect is bound.
  30115. */
  30116. onBind: Nullable<(effect: Effect) => void>;
  30117. /**
  30118. * Unique ID of the effect.
  30119. */
  30120. uniqueId: number;
  30121. /**
  30122. * Observable that will be called when the shader is compiled.
  30123. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30124. */
  30125. onCompileObservable: Observable<Effect>;
  30126. /**
  30127. * Observable that will be called if an error occurs during shader compilation.
  30128. */
  30129. onErrorObservable: Observable<Effect>;
  30130. /** @hidden */
  30131. _onBindObservable: Nullable<Observable<Effect>>;
  30132. /**
  30133. * Observable that will be called when effect is bound.
  30134. */
  30135. readonly onBindObservable: Observable<Effect>;
  30136. /** @hidden */
  30137. _bonesComputationForcedToCPU: boolean;
  30138. private static _uniqueIdSeed;
  30139. private _engine;
  30140. private _uniformBuffersNames;
  30141. private _uniformsNames;
  30142. private _samplerList;
  30143. private _samplers;
  30144. private _isReady;
  30145. private _compilationError;
  30146. private _attributesNames;
  30147. private _attributes;
  30148. private _uniforms;
  30149. /**
  30150. * Key for the effect.
  30151. * @hidden
  30152. */
  30153. _key: string;
  30154. private _indexParameters;
  30155. private _fallbacks;
  30156. private _vertexSourceCode;
  30157. private _fragmentSourceCode;
  30158. private _vertexSourceCodeOverride;
  30159. private _fragmentSourceCodeOverride;
  30160. private _transformFeedbackVaryings;
  30161. /**
  30162. * Compiled shader to webGL program.
  30163. * @hidden
  30164. */
  30165. _pipelineContext: Nullable<IPipelineContext>;
  30166. private _valueCache;
  30167. private static _baseCache;
  30168. /**
  30169. * Instantiates an effect.
  30170. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30171. * @param baseName Name of the effect.
  30172. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30173. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30174. * @param samplers List of sampler variables that will be passed to the shader.
  30175. * @param engine Engine to be used to render the effect
  30176. * @param defines Define statements to be added to the shader.
  30177. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30178. * @param onCompiled Callback that will be called when the shader is compiled.
  30179. * @param onError Callback that will be called if an error occurs during shader compilation.
  30180. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30181. */
  30182. 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);
  30183. private _useFinalCode;
  30184. /**
  30185. * Unique key for this effect
  30186. */
  30187. readonly key: string;
  30188. /**
  30189. * If the effect has been compiled and prepared.
  30190. * @returns if the effect is compiled and prepared.
  30191. */
  30192. isReady(): boolean;
  30193. /**
  30194. * The engine the effect was initialized with.
  30195. * @returns the engine.
  30196. */
  30197. getEngine(): Engine;
  30198. /**
  30199. * The pipeline context for this effect
  30200. * @returns the associated pipeline context
  30201. */
  30202. getPipelineContext(): Nullable<IPipelineContext>;
  30203. /**
  30204. * The set of names of attribute variables for the shader.
  30205. * @returns An array of attribute names.
  30206. */
  30207. getAttributesNames(): string[];
  30208. /**
  30209. * Returns the attribute at the given index.
  30210. * @param index The index of the attribute.
  30211. * @returns The location of the attribute.
  30212. */
  30213. getAttributeLocation(index: number): number;
  30214. /**
  30215. * Returns the attribute based on the name of the variable.
  30216. * @param name of the attribute to look up.
  30217. * @returns the attribute location.
  30218. */
  30219. getAttributeLocationByName(name: string): number;
  30220. /**
  30221. * The number of attributes.
  30222. * @returns the numnber of attributes.
  30223. */
  30224. getAttributesCount(): number;
  30225. /**
  30226. * Gets the index of a uniform variable.
  30227. * @param uniformName of the uniform to look up.
  30228. * @returns the index.
  30229. */
  30230. getUniformIndex(uniformName: string): number;
  30231. /**
  30232. * Returns the attribute based on the name of the variable.
  30233. * @param uniformName of the uniform to look up.
  30234. * @returns the location of the uniform.
  30235. */
  30236. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30237. /**
  30238. * Returns an array of sampler variable names
  30239. * @returns The array of sampler variable neames.
  30240. */
  30241. getSamplers(): string[];
  30242. /**
  30243. * The error from the last compilation.
  30244. * @returns the error string.
  30245. */
  30246. getCompilationError(): string;
  30247. /**
  30248. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30249. * @param func The callback to be used.
  30250. */
  30251. executeWhenCompiled(func: (effect: Effect) => void): void;
  30252. private _checkIsReady;
  30253. /** @hidden */
  30254. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30255. /** @hidden */
  30256. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30257. /** @hidden */
  30258. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30259. /**
  30260. * Recompiles the webGL program
  30261. * @param vertexSourceCode The source code for the vertex shader.
  30262. * @param fragmentSourceCode The source code for the fragment shader.
  30263. * @param onCompiled Callback called when completed.
  30264. * @param onError Callback called on error.
  30265. * @hidden
  30266. */
  30267. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30268. /**
  30269. * Prepares the effect
  30270. * @hidden
  30271. */
  30272. _prepareEffect(): void;
  30273. /**
  30274. * Checks if the effect is supported. (Must be called after compilation)
  30275. */
  30276. readonly isSupported: boolean;
  30277. /**
  30278. * Binds a texture to the engine to be used as output of the shader.
  30279. * @param channel Name of the output variable.
  30280. * @param texture Texture to bind.
  30281. * @hidden
  30282. */
  30283. _bindTexture(channel: string, texture: InternalTexture): void;
  30284. /**
  30285. * Sets a texture on the engine to be used in the shader.
  30286. * @param channel Name of the sampler variable.
  30287. * @param texture Texture to set.
  30288. */
  30289. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30290. /**
  30291. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30292. * @param channel Name of the sampler variable.
  30293. * @param texture Texture to set.
  30294. */
  30295. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30296. /**
  30297. * Sets an array of textures on the engine to be used in the shader.
  30298. * @param channel Name of the variable.
  30299. * @param textures Textures to set.
  30300. */
  30301. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30302. /**
  30303. * 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)
  30304. * @param channel Name of the sampler variable.
  30305. * @param postProcess Post process to get the input texture from.
  30306. */
  30307. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30308. /**
  30309. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30310. * 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)
  30311. * @param channel Name of the sampler variable.
  30312. * @param postProcess Post process to get the output texture from.
  30313. */
  30314. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30315. /** @hidden */
  30316. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30317. /** @hidden */
  30318. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30319. /** @hidden */
  30320. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30321. /** @hidden */
  30322. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30323. /**
  30324. * Binds a buffer to a uniform.
  30325. * @param buffer Buffer to bind.
  30326. * @param name Name of the uniform variable to bind to.
  30327. */
  30328. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30329. /**
  30330. * Binds block to a uniform.
  30331. * @param blockName Name of the block to bind.
  30332. * @param index Index to bind.
  30333. */
  30334. bindUniformBlock(blockName: string, index: number): void;
  30335. /**
  30336. * Sets an interger value on a uniform variable.
  30337. * @param uniformName Name of the variable.
  30338. * @param value Value to be set.
  30339. * @returns this effect.
  30340. */
  30341. setInt(uniformName: string, value: number): Effect;
  30342. /**
  30343. * Sets an int array on a uniform variable.
  30344. * @param uniformName Name of the variable.
  30345. * @param array array to be set.
  30346. * @returns this effect.
  30347. */
  30348. setIntArray(uniformName: string, array: Int32Array): Effect;
  30349. /**
  30350. * 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)
  30351. * @param uniformName Name of the variable.
  30352. * @param array array to be set.
  30353. * @returns this effect.
  30354. */
  30355. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30356. /**
  30357. * 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)
  30358. * @param uniformName Name of the variable.
  30359. * @param array array to be set.
  30360. * @returns this effect.
  30361. */
  30362. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30363. /**
  30364. * 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)
  30365. * @param uniformName Name of the variable.
  30366. * @param array array to be set.
  30367. * @returns this effect.
  30368. */
  30369. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30370. /**
  30371. * Sets an float array on a uniform variable.
  30372. * @param uniformName Name of the variable.
  30373. * @param array array to be set.
  30374. * @returns this effect.
  30375. */
  30376. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30377. /**
  30378. * 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)
  30379. * @param uniformName Name of the variable.
  30380. * @param array array to be set.
  30381. * @returns this effect.
  30382. */
  30383. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30384. /**
  30385. * 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)
  30386. * @param uniformName Name of the variable.
  30387. * @param array array to be set.
  30388. * @returns this effect.
  30389. */
  30390. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30391. /**
  30392. * 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)
  30393. * @param uniformName Name of the variable.
  30394. * @param array array to be set.
  30395. * @returns this effect.
  30396. */
  30397. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30398. /**
  30399. * Sets an array on a uniform variable.
  30400. * @param uniformName Name of the variable.
  30401. * @param array array to be set.
  30402. * @returns this effect.
  30403. */
  30404. setArray(uniformName: string, array: number[]): Effect;
  30405. /**
  30406. * 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)
  30407. * @param uniformName Name of the variable.
  30408. * @param array array to be set.
  30409. * @returns this effect.
  30410. */
  30411. setArray2(uniformName: string, array: number[]): Effect;
  30412. /**
  30413. * 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)
  30414. * @param uniformName Name of the variable.
  30415. * @param array array to be set.
  30416. * @returns this effect.
  30417. */
  30418. setArray3(uniformName: string, array: number[]): Effect;
  30419. /**
  30420. * 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)
  30421. * @param uniformName Name of the variable.
  30422. * @param array array to be set.
  30423. * @returns this effect.
  30424. */
  30425. setArray4(uniformName: string, array: number[]): Effect;
  30426. /**
  30427. * Sets matrices on a uniform variable.
  30428. * @param uniformName Name of the variable.
  30429. * @param matrices matrices to be set.
  30430. * @returns this effect.
  30431. */
  30432. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30433. /**
  30434. * Sets matrix on a uniform variable.
  30435. * @param uniformName Name of the variable.
  30436. * @param matrix matrix to be set.
  30437. * @returns this effect.
  30438. */
  30439. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30440. /**
  30441. * 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)
  30442. * @param uniformName Name of the variable.
  30443. * @param matrix matrix to be set.
  30444. * @returns this effect.
  30445. */
  30446. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30447. /**
  30448. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30449. * @param uniformName Name of the variable.
  30450. * @param matrix matrix to be set.
  30451. * @returns this effect.
  30452. */
  30453. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30454. /**
  30455. * Sets a float on a uniform variable.
  30456. * @param uniformName Name of the variable.
  30457. * @param value value to be set.
  30458. * @returns this effect.
  30459. */
  30460. setFloat(uniformName: string, value: number): Effect;
  30461. /**
  30462. * Sets a boolean on a uniform variable.
  30463. * @param uniformName Name of the variable.
  30464. * @param bool value to be set.
  30465. * @returns this effect.
  30466. */
  30467. setBool(uniformName: string, bool: boolean): Effect;
  30468. /**
  30469. * Sets a Vector2 on a uniform variable.
  30470. * @param uniformName Name of the variable.
  30471. * @param vector2 vector2 to be set.
  30472. * @returns this effect.
  30473. */
  30474. setVector2(uniformName: string, vector2: Vector2): Effect;
  30475. /**
  30476. * Sets a float2 on a uniform variable.
  30477. * @param uniformName Name of the variable.
  30478. * @param x First float in float2.
  30479. * @param y Second float in float2.
  30480. * @returns this effect.
  30481. */
  30482. setFloat2(uniformName: string, x: number, y: number): Effect;
  30483. /**
  30484. * Sets a Vector3 on a uniform variable.
  30485. * @param uniformName Name of the variable.
  30486. * @param vector3 Value to be set.
  30487. * @returns this effect.
  30488. */
  30489. setVector3(uniformName: string, vector3: Vector3): Effect;
  30490. /**
  30491. * Sets a float3 on a uniform variable.
  30492. * @param uniformName Name of the variable.
  30493. * @param x First float in float3.
  30494. * @param y Second float in float3.
  30495. * @param z Third float in float3.
  30496. * @returns this effect.
  30497. */
  30498. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30499. /**
  30500. * Sets a Vector4 on a uniform variable.
  30501. * @param uniformName Name of the variable.
  30502. * @param vector4 Value to be set.
  30503. * @returns this effect.
  30504. */
  30505. setVector4(uniformName: string, vector4: Vector4): Effect;
  30506. /**
  30507. * Sets a float4 on a uniform variable.
  30508. * @param uniformName Name of the variable.
  30509. * @param x First float in float4.
  30510. * @param y Second float in float4.
  30511. * @param z Third float in float4.
  30512. * @param w Fourth float in float4.
  30513. * @returns this effect.
  30514. */
  30515. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30516. /**
  30517. * Sets a Color3 on a uniform variable.
  30518. * @param uniformName Name of the variable.
  30519. * @param color3 Value to be set.
  30520. * @returns this effect.
  30521. */
  30522. setColor3(uniformName: string, color3: Color3): Effect;
  30523. /**
  30524. * Sets a Color4 on a uniform variable.
  30525. * @param uniformName Name of the variable.
  30526. * @param color3 Value to be set.
  30527. * @param alpha Alpha value to be set.
  30528. * @returns this effect.
  30529. */
  30530. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30531. /**
  30532. * Sets a Color4 on a uniform variable
  30533. * @param uniformName defines the name of the variable
  30534. * @param color4 defines the value to be set
  30535. * @returns this effect.
  30536. */
  30537. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30538. /** Release all associated resources */
  30539. dispose(): void;
  30540. /**
  30541. * This function will add a new shader to the shader store
  30542. * @param name the name of the shader
  30543. * @param pixelShader optional pixel shader content
  30544. * @param vertexShader optional vertex shader content
  30545. */
  30546. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30547. /**
  30548. * Store of each shader (The can be looked up using effect.key)
  30549. */
  30550. static ShadersStore: {
  30551. [key: string]: string;
  30552. };
  30553. /**
  30554. * Store of each included file for a shader (The can be looked up using effect.key)
  30555. */
  30556. static IncludesShadersStore: {
  30557. [key: string]: string;
  30558. };
  30559. /**
  30560. * Resets the cache of effects.
  30561. */
  30562. static ResetCache(): void;
  30563. }
  30564. }
  30565. declare module "babylonjs/Materials/colorCurves" {
  30566. import { Effect } from "babylonjs/Materials/effect";
  30567. /**
  30568. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30569. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30570. * 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;
  30571. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30572. */
  30573. export class ColorCurves {
  30574. private _dirty;
  30575. private _tempColor;
  30576. private _globalCurve;
  30577. private _highlightsCurve;
  30578. private _midtonesCurve;
  30579. private _shadowsCurve;
  30580. private _positiveCurve;
  30581. private _negativeCurve;
  30582. private _globalHue;
  30583. private _globalDensity;
  30584. private _globalSaturation;
  30585. private _globalExposure;
  30586. /**
  30587. * Gets the global Hue value.
  30588. * 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).
  30589. */
  30590. /**
  30591. * Sets the global Hue value.
  30592. * 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).
  30593. */
  30594. globalHue: number;
  30595. /**
  30596. * Gets the global Density value.
  30597. * 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.
  30598. * Values less than zero provide a filter of opposite hue.
  30599. */
  30600. /**
  30601. * Sets the global Density value.
  30602. * 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.
  30603. * Values less than zero provide a filter of opposite hue.
  30604. */
  30605. globalDensity: number;
  30606. /**
  30607. * Gets the global Saturation value.
  30608. * 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.
  30609. */
  30610. /**
  30611. * Sets the global Saturation value.
  30612. * 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.
  30613. */
  30614. globalSaturation: number;
  30615. /**
  30616. * Gets the global Exposure value.
  30617. * 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.
  30618. */
  30619. /**
  30620. * Sets the global Exposure value.
  30621. * 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.
  30622. */
  30623. globalExposure: number;
  30624. private _highlightsHue;
  30625. private _highlightsDensity;
  30626. private _highlightsSaturation;
  30627. private _highlightsExposure;
  30628. /**
  30629. * Gets the highlights Hue value.
  30630. * 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).
  30631. */
  30632. /**
  30633. * Sets the highlights Hue value.
  30634. * 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).
  30635. */
  30636. highlightsHue: number;
  30637. /**
  30638. * Gets the highlights Density value.
  30639. * 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.
  30640. * Values less than zero provide a filter of opposite hue.
  30641. */
  30642. /**
  30643. * Sets the highlights Density value.
  30644. * 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.
  30645. * Values less than zero provide a filter of opposite hue.
  30646. */
  30647. highlightsDensity: number;
  30648. /**
  30649. * Gets the highlights Saturation value.
  30650. * 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.
  30651. */
  30652. /**
  30653. * Sets the highlights Saturation value.
  30654. * 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.
  30655. */
  30656. highlightsSaturation: number;
  30657. /**
  30658. * Gets the highlights Exposure value.
  30659. * 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.
  30660. */
  30661. /**
  30662. * Sets the highlights Exposure value.
  30663. * 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.
  30664. */
  30665. highlightsExposure: number;
  30666. private _midtonesHue;
  30667. private _midtonesDensity;
  30668. private _midtonesSaturation;
  30669. private _midtonesExposure;
  30670. /**
  30671. * Gets the midtones Hue value.
  30672. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  30673. */
  30674. /**
  30675. * Sets the midtones Hue value.
  30676. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  30677. */
  30678. midtonesHue: number;
  30679. /**
  30680. * Gets the midtones Density value.
  30681. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  30682. * Values less than zero provide a filter of opposite hue.
  30683. */
  30684. /**
  30685. * Sets the midtones Density value.
  30686. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  30687. * Values less than zero provide a filter of opposite hue.
  30688. */
  30689. midtonesDensity: number;
  30690. /**
  30691. * Gets the midtones Saturation value.
  30692. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  30693. */
  30694. /**
  30695. * Sets the midtones Saturation value.
  30696. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  30697. */
  30698. midtonesSaturation: number;
  30699. /**
  30700. * Gets the midtones Exposure value.
  30701. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30702. */
  30703. /**
  30704. * Sets the midtones Exposure value.
  30705. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30706. */
  30707. midtonesExposure: number;
  30708. private _shadowsHue;
  30709. private _shadowsDensity;
  30710. private _shadowsSaturation;
  30711. private _shadowsExposure;
  30712. /**
  30713. * Gets the shadows Hue value.
  30714. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  30715. */
  30716. /**
  30717. * Sets the shadows Hue value.
  30718. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  30719. */
  30720. shadowsHue: number;
  30721. /**
  30722. * Gets the shadows Density value.
  30723. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  30724. * Values less than zero provide a filter of opposite hue.
  30725. */
  30726. /**
  30727. * Sets the shadows Density value.
  30728. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  30729. * Values less than zero provide a filter of opposite hue.
  30730. */
  30731. shadowsDensity: number;
  30732. /**
  30733. * Gets the shadows Saturation value.
  30734. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  30735. */
  30736. /**
  30737. * Sets the shadows Saturation value.
  30738. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  30739. */
  30740. shadowsSaturation: number;
  30741. /**
  30742. * Gets the shadows Exposure value.
  30743. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30744. */
  30745. /**
  30746. * Sets the shadows Exposure value.
  30747. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30748. */
  30749. shadowsExposure: number;
  30750. /**
  30751. * Returns the class name
  30752. * @returns The class name
  30753. */
  30754. getClassName(): string;
  30755. /**
  30756. * Binds the color curves to the shader.
  30757. * @param colorCurves The color curve to bind
  30758. * @param effect The effect to bind to
  30759. * @param positiveUniform The positive uniform shader parameter
  30760. * @param neutralUniform The neutral uniform shader parameter
  30761. * @param negativeUniform The negative uniform shader parameter
  30762. */
  30763. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30764. /**
  30765. * Prepare the list of uniforms associated with the ColorCurves effects.
  30766. * @param uniformsList The list of uniforms used in the effect
  30767. */
  30768. static PrepareUniforms(uniformsList: string[]): void;
  30769. /**
  30770. * Returns color grading data based on a hue, density, saturation and exposure value.
  30771. * @param filterHue The hue of the color filter.
  30772. * @param filterDensity The density of the color filter.
  30773. * @param saturation The saturation.
  30774. * @param exposure The exposure.
  30775. * @param result The result data container.
  30776. */
  30777. private getColorGradingDataToRef;
  30778. /**
  30779. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30780. * @param value The input slider value in range [-100,100].
  30781. * @returns Adjusted value.
  30782. */
  30783. private static applyColorGradingSliderNonlinear;
  30784. /**
  30785. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30786. * @param hue The hue (H) input.
  30787. * @param saturation The saturation (S) input.
  30788. * @param brightness The brightness (B) input.
  30789. * @result An RGBA color represented as Vector4.
  30790. */
  30791. private static fromHSBToRef;
  30792. /**
  30793. * Returns a value clamped between min and max
  30794. * @param value The value to clamp
  30795. * @param min The minimum of value
  30796. * @param max The maximum of value
  30797. * @returns The clamped value.
  30798. */
  30799. private static clamp;
  30800. /**
  30801. * Clones the current color curve instance.
  30802. * @return The cloned curves
  30803. */
  30804. clone(): ColorCurves;
  30805. /**
  30806. * Serializes the current color curve instance to a json representation.
  30807. * @return a JSON representation
  30808. */
  30809. serialize(): any;
  30810. /**
  30811. * Parses the color curve from a json representation.
  30812. * @param source the JSON source to parse
  30813. * @return The parsed curves
  30814. */
  30815. static Parse(source: any): ColorCurves;
  30816. }
  30817. }
  30818. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30819. import { Observable } from "babylonjs/Misc/observable";
  30820. import { Nullable } from "babylonjs/types";
  30821. import { Color4 } from "babylonjs/Maths/math";
  30822. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30823. import { Effect } from "babylonjs/Materials/effect";
  30824. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30825. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30826. /**
  30827. * Interface to follow in your material defines to integrate easily the
  30828. * Image proccessing functions.
  30829. * @hidden
  30830. */
  30831. export interface IImageProcessingConfigurationDefines {
  30832. IMAGEPROCESSING: boolean;
  30833. VIGNETTE: boolean;
  30834. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30835. VIGNETTEBLENDMODEOPAQUE: boolean;
  30836. TONEMAPPING: boolean;
  30837. TONEMAPPING_ACES: boolean;
  30838. CONTRAST: boolean;
  30839. EXPOSURE: boolean;
  30840. COLORCURVES: boolean;
  30841. COLORGRADING: boolean;
  30842. COLORGRADING3D: boolean;
  30843. SAMPLER3DGREENDEPTH: boolean;
  30844. SAMPLER3DBGRMAP: boolean;
  30845. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30846. }
  30847. /**
  30848. * @hidden
  30849. */
  30850. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30851. IMAGEPROCESSING: boolean;
  30852. VIGNETTE: boolean;
  30853. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30854. VIGNETTEBLENDMODEOPAQUE: boolean;
  30855. TONEMAPPING: boolean;
  30856. TONEMAPPING_ACES: boolean;
  30857. CONTRAST: boolean;
  30858. COLORCURVES: boolean;
  30859. COLORGRADING: boolean;
  30860. COLORGRADING3D: boolean;
  30861. SAMPLER3DGREENDEPTH: boolean;
  30862. SAMPLER3DBGRMAP: boolean;
  30863. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30864. EXPOSURE: boolean;
  30865. constructor();
  30866. }
  30867. /**
  30868. * This groups together the common properties used for image processing either in direct forward pass
  30869. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30870. * or not.
  30871. */
  30872. export class ImageProcessingConfiguration {
  30873. /**
  30874. * Default tone mapping applied in BabylonJS.
  30875. */
  30876. static readonly TONEMAPPING_STANDARD: number;
  30877. /**
  30878. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30879. * to other engines rendering to increase portability.
  30880. */
  30881. static readonly TONEMAPPING_ACES: number;
  30882. /**
  30883. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30884. */
  30885. colorCurves: Nullable<ColorCurves>;
  30886. private _colorCurvesEnabled;
  30887. /**
  30888. * Gets wether the color curves effect is enabled.
  30889. */
  30890. /**
  30891. * Sets wether the color curves effect is enabled.
  30892. */
  30893. colorCurvesEnabled: boolean;
  30894. private _colorGradingTexture;
  30895. /**
  30896. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30897. */
  30898. /**
  30899. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30900. */
  30901. colorGradingTexture: Nullable<BaseTexture>;
  30902. private _colorGradingEnabled;
  30903. /**
  30904. * Gets wether the color grading effect is enabled.
  30905. */
  30906. /**
  30907. * Sets wether the color grading effect is enabled.
  30908. */
  30909. colorGradingEnabled: boolean;
  30910. private _colorGradingWithGreenDepth;
  30911. /**
  30912. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30913. */
  30914. /**
  30915. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30916. */
  30917. colorGradingWithGreenDepth: boolean;
  30918. private _colorGradingBGR;
  30919. /**
  30920. * Gets wether the color grading texture contains BGR values.
  30921. */
  30922. /**
  30923. * Sets wether the color grading texture contains BGR values.
  30924. */
  30925. colorGradingBGR: boolean;
  30926. /** @hidden */
  30927. _exposure: number;
  30928. /**
  30929. * Gets the Exposure used in the effect.
  30930. */
  30931. /**
  30932. * Sets the Exposure used in the effect.
  30933. */
  30934. exposure: number;
  30935. private _toneMappingEnabled;
  30936. /**
  30937. * Gets wether the tone mapping effect is enabled.
  30938. */
  30939. /**
  30940. * Sets wether the tone mapping effect is enabled.
  30941. */
  30942. toneMappingEnabled: boolean;
  30943. private _toneMappingType;
  30944. /**
  30945. * Gets the type of tone mapping effect.
  30946. */
  30947. /**
  30948. * Sets the type of tone mapping effect used in BabylonJS.
  30949. */
  30950. toneMappingType: number;
  30951. protected _contrast: number;
  30952. /**
  30953. * Gets the contrast used in the effect.
  30954. */
  30955. /**
  30956. * Sets the contrast used in the effect.
  30957. */
  30958. contrast: number;
  30959. /**
  30960. * Vignette stretch size.
  30961. */
  30962. vignetteStretch: number;
  30963. /**
  30964. * Vignette centre X Offset.
  30965. */
  30966. vignetteCentreX: number;
  30967. /**
  30968. * Vignette centre Y Offset.
  30969. */
  30970. vignetteCentreY: number;
  30971. /**
  30972. * Vignette weight or intensity of the vignette effect.
  30973. */
  30974. vignetteWeight: number;
  30975. /**
  30976. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30977. * if vignetteEnabled is set to true.
  30978. */
  30979. vignetteColor: Color4;
  30980. /**
  30981. * Camera field of view used by the Vignette effect.
  30982. */
  30983. vignetteCameraFov: number;
  30984. private _vignetteBlendMode;
  30985. /**
  30986. * Gets the vignette blend mode allowing different kind of effect.
  30987. */
  30988. /**
  30989. * Sets the vignette blend mode allowing different kind of effect.
  30990. */
  30991. vignetteBlendMode: number;
  30992. private _vignetteEnabled;
  30993. /**
  30994. * Gets wether the vignette effect is enabled.
  30995. */
  30996. /**
  30997. * Sets wether the vignette effect is enabled.
  30998. */
  30999. vignetteEnabled: boolean;
  31000. private _applyByPostProcess;
  31001. /**
  31002. * Gets wether the image processing is applied through a post process or not.
  31003. */
  31004. /**
  31005. * Sets wether the image processing is applied through a post process or not.
  31006. */
  31007. applyByPostProcess: boolean;
  31008. private _isEnabled;
  31009. /**
  31010. * Gets wether the image processing is enabled or not.
  31011. */
  31012. /**
  31013. * Sets wether the image processing is enabled or not.
  31014. */
  31015. isEnabled: boolean;
  31016. /**
  31017. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  31018. */
  31019. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  31020. /**
  31021. * Method called each time the image processing information changes requires to recompile the effect.
  31022. */
  31023. protected _updateParameters(): void;
  31024. /**
  31025. * Gets the current class name.
  31026. * @return "ImageProcessingConfiguration"
  31027. */
  31028. getClassName(): string;
  31029. /**
  31030. * Prepare the list of uniforms associated with the Image Processing effects.
  31031. * @param uniforms The list of uniforms used in the effect
  31032. * @param defines the list of defines currently in use
  31033. */
  31034. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31035. /**
  31036. * Prepare the list of samplers associated with the Image Processing effects.
  31037. * @param samplersList The list of uniforms used in the effect
  31038. * @param defines the list of defines currently in use
  31039. */
  31040. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31041. /**
  31042. * Prepare the list of defines associated to the shader.
  31043. * @param defines the list of defines to complete
  31044. * @param forPostProcess Define if we are currently in post process mode or not
  31045. */
  31046. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31047. /**
  31048. * Returns true if all the image processing information are ready.
  31049. * @returns True if ready, otherwise, false
  31050. */
  31051. isReady(): boolean;
  31052. /**
  31053. * Binds the image processing to the shader.
  31054. * @param effect The effect to bind to
  31055. * @param aspectRatio Define the current aspect ratio of the effect
  31056. */
  31057. bind(effect: Effect, aspectRatio?: number): void;
  31058. /**
  31059. * Clones the current image processing instance.
  31060. * @return The cloned image processing
  31061. */
  31062. clone(): ImageProcessingConfiguration;
  31063. /**
  31064. * Serializes the current image processing instance to a json representation.
  31065. * @return a JSON representation
  31066. */
  31067. serialize(): any;
  31068. /**
  31069. * Parses the image processing from a json representation.
  31070. * @param source the JSON source to parse
  31071. * @return The parsed image processing
  31072. */
  31073. static Parse(source: any): ImageProcessingConfiguration;
  31074. private static _VIGNETTEMODE_MULTIPLY;
  31075. private static _VIGNETTEMODE_OPAQUE;
  31076. /**
  31077. * Used to apply the vignette as a mix with the pixel color.
  31078. */
  31079. static readonly VIGNETTEMODE_MULTIPLY: number;
  31080. /**
  31081. * Used to apply the vignette as a replacement of the pixel color.
  31082. */
  31083. static readonly VIGNETTEMODE_OPAQUE: number;
  31084. }
  31085. }
  31086. declare module "babylonjs/Materials/fresnelParameters" {
  31087. import { Color3 } from "babylonjs/Maths/math";
  31088. /**
  31089. * This represents all the required information to add a fresnel effect on a material:
  31090. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31091. */
  31092. export class FresnelParameters {
  31093. private _isEnabled;
  31094. /**
  31095. * Define if the fresnel effect is enable or not.
  31096. */
  31097. isEnabled: boolean;
  31098. /**
  31099. * Define the color used on edges (grazing angle)
  31100. */
  31101. leftColor: Color3;
  31102. /**
  31103. * Define the color used on center
  31104. */
  31105. rightColor: Color3;
  31106. /**
  31107. * Define bias applied to computed fresnel term
  31108. */
  31109. bias: number;
  31110. /**
  31111. * Defined the power exponent applied to fresnel term
  31112. */
  31113. power: number;
  31114. /**
  31115. * Clones the current fresnel and its valuues
  31116. * @returns a clone fresnel configuration
  31117. */
  31118. clone(): FresnelParameters;
  31119. /**
  31120. * Serializes the current fresnel parameters to a JSON representation.
  31121. * @return the JSON serialization
  31122. */
  31123. serialize(): any;
  31124. /**
  31125. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31126. * @param parsedFresnelParameters Define the JSON representation
  31127. * @returns the parsed parameters
  31128. */
  31129. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31130. }
  31131. }
  31132. declare module "babylonjs/Misc/decorators" {
  31133. import { Nullable } from "babylonjs/types";
  31134. import { Scene } from "babylonjs/scene";
  31135. import { IAnimatable } from "babylonjs/Misc/tools";
  31136. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31137. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31138. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31139. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31140. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31141. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31142. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31143. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31144. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31145. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31146. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31147. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31148. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31149. /**
  31150. * Decorator used to define property that can be serialized as reference to a camera
  31151. * @param sourceName defines the name of the property to decorate
  31152. */
  31153. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31154. /**
  31155. * Class used to help serialization objects
  31156. */
  31157. export class SerializationHelper {
  31158. /** @hidden */
  31159. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31160. /** @hidden */
  31161. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31162. /** @hidden */
  31163. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31164. /** @hidden */
  31165. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31166. /**
  31167. * Appends the serialized animations from the source animations
  31168. * @param source Source containing the animations
  31169. * @param destination Target to store the animations
  31170. */
  31171. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31172. /**
  31173. * Static function used to serialized a specific entity
  31174. * @param entity defines the entity to serialize
  31175. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31176. * @returns a JSON compatible object representing the serialization of the entity
  31177. */
  31178. static Serialize<T>(entity: T, serializationObject?: any): any;
  31179. /**
  31180. * Creates a new entity from a serialization data object
  31181. * @param creationFunction defines a function used to instanciated the new entity
  31182. * @param source defines the source serialization data
  31183. * @param scene defines the hosting scene
  31184. * @param rootUrl defines the root url for resources
  31185. * @returns a new entity
  31186. */
  31187. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31188. /**
  31189. * Clones an object
  31190. * @param creationFunction defines the function used to instanciate the new object
  31191. * @param source defines the source object
  31192. * @returns the cloned object
  31193. */
  31194. static Clone<T>(creationFunction: () => T, source: T): T;
  31195. /**
  31196. * Instanciates a new object based on a source one (some data will be shared between both object)
  31197. * @param creationFunction defines the function used to instanciate the new object
  31198. * @param source defines the source object
  31199. * @returns the new object
  31200. */
  31201. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31202. }
  31203. }
  31204. declare module "babylonjs/Cameras/camera" {
  31205. import { SmartArray } from "babylonjs/Misc/smartArray";
  31206. import { Observable } from "babylonjs/Misc/observable";
  31207. import { Nullable } from "babylonjs/types";
  31208. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31209. import { Scene } from "babylonjs/scene";
  31210. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31211. import { Node } from "babylonjs/node";
  31212. import { Mesh } from "babylonjs/Meshes/mesh";
  31213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31214. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31215. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31216. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31217. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31218. import { Ray } from "babylonjs/Culling/ray";
  31219. /**
  31220. * This is the base class of all the camera used in the application.
  31221. * @see http://doc.babylonjs.com/features/cameras
  31222. */
  31223. export class Camera extends Node {
  31224. /** @hidden */
  31225. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31226. /**
  31227. * This is the default projection mode used by the cameras.
  31228. * It helps recreating a feeling of perspective and better appreciate depth.
  31229. * This is the best way to simulate real life cameras.
  31230. */
  31231. static readonly PERSPECTIVE_CAMERA: number;
  31232. /**
  31233. * This helps creating camera with an orthographic mode.
  31234. * 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.
  31235. */
  31236. static readonly ORTHOGRAPHIC_CAMERA: number;
  31237. /**
  31238. * This is the default FOV mode for perspective cameras.
  31239. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31240. */
  31241. static readonly FOVMODE_VERTICAL_FIXED: number;
  31242. /**
  31243. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31244. */
  31245. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31246. /**
  31247. * This specifies ther is no need for a camera rig.
  31248. * Basically only one eye is rendered corresponding to the camera.
  31249. */
  31250. static readonly RIG_MODE_NONE: number;
  31251. /**
  31252. * Simulates a camera Rig with one blue eye and one red eye.
  31253. * This can be use with 3d blue and red glasses.
  31254. */
  31255. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31256. /**
  31257. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31258. */
  31259. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31260. /**
  31261. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31262. */
  31263. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31264. /**
  31265. * Defines that both eyes of the camera will be rendered over under each other.
  31266. */
  31267. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31268. /**
  31269. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31270. */
  31271. static readonly RIG_MODE_VR: number;
  31272. /**
  31273. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31274. */
  31275. static readonly RIG_MODE_WEBVR: number;
  31276. /**
  31277. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31278. */
  31279. static readonly RIG_MODE_CUSTOM: number;
  31280. /**
  31281. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31282. */
  31283. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31284. /**
  31285. * Define the input manager associated with the camera.
  31286. */
  31287. inputs: CameraInputsManager<Camera>;
  31288. /** @hidden */
  31289. _position: Vector3;
  31290. /**
  31291. * Define the current local position of the camera in the scene
  31292. */
  31293. position: Vector3;
  31294. /**
  31295. * The vector the camera should consider as up.
  31296. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31297. */
  31298. upVector: Vector3;
  31299. /**
  31300. * Define the current limit on the left side for an orthographic camera
  31301. * In scene unit
  31302. */
  31303. orthoLeft: Nullable<number>;
  31304. /**
  31305. * Define the current limit on the right side for an orthographic camera
  31306. * In scene unit
  31307. */
  31308. orthoRight: Nullable<number>;
  31309. /**
  31310. * Define the current limit on the bottom side for an orthographic camera
  31311. * In scene unit
  31312. */
  31313. orthoBottom: Nullable<number>;
  31314. /**
  31315. * Define the current limit on the top side for an orthographic camera
  31316. * In scene unit
  31317. */
  31318. orthoTop: Nullable<number>;
  31319. /**
  31320. * Field Of View is set in Radians. (default is 0.8)
  31321. */
  31322. fov: number;
  31323. /**
  31324. * Define the minimum distance the camera can see from.
  31325. * This is important to note that the depth buffer are not infinite and the closer it starts
  31326. * the more your scene might encounter depth fighting issue.
  31327. */
  31328. minZ: number;
  31329. /**
  31330. * Define the maximum distance the camera can see to.
  31331. * This is important to note that the depth buffer are not infinite and the further it end
  31332. * the more your scene might encounter depth fighting issue.
  31333. */
  31334. maxZ: number;
  31335. /**
  31336. * Define the default inertia of the camera.
  31337. * This helps giving a smooth feeling to the camera movement.
  31338. */
  31339. inertia: number;
  31340. /**
  31341. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31342. */
  31343. mode: number;
  31344. /**
  31345. * Define wether the camera is intermediate.
  31346. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31347. */
  31348. isIntermediate: boolean;
  31349. /**
  31350. * Define the viewport of the camera.
  31351. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31352. */
  31353. viewport: Viewport;
  31354. /**
  31355. * Restricts the camera to viewing objects with the same layerMask.
  31356. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31357. */
  31358. layerMask: number;
  31359. /**
  31360. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31361. */
  31362. fovMode: number;
  31363. /**
  31364. * Rig mode of the camera.
  31365. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31366. * This is normally controlled byt the camera themselves as internal use.
  31367. */
  31368. cameraRigMode: number;
  31369. /**
  31370. * Defines the distance between both "eyes" in case of a RIG
  31371. */
  31372. interaxialDistance: number;
  31373. /**
  31374. * Defines if stereoscopic rendering is done side by side or over under.
  31375. */
  31376. isStereoscopicSideBySide: boolean;
  31377. /**
  31378. * 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
  31379. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31380. * else in the scene.
  31381. */
  31382. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31383. /**
  31384. * When set, the camera will render to this render target instead of the default canvas
  31385. */
  31386. outputRenderTarget: Nullable<RenderTargetTexture>;
  31387. /**
  31388. * Observable triggered when the camera view matrix has changed.
  31389. */
  31390. onViewMatrixChangedObservable: Observable<Camera>;
  31391. /**
  31392. * Observable triggered when the camera Projection matrix has changed.
  31393. */
  31394. onProjectionMatrixChangedObservable: Observable<Camera>;
  31395. /**
  31396. * Observable triggered when the inputs have been processed.
  31397. */
  31398. onAfterCheckInputsObservable: Observable<Camera>;
  31399. /**
  31400. * Observable triggered when reset has been called and applied to the camera.
  31401. */
  31402. onRestoreStateObservable: Observable<Camera>;
  31403. /** @hidden */
  31404. _cameraRigParams: any;
  31405. /** @hidden */
  31406. _rigCameras: Camera[];
  31407. /** @hidden */
  31408. _rigPostProcess: Nullable<PostProcess>;
  31409. protected _webvrViewMatrix: Matrix;
  31410. /** @hidden */
  31411. _skipRendering: boolean;
  31412. /** @hidden */
  31413. _projectionMatrix: Matrix;
  31414. /** @hidden */
  31415. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31416. /** @hidden */
  31417. _activeMeshes: SmartArray<AbstractMesh>;
  31418. protected _globalPosition: Vector3;
  31419. /** @hidden */
  31420. _computedViewMatrix: Matrix;
  31421. private _doNotComputeProjectionMatrix;
  31422. private _transformMatrix;
  31423. private _frustumPlanes;
  31424. private _refreshFrustumPlanes;
  31425. private _storedFov;
  31426. private _stateStored;
  31427. /**
  31428. * Instantiates a new camera object.
  31429. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31430. * @see http://doc.babylonjs.com/features/cameras
  31431. * @param name Defines the name of the camera in the scene
  31432. * @param position Defines the position of the camera
  31433. * @param scene Defines the scene the camera belongs too
  31434. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31435. */
  31436. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31437. /**
  31438. * Store current camera state (fov, position, etc..)
  31439. * @returns the camera
  31440. */
  31441. storeState(): Camera;
  31442. /**
  31443. * Restores the camera state values if it has been stored. You must call storeState() first
  31444. */
  31445. protected _restoreStateValues(): boolean;
  31446. /**
  31447. * Restored camera state. You must call storeState() first.
  31448. * @returns true if restored and false otherwise
  31449. */
  31450. restoreState(): boolean;
  31451. /**
  31452. * Gets the class name of the camera.
  31453. * @returns the class name
  31454. */
  31455. getClassName(): string;
  31456. /** @hidden */
  31457. readonly _isCamera: boolean;
  31458. /**
  31459. * Gets a string representation of the camera useful for debug purpose.
  31460. * @param fullDetails Defines that a more verboe level of logging is required
  31461. * @returns the string representation
  31462. */
  31463. toString(fullDetails?: boolean): string;
  31464. /**
  31465. * Gets the current world space position of the camera.
  31466. */
  31467. readonly globalPosition: Vector3;
  31468. /**
  31469. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31470. * @returns the active meshe list
  31471. */
  31472. getActiveMeshes(): SmartArray<AbstractMesh>;
  31473. /**
  31474. * Check wether a mesh is part of the current active mesh list of the camera
  31475. * @param mesh Defines the mesh to check
  31476. * @returns true if active, false otherwise
  31477. */
  31478. isActiveMesh(mesh: Mesh): boolean;
  31479. /**
  31480. * Is this camera ready to be used/rendered
  31481. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31482. * @return true if the camera is ready
  31483. */
  31484. isReady(completeCheck?: boolean): boolean;
  31485. /** @hidden */
  31486. _initCache(): void;
  31487. /** @hidden */
  31488. _updateCache(ignoreParentClass?: boolean): void;
  31489. /** @hidden */
  31490. _isSynchronized(): boolean;
  31491. /** @hidden */
  31492. _isSynchronizedViewMatrix(): boolean;
  31493. /** @hidden */
  31494. _isSynchronizedProjectionMatrix(): boolean;
  31495. /**
  31496. * Attach the input controls to a specific dom element to get the input from.
  31497. * @param element Defines the element the controls should be listened from
  31498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31499. */
  31500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31501. /**
  31502. * Detach the current controls from the specified dom element.
  31503. * @param element Defines the element to stop listening the inputs from
  31504. */
  31505. detachControl(element: HTMLElement): void;
  31506. /**
  31507. * Update the camera state according to the different inputs gathered during the frame.
  31508. */
  31509. update(): void;
  31510. /** @hidden */
  31511. _checkInputs(): void;
  31512. /** @hidden */
  31513. readonly rigCameras: Camera[];
  31514. /**
  31515. * Gets the post process used by the rig cameras
  31516. */
  31517. readonly rigPostProcess: Nullable<PostProcess>;
  31518. /**
  31519. * Internal, gets the first post proces.
  31520. * @returns the first post process to be run on this camera.
  31521. */
  31522. _getFirstPostProcess(): Nullable<PostProcess>;
  31523. private _cascadePostProcessesToRigCams;
  31524. /**
  31525. * Attach a post process to the camera.
  31526. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31527. * @param postProcess The post process to attach to the camera
  31528. * @param insertAt The position of the post process in case several of them are in use in the scene
  31529. * @returns the position the post process has been inserted at
  31530. */
  31531. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31532. /**
  31533. * Detach a post process to the camera.
  31534. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31535. * @param postProcess The post process to detach from the camera
  31536. */
  31537. detachPostProcess(postProcess: PostProcess): void;
  31538. /**
  31539. * Gets the current world matrix of the camera
  31540. */
  31541. getWorldMatrix(): Matrix;
  31542. /** @hidden */
  31543. _getViewMatrix(): Matrix;
  31544. /**
  31545. * Gets the current view matrix of the camera.
  31546. * @param force forces the camera to recompute the matrix without looking at the cached state
  31547. * @returns the view matrix
  31548. */
  31549. getViewMatrix(force?: boolean): Matrix;
  31550. /**
  31551. * Freeze the projection matrix.
  31552. * It will prevent the cache check of the camera projection compute and can speed up perf
  31553. * if no parameter of the camera are meant to change
  31554. * @param projection Defines manually a projection if necessary
  31555. */
  31556. freezeProjectionMatrix(projection?: Matrix): void;
  31557. /**
  31558. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31559. */
  31560. unfreezeProjectionMatrix(): void;
  31561. /**
  31562. * Gets the current projection matrix of the camera.
  31563. * @param force forces the camera to recompute the matrix without looking at the cached state
  31564. * @returns the projection matrix
  31565. */
  31566. getProjectionMatrix(force?: boolean): Matrix;
  31567. /**
  31568. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31569. * @returns a Matrix
  31570. */
  31571. getTransformationMatrix(): Matrix;
  31572. private _updateFrustumPlanes;
  31573. /**
  31574. * Checks if a cullable object (mesh...) is in the camera frustum
  31575. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31576. * @param target The object to check
  31577. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31578. * @returns true if the object is in frustum otherwise false
  31579. */
  31580. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31581. /**
  31582. * Checks if a cullable object (mesh...) is in the camera frustum
  31583. * Unlike isInFrustum this cheks the full bounding box
  31584. * @param target The object to check
  31585. * @returns true if the object is in frustum otherwise false
  31586. */
  31587. isCompletelyInFrustum(target: ICullable): boolean;
  31588. /**
  31589. * Gets a ray in the forward direction from the camera.
  31590. * @param length Defines the length of the ray to create
  31591. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31592. * @param origin Defines the start point of the ray which defaults to the camera position
  31593. * @returns the forward ray
  31594. */
  31595. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31596. /**
  31597. * Releases resources associated with this node.
  31598. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31599. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31600. */
  31601. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31602. /** @hidden */
  31603. _isLeftCamera: boolean;
  31604. /**
  31605. * Gets the left camera of a rig setup in case of Rigged Camera
  31606. */
  31607. readonly isLeftCamera: boolean;
  31608. /** @hidden */
  31609. _isRightCamera: boolean;
  31610. /**
  31611. * Gets the right camera of a rig setup in case of Rigged Camera
  31612. */
  31613. readonly isRightCamera: boolean;
  31614. /**
  31615. * Gets the left camera of a rig setup in case of Rigged Camera
  31616. */
  31617. readonly leftCamera: Nullable<FreeCamera>;
  31618. /**
  31619. * Gets the right camera of a rig setup in case of Rigged Camera
  31620. */
  31621. readonly rightCamera: Nullable<FreeCamera>;
  31622. /**
  31623. * Gets the left camera target of a rig setup in case of Rigged Camera
  31624. * @returns the target position
  31625. */
  31626. getLeftTarget(): Nullable<Vector3>;
  31627. /**
  31628. * Gets the right camera target of a rig setup in case of Rigged Camera
  31629. * @returns the target position
  31630. */
  31631. getRightTarget(): Nullable<Vector3>;
  31632. /**
  31633. * @hidden
  31634. */
  31635. setCameraRigMode(mode: number, rigParams: any): void;
  31636. /** @hidden */
  31637. static _setStereoscopicRigMode(camera: Camera): void;
  31638. /** @hidden */
  31639. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31640. /** @hidden */
  31641. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31642. /** @hidden */
  31643. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31644. /** @hidden */
  31645. _getVRProjectionMatrix(): Matrix;
  31646. protected _updateCameraRotationMatrix(): void;
  31647. protected _updateWebVRCameraRotationMatrix(): void;
  31648. /**
  31649. * This function MUST be overwritten by the different WebVR cameras available.
  31650. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31651. * @hidden
  31652. */
  31653. _getWebVRProjectionMatrix(): Matrix;
  31654. /**
  31655. * This function MUST be overwritten by the different WebVR cameras available.
  31656. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31657. * @hidden
  31658. */
  31659. _getWebVRViewMatrix(): Matrix;
  31660. /** @hidden */
  31661. setCameraRigParameter(name: string, value: any): void;
  31662. /**
  31663. * needs to be overridden by children so sub has required properties to be copied
  31664. * @hidden
  31665. */
  31666. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31667. /**
  31668. * May need to be overridden by children
  31669. * @hidden
  31670. */
  31671. _updateRigCameras(): void;
  31672. /** @hidden */
  31673. _setupInputs(): void;
  31674. /**
  31675. * Serialiaze the camera setup to a json represention
  31676. * @returns the JSON representation
  31677. */
  31678. serialize(): any;
  31679. /**
  31680. * Clones the current camera.
  31681. * @param name The cloned camera name
  31682. * @returns the cloned camera
  31683. */
  31684. clone(name: string): Camera;
  31685. /**
  31686. * Gets the direction of the camera relative to a given local axis.
  31687. * @param localAxis Defines the reference axis to provide a relative direction.
  31688. * @return the direction
  31689. */
  31690. getDirection(localAxis: Vector3): Vector3;
  31691. /**
  31692. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31693. * @param localAxis Defines the reference axis to provide a relative direction.
  31694. * @param result Defines the vector to store the result in
  31695. */
  31696. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31697. /**
  31698. * Gets a camera constructor for a given camera type
  31699. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31700. * @param name The name of the camera the result will be able to instantiate
  31701. * @param scene The scene the result will construct the camera in
  31702. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31703. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31704. * @returns a factory method to construc the camera
  31705. */
  31706. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31707. /**
  31708. * Compute the world matrix of the camera.
  31709. * @returns the camera workd matrix
  31710. */
  31711. computeWorldMatrix(): Matrix;
  31712. /**
  31713. * Parse a JSON and creates the camera from the parsed information
  31714. * @param parsedCamera The JSON to parse
  31715. * @param scene The scene to instantiate the camera in
  31716. * @returns the newly constructed camera
  31717. */
  31718. static Parse(parsedCamera: any, scene: Scene): Camera;
  31719. }
  31720. }
  31721. declare module "babylonjs/Misc/tools" {
  31722. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31723. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31724. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31725. import { Observable } from "babylonjs/Misc/observable";
  31726. import { DomManagement } from "babylonjs/Misc/domManagement";
  31727. import { WebRequest } from "babylonjs/Misc/webRequest";
  31728. import { Camera } from "babylonjs/Cameras/camera";
  31729. import { Engine } from "babylonjs/Engines/engine";
  31730. import { Animation } from "babylonjs/Animations/animation";
  31731. /**
  31732. * Interface for any object that can request an animation frame
  31733. */
  31734. export interface ICustomAnimationFrameRequester {
  31735. /**
  31736. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31737. */
  31738. renderFunction?: Function;
  31739. /**
  31740. * Called to request the next frame to render to
  31741. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31742. */
  31743. requestAnimationFrame: Function;
  31744. /**
  31745. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31746. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31747. */
  31748. requestID?: number;
  31749. }
  31750. /**
  31751. * Interface containing an array of animations
  31752. */
  31753. export interface IAnimatable {
  31754. /**
  31755. * Array of animations
  31756. */
  31757. animations: Nullable<Array<Animation>>;
  31758. }
  31759. /** Interface used by value gradients (color, factor, ...) */
  31760. export interface IValueGradient {
  31761. /**
  31762. * Gets or sets the gradient value (between 0 and 1)
  31763. */
  31764. gradient: number;
  31765. }
  31766. /** Class used to store color4 gradient */
  31767. export class ColorGradient implements IValueGradient {
  31768. /**
  31769. * Gets or sets the gradient value (between 0 and 1)
  31770. */
  31771. gradient: number;
  31772. /**
  31773. * Gets or sets first associated color
  31774. */
  31775. color1: Color4;
  31776. /**
  31777. * Gets or sets second associated color
  31778. */
  31779. color2?: Color4;
  31780. /**
  31781. * Will get a color picked randomly between color1 and color2.
  31782. * If color2 is undefined then color1 will be used
  31783. * @param result defines the target Color4 to store the result in
  31784. */
  31785. getColorToRef(result: Color4): void;
  31786. }
  31787. /** Class used to store color 3 gradient */
  31788. export class Color3Gradient implements IValueGradient {
  31789. /**
  31790. * Gets or sets the gradient value (between 0 and 1)
  31791. */
  31792. gradient: number;
  31793. /**
  31794. * Gets or sets the associated color
  31795. */
  31796. color: Color3;
  31797. }
  31798. /** Class used to store factor gradient */
  31799. export class FactorGradient implements IValueGradient {
  31800. /**
  31801. * Gets or sets the gradient value (between 0 and 1)
  31802. */
  31803. gradient: number;
  31804. /**
  31805. * Gets or sets first associated factor
  31806. */
  31807. factor1: number;
  31808. /**
  31809. * Gets or sets second associated factor
  31810. */
  31811. factor2?: number;
  31812. /**
  31813. * Will get a number picked randomly between factor1 and factor2.
  31814. * If factor2 is undefined then factor1 will be used
  31815. * @returns the picked number
  31816. */
  31817. getFactor(): number;
  31818. }
  31819. /**
  31820. * @ignore
  31821. * Application error to support additional information when loading a file
  31822. */
  31823. export class LoadFileError extends Error {
  31824. /** defines the optional web request */
  31825. request?: WebRequest | undefined;
  31826. private static _setPrototypeOf;
  31827. /**
  31828. * Creates a new LoadFileError
  31829. * @param message defines the message of the error
  31830. * @param request defines the optional web request
  31831. */
  31832. constructor(message: string,
  31833. /** defines the optional web request */
  31834. request?: WebRequest | undefined);
  31835. }
  31836. /**
  31837. * Class used to define a retry strategy when error happens while loading assets
  31838. */
  31839. export class RetryStrategy {
  31840. /**
  31841. * Function used to defines an exponential back off strategy
  31842. * @param maxRetries defines the maximum number of retries (3 by default)
  31843. * @param baseInterval defines the interval between retries
  31844. * @returns the strategy function to use
  31845. */
  31846. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31847. }
  31848. /**
  31849. * File request interface
  31850. */
  31851. export interface IFileRequest {
  31852. /**
  31853. * Raised when the request is complete (success or error).
  31854. */
  31855. onCompleteObservable: Observable<IFileRequest>;
  31856. /**
  31857. * Aborts the request for a file.
  31858. */
  31859. abort: () => void;
  31860. }
  31861. /**
  31862. * Class containing a set of static utilities functions
  31863. */
  31864. export class Tools {
  31865. /**
  31866. * Gets or sets the base URL to use to load assets
  31867. */
  31868. static BaseUrl: string;
  31869. /**
  31870. * Enable/Disable Custom HTTP Request Headers globally.
  31871. * default = false
  31872. * @see CustomRequestHeaders
  31873. */
  31874. static UseCustomRequestHeaders: boolean;
  31875. /**
  31876. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31877. * i.e. when loading files, where the server/service expects an Authorization header
  31878. */
  31879. static CustomRequestHeaders: {
  31880. [key: string]: string;
  31881. };
  31882. /**
  31883. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31884. */
  31885. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31886. /**
  31887. * Default behaviour for cors in the application.
  31888. * It can be a string if the expected behavior is identical in the entire app.
  31889. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31890. */
  31891. static CorsBehavior: string | ((url: string | string[]) => string);
  31892. /**
  31893. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31894. * @ignorenaming
  31895. */
  31896. static UseFallbackTexture: boolean;
  31897. /**
  31898. * Use this object to register external classes like custom textures or material
  31899. * to allow the laoders to instantiate them
  31900. */
  31901. static RegisteredExternalClasses: {
  31902. [key: string]: Object;
  31903. };
  31904. /**
  31905. * Texture content used if a texture cannot loaded
  31906. * @ignorenaming
  31907. */
  31908. static fallbackTexture: string;
  31909. /**
  31910. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31911. * @param u defines the coordinate on X axis
  31912. * @param v defines the coordinate on Y axis
  31913. * @param width defines the width of the source data
  31914. * @param height defines the height of the source data
  31915. * @param pixels defines the source byte array
  31916. * @param color defines the output color
  31917. */
  31918. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31919. /**
  31920. * Interpolates between a and b via alpha
  31921. * @param a The lower value (returned when alpha = 0)
  31922. * @param b The upper value (returned when alpha = 1)
  31923. * @param alpha The interpolation-factor
  31924. * @return The mixed value
  31925. */
  31926. static Mix(a: number, b: number, alpha: number): number;
  31927. /**
  31928. * Tries to instantiate a new object from a given class name
  31929. * @param className defines the class name to instantiate
  31930. * @returns the new object or null if the system was not able to do the instantiation
  31931. */
  31932. static Instantiate(className: string): any;
  31933. /**
  31934. * Provides a slice function that will work even on IE
  31935. * @param data defines the array to slice
  31936. * @param start defines the start of the data (optional)
  31937. * @param end defines the end of the data (optional)
  31938. * @returns the new sliced array
  31939. */
  31940. static Slice<T>(data: T, start?: number, end?: number): T;
  31941. /**
  31942. * Polyfill for setImmediate
  31943. * @param action defines the action to execute after the current execution block
  31944. */
  31945. static SetImmediate(action: () => void): void;
  31946. /**
  31947. * Function indicating if a number is an exponent of 2
  31948. * @param value defines the value to test
  31949. * @returns true if the value is an exponent of 2
  31950. */
  31951. static IsExponentOfTwo(value: number): boolean;
  31952. private static _tmpFloatArray;
  31953. /**
  31954. * Returns the nearest 32-bit single precision float representation of a Number
  31955. * @param value A Number. If the parameter is of a different type, it will get converted
  31956. * to a number or to NaN if it cannot be converted
  31957. * @returns number
  31958. */
  31959. static FloatRound(value: number): number;
  31960. /**
  31961. * Find the next highest power of two.
  31962. * @param x Number to start search from.
  31963. * @return Next highest power of two.
  31964. */
  31965. static CeilingPOT(x: number): number;
  31966. /**
  31967. * Find the next lowest power of two.
  31968. * @param x Number to start search from.
  31969. * @return Next lowest power of two.
  31970. */
  31971. static FloorPOT(x: number): number;
  31972. /**
  31973. * Find the nearest power of two.
  31974. * @param x Number to start search from.
  31975. * @return Next nearest power of two.
  31976. */
  31977. static NearestPOT(x: number): number;
  31978. /**
  31979. * Get the closest exponent of two
  31980. * @param value defines the value to approximate
  31981. * @param max defines the maximum value to return
  31982. * @param mode defines how to define the closest value
  31983. * @returns closest exponent of two of the given value
  31984. */
  31985. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31986. /**
  31987. * Extracts the filename from a path
  31988. * @param path defines the path to use
  31989. * @returns the filename
  31990. */
  31991. static GetFilename(path: string): string;
  31992. /**
  31993. * Extracts the "folder" part of a path (everything before the filename).
  31994. * @param uri The URI to extract the info from
  31995. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31996. * @returns The "folder" part of the path
  31997. */
  31998. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31999. /**
  32000. * Extracts text content from a DOM element hierarchy
  32001. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32002. */
  32003. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32004. /**
  32005. * Convert an angle in radians to degrees
  32006. * @param angle defines the angle to convert
  32007. * @returns the angle in degrees
  32008. */
  32009. static ToDegrees(angle: number): number;
  32010. /**
  32011. * Convert an angle in degrees to radians
  32012. * @param angle defines the angle to convert
  32013. * @returns the angle in radians
  32014. */
  32015. static ToRadians(angle: number): number;
  32016. /**
  32017. * Encode a buffer to a base64 string
  32018. * @param buffer defines the buffer to encode
  32019. * @returns the encoded string
  32020. */
  32021. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32022. /**
  32023. * Extracts minimum and maximum values from a list of indexed positions
  32024. * @param positions defines the positions to use
  32025. * @param indices defines the indices to the positions
  32026. * @param indexStart defines the start index
  32027. * @param indexCount defines the end index
  32028. * @param bias defines bias value to add to the result
  32029. * @return minimum and maximum values
  32030. */
  32031. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32032. minimum: Vector3;
  32033. maximum: Vector3;
  32034. };
  32035. /**
  32036. * Extracts minimum and maximum values from a list of positions
  32037. * @param positions defines the positions to use
  32038. * @param start defines the start index in the positions array
  32039. * @param count defines the number of positions to handle
  32040. * @param bias defines bias value to add to the result
  32041. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32042. * @return minimum and maximum values
  32043. */
  32044. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32045. minimum: Vector3;
  32046. maximum: Vector3;
  32047. };
  32048. /**
  32049. * Returns an array if obj is not an array
  32050. * @param obj defines the object to evaluate as an array
  32051. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32052. * @returns either obj directly if obj is an array or a new array containing obj
  32053. */
  32054. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32055. /**
  32056. * Gets the pointer prefix to use
  32057. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32058. */
  32059. static GetPointerPrefix(): string;
  32060. /**
  32061. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32062. * @param func - the function to be called
  32063. * @param requester - the object that will request the next frame. Falls back to window.
  32064. * @returns frame number
  32065. */
  32066. static QueueNewFrame(func: () => void, requester?: any): number;
  32067. /**
  32068. * Ask the browser to promote the current element to fullscreen rendering mode
  32069. * @param element defines the DOM element to promote
  32070. */
  32071. static RequestFullscreen(element: HTMLElement): void;
  32072. /**
  32073. * Asks the browser to exit fullscreen mode
  32074. */
  32075. static ExitFullscreen(): void;
  32076. /**
  32077. * Ask the browser to promote the current element to pointerlock mode
  32078. * @param element defines the DOM element to promote
  32079. */
  32080. static RequestPointerlock(element: HTMLElement): void;
  32081. /**
  32082. * Asks the browser to exit pointerlock mode
  32083. */
  32084. static ExitPointerlock(): void;
  32085. /**
  32086. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32087. * @param url define the url we are trying
  32088. * @param element define the dom element where to configure the cors policy
  32089. */
  32090. static SetCorsBehavior(url: string | string[], element: {
  32091. crossOrigin: string | null;
  32092. }): void;
  32093. /**
  32094. * Removes unwanted characters from an url
  32095. * @param url defines the url to clean
  32096. * @returns the cleaned url
  32097. */
  32098. static CleanUrl(url: string): string;
  32099. /**
  32100. * Gets or sets a function used to pre-process url before using them to load assets
  32101. */
  32102. static PreprocessUrl: (url: string) => string;
  32103. /**
  32104. * Loads an image as an HTMLImageElement.
  32105. * @param input url string, ArrayBuffer, or Blob to load
  32106. * @param onLoad callback called when the image successfully loads
  32107. * @param onError callback called when the image fails to load
  32108. * @param offlineProvider offline provider for caching
  32109. * @returns the HTMLImageElement of the loaded image
  32110. */
  32111. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32112. /**
  32113. * Loads a file
  32114. * @param url url string, ArrayBuffer, or Blob to load
  32115. * @param onSuccess callback called when the file successfully loads
  32116. * @param onProgress callback called while file is loading (if the server supports this mode)
  32117. * @param offlineProvider defines the offline provider for caching
  32118. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32119. * @param onError callback called when the file fails to load
  32120. * @returns a file request object
  32121. */
  32122. 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;
  32123. /**
  32124. * Loads a file from a url
  32125. * @param url the file url to load
  32126. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32127. */
  32128. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32129. /**
  32130. * Load a script (identified by an url). When the url returns, the
  32131. * content of this file is added into a new script element, attached to the DOM (body element)
  32132. * @param scriptUrl defines the url of the script to laod
  32133. * @param onSuccess defines the callback called when the script is loaded
  32134. * @param onError defines the callback to call if an error occurs
  32135. * @param scriptId defines the id of the script element
  32136. */
  32137. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32138. /**
  32139. * Load an asynchronous script (identified by an url). When the url returns, the
  32140. * content of this file is added into a new script element, attached to the DOM (body element)
  32141. * @param scriptUrl defines the url of the script to laod
  32142. * @param scriptId defines the id of the script element
  32143. * @returns a promise request object
  32144. */
  32145. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32146. /**
  32147. * Loads a file from a blob
  32148. * @param fileToLoad defines the blob to use
  32149. * @param callback defines the callback to call when data is loaded
  32150. * @param progressCallback defines the callback to call during loading process
  32151. * @returns a file request object
  32152. */
  32153. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32154. /**
  32155. * Loads a file
  32156. * @param fileToLoad defines the file to load
  32157. * @param callback defines the callback to call when data is loaded
  32158. * @param progressCallBack defines the callback to call during loading process
  32159. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32160. * @returns a file request object
  32161. */
  32162. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32163. /**
  32164. * Creates a data url from a given string content
  32165. * @param content defines the content to convert
  32166. * @returns the new data url link
  32167. */
  32168. static FileAsURL(content: string): string;
  32169. /**
  32170. * Format the given number to a specific decimal format
  32171. * @param value defines the number to format
  32172. * @param decimals defines the number of decimals to use
  32173. * @returns the formatted string
  32174. */
  32175. static Format(value: number, decimals?: number): string;
  32176. /**
  32177. * Checks if a given vector is inside a specific range
  32178. * @param v defines the vector to test
  32179. * @param min defines the minimum range
  32180. * @param max defines the maximum range
  32181. */
  32182. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32183. /**
  32184. * Tries to copy an object by duplicating every property
  32185. * @param source defines the source object
  32186. * @param destination defines the target object
  32187. * @param doNotCopyList defines a list of properties to avoid
  32188. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32189. */
  32190. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32191. /**
  32192. * Gets a boolean indicating if the given object has no own property
  32193. * @param obj defines the object to test
  32194. * @returns true if object has no own property
  32195. */
  32196. static IsEmpty(obj: any): boolean;
  32197. /**
  32198. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32199. * @param str Source string
  32200. * @param suffix Suffix to search for in the source string
  32201. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32202. */
  32203. static EndsWith(str: string, suffix: string): boolean;
  32204. /**
  32205. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  32206. * @param str Source string
  32207. * @param suffix Suffix to search for in the source string
  32208. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32209. */
  32210. static StartsWith(str: string, suffix: string): boolean;
  32211. /**
  32212. * Function used to register events at window level
  32213. * @param events defines the events to register
  32214. */
  32215. static RegisterTopRootEvents(events: {
  32216. name: string;
  32217. handler: Nullable<(e: FocusEvent) => any>;
  32218. }[]): void;
  32219. /**
  32220. * Function used to unregister events from window level
  32221. * @param events defines the events to unregister
  32222. */
  32223. static UnregisterTopRootEvents(events: {
  32224. name: string;
  32225. handler: Nullable<(e: FocusEvent) => any>;
  32226. }[]): void;
  32227. /**
  32228. * @ignore
  32229. */
  32230. static _ScreenshotCanvas: HTMLCanvasElement;
  32231. /**
  32232. * Dumps the current bound framebuffer
  32233. * @param width defines the rendering width
  32234. * @param height defines the rendering height
  32235. * @param engine defines the hosting engine
  32236. * @param successCallback defines the callback triggered once the data are available
  32237. * @param mimeType defines the mime type of the result
  32238. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32239. */
  32240. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32241. /**
  32242. * Converts the canvas data to blob.
  32243. * This acts as a polyfill for browsers not supporting the to blob function.
  32244. * @param canvas Defines the canvas to extract the data from
  32245. * @param successCallback Defines the callback triggered once the data are available
  32246. * @param mimeType Defines the mime type of the result
  32247. */
  32248. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32249. /**
  32250. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32251. * @param successCallback defines the callback triggered once the data are available
  32252. * @param mimeType defines the mime type of the result
  32253. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32254. */
  32255. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32256. /**
  32257. * Downloads a blob in the browser
  32258. * @param blob defines the blob to download
  32259. * @param fileName defines the name of the downloaded file
  32260. */
  32261. static Download(blob: Blob, fileName: string): void;
  32262. /**
  32263. * Captures a screenshot of the current rendering
  32264. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32265. * @param engine defines the rendering engine
  32266. * @param camera defines the source camera
  32267. * @param size This parameter can be set to a single number or to an object with the
  32268. * following (optional) properties: precision, width, height. If a single number is passed,
  32269. * it will be used for both width and height. If an object is passed, the screenshot size
  32270. * will be derived from the parameters. The precision property is a multiplier allowing
  32271. * rendering at a higher or lower resolution
  32272. * @param successCallback defines the callback receives a single parameter which contains the
  32273. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32274. * src parameter of an <img> to display it
  32275. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32276. * Check your browser for supported MIME types
  32277. */
  32278. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32279. /**
  32280. * Generates an image screenshot from the specified camera.
  32281. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32282. * @param engine The engine to use for rendering
  32283. * @param camera The camera to use for rendering
  32284. * @param size This parameter can be set to a single number or to an object with the
  32285. * following (optional) properties: precision, width, height. If a single number is passed,
  32286. * it will be used for both width and height. If an object is passed, the screenshot size
  32287. * will be derived from the parameters. The precision property is a multiplier allowing
  32288. * rendering at a higher or lower resolution
  32289. * @param successCallback The callback receives a single parameter which contains the
  32290. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32291. * src parameter of an <img> to display it
  32292. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32293. * Check your browser for supported MIME types
  32294. * @param samples Texture samples (default: 1)
  32295. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32296. * @param fileName A name for for the downloaded file.
  32297. */
  32298. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32299. /**
  32300. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32301. * Be aware Math.random() could cause collisions, but:
  32302. * "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"
  32303. * @returns a pseudo random id
  32304. */
  32305. static RandomId(): string;
  32306. /**
  32307. * Test if the given uri is a base64 string
  32308. * @param uri The uri to test
  32309. * @return True if the uri is a base64 string or false otherwise
  32310. */
  32311. static IsBase64(uri: string): boolean;
  32312. /**
  32313. * Decode the given base64 uri.
  32314. * @param uri The uri to decode
  32315. * @return The decoded base64 data.
  32316. */
  32317. static DecodeBase64(uri: string): ArrayBuffer;
  32318. /**
  32319. * Gets the absolute url.
  32320. * @param url the input url
  32321. * @return the absolute url
  32322. */
  32323. static GetAbsoluteUrl(url: string): string;
  32324. /**
  32325. * No log
  32326. */
  32327. static readonly NoneLogLevel: number;
  32328. /**
  32329. * Only message logs
  32330. */
  32331. static readonly MessageLogLevel: number;
  32332. /**
  32333. * Only warning logs
  32334. */
  32335. static readonly WarningLogLevel: number;
  32336. /**
  32337. * Only error logs
  32338. */
  32339. static readonly ErrorLogLevel: number;
  32340. /**
  32341. * All logs
  32342. */
  32343. static readonly AllLogLevel: number;
  32344. /**
  32345. * Gets a value indicating the number of loading errors
  32346. * @ignorenaming
  32347. */
  32348. static readonly errorsCount: number;
  32349. /**
  32350. * Callback called when a new log is added
  32351. */
  32352. static OnNewCacheEntry: (entry: string) => void;
  32353. /**
  32354. * Log a message to the console
  32355. * @param message defines the message to log
  32356. */
  32357. static Log(message: string): void;
  32358. /**
  32359. * Write a warning message to the console
  32360. * @param message defines the message to log
  32361. */
  32362. static Warn(message: string): void;
  32363. /**
  32364. * Write an error message to the console
  32365. * @param message defines the message to log
  32366. */
  32367. static Error(message: string): void;
  32368. /**
  32369. * Gets current log cache (list of logs)
  32370. */
  32371. static readonly LogCache: string;
  32372. /**
  32373. * Clears the log cache
  32374. */
  32375. static ClearLogCache(): void;
  32376. /**
  32377. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32378. */
  32379. static LogLevels: number;
  32380. /**
  32381. * Checks if the loaded document was accessed via `file:`-Protocol.
  32382. * @returns boolean
  32383. */
  32384. static IsFileURL(): boolean;
  32385. /**
  32386. * Checks if the window object exists
  32387. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32388. */
  32389. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32390. /**
  32391. * No performance log
  32392. */
  32393. static readonly PerformanceNoneLogLevel: number;
  32394. /**
  32395. * Use user marks to log performance
  32396. */
  32397. static readonly PerformanceUserMarkLogLevel: number;
  32398. /**
  32399. * Log performance to the console
  32400. */
  32401. static readonly PerformanceConsoleLogLevel: number;
  32402. private static _performance;
  32403. /**
  32404. * Sets the current performance log level
  32405. */
  32406. static PerformanceLogLevel: number;
  32407. private static _StartPerformanceCounterDisabled;
  32408. private static _EndPerformanceCounterDisabled;
  32409. private static _StartUserMark;
  32410. private static _EndUserMark;
  32411. private static _StartPerformanceConsole;
  32412. private static _EndPerformanceConsole;
  32413. /**
  32414. * Starts a performance counter
  32415. */
  32416. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32417. /**
  32418. * Ends a specific performance coutner
  32419. */
  32420. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32421. /**
  32422. * Gets either window.performance.now() if supported or Date.now() else
  32423. */
  32424. static readonly Now: number;
  32425. /**
  32426. * This method will return the name of the class used to create the instance of the given object.
  32427. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32428. * @param object the object to get the class name from
  32429. * @param isType defines if the object is actually a type
  32430. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32431. */
  32432. static GetClassName(object: any, isType?: boolean): string;
  32433. /**
  32434. * Gets the first element of an array satisfying a given predicate
  32435. * @param array defines the array to browse
  32436. * @param predicate defines the predicate to use
  32437. * @returns null if not found or the element
  32438. */
  32439. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32440. /**
  32441. * This method will return the name of the full name of the class, including its owning module (if any).
  32442. * 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).
  32443. * @param object the object to get the class name from
  32444. * @param isType defines if the object is actually a type
  32445. * @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.
  32446. * @ignorenaming
  32447. */
  32448. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32449. /**
  32450. * Returns a promise that resolves after the given amount of time.
  32451. * @param delay Number of milliseconds to delay
  32452. * @returns Promise that resolves after the given amount of time
  32453. */
  32454. static DelayAsync(delay: number): Promise<void>;
  32455. /**
  32456. * Gets the current gradient from an array of IValueGradient
  32457. * @param ratio defines the current ratio to get
  32458. * @param gradients defines the array of IValueGradient
  32459. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32460. */
  32461. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32462. }
  32463. /**
  32464. * This class is used to track a performance counter which is number based.
  32465. * The user has access to many properties which give statistics of different nature.
  32466. *
  32467. * The implementer can track two kinds of Performance Counter: time and count.
  32468. * 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.
  32469. * 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.
  32470. */
  32471. export class PerfCounter {
  32472. /**
  32473. * Gets or sets a global boolean to turn on and off all the counters
  32474. */
  32475. static Enabled: boolean;
  32476. /**
  32477. * Returns the smallest value ever
  32478. */
  32479. readonly min: number;
  32480. /**
  32481. * Returns the biggest value ever
  32482. */
  32483. readonly max: number;
  32484. /**
  32485. * Returns the average value since the performance counter is running
  32486. */
  32487. readonly average: number;
  32488. /**
  32489. * Returns the average value of the last second the counter was monitored
  32490. */
  32491. readonly lastSecAverage: number;
  32492. /**
  32493. * Returns the current value
  32494. */
  32495. readonly current: number;
  32496. /**
  32497. * Gets the accumulated total
  32498. */
  32499. readonly total: number;
  32500. /**
  32501. * Gets the total value count
  32502. */
  32503. readonly count: number;
  32504. /**
  32505. * Creates a new counter
  32506. */
  32507. constructor();
  32508. /**
  32509. * Call this method to start monitoring a new frame.
  32510. * 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.
  32511. */
  32512. fetchNewFrame(): void;
  32513. /**
  32514. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32515. * @param newCount the count value to add to the monitored count
  32516. * @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.
  32517. */
  32518. addCount(newCount: number, fetchResult: boolean): void;
  32519. /**
  32520. * Start monitoring this performance counter
  32521. */
  32522. beginMonitoring(): void;
  32523. /**
  32524. * Compute the time lapsed since the previous beginMonitoring() call.
  32525. * @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
  32526. */
  32527. endMonitoring(newFrame?: boolean): void;
  32528. private _fetchResult;
  32529. private _startMonitoringTime;
  32530. private _min;
  32531. private _max;
  32532. private _average;
  32533. private _current;
  32534. private _totalValueCount;
  32535. private _totalAccumulated;
  32536. private _lastSecAverage;
  32537. private _lastSecAccumulated;
  32538. private _lastSecTime;
  32539. private _lastSecValueCount;
  32540. }
  32541. /**
  32542. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32543. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32544. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32545. * @param name The name of the class, case should be preserved
  32546. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32547. */
  32548. export function className(name: string, module?: string): (target: Object) => void;
  32549. /**
  32550. * An implementation of a loop for asynchronous functions.
  32551. */
  32552. export class AsyncLoop {
  32553. /**
  32554. * Defines the number of iterations for the loop
  32555. */
  32556. iterations: number;
  32557. /**
  32558. * Defines the current index of the loop.
  32559. */
  32560. index: number;
  32561. private _done;
  32562. private _fn;
  32563. private _successCallback;
  32564. /**
  32565. * Constructor.
  32566. * @param iterations the number of iterations.
  32567. * @param func the function to run each iteration
  32568. * @param successCallback the callback that will be called upon succesful execution
  32569. * @param offset starting offset.
  32570. */
  32571. constructor(
  32572. /**
  32573. * Defines the number of iterations for the loop
  32574. */
  32575. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32576. /**
  32577. * Execute the next iteration. Must be called after the last iteration was finished.
  32578. */
  32579. executeNext(): void;
  32580. /**
  32581. * Break the loop and run the success callback.
  32582. */
  32583. breakLoop(): void;
  32584. /**
  32585. * Create and run an async loop.
  32586. * @param iterations the number of iterations.
  32587. * @param fn the function to run each iteration
  32588. * @param successCallback the callback that will be called upon succesful execution
  32589. * @param offset starting offset.
  32590. * @returns the created async loop object
  32591. */
  32592. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32593. /**
  32594. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32595. * @param iterations total number of iterations
  32596. * @param syncedIterations number of synchronous iterations in each async iteration.
  32597. * @param fn the function to call each iteration.
  32598. * @param callback a success call back that will be called when iterating stops.
  32599. * @param breakFunction a break condition (optional)
  32600. * @param timeout timeout settings for the setTimeout function. default - 0.
  32601. * @returns the created async loop object
  32602. */
  32603. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32604. }
  32605. }
  32606. declare module "babylonjs/Collisions/collisionCoordinator" {
  32607. import { Nullable } from "babylonjs/types";
  32608. import { Scene } from "babylonjs/scene";
  32609. import { Vector3 } from "babylonjs/Maths/math";
  32610. import { Collider } from "babylonjs/Collisions/collider";
  32611. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32612. /** @hidden */
  32613. export interface ICollisionCoordinator {
  32614. createCollider(): Collider;
  32615. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32616. init(scene: Scene): void;
  32617. }
  32618. /** @hidden */
  32619. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32620. private _scene;
  32621. private _scaledPosition;
  32622. private _scaledVelocity;
  32623. private _finalPosition;
  32624. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32625. createCollider(): Collider;
  32626. init(scene: Scene): void;
  32627. private _collideWithWorld;
  32628. }
  32629. }
  32630. declare module "babylonjs/Inputs/scene.inputManager" {
  32631. import { Nullable } from "babylonjs/types";
  32632. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32633. import { Vector2 } from "babylonjs/Maths/math";
  32634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32635. import { Scene } from "babylonjs/scene";
  32636. /**
  32637. * Class used to manage all inputs for the scene.
  32638. */
  32639. export class InputManager {
  32640. /** The distance in pixel that you have to move to prevent some events */
  32641. static DragMovementThreshold: number;
  32642. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32643. static LongPressDelay: number;
  32644. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32645. static DoubleClickDelay: number;
  32646. /** If you need to check double click without raising a single click at first click, enable this flag */
  32647. static ExclusiveDoubleClickMode: boolean;
  32648. private _wheelEventName;
  32649. private _onPointerMove;
  32650. private _onPointerDown;
  32651. private _onPointerUp;
  32652. private _initClickEvent;
  32653. private _initActionManager;
  32654. private _delayedSimpleClick;
  32655. private _delayedSimpleClickTimeout;
  32656. private _previousDelayedSimpleClickTimeout;
  32657. private _meshPickProceed;
  32658. private _previousButtonPressed;
  32659. private _currentPickResult;
  32660. private _previousPickResult;
  32661. private _totalPointersPressed;
  32662. private _doubleClickOccured;
  32663. private _pointerOverMesh;
  32664. private _pickedDownMesh;
  32665. private _pickedUpMesh;
  32666. private _pointerX;
  32667. private _pointerY;
  32668. private _unTranslatedPointerX;
  32669. private _unTranslatedPointerY;
  32670. private _startingPointerPosition;
  32671. private _previousStartingPointerPosition;
  32672. private _startingPointerTime;
  32673. private _previousStartingPointerTime;
  32674. private _pointerCaptures;
  32675. private _onKeyDown;
  32676. private _onKeyUp;
  32677. private _onCanvasFocusObserver;
  32678. private _onCanvasBlurObserver;
  32679. private _scene;
  32680. /**
  32681. * Creates a new InputManager
  32682. * @param scene defines the hosting scene
  32683. */
  32684. constructor(scene: Scene);
  32685. /**
  32686. * Gets the mesh that is currently under the pointer
  32687. */
  32688. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32689. /**
  32690. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32691. */
  32692. readonly unTranslatedPointer: Vector2;
  32693. /**
  32694. * Gets or sets the current on-screen X position of the pointer
  32695. */
  32696. pointerX: number;
  32697. /**
  32698. * Gets or sets the current on-screen Y position of the pointer
  32699. */
  32700. pointerY: number;
  32701. private _updatePointerPosition;
  32702. private _processPointerMove;
  32703. private _setRayOnPointerInfo;
  32704. private _checkPrePointerObservable;
  32705. /**
  32706. * Use this method to simulate a pointer move on a mesh
  32707. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32708. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32709. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32710. */
  32711. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32712. /**
  32713. * Use this method to simulate a pointer down on a mesh
  32714. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32715. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32716. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32717. */
  32718. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32719. private _processPointerDown;
  32720. /** @hidden */
  32721. _isPointerSwiping(): boolean;
  32722. /**
  32723. * Use this method to simulate a pointer up on a mesh
  32724. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32725. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32726. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32727. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32728. */
  32729. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32730. private _processPointerUp;
  32731. /**
  32732. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32733. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32734. * @returns true if the pointer was captured
  32735. */
  32736. isPointerCaptured(pointerId?: number): boolean;
  32737. /**
  32738. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32739. * @param attachUp defines if you want to attach events to pointerup
  32740. * @param attachDown defines if you want to attach events to pointerdown
  32741. * @param attachMove defines if you want to attach events to pointermove
  32742. */
  32743. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32744. /**
  32745. * Detaches all event handlers
  32746. */
  32747. detachControl(): void;
  32748. /**
  32749. * Force the value of meshUnderPointer
  32750. * @param mesh defines the mesh to use
  32751. */
  32752. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32753. /**
  32754. * Gets the mesh under the pointer
  32755. * @returns a Mesh or null if no mesh is under the pointer
  32756. */
  32757. getPointerOverMesh(): Nullable<AbstractMesh>;
  32758. }
  32759. }
  32760. declare module "babylonjs/Animations/animationGroup" {
  32761. import { Animatable } from "babylonjs/Animations/animatable";
  32762. import { Animation } from "babylonjs/Animations/animation";
  32763. import { Scene, IDisposable } from "babylonjs/scene";
  32764. import { Observable } from "babylonjs/Misc/observable";
  32765. import { Nullable } from "babylonjs/types";
  32766. import "babylonjs/Animations/animatable";
  32767. /**
  32768. * This class defines the direct association between an animation and a target
  32769. */
  32770. export class TargetedAnimation {
  32771. /**
  32772. * Animation to perform
  32773. */
  32774. animation: Animation;
  32775. /**
  32776. * Target to animate
  32777. */
  32778. target: any;
  32779. /**
  32780. * Serialize the object
  32781. * @returns the JSON object representing the current entity
  32782. */
  32783. serialize(): any;
  32784. }
  32785. /**
  32786. * Use this class to create coordinated animations on multiple targets
  32787. */
  32788. export class AnimationGroup implements IDisposable {
  32789. /** The name of the animation group */
  32790. name: string;
  32791. private _scene;
  32792. private _targetedAnimations;
  32793. private _animatables;
  32794. private _from;
  32795. private _to;
  32796. private _isStarted;
  32797. private _isPaused;
  32798. private _speedRatio;
  32799. private _loopAnimation;
  32800. /**
  32801. * Gets or sets the unique id of the node
  32802. */
  32803. uniqueId: number;
  32804. /**
  32805. * This observable will notify when one animation have ended
  32806. */
  32807. onAnimationEndObservable: Observable<TargetedAnimation>;
  32808. /**
  32809. * Observer raised when one animation loops
  32810. */
  32811. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32812. /**
  32813. * This observable will notify when all animations have ended.
  32814. */
  32815. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32816. /**
  32817. * This observable will notify when all animations have paused.
  32818. */
  32819. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32820. /**
  32821. * This observable will notify when all animations are playing.
  32822. */
  32823. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32824. /**
  32825. * Gets the first frame
  32826. */
  32827. readonly from: number;
  32828. /**
  32829. * Gets the last frame
  32830. */
  32831. readonly to: number;
  32832. /**
  32833. * Define if the animations are started
  32834. */
  32835. readonly isStarted: boolean;
  32836. /**
  32837. * Gets a value indicating that the current group is playing
  32838. */
  32839. readonly isPlaying: boolean;
  32840. /**
  32841. * Gets or sets the speed ratio to use for all animations
  32842. */
  32843. /**
  32844. * Gets or sets the speed ratio to use for all animations
  32845. */
  32846. speedRatio: number;
  32847. /**
  32848. * Gets or sets if all animations should loop or not
  32849. */
  32850. loopAnimation: boolean;
  32851. /**
  32852. * Gets the targeted animations for this animation group
  32853. */
  32854. readonly targetedAnimations: Array<TargetedAnimation>;
  32855. /**
  32856. * returning the list of animatables controlled by this animation group.
  32857. */
  32858. readonly animatables: Array<Animatable>;
  32859. /**
  32860. * Instantiates a new Animation Group.
  32861. * This helps managing several animations at once.
  32862. * @see http://doc.babylonjs.com/how_to/group
  32863. * @param name Defines the name of the group
  32864. * @param scene Defines the scene the group belongs to
  32865. */
  32866. constructor(
  32867. /** The name of the animation group */
  32868. name: string, scene?: Nullable<Scene>);
  32869. /**
  32870. * Add an animation (with its target) in the group
  32871. * @param animation defines the animation we want to add
  32872. * @param target defines the target of the animation
  32873. * @returns the TargetedAnimation object
  32874. */
  32875. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32876. /**
  32877. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32878. * It can add constant keys at begin or end
  32879. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32880. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32881. * @returns the animation group
  32882. */
  32883. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32884. /**
  32885. * Start all animations on given targets
  32886. * @param loop defines if animations must loop
  32887. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32888. * @param from defines the from key (optional)
  32889. * @param to defines the to key (optional)
  32890. * @returns the current animation group
  32891. */
  32892. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32893. /**
  32894. * Pause all animations
  32895. * @returns the animation group
  32896. */
  32897. pause(): AnimationGroup;
  32898. /**
  32899. * Play all animations to initial state
  32900. * This function will start() the animations if they were not started or will restart() them if they were paused
  32901. * @param loop defines if animations must loop
  32902. * @returns the animation group
  32903. */
  32904. play(loop?: boolean): AnimationGroup;
  32905. /**
  32906. * Reset all animations to initial state
  32907. * @returns the animation group
  32908. */
  32909. reset(): AnimationGroup;
  32910. /**
  32911. * Restart animations from key 0
  32912. * @returns the animation group
  32913. */
  32914. restart(): AnimationGroup;
  32915. /**
  32916. * Stop all animations
  32917. * @returns the animation group
  32918. */
  32919. stop(): AnimationGroup;
  32920. /**
  32921. * Set animation weight for all animatables
  32922. * @param weight defines the weight to use
  32923. * @return the animationGroup
  32924. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32925. */
  32926. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32927. /**
  32928. * Synchronize and normalize all animatables with a source animatable
  32929. * @param root defines the root animatable to synchronize with
  32930. * @return the animationGroup
  32931. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32932. */
  32933. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32934. /**
  32935. * Goes to a specific frame in this animation group
  32936. * @param frame the frame number to go to
  32937. * @return the animationGroup
  32938. */
  32939. goToFrame(frame: number): AnimationGroup;
  32940. /**
  32941. * Dispose all associated resources
  32942. */
  32943. dispose(): void;
  32944. private _checkAnimationGroupEnded;
  32945. /**
  32946. * Clone the current animation group and returns a copy
  32947. * @param newName defines the name of the new group
  32948. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32949. * @returns the new aniamtion group
  32950. */
  32951. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32952. /**
  32953. * Serializes the animationGroup to an object
  32954. * @returns Serialized object
  32955. */
  32956. serialize(): any;
  32957. /**
  32958. * Returns a new AnimationGroup object parsed from the source provided.
  32959. * @param parsedAnimationGroup defines the source
  32960. * @param scene defines the scene that will receive the animationGroup
  32961. * @returns a new AnimationGroup
  32962. */
  32963. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32964. /**
  32965. * Returns the string "AnimationGroup"
  32966. * @returns "AnimationGroup"
  32967. */
  32968. getClassName(): string;
  32969. /**
  32970. * Creates a detailled string about the object
  32971. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32972. * @returns a string representing the object
  32973. */
  32974. toString(fullDetails?: boolean): string;
  32975. }
  32976. }
  32977. declare module "babylonjs/scene" {
  32978. import { Nullable } from "babylonjs/types";
  32979. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32980. import { Observable } from "babylonjs/Misc/observable";
  32981. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32982. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32983. import { Geometry } from "babylonjs/Meshes/geometry";
  32984. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32985. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32987. import { Mesh } from "babylonjs/Meshes/mesh";
  32988. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32989. import { Bone } from "babylonjs/Bones/bone";
  32990. import { Skeleton } from "babylonjs/Bones/skeleton";
  32991. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32992. import { Camera } from "babylonjs/Cameras/camera";
  32993. import { AbstractScene } from "babylonjs/abstractScene";
  32994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32995. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32996. import { Material } from "babylonjs/Materials/material";
  32997. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32998. import { Effect } from "babylonjs/Materials/effect";
  32999. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33000. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33001. import { Light } from "babylonjs/Lights/light";
  33002. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33003. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33004. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33005. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33006. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33007. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33008. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33009. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33010. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33011. import { Engine } from "babylonjs/Engines/engine";
  33012. import { Node } from "babylonjs/node";
  33013. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33014. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33015. import { WebRequest } from "babylonjs/Misc/webRequest";
  33016. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33017. import { Ray } from "babylonjs/Culling/ray";
  33018. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33019. import { Animation } from "babylonjs/Animations/animation";
  33020. import { Animatable } from "babylonjs/Animations/animatable";
  33021. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33022. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33023. import { Collider } from "babylonjs/Collisions/collider";
  33024. /**
  33025. * Define an interface for all classes that will hold resources
  33026. */
  33027. export interface IDisposable {
  33028. /**
  33029. * Releases all held resources
  33030. */
  33031. dispose(): void;
  33032. }
  33033. /** Interface defining initialization parameters for Scene class */
  33034. export interface SceneOptions {
  33035. /**
  33036. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33037. * It will improve performance when the number of geometries becomes important.
  33038. */
  33039. useGeometryUniqueIdsMap?: boolean;
  33040. /**
  33041. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33042. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33043. */
  33044. useMaterialMeshMap?: boolean;
  33045. /**
  33046. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33047. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33048. */
  33049. useClonedMeshhMap?: boolean;
  33050. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33051. virtual?: boolean;
  33052. }
  33053. /**
  33054. * Represents a scene to be rendered by the engine.
  33055. * @see http://doc.babylonjs.com/features/scene
  33056. */
  33057. export class Scene extends AbstractScene implements IAnimatable {
  33058. private static _uniqueIdCounter;
  33059. /** The fog is deactivated */
  33060. static readonly FOGMODE_NONE: number;
  33061. /** The fog density is following an exponential function */
  33062. static readonly FOGMODE_EXP: number;
  33063. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33064. static readonly FOGMODE_EXP2: number;
  33065. /** The fog density is following a linear function. */
  33066. static readonly FOGMODE_LINEAR: number;
  33067. /**
  33068. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33069. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33070. */
  33071. static MinDeltaTime: number;
  33072. /**
  33073. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33074. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33075. */
  33076. static MaxDeltaTime: number;
  33077. /**
  33078. * Factory used to create the default material.
  33079. * @param name The name of the material to create
  33080. * @param scene The scene to create the material for
  33081. * @returns The default material
  33082. */
  33083. static DefaultMaterialFactory(scene: Scene): Material;
  33084. /**
  33085. * Factory used to create the a collision coordinator.
  33086. * @returns The collision coordinator
  33087. */
  33088. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33089. /** @hidden */
  33090. _inputManager: InputManager;
  33091. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33092. cameraToUseForPointers: Nullable<Camera>;
  33093. /** @hidden */
  33094. readonly _isScene: boolean;
  33095. /**
  33096. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33097. */
  33098. autoClear: boolean;
  33099. /**
  33100. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33101. */
  33102. autoClearDepthAndStencil: boolean;
  33103. /**
  33104. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33105. */
  33106. clearColor: Color4;
  33107. /**
  33108. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33109. */
  33110. ambientColor: Color3;
  33111. /**
  33112. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33113. * It should only be one of the following (if not the default embedded one):
  33114. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33115. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33116. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33117. * The material properties need to be setup according to the type of texture in use.
  33118. */
  33119. environmentBRDFTexture: BaseTexture;
  33120. /** @hidden */
  33121. protected _environmentTexture: Nullable<BaseTexture>;
  33122. /**
  33123. * Texture used in all pbr material as the reflection texture.
  33124. * As in the majority of the scene they are the same (exception for multi room and so on),
  33125. * this is easier to reference from here than from all the materials.
  33126. */
  33127. /**
  33128. * Texture used in all pbr material as the reflection texture.
  33129. * As in the majority of the scene they are the same (exception for multi room and so on),
  33130. * this is easier to set here than in all the materials.
  33131. */
  33132. environmentTexture: Nullable<BaseTexture>;
  33133. /** @hidden */
  33134. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33135. /**
  33136. * Default image processing configuration used either in the rendering
  33137. * Forward main pass or through the imageProcessingPostProcess if present.
  33138. * As in the majority of the scene they are the same (exception for multi camera),
  33139. * this is easier to reference from here than from all the materials and post process.
  33140. *
  33141. * No setter as we it is a shared configuration, you can set the values instead.
  33142. */
  33143. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33144. private _forceWireframe;
  33145. /**
  33146. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33147. */
  33148. forceWireframe: boolean;
  33149. private _forcePointsCloud;
  33150. /**
  33151. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33152. */
  33153. forcePointsCloud: boolean;
  33154. /**
  33155. * Gets or sets the active clipplane 1
  33156. */
  33157. clipPlane: Nullable<Plane>;
  33158. /**
  33159. * Gets or sets the active clipplane 2
  33160. */
  33161. clipPlane2: Nullable<Plane>;
  33162. /**
  33163. * Gets or sets the active clipplane 3
  33164. */
  33165. clipPlane3: Nullable<Plane>;
  33166. /**
  33167. * Gets or sets the active clipplane 4
  33168. */
  33169. clipPlane4: Nullable<Plane>;
  33170. /**
  33171. * Gets or sets a boolean indicating if animations are enabled
  33172. */
  33173. animationsEnabled: boolean;
  33174. private _animationPropertiesOverride;
  33175. /**
  33176. * Gets or sets the animation properties override
  33177. */
  33178. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33179. /**
  33180. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33181. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33182. */
  33183. useConstantAnimationDeltaTime: boolean;
  33184. /**
  33185. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33186. * Please note that it requires to run a ray cast through the scene on every frame
  33187. */
  33188. constantlyUpdateMeshUnderPointer: boolean;
  33189. /**
  33190. * Defines the HTML cursor to use when hovering over interactive elements
  33191. */
  33192. hoverCursor: string;
  33193. /**
  33194. * Defines the HTML default cursor to use (empty by default)
  33195. */
  33196. defaultCursor: string;
  33197. /**
  33198. * This is used to call preventDefault() on pointer down
  33199. * in order to block unwanted artifacts like system double clicks
  33200. */
  33201. preventDefaultOnPointerDown: boolean;
  33202. /**
  33203. * This is used to call preventDefault() on pointer up
  33204. * in order to block unwanted artifacts like system double clicks
  33205. */
  33206. preventDefaultOnPointerUp: boolean;
  33207. /**
  33208. * Gets or sets user defined metadata
  33209. */
  33210. metadata: any;
  33211. /**
  33212. * For internal use only. Please do not use.
  33213. */
  33214. reservedDataStore: any;
  33215. /**
  33216. * Gets the name of the plugin used to load this scene (null by default)
  33217. */
  33218. loadingPluginName: string;
  33219. /**
  33220. * Use this array to add regular expressions used to disable offline support for specific urls
  33221. */
  33222. disableOfflineSupportExceptionRules: RegExp[];
  33223. /**
  33224. * An event triggered when the scene is disposed.
  33225. */
  33226. onDisposeObservable: Observable<Scene>;
  33227. private _onDisposeObserver;
  33228. /** Sets a function to be executed when this scene is disposed. */
  33229. onDispose: () => void;
  33230. /**
  33231. * An event triggered before rendering the scene (right after animations and physics)
  33232. */
  33233. onBeforeRenderObservable: Observable<Scene>;
  33234. private _onBeforeRenderObserver;
  33235. /** Sets a function to be executed before rendering this scene */
  33236. beforeRender: Nullable<() => void>;
  33237. /**
  33238. * An event triggered after rendering the scene
  33239. */
  33240. onAfterRenderObservable: Observable<Scene>;
  33241. /**
  33242. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33243. */
  33244. onAfterRenderCameraObservable: Observable<Camera>;
  33245. private _onAfterRenderObserver;
  33246. /** Sets a function to be executed after rendering this scene */
  33247. afterRender: Nullable<() => void>;
  33248. /**
  33249. * An event triggered before animating the scene
  33250. */
  33251. onBeforeAnimationsObservable: Observable<Scene>;
  33252. /**
  33253. * An event triggered after animations processing
  33254. */
  33255. onAfterAnimationsObservable: Observable<Scene>;
  33256. /**
  33257. * An event triggered before draw calls are ready to be sent
  33258. */
  33259. onBeforeDrawPhaseObservable: Observable<Scene>;
  33260. /**
  33261. * An event triggered after draw calls have been sent
  33262. */
  33263. onAfterDrawPhaseObservable: Observable<Scene>;
  33264. /**
  33265. * An event triggered when the scene is ready
  33266. */
  33267. onReadyObservable: Observable<Scene>;
  33268. /**
  33269. * An event triggered before rendering a camera
  33270. */
  33271. onBeforeCameraRenderObservable: Observable<Camera>;
  33272. private _onBeforeCameraRenderObserver;
  33273. /** Sets a function to be executed before rendering a camera*/
  33274. beforeCameraRender: () => void;
  33275. /**
  33276. * An event triggered after rendering a camera
  33277. */
  33278. onAfterCameraRenderObservable: Observable<Camera>;
  33279. private _onAfterCameraRenderObserver;
  33280. /** Sets a function to be executed after rendering a camera*/
  33281. afterCameraRender: () => void;
  33282. /**
  33283. * An event triggered when active meshes evaluation is about to start
  33284. */
  33285. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33286. /**
  33287. * An event triggered when active meshes evaluation is done
  33288. */
  33289. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33290. /**
  33291. * An event triggered when particles rendering is about to start
  33292. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33293. */
  33294. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33295. /**
  33296. * An event triggered when particles rendering is done
  33297. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33298. */
  33299. onAfterParticlesRenderingObservable: Observable<Scene>;
  33300. /**
  33301. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33302. */
  33303. onDataLoadedObservable: Observable<Scene>;
  33304. /**
  33305. * An event triggered when a camera is created
  33306. */
  33307. onNewCameraAddedObservable: Observable<Camera>;
  33308. /**
  33309. * An event triggered when a camera is removed
  33310. */
  33311. onCameraRemovedObservable: Observable<Camera>;
  33312. /**
  33313. * An event triggered when a light is created
  33314. */
  33315. onNewLightAddedObservable: Observable<Light>;
  33316. /**
  33317. * An event triggered when a light is removed
  33318. */
  33319. onLightRemovedObservable: Observable<Light>;
  33320. /**
  33321. * An event triggered when a geometry is created
  33322. */
  33323. onNewGeometryAddedObservable: Observable<Geometry>;
  33324. /**
  33325. * An event triggered when a geometry is removed
  33326. */
  33327. onGeometryRemovedObservable: Observable<Geometry>;
  33328. /**
  33329. * An event triggered when a transform node is created
  33330. */
  33331. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33332. /**
  33333. * An event triggered when a transform node is removed
  33334. */
  33335. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33336. /**
  33337. * An event triggered when a mesh is created
  33338. */
  33339. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33340. /**
  33341. * An event triggered when a mesh is removed
  33342. */
  33343. onMeshRemovedObservable: Observable<AbstractMesh>;
  33344. /**
  33345. * An event triggered when a skeleton is created
  33346. */
  33347. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33348. /**
  33349. * An event triggered when a skeleton is removed
  33350. */
  33351. onSkeletonRemovedObservable: Observable<Skeleton>;
  33352. /**
  33353. * An event triggered when a material is created
  33354. */
  33355. onNewMaterialAddedObservable: Observable<Material>;
  33356. /**
  33357. * An event triggered when a material is removed
  33358. */
  33359. onMaterialRemovedObservable: Observable<Material>;
  33360. /**
  33361. * An event triggered when a texture is created
  33362. */
  33363. onNewTextureAddedObservable: Observable<BaseTexture>;
  33364. /**
  33365. * An event triggered when a texture is removed
  33366. */
  33367. onTextureRemovedObservable: Observable<BaseTexture>;
  33368. /**
  33369. * An event triggered when render targets are about to be rendered
  33370. * Can happen multiple times per frame.
  33371. */
  33372. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33373. /**
  33374. * An event triggered when render targets were rendered.
  33375. * Can happen multiple times per frame.
  33376. */
  33377. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33378. /**
  33379. * An event triggered before calculating deterministic simulation step
  33380. */
  33381. onBeforeStepObservable: Observable<Scene>;
  33382. /**
  33383. * An event triggered after calculating deterministic simulation step
  33384. */
  33385. onAfterStepObservable: Observable<Scene>;
  33386. /**
  33387. * An event triggered when the activeCamera property is updated
  33388. */
  33389. onActiveCameraChanged: Observable<Scene>;
  33390. /**
  33391. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33392. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33393. * 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)
  33394. */
  33395. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33396. /**
  33397. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33398. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33399. * 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)
  33400. */
  33401. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33402. /**
  33403. * This Observable will when a mesh has been imported into the scene.
  33404. */
  33405. onMeshImportedObservable: Observable<AbstractMesh>;
  33406. /**
  33407. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33408. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33409. */
  33410. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33411. /** @hidden */
  33412. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33413. /**
  33414. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33415. */
  33416. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33417. /**
  33418. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33419. */
  33420. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33421. /**
  33422. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33423. */
  33424. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33425. /** Callback called when a pointer move is detected */
  33426. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33427. /** Callback called when a pointer down is detected */
  33428. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33429. /** Callback called when a pointer up is detected */
  33430. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33431. /** Callback called when a pointer pick is detected */
  33432. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33433. /**
  33434. * 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).
  33435. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33436. */
  33437. onPrePointerObservable: Observable<PointerInfoPre>;
  33438. /**
  33439. * Observable event triggered each time an input event is received from the rendering canvas
  33440. */
  33441. onPointerObservable: Observable<PointerInfo>;
  33442. /**
  33443. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33444. */
  33445. readonly unTranslatedPointer: Vector2;
  33446. /**
  33447. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33448. */
  33449. static DragMovementThreshold: number;
  33450. /**
  33451. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33452. */
  33453. static LongPressDelay: number;
  33454. /**
  33455. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33456. */
  33457. static DoubleClickDelay: number;
  33458. /** If you need to check double click without raising a single click at first click, enable this flag */
  33459. static ExclusiveDoubleClickMode: boolean;
  33460. /** @hidden */
  33461. _mirroredCameraPosition: Nullable<Vector3>;
  33462. /**
  33463. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33464. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33465. */
  33466. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33467. /**
  33468. * Observable event triggered each time an keyboard event is received from the hosting window
  33469. */
  33470. onKeyboardObservable: Observable<KeyboardInfo>;
  33471. private _useRightHandedSystem;
  33472. /**
  33473. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33474. */
  33475. useRightHandedSystem: boolean;
  33476. private _timeAccumulator;
  33477. private _currentStepId;
  33478. private _currentInternalStep;
  33479. /**
  33480. * Sets the step Id used by deterministic lock step
  33481. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33482. * @param newStepId defines the step Id
  33483. */
  33484. setStepId(newStepId: number): void;
  33485. /**
  33486. * Gets the step Id used by deterministic lock step
  33487. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33488. * @returns the step Id
  33489. */
  33490. getStepId(): number;
  33491. /**
  33492. * Gets the internal step used by deterministic lock step
  33493. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33494. * @returns the internal step
  33495. */
  33496. getInternalStep(): number;
  33497. private _fogEnabled;
  33498. /**
  33499. * Gets or sets a boolean indicating if fog is enabled on this scene
  33500. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33501. * (Default is true)
  33502. */
  33503. fogEnabled: boolean;
  33504. private _fogMode;
  33505. /**
  33506. * Gets or sets the fog mode to use
  33507. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33508. * | mode | value |
  33509. * | --- | --- |
  33510. * | FOGMODE_NONE | 0 |
  33511. * | FOGMODE_EXP | 1 |
  33512. * | FOGMODE_EXP2 | 2 |
  33513. * | FOGMODE_LINEAR | 3 |
  33514. */
  33515. fogMode: number;
  33516. /**
  33517. * Gets or sets the fog color to use
  33518. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33519. * (Default is Color3(0.2, 0.2, 0.3))
  33520. */
  33521. fogColor: Color3;
  33522. /**
  33523. * Gets or sets the fog density to use
  33524. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33525. * (Default is 0.1)
  33526. */
  33527. fogDensity: number;
  33528. /**
  33529. * Gets or sets the fog start distance to use
  33530. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33531. * (Default is 0)
  33532. */
  33533. fogStart: number;
  33534. /**
  33535. * Gets or sets the fog end distance to use
  33536. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33537. * (Default is 1000)
  33538. */
  33539. fogEnd: number;
  33540. private _shadowsEnabled;
  33541. /**
  33542. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33543. */
  33544. shadowsEnabled: boolean;
  33545. private _lightsEnabled;
  33546. /**
  33547. * Gets or sets a boolean indicating if lights are enabled on this scene
  33548. */
  33549. lightsEnabled: boolean;
  33550. /** All of the active cameras added to this scene. */
  33551. activeCameras: Camera[];
  33552. /** @hidden */
  33553. _activeCamera: Nullable<Camera>;
  33554. /** Gets or sets the current active camera */
  33555. activeCamera: Nullable<Camera>;
  33556. private _defaultMaterial;
  33557. /** The default material used on meshes when no material is affected */
  33558. /** The default material used on meshes when no material is affected */
  33559. defaultMaterial: Material;
  33560. private _texturesEnabled;
  33561. /**
  33562. * Gets or sets a boolean indicating if textures are enabled on this scene
  33563. */
  33564. texturesEnabled: boolean;
  33565. /**
  33566. * Gets or sets a boolean indicating if particles are enabled on this scene
  33567. */
  33568. particlesEnabled: boolean;
  33569. /**
  33570. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33571. */
  33572. spritesEnabled: boolean;
  33573. private _skeletonsEnabled;
  33574. /**
  33575. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33576. */
  33577. skeletonsEnabled: boolean;
  33578. /**
  33579. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33580. */
  33581. lensFlaresEnabled: boolean;
  33582. /**
  33583. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33584. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33585. */
  33586. collisionsEnabled: boolean;
  33587. private _collisionCoordinator;
  33588. /** @hidden */
  33589. readonly collisionCoordinator: ICollisionCoordinator;
  33590. /**
  33591. * Defines the gravity applied to this scene (used only for collisions)
  33592. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33593. */
  33594. gravity: Vector3;
  33595. /**
  33596. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33597. */
  33598. postProcessesEnabled: boolean;
  33599. /**
  33600. * The list of postprocesses added to the scene
  33601. */
  33602. postProcesses: PostProcess[];
  33603. /**
  33604. * Gets the current postprocess manager
  33605. */
  33606. postProcessManager: PostProcessManager;
  33607. /**
  33608. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33609. */
  33610. renderTargetsEnabled: boolean;
  33611. /**
  33612. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33613. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33614. */
  33615. dumpNextRenderTargets: boolean;
  33616. /**
  33617. * The list of user defined render targets added to the scene
  33618. */
  33619. customRenderTargets: RenderTargetTexture[];
  33620. /**
  33621. * Defines if texture loading must be delayed
  33622. * If true, textures will only be loaded when they need to be rendered
  33623. */
  33624. useDelayedTextureLoading: boolean;
  33625. /**
  33626. * Gets the list of meshes imported to the scene through SceneLoader
  33627. */
  33628. importedMeshesFiles: String[];
  33629. /**
  33630. * Gets or sets a boolean indicating if probes are enabled on this scene
  33631. */
  33632. probesEnabled: boolean;
  33633. /**
  33634. * Gets or sets the current offline provider to use to store scene data
  33635. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33636. */
  33637. offlineProvider: IOfflineProvider;
  33638. /**
  33639. * Gets or sets the action manager associated with the scene
  33640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33641. */
  33642. actionManager: AbstractActionManager;
  33643. private _meshesForIntersections;
  33644. /**
  33645. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33646. */
  33647. proceduralTexturesEnabled: boolean;
  33648. private _engine;
  33649. private _totalVertices;
  33650. /** @hidden */
  33651. _activeIndices: PerfCounter;
  33652. /** @hidden */
  33653. _activeParticles: PerfCounter;
  33654. /** @hidden */
  33655. _activeBones: PerfCounter;
  33656. private _animationRatio;
  33657. /** @hidden */
  33658. _animationTimeLast: number;
  33659. /** @hidden */
  33660. _animationTime: number;
  33661. /**
  33662. * Gets or sets a general scale for animation speed
  33663. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33664. */
  33665. animationTimeScale: number;
  33666. /** @hidden */
  33667. _cachedMaterial: Nullable<Material>;
  33668. /** @hidden */
  33669. _cachedEffect: Nullable<Effect>;
  33670. /** @hidden */
  33671. _cachedVisibility: Nullable<number>;
  33672. private _renderId;
  33673. private _frameId;
  33674. private _executeWhenReadyTimeoutId;
  33675. private _intermediateRendering;
  33676. private _viewUpdateFlag;
  33677. private _projectionUpdateFlag;
  33678. /** @hidden */
  33679. _toBeDisposed: Nullable<IDisposable>[];
  33680. private _activeRequests;
  33681. /** @hidden */
  33682. _pendingData: any[];
  33683. private _isDisposed;
  33684. /**
  33685. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33686. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33687. */
  33688. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33689. private _activeMeshes;
  33690. private _processedMaterials;
  33691. private _renderTargets;
  33692. /** @hidden */
  33693. _activeParticleSystems: SmartArray<IParticleSystem>;
  33694. private _activeSkeletons;
  33695. private _softwareSkinnedMeshes;
  33696. private _renderingManager;
  33697. /** @hidden */
  33698. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33699. private _transformMatrix;
  33700. private _sceneUbo;
  33701. /** @hidden */
  33702. _viewMatrix: Matrix;
  33703. private _projectionMatrix;
  33704. /** @hidden */
  33705. _forcedViewPosition: Nullable<Vector3>;
  33706. /** @hidden */
  33707. _frustumPlanes: Plane[];
  33708. /**
  33709. * Gets the list of frustum planes (built from the active camera)
  33710. */
  33711. readonly frustumPlanes: Plane[];
  33712. /**
  33713. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33714. * This is useful if there are more lights that the maximum simulteanous authorized
  33715. */
  33716. requireLightSorting: boolean;
  33717. /** @hidden */
  33718. readonly useMaterialMeshMap: boolean;
  33719. /** @hidden */
  33720. readonly useClonedMeshhMap: boolean;
  33721. private _externalData;
  33722. private _uid;
  33723. /**
  33724. * @hidden
  33725. * Backing store of defined scene components.
  33726. */
  33727. _components: ISceneComponent[];
  33728. /**
  33729. * @hidden
  33730. * Backing store of defined scene components.
  33731. */
  33732. _serializableComponents: ISceneSerializableComponent[];
  33733. /**
  33734. * List of components to register on the next registration step.
  33735. */
  33736. private _transientComponents;
  33737. /**
  33738. * Registers the transient components if needed.
  33739. */
  33740. private _registerTransientComponents;
  33741. /**
  33742. * @hidden
  33743. * Add a component to the scene.
  33744. * Note that the ccomponent could be registered on th next frame if this is called after
  33745. * the register component stage.
  33746. * @param component Defines the component to add to the scene
  33747. */
  33748. _addComponent(component: ISceneComponent): void;
  33749. /**
  33750. * @hidden
  33751. * Gets a component from the scene.
  33752. * @param name defines the name of the component to retrieve
  33753. * @returns the component or null if not present
  33754. */
  33755. _getComponent(name: string): Nullable<ISceneComponent>;
  33756. /**
  33757. * @hidden
  33758. * Defines the actions happening before camera updates.
  33759. */
  33760. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33761. /**
  33762. * @hidden
  33763. * Defines the actions happening before clear the canvas.
  33764. */
  33765. _beforeClearStage: Stage<SimpleStageAction>;
  33766. /**
  33767. * @hidden
  33768. * Defines the actions when collecting render targets for the frame.
  33769. */
  33770. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33771. /**
  33772. * @hidden
  33773. * Defines the actions happening for one camera in the frame.
  33774. */
  33775. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33776. /**
  33777. * @hidden
  33778. * Defines the actions happening during the per mesh ready checks.
  33779. */
  33780. _isReadyForMeshStage: Stage<MeshStageAction>;
  33781. /**
  33782. * @hidden
  33783. * Defines the actions happening before evaluate active mesh checks.
  33784. */
  33785. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33786. /**
  33787. * @hidden
  33788. * Defines the actions happening during the evaluate sub mesh checks.
  33789. */
  33790. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33791. /**
  33792. * @hidden
  33793. * Defines the actions happening during the active mesh stage.
  33794. */
  33795. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33796. /**
  33797. * @hidden
  33798. * Defines the actions happening during the per camera render target step.
  33799. */
  33800. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33801. /**
  33802. * @hidden
  33803. * Defines the actions happening just before the active camera is drawing.
  33804. */
  33805. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33806. /**
  33807. * @hidden
  33808. * Defines the actions happening just before a render target is drawing.
  33809. */
  33810. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33811. /**
  33812. * @hidden
  33813. * Defines the actions happening just before a rendering group is drawing.
  33814. */
  33815. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33816. /**
  33817. * @hidden
  33818. * Defines the actions happening just before a mesh is drawing.
  33819. */
  33820. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33821. /**
  33822. * @hidden
  33823. * Defines the actions happening just after a mesh has been drawn.
  33824. */
  33825. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33826. /**
  33827. * @hidden
  33828. * Defines the actions happening just after a rendering group has been drawn.
  33829. */
  33830. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33831. /**
  33832. * @hidden
  33833. * Defines the actions happening just after the active camera has been drawn.
  33834. */
  33835. _afterCameraDrawStage: Stage<CameraStageAction>;
  33836. /**
  33837. * @hidden
  33838. * Defines the actions happening just after a render target has been drawn.
  33839. */
  33840. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33841. /**
  33842. * @hidden
  33843. * Defines the actions happening just after rendering all cameras and computing intersections.
  33844. */
  33845. _afterRenderStage: Stage<SimpleStageAction>;
  33846. /**
  33847. * @hidden
  33848. * Defines the actions happening when a pointer move event happens.
  33849. */
  33850. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33851. /**
  33852. * @hidden
  33853. * Defines the actions happening when a pointer down event happens.
  33854. */
  33855. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33856. /**
  33857. * @hidden
  33858. * Defines the actions happening when a pointer up event happens.
  33859. */
  33860. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33861. /**
  33862. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33863. */
  33864. private geometriesByUniqueId;
  33865. /**
  33866. * Creates a new Scene
  33867. * @param engine defines the engine to use to render this scene
  33868. * @param options defines the scene options
  33869. */
  33870. constructor(engine: Engine, options?: SceneOptions);
  33871. /**
  33872. * Gets a string idenfifying the name of the class
  33873. * @returns "Scene" string
  33874. */
  33875. getClassName(): string;
  33876. private _defaultMeshCandidates;
  33877. /**
  33878. * @hidden
  33879. */
  33880. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33881. private _defaultSubMeshCandidates;
  33882. /**
  33883. * @hidden
  33884. */
  33885. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33886. /**
  33887. * Sets the default candidate providers for the scene.
  33888. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33889. * and getCollidingSubMeshCandidates to their default function
  33890. */
  33891. setDefaultCandidateProviders(): void;
  33892. /**
  33893. * Gets the mesh that is currently under the pointer
  33894. */
  33895. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33896. /**
  33897. * Gets or sets the current on-screen X position of the pointer
  33898. */
  33899. pointerX: number;
  33900. /**
  33901. * Gets or sets the current on-screen Y position of the pointer
  33902. */
  33903. pointerY: number;
  33904. /**
  33905. * Gets the cached material (ie. the latest rendered one)
  33906. * @returns the cached material
  33907. */
  33908. getCachedMaterial(): Nullable<Material>;
  33909. /**
  33910. * Gets the cached effect (ie. the latest rendered one)
  33911. * @returns the cached effect
  33912. */
  33913. getCachedEffect(): Nullable<Effect>;
  33914. /**
  33915. * Gets the cached visibility state (ie. the latest rendered one)
  33916. * @returns the cached visibility state
  33917. */
  33918. getCachedVisibility(): Nullable<number>;
  33919. /**
  33920. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33921. * @param material defines the current material
  33922. * @param effect defines the current effect
  33923. * @param visibility defines the current visibility state
  33924. * @returns true if one parameter is not cached
  33925. */
  33926. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33927. /**
  33928. * Gets the engine associated with the scene
  33929. * @returns an Engine
  33930. */
  33931. getEngine(): Engine;
  33932. /**
  33933. * Gets the total number of vertices rendered per frame
  33934. * @returns the total number of vertices rendered per frame
  33935. */
  33936. getTotalVertices(): number;
  33937. /**
  33938. * Gets the performance counter for total vertices
  33939. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33940. */
  33941. readonly totalVerticesPerfCounter: PerfCounter;
  33942. /**
  33943. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33944. * @returns the total number of active indices rendered per frame
  33945. */
  33946. getActiveIndices(): number;
  33947. /**
  33948. * Gets the performance counter for active indices
  33949. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33950. */
  33951. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33952. /**
  33953. * Gets the total number of active particles rendered per frame
  33954. * @returns the total number of active particles rendered per frame
  33955. */
  33956. getActiveParticles(): number;
  33957. /**
  33958. * Gets the performance counter for active particles
  33959. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33960. */
  33961. readonly activeParticlesPerfCounter: PerfCounter;
  33962. /**
  33963. * Gets the total number of active bones rendered per frame
  33964. * @returns the total number of active bones rendered per frame
  33965. */
  33966. getActiveBones(): number;
  33967. /**
  33968. * Gets the performance counter for active bones
  33969. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33970. */
  33971. readonly activeBonesPerfCounter: PerfCounter;
  33972. /**
  33973. * Gets the array of active meshes
  33974. * @returns an array of AbstractMesh
  33975. */
  33976. getActiveMeshes(): SmartArray<AbstractMesh>;
  33977. /**
  33978. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33979. * @returns a number
  33980. */
  33981. getAnimationRatio(): number;
  33982. /**
  33983. * Gets an unique Id for the current render phase
  33984. * @returns a number
  33985. */
  33986. getRenderId(): number;
  33987. /**
  33988. * Gets an unique Id for the current frame
  33989. * @returns a number
  33990. */
  33991. getFrameId(): number;
  33992. /** Call this function if you want to manually increment the render Id*/
  33993. incrementRenderId(): void;
  33994. private _createUbo;
  33995. /**
  33996. * Use this method to simulate a pointer move on a mesh
  33997. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33998. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33999. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34000. * @returns the current scene
  34001. */
  34002. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34003. /**
  34004. * Use this method to simulate a pointer down on a mesh
  34005. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34006. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34007. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34008. * @returns the current scene
  34009. */
  34010. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34011. /**
  34012. * Use this method to simulate a pointer up on a mesh
  34013. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34014. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34015. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34016. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34017. * @returns the current scene
  34018. */
  34019. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34020. /**
  34021. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34022. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34023. * @returns true if the pointer was captured
  34024. */
  34025. isPointerCaptured(pointerId?: number): boolean;
  34026. /**
  34027. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34028. * @param attachUp defines if you want to attach events to pointerup
  34029. * @param attachDown defines if you want to attach events to pointerdown
  34030. * @param attachMove defines if you want to attach events to pointermove
  34031. */
  34032. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34033. /** Detaches all event handlers*/
  34034. detachControl(): void;
  34035. /**
  34036. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34037. * Delay loaded resources are not taking in account
  34038. * @return true if all required resources are ready
  34039. */
  34040. isReady(): boolean;
  34041. /** Resets all cached information relative to material (including effect and visibility) */
  34042. resetCachedMaterial(): void;
  34043. /**
  34044. * Registers a function to be called before every frame render
  34045. * @param func defines the function to register
  34046. */
  34047. registerBeforeRender(func: () => void): void;
  34048. /**
  34049. * Unregisters a function called before every frame render
  34050. * @param func defines the function to unregister
  34051. */
  34052. unregisterBeforeRender(func: () => void): void;
  34053. /**
  34054. * Registers a function to be called after every frame render
  34055. * @param func defines the function to register
  34056. */
  34057. registerAfterRender(func: () => void): void;
  34058. /**
  34059. * Unregisters a function called after every frame render
  34060. * @param func defines the function to unregister
  34061. */
  34062. unregisterAfterRender(func: () => void): void;
  34063. private _executeOnceBeforeRender;
  34064. /**
  34065. * The provided function will run before render once and will be disposed afterwards.
  34066. * A timeout delay can be provided so that the function will be executed in N ms.
  34067. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34068. * @param func The function to be executed.
  34069. * @param timeout optional delay in ms
  34070. */
  34071. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34072. /** @hidden */
  34073. _addPendingData(data: any): void;
  34074. /** @hidden */
  34075. _removePendingData(data: any): void;
  34076. /**
  34077. * Returns the number of items waiting to be loaded
  34078. * @returns the number of items waiting to be loaded
  34079. */
  34080. getWaitingItemsCount(): number;
  34081. /**
  34082. * Returns a boolean indicating if the scene is still loading data
  34083. */
  34084. readonly isLoading: boolean;
  34085. /**
  34086. * Registers a function to be executed when the scene is ready
  34087. * @param {Function} func - the function to be executed
  34088. */
  34089. executeWhenReady(func: () => void): void;
  34090. /**
  34091. * Returns a promise that resolves when the scene is ready
  34092. * @returns A promise that resolves when the scene is ready
  34093. */
  34094. whenReadyAsync(): Promise<void>;
  34095. /** @hidden */
  34096. _checkIsReady(): void;
  34097. /**
  34098. * Gets all animatable attached to the scene
  34099. */
  34100. readonly animatables: Animatable[];
  34101. /**
  34102. * Resets the last animation time frame.
  34103. * Useful to override when animations start running when loading a scene for the first time.
  34104. */
  34105. resetLastAnimationTimeFrame(): void;
  34106. /**
  34107. * Gets the current view matrix
  34108. * @returns a Matrix
  34109. */
  34110. getViewMatrix(): Matrix;
  34111. /**
  34112. * Gets the current projection matrix
  34113. * @returns a Matrix
  34114. */
  34115. getProjectionMatrix(): Matrix;
  34116. /**
  34117. * Gets the current transform matrix
  34118. * @returns a Matrix made of View * Projection
  34119. */
  34120. getTransformMatrix(): Matrix;
  34121. /**
  34122. * Sets the current transform matrix
  34123. * @param viewL defines the View matrix to use
  34124. * @param projectionL defines the Projection matrix to use
  34125. * @param viewR defines the right View matrix to use (if provided)
  34126. * @param projectionR defines the right Projection matrix to use (if provided)
  34127. */
  34128. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34129. /**
  34130. * Gets the uniform buffer used to store scene data
  34131. * @returns a UniformBuffer
  34132. */
  34133. getSceneUniformBuffer(): UniformBuffer;
  34134. /**
  34135. * Gets an unique (relatively to the current scene) Id
  34136. * @returns an unique number for the scene
  34137. */
  34138. getUniqueId(): number;
  34139. /**
  34140. * Add a mesh to the list of scene's meshes
  34141. * @param newMesh defines the mesh to add
  34142. * @param recursive if all child meshes should also be added to the scene
  34143. */
  34144. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34145. /**
  34146. * Remove a mesh for the list of scene's meshes
  34147. * @param toRemove defines the mesh to remove
  34148. * @param recursive if all child meshes should also be removed from the scene
  34149. * @returns the index where the mesh was in the mesh list
  34150. */
  34151. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34152. /**
  34153. * Add a transform node to the list of scene's transform nodes
  34154. * @param newTransformNode defines the transform node to add
  34155. */
  34156. addTransformNode(newTransformNode: TransformNode): void;
  34157. /**
  34158. * Remove a transform node for the list of scene's transform nodes
  34159. * @param toRemove defines the transform node to remove
  34160. * @returns the index where the transform node was in the transform node list
  34161. */
  34162. removeTransformNode(toRemove: TransformNode): number;
  34163. /**
  34164. * Remove a skeleton for the list of scene's skeletons
  34165. * @param toRemove defines the skeleton to remove
  34166. * @returns the index where the skeleton was in the skeleton list
  34167. */
  34168. removeSkeleton(toRemove: Skeleton): number;
  34169. /**
  34170. * Remove a morph target for the list of scene's morph targets
  34171. * @param toRemove defines the morph target to remove
  34172. * @returns the index where the morph target was in the morph target list
  34173. */
  34174. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34175. /**
  34176. * Remove a light for the list of scene's lights
  34177. * @param toRemove defines the light to remove
  34178. * @returns the index where the light was in the light list
  34179. */
  34180. removeLight(toRemove: Light): number;
  34181. /**
  34182. * Remove a camera for the list of scene's cameras
  34183. * @param toRemove defines the camera to remove
  34184. * @returns the index where the camera was in the camera list
  34185. */
  34186. removeCamera(toRemove: Camera): number;
  34187. /**
  34188. * Remove a particle system for the list of scene's particle systems
  34189. * @param toRemove defines the particle system to remove
  34190. * @returns the index where the particle system was in the particle system list
  34191. */
  34192. removeParticleSystem(toRemove: IParticleSystem): number;
  34193. /**
  34194. * Remove a animation for the list of scene's animations
  34195. * @param toRemove defines the animation to remove
  34196. * @returns the index where the animation was in the animation list
  34197. */
  34198. removeAnimation(toRemove: Animation): number;
  34199. /**
  34200. * Will stop the animation of the given target
  34201. * @param target - the target
  34202. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34203. * @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)
  34204. */
  34205. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34206. /**
  34207. * Removes the given animation group from this scene.
  34208. * @param toRemove The animation group to remove
  34209. * @returns The index of the removed animation group
  34210. */
  34211. removeAnimationGroup(toRemove: AnimationGroup): number;
  34212. /**
  34213. * Removes the given multi-material from this scene.
  34214. * @param toRemove The multi-material to remove
  34215. * @returns The index of the removed multi-material
  34216. */
  34217. removeMultiMaterial(toRemove: MultiMaterial): number;
  34218. /**
  34219. * Removes the given material from this scene.
  34220. * @param toRemove The material to remove
  34221. * @returns The index of the removed material
  34222. */
  34223. removeMaterial(toRemove: Material): number;
  34224. /**
  34225. * Removes the given action manager from this scene.
  34226. * @param toRemove The action manager to remove
  34227. * @returns The index of the removed action manager
  34228. */
  34229. removeActionManager(toRemove: AbstractActionManager): number;
  34230. /**
  34231. * Removes the given texture from this scene.
  34232. * @param toRemove The texture to remove
  34233. * @returns The index of the removed texture
  34234. */
  34235. removeTexture(toRemove: BaseTexture): number;
  34236. /**
  34237. * Adds the given light to this scene
  34238. * @param newLight The light to add
  34239. */
  34240. addLight(newLight: Light): void;
  34241. /**
  34242. * Sorts the list list based on light priorities
  34243. */
  34244. sortLightsByPriority(): void;
  34245. /**
  34246. * Adds the given camera to this scene
  34247. * @param newCamera The camera to add
  34248. */
  34249. addCamera(newCamera: Camera): void;
  34250. /**
  34251. * Adds the given skeleton to this scene
  34252. * @param newSkeleton The skeleton to add
  34253. */
  34254. addSkeleton(newSkeleton: Skeleton): void;
  34255. /**
  34256. * Adds the given particle system to this scene
  34257. * @param newParticleSystem The particle system to add
  34258. */
  34259. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34260. /**
  34261. * Adds the given animation to this scene
  34262. * @param newAnimation The animation to add
  34263. */
  34264. addAnimation(newAnimation: Animation): void;
  34265. /**
  34266. * Adds the given animation group to this scene.
  34267. * @param newAnimationGroup The animation group to add
  34268. */
  34269. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34270. /**
  34271. * Adds the given multi-material to this scene
  34272. * @param newMultiMaterial The multi-material to add
  34273. */
  34274. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34275. /**
  34276. * Adds the given material to this scene
  34277. * @param newMaterial The material to add
  34278. */
  34279. addMaterial(newMaterial: Material): void;
  34280. /**
  34281. * Adds the given morph target to this scene
  34282. * @param newMorphTargetManager The morph target to add
  34283. */
  34284. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34285. /**
  34286. * Adds the given geometry to this scene
  34287. * @param newGeometry The geometry to add
  34288. */
  34289. addGeometry(newGeometry: Geometry): void;
  34290. /**
  34291. * Adds the given action manager to this scene
  34292. * @param newActionManager The action manager to add
  34293. */
  34294. addActionManager(newActionManager: AbstractActionManager): void;
  34295. /**
  34296. * Adds the given texture to this scene.
  34297. * @param newTexture The texture to add
  34298. */
  34299. addTexture(newTexture: BaseTexture): void;
  34300. /**
  34301. * Switch active camera
  34302. * @param newCamera defines the new active camera
  34303. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34304. */
  34305. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34306. /**
  34307. * sets the active camera of the scene using its ID
  34308. * @param id defines the camera's ID
  34309. * @return the new active camera or null if none found.
  34310. */
  34311. setActiveCameraByID(id: string): Nullable<Camera>;
  34312. /**
  34313. * sets the active camera of the scene using its name
  34314. * @param name defines the camera's name
  34315. * @returns the new active camera or null if none found.
  34316. */
  34317. setActiveCameraByName(name: string): Nullable<Camera>;
  34318. /**
  34319. * get an animation group using its name
  34320. * @param name defines the material's name
  34321. * @return the animation group or null if none found.
  34322. */
  34323. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34324. /**
  34325. * Get a material using its unique id
  34326. * @param uniqueId defines the material's unique id
  34327. * @return the material or null if none found.
  34328. */
  34329. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34330. /**
  34331. * get a material using its id
  34332. * @param id defines the material's ID
  34333. * @return the material or null if none found.
  34334. */
  34335. getMaterialByID(id: string): Nullable<Material>;
  34336. /**
  34337. * Gets a material using its name
  34338. * @param name defines the material's name
  34339. * @return the material or null if none found.
  34340. */
  34341. getMaterialByName(name: string): Nullable<Material>;
  34342. /**
  34343. * Gets a camera using its id
  34344. * @param id defines the id to look for
  34345. * @returns the camera or null if not found
  34346. */
  34347. getCameraByID(id: string): Nullable<Camera>;
  34348. /**
  34349. * Gets a camera using its unique id
  34350. * @param uniqueId defines the unique id to look for
  34351. * @returns the camera or null if not found
  34352. */
  34353. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34354. /**
  34355. * Gets a camera using its name
  34356. * @param name defines the camera's name
  34357. * @return the camera or null if none found.
  34358. */
  34359. getCameraByName(name: string): Nullable<Camera>;
  34360. /**
  34361. * Gets a bone using its id
  34362. * @param id defines the bone's id
  34363. * @return the bone or null if not found
  34364. */
  34365. getBoneByID(id: string): Nullable<Bone>;
  34366. /**
  34367. * Gets a bone using its id
  34368. * @param name defines the bone's name
  34369. * @return the bone or null if not found
  34370. */
  34371. getBoneByName(name: string): Nullable<Bone>;
  34372. /**
  34373. * Gets a light node using its name
  34374. * @param name defines the the light's name
  34375. * @return the light or null if none found.
  34376. */
  34377. getLightByName(name: string): Nullable<Light>;
  34378. /**
  34379. * Gets a light node using its id
  34380. * @param id defines the light's id
  34381. * @return the light or null if none found.
  34382. */
  34383. getLightByID(id: string): Nullable<Light>;
  34384. /**
  34385. * Gets a light node using its scene-generated unique ID
  34386. * @param uniqueId defines the light's unique id
  34387. * @return the light or null if none found.
  34388. */
  34389. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34390. /**
  34391. * Gets a particle system by id
  34392. * @param id defines the particle system id
  34393. * @return the corresponding system or null if none found
  34394. */
  34395. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34396. /**
  34397. * Gets a geometry using its ID
  34398. * @param id defines the geometry's id
  34399. * @return the geometry or null if none found.
  34400. */
  34401. getGeometryByID(id: string): Nullable<Geometry>;
  34402. private _getGeometryByUniqueID;
  34403. /**
  34404. * Add a new geometry to this scene
  34405. * @param geometry defines the geometry to be added to the scene.
  34406. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34407. * @return a boolean defining if the geometry was added or not
  34408. */
  34409. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34410. /**
  34411. * Removes an existing geometry
  34412. * @param geometry defines the geometry to be removed from the scene
  34413. * @return a boolean defining if the geometry was removed or not
  34414. */
  34415. removeGeometry(geometry: Geometry): boolean;
  34416. /**
  34417. * Gets the list of geometries attached to the scene
  34418. * @returns an array of Geometry
  34419. */
  34420. getGeometries(): Geometry[];
  34421. /**
  34422. * Gets the first added mesh found of a given ID
  34423. * @param id defines the id to search for
  34424. * @return the mesh found or null if not found at all
  34425. */
  34426. getMeshByID(id: string): Nullable<AbstractMesh>;
  34427. /**
  34428. * Gets a list of meshes using their id
  34429. * @param id defines the id to search for
  34430. * @returns a list of meshes
  34431. */
  34432. getMeshesByID(id: string): Array<AbstractMesh>;
  34433. /**
  34434. * Gets the first added transform node found of a given ID
  34435. * @param id defines the id to search for
  34436. * @return the found transform node or null if not found at all.
  34437. */
  34438. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34439. /**
  34440. * Gets a transform node with its auto-generated unique id
  34441. * @param uniqueId efines the unique id to search for
  34442. * @return the found transform node or null if not found at all.
  34443. */
  34444. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34445. /**
  34446. * Gets a list of transform nodes using their id
  34447. * @param id defines the id to search for
  34448. * @returns a list of transform nodes
  34449. */
  34450. getTransformNodesByID(id: string): Array<TransformNode>;
  34451. /**
  34452. * Gets a mesh with its auto-generated unique id
  34453. * @param uniqueId defines the unique id to search for
  34454. * @return the found mesh or null if not found at all.
  34455. */
  34456. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34457. /**
  34458. * Gets a the last added mesh using a given id
  34459. * @param id defines the id to search for
  34460. * @return the found mesh or null if not found at all.
  34461. */
  34462. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34463. /**
  34464. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34465. * @param id defines the id to search for
  34466. * @return the found node or null if not found at all
  34467. */
  34468. getLastEntryByID(id: string): Nullable<Node>;
  34469. /**
  34470. * Gets a node (Mesh, Camera, Light) using a given id
  34471. * @param id defines the id to search for
  34472. * @return the found node or null if not found at all
  34473. */
  34474. getNodeByID(id: string): Nullable<Node>;
  34475. /**
  34476. * Gets a node (Mesh, Camera, Light) using a given name
  34477. * @param name defines the name to search for
  34478. * @return the found node or null if not found at all.
  34479. */
  34480. getNodeByName(name: string): Nullable<Node>;
  34481. /**
  34482. * Gets a mesh using a given name
  34483. * @param name defines the name to search for
  34484. * @return the found mesh or null if not found at all.
  34485. */
  34486. getMeshByName(name: string): Nullable<AbstractMesh>;
  34487. /**
  34488. * Gets a transform node using a given name
  34489. * @param name defines the name to search for
  34490. * @return the found transform node or null if not found at all.
  34491. */
  34492. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34493. /**
  34494. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34495. * @param id defines the id to search for
  34496. * @return the found skeleton or null if not found at all.
  34497. */
  34498. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34499. /**
  34500. * Gets a skeleton using a given auto generated unique id
  34501. * @param uniqueId defines the unique id to search for
  34502. * @return the found skeleton or null if not found at all.
  34503. */
  34504. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34505. /**
  34506. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34507. * @param id defines the id to search for
  34508. * @return the found skeleton or null if not found at all.
  34509. */
  34510. getSkeletonById(id: string): Nullable<Skeleton>;
  34511. /**
  34512. * Gets a skeleton using a given name
  34513. * @param name defines the name to search for
  34514. * @return the found skeleton or null if not found at all.
  34515. */
  34516. getSkeletonByName(name: string): Nullable<Skeleton>;
  34517. /**
  34518. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34519. * @param id defines the id to search for
  34520. * @return the found morph target manager or null if not found at all.
  34521. */
  34522. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34523. /**
  34524. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34525. * @param id defines the id to search for
  34526. * @return the found morph target or null if not found at all.
  34527. */
  34528. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34529. /**
  34530. * Gets a boolean indicating if the given mesh is active
  34531. * @param mesh defines the mesh to look for
  34532. * @returns true if the mesh is in the active list
  34533. */
  34534. isActiveMesh(mesh: AbstractMesh): boolean;
  34535. /**
  34536. * Return a unique id as a string which can serve as an identifier for the scene
  34537. */
  34538. readonly uid: string;
  34539. /**
  34540. * Add an externaly attached data from its key.
  34541. * This method call will fail and return false, if such key already exists.
  34542. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34543. * @param key the unique key that identifies the data
  34544. * @param data the data object to associate to the key for this Engine instance
  34545. * @return true if no such key were already present and the data was added successfully, false otherwise
  34546. */
  34547. addExternalData<T>(key: string, data: T): boolean;
  34548. /**
  34549. * Get an externaly attached data from its key
  34550. * @param key the unique key that identifies the data
  34551. * @return the associated data, if present (can be null), or undefined if not present
  34552. */
  34553. getExternalData<T>(key: string): Nullable<T>;
  34554. /**
  34555. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34556. * @param key the unique key that identifies the data
  34557. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34558. * @return the associated data, can be null if the factory returned null.
  34559. */
  34560. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34561. /**
  34562. * Remove an externaly attached data from the Engine instance
  34563. * @param key the unique key that identifies the data
  34564. * @return true if the data was successfully removed, false if it doesn't exist
  34565. */
  34566. removeExternalData(key: string): boolean;
  34567. private _evaluateSubMesh;
  34568. /**
  34569. * Clear the processed materials smart array preventing retention point in material dispose.
  34570. */
  34571. freeProcessedMaterials(): void;
  34572. private _preventFreeActiveMeshesAndRenderingGroups;
  34573. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34574. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34575. * when disposing several meshes in a row or a hierarchy of meshes.
  34576. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34577. */
  34578. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34579. /**
  34580. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34581. */
  34582. freeActiveMeshes(): void;
  34583. /**
  34584. * Clear the info related to rendering groups preventing retention points during dispose.
  34585. */
  34586. freeRenderingGroups(): void;
  34587. /** @hidden */
  34588. _isInIntermediateRendering(): boolean;
  34589. /**
  34590. * Lambda returning the list of potentially active meshes.
  34591. */
  34592. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34593. /**
  34594. * Lambda returning the list of potentially active sub meshes.
  34595. */
  34596. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34597. /**
  34598. * Lambda returning the list of potentially intersecting sub meshes.
  34599. */
  34600. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34601. /**
  34602. * Lambda returning the list of potentially colliding sub meshes.
  34603. */
  34604. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34605. private _activeMeshesFrozen;
  34606. /**
  34607. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34608. * @returns the current scene
  34609. */
  34610. freezeActiveMeshes(): Scene;
  34611. /**
  34612. * Use this function to restart evaluating active meshes on every frame
  34613. * @returns the current scene
  34614. */
  34615. unfreezeActiveMeshes(): Scene;
  34616. private _evaluateActiveMeshes;
  34617. private _activeMesh;
  34618. /**
  34619. * Update the transform matrix to update from the current active camera
  34620. * @param force defines a boolean used to force the update even if cache is up to date
  34621. */
  34622. updateTransformMatrix(force?: boolean): void;
  34623. private _bindFrameBuffer;
  34624. /** @hidden */
  34625. _allowPostProcessClearColor: boolean;
  34626. /** @hidden */
  34627. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34628. private _processSubCameras;
  34629. private _checkIntersections;
  34630. /** @hidden */
  34631. _advancePhysicsEngineStep(step: number): void;
  34632. /**
  34633. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34634. */
  34635. getDeterministicFrameTime: () => number;
  34636. /** @hidden */
  34637. _animate(): void;
  34638. /** Execute all animations (for a frame) */
  34639. animate(): void;
  34640. /**
  34641. * Render the scene
  34642. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34643. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34644. */
  34645. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34646. /**
  34647. * Freeze all materials
  34648. * A frozen material will not be updatable but should be faster to render
  34649. */
  34650. freezeMaterials(): void;
  34651. /**
  34652. * Unfreeze all materials
  34653. * A frozen material will not be updatable but should be faster to render
  34654. */
  34655. unfreezeMaterials(): void;
  34656. /**
  34657. * Releases all held ressources
  34658. */
  34659. dispose(): void;
  34660. /**
  34661. * Gets if the scene is already disposed
  34662. */
  34663. readonly isDisposed: boolean;
  34664. /**
  34665. * Call this function to reduce memory footprint of the scene.
  34666. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34667. */
  34668. clearCachedVertexData(): void;
  34669. /**
  34670. * This function will remove the local cached buffer data from texture.
  34671. * It will save memory but will prevent the texture from being rebuilt
  34672. */
  34673. cleanCachedTextureBuffer(): void;
  34674. /**
  34675. * Get the world extend vectors with an optional filter
  34676. *
  34677. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34678. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34679. */
  34680. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34681. min: Vector3;
  34682. max: Vector3;
  34683. };
  34684. /**
  34685. * Creates a ray that can be used to pick in the scene
  34686. * @param x defines the x coordinate of the origin (on-screen)
  34687. * @param y defines the y coordinate of the origin (on-screen)
  34688. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34689. * @param camera defines the camera to use for the picking
  34690. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34691. * @returns a Ray
  34692. */
  34693. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34694. /**
  34695. * Creates a ray that can be used to pick in the scene
  34696. * @param x defines the x coordinate of the origin (on-screen)
  34697. * @param y defines the y coordinate of the origin (on-screen)
  34698. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34699. * @param result defines the ray where to store the picking ray
  34700. * @param camera defines the camera to use for the picking
  34701. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34702. * @returns the current scene
  34703. */
  34704. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34705. /**
  34706. * Creates a ray that can be used to pick in the scene
  34707. * @param x defines the x coordinate of the origin (on-screen)
  34708. * @param y defines the y coordinate of the origin (on-screen)
  34709. * @param camera defines the camera to use for the picking
  34710. * @returns a Ray
  34711. */
  34712. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34713. /**
  34714. * Creates a ray that can be used to pick in the scene
  34715. * @param x defines the x coordinate of the origin (on-screen)
  34716. * @param y defines the y coordinate of the origin (on-screen)
  34717. * @param result defines the ray where to store the picking ray
  34718. * @param camera defines the camera to use for the picking
  34719. * @returns the current scene
  34720. */
  34721. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34722. /** Launch a ray to try to pick a mesh in the scene
  34723. * @param x position on screen
  34724. * @param y position on screen
  34725. * @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
  34726. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34727. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34728. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34729. * @returns a PickingInfo
  34730. */
  34731. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34732. /** Use the given ray to pick a mesh in the scene
  34733. * @param ray The ray to use to pick meshes
  34734. * @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
  34735. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34736. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34737. * @returns a PickingInfo
  34738. */
  34739. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34740. /**
  34741. * Launch a ray to try to pick a mesh in the scene
  34742. * @param x X position on screen
  34743. * @param y Y position on screen
  34744. * @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
  34745. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34746. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34747. * @returns an array of PickingInfo
  34748. */
  34749. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34750. /**
  34751. * Launch a ray to try to pick a mesh in the scene
  34752. * @param ray Ray to use
  34753. * @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
  34754. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34755. * @returns an array of PickingInfo
  34756. */
  34757. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34758. /**
  34759. * Force the value of meshUnderPointer
  34760. * @param mesh defines the mesh to use
  34761. */
  34762. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34763. /**
  34764. * Gets the mesh under the pointer
  34765. * @returns a Mesh or null if no mesh is under the pointer
  34766. */
  34767. getPointerOverMesh(): Nullable<AbstractMesh>;
  34768. /** @hidden */
  34769. _rebuildGeometries(): void;
  34770. /** @hidden */
  34771. _rebuildTextures(): void;
  34772. private _getByTags;
  34773. /**
  34774. * Get a list of meshes by tags
  34775. * @param tagsQuery defines the tags query to use
  34776. * @param forEach defines a predicate used to filter results
  34777. * @returns an array of Mesh
  34778. */
  34779. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34780. /**
  34781. * Get a list of cameras by tags
  34782. * @param tagsQuery defines the tags query to use
  34783. * @param forEach defines a predicate used to filter results
  34784. * @returns an array of Camera
  34785. */
  34786. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34787. /**
  34788. * Get a list of lights by tags
  34789. * @param tagsQuery defines the tags query to use
  34790. * @param forEach defines a predicate used to filter results
  34791. * @returns an array of Light
  34792. */
  34793. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34794. /**
  34795. * Get a list of materials by tags
  34796. * @param tagsQuery defines the tags query to use
  34797. * @param forEach defines a predicate used to filter results
  34798. * @returns an array of Material
  34799. */
  34800. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34801. /**
  34802. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34803. * This allowed control for front to back rendering or reversly depending of the special needs.
  34804. *
  34805. * @param renderingGroupId The rendering group id corresponding to its index
  34806. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34807. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34808. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34809. */
  34810. 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;
  34811. /**
  34812. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34813. *
  34814. * @param renderingGroupId The rendering group id corresponding to its index
  34815. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34816. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34817. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34818. */
  34819. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34820. /**
  34821. * Gets the current auto clear configuration for one rendering group of the rendering
  34822. * manager.
  34823. * @param index the rendering group index to get the information for
  34824. * @returns The auto clear setup for the requested rendering group
  34825. */
  34826. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34827. private _blockMaterialDirtyMechanism;
  34828. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34829. blockMaterialDirtyMechanism: boolean;
  34830. /**
  34831. * Will flag all materials as dirty to trigger new shader compilation
  34832. * @param flag defines the flag used to specify which material part must be marked as dirty
  34833. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34834. */
  34835. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34836. /** @hidden */
  34837. _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;
  34838. /** @hidden */
  34839. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34840. }
  34841. }
  34842. declare module "babylonjs/assetContainer" {
  34843. import { AbstractScene } from "babylonjs/abstractScene";
  34844. import { Scene } from "babylonjs/scene";
  34845. import { Mesh } from "babylonjs/Meshes/mesh";
  34846. /**
  34847. * Set of assets to keep when moving a scene into an asset container.
  34848. */
  34849. export class KeepAssets extends AbstractScene {
  34850. }
  34851. /**
  34852. * Container with a set of assets that can be added or removed from a scene.
  34853. */
  34854. export class AssetContainer extends AbstractScene {
  34855. /**
  34856. * The scene the AssetContainer belongs to.
  34857. */
  34858. scene: Scene;
  34859. /**
  34860. * Instantiates an AssetContainer.
  34861. * @param scene The scene the AssetContainer belongs to.
  34862. */
  34863. constructor(scene: Scene);
  34864. /**
  34865. * Adds all the assets from the container to the scene.
  34866. */
  34867. addAllToScene(): void;
  34868. /**
  34869. * Removes all the assets in the container from the scene
  34870. */
  34871. removeAllFromScene(): void;
  34872. /**
  34873. * Disposes all the assets in the container
  34874. */
  34875. dispose(): void;
  34876. private _moveAssets;
  34877. /**
  34878. * Removes all the assets contained in the scene and adds them to the container.
  34879. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34880. */
  34881. moveAllFromScene(keepAssets?: KeepAssets): void;
  34882. /**
  34883. * 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.
  34884. * @returns the root mesh
  34885. */
  34886. createRootMesh(): Mesh;
  34887. }
  34888. }
  34889. declare module "babylonjs/abstractScene" {
  34890. import { Scene } from "babylonjs/scene";
  34891. import { Nullable } from "babylonjs/types";
  34892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34893. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34894. import { Geometry } from "babylonjs/Meshes/geometry";
  34895. import { Skeleton } from "babylonjs/Bones/skeleton";
  34896. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34897. import { AssetContainer } from "babylonjs/assetContainer";
  34898. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34899. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34900. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34901. import { Material } from "babylonjs/Materials/material";
  34902. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34903. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34904. import { Camera } from "babylonjs/Cameras/camera";
  34905. import { Light } from "babylonjs/Lights/light";
  34906. import { Node } from "babylonjs/node";
  34907. import { Animation } from "babylonjs/Animations/animation";
  34908. /**
  34909. * Defines how the parser contract is defined.
  34910. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34911. */
  34912. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34913. /**
  34914. * Defines how the individual parser contract is defined.
  34915. * These parser can parse an individual asset
  34916. */
  34917. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34918. /**
  34919. * Base class of the scene acting as a container for the different elements composing a scene.
  34920. * This class is dynamically extended by the different components of the scene increasing
  34921. * flexibility and reducing coupling
  34922. */
  34923. export abstract class AbstractScene {
  34924. /**
  34925. * Stores the list of available parsers in the application.
  34926. */
  34927. private static _BabylonFileParsers;
  34928. /**
  34929. * Stores the list of available individual parsers in the application.
  34930. */
  34931. private static _IndividualBabylonFileParsers;
  34932. /**
  34933. * Adds a parser in the list of available ones
  34934. * @param name Defines the name of the parser
  34935. * @param parser Defines the parser to add
  34936. */
  34937. static AddParser(name: string, parser: BabylonFileParser): void;
  34938. /**
  34939. * Gets a general parser from the list of avaialble ones
  34940. * @param name Defines the name of the parser
  34941. * @returns the requested parser or null
  34942. */
  34943. static GetParser(name: string): Nullable<BabylonFileParser>;
  34944. /**
  34945. * Adds n individual parser in the list of available ones
  34946. * @param name Defines the name of the parser
  34947. * @param parser Defines the parser to add
  34948. */
  34949. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34950. /**
  34951. * Gets an individual parser from the list of avaialble ones
  34952. * @param name Defines the name of the parser
  34953. * @returns the requested parser or null
  34954. */
  34955. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34956. /**
  34957. * Parser json data and populate both a scene and its associated container object
  34958. * @param jsonData Defines the data to parse
  34959. * @param scene Defines the scene to parse the data for
  34960. * @param container Defines the container attached to the parsing sequence
  34961. * @param rootUrl Defines the root url of the data
  34962. */
  34963. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34964. /**
  34965. * Gets the list of root nodes (ie. nodes with no parent)
  34966. */
  34967. rootNodes: Node[];
  34968. /** All of the cameras added to this scene
  34969. * @see http://doc.babylonjs.com/babylon101/cameras
  34970. */
  34971. cameras: Camera[];
  34972. /**
  34973. * All of the lights added to this scene
  34974. * @see http://doc.babylonjs.com/babylon101/lights
  34975. */
  34976. lights: Light[];
  34977. /**
  34978. * All of the (abstract) meshes added to this scene
  34979. */
  34980. meshes: AbstractMesh[];
  34981. /**
  34982. * The list of skeletons added to the scene
  34983. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34984. */
  34985. skeletons: Skeleton[];
  34986. /**
  34987. * All of the particle systems added to this scene
  34988. * @see http://doc.babylonjs.com/babylon101/particles
  34989. */
  34990. particleSystems: IParticleSystem[];
  34991. /**
  34992. * Gets a list of Animations associated with the scene
  34993. */
  34994. animations: Animation[];
  34995. /**
  34996. * All of the animation groups added to this scene
  34997. * @see http://doc.babylonjs.com/how_to/group
  34998. */
  34999. animationGroups: AnimationGroup[];
  35000. /**
  35001. * All of the multi-materials added to this scene
  35002. * @see http://doc.babylonjs.com/how_to/multi_materials
  35003. */
  35004. multiMaterials: MultiMaterial[];
  35005. /**
  35006. * All of the materials added to this scene
  35007. * In the context of a Scene, it is not supposed to be modified manually.
  35008. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35009. * Note also that the order of the Material wihin the array is not significant and might change.
  35010. * @see http://doc.babylonjs.com/babylon101/materials
  35011. */
  35012. materials: Material[];
  35013. /**
  35014. * The list of morph target managers added to the scene
  35015. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35016. */
  35017. morphTargetManagers: MorphTargetManager[];
  35018. /**
  35019. * The list of geometries used in the scene.
  35020. */
  35021. geometries: Geometry[];
  35022. /**
  35023. * All of the tranform nodes added to this scene
  35024. * In the context of a Scene, it is not supposed to be modified manually.
  35025. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35026. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35027. * @see http://doc.babylonjs.com/how_to/transformnode
  35028. */
  35029. transformNodes: TransformNode[];
  35030. /**
  35031. * ActionManagers available on the scene.
  35032. */
  35033. actionManagers: AbstractActionManager[];
  35034. /**
  35035. * Textures to keep.
  35036. */
  35037. textures: BaseTexture[];
  35038. /**
  35039. * Environment texture for the scene
  35040. */
  35041. environmentTexture: Nullable<BaseTexture>;
  35042. }
  35043. }
  35044. declare module "babylonjs/Audio/sound" {
  35045. import { Observable } from "babylonjs/Misc/observable";
  35046. import { Vector3 } from "babylonjs/Maths/math";
  35047. import { Nullable } from "babylonjs/types";
  35048. import { Scene } from "babylonjs/scene";
  35049. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35050. /**
  35051. * Defines a sound that can be played in the application.
  35052. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35054. */
  35055. export class Sound {
  35056. /**
  35057. * The name of the sound in the scene.
  35058. */
  35059. name: string;
  35060. /**
  35061. * Does the sound autoplay once loaded.
  35062. */
  35063. autoplay: boolean;
  35064. /**
  35065. * Does the sound loop after it finishes playing once.
  35066. */
  35067. loop: boolean;
  35068. /**
  35069. * Does the sound use a custom attenuation curve to simulate the falloff
  35070. * happening when the source gets further away from the camera.
  35071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35072. */
  35073. useCustomAttenuation: boolean;
  35074. /**
  35075. * The sound track id this sound belongs to.
  35076. */
  35077. soundTrackId: number;
  35078. /**
  35079. * Is this sound currently played.
  35080. */
  35081. isPlaying: boolean;
  35082. /**
  35083. * Is this sound currently paused.
  35084. */
  35085. isPaused: boolean;
  35086. /**
  35087. * Does this sound enables spatial sound.
  35088. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35089. */
  35090. spatialSound: boolean;
  35091. /**
  35092. * Define the reference distance the sound should be heard perfectly.
  35093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35094. */
  35095. refDistance: number;
  35096. /**
  35097. * Define the roll off factor of spatial sounds.
  35098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35099. */
  35100. rolloffFactor: number;
  35101. /**
  35102. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35104. */
  35105. maxDistance: number;
  35106. /**
  35107. * Define the distance attenuation model the sound will follow.
  35108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35109. */
  35110. distanceModel: string;
  35111. /**
  35112. * @hidden
  35113. * Back Compat
  35114. **/
  35115. onended: () => any;
  35116. /**
  35117. * Observable event when the current playing sound finishes.
  35118. */
  35119. onEndedObservable: Observable<Sound>;
  35120. private _panningModel;
  35121. private _playbackRate;
  35122. private _streaming;
  35123. private _startTime;
  35124. private _startOffset;
  35125. private _position;
  35126. /** @hidden */
  35127. _positionInEmitterSpace: boolean;
  35128. private _localDirection;
  35129. private _volume;
  35130. private _isReadyToPlay;
  35131. private _isDirectional;
  35132. private _readyToPlayCallback;
  35133. private _audioBuffer;
  35134. private _soundSource;
  35135. private _streamingSource;
  35136. private _soundPanner;
  35137. private _soundGain;
  35138. private _inputAudioNode;
  35139. private _outputAudioNode;
  35140. private _coneInnerAngle;
  35141. private _coneOuterAngle;
  35142. private _coneOuterGain;
  35143. private _scene;
  35144. private _connectedTransformNode;
  35145. private _customAttenuationFunction;
  35146. private _registerFunc;
  35147. private _isOutputConnected;
  35148. private _htmlAudioElement;
  35149. private _urlType;
  35150. /** @hidden */
  35151. static _SceneComponentInitialization: (scene: Scene) => void;
  35152. /**
  35153. * Create a sound and attach it to a scene
  35154. * @param name Name of your sound
  35155. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35156. * @param scene defines the scene the sound belongs to
  35157. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35158. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35159. */
  35160. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  35161. /**
  35162. * Release the sound and its associated resources
  35163. */
  35164. dispose(): void;
  35165. /**
  35166. * Gets if the sounds is ready to be played or not.
  35167. * @returns true if ready, otherwise false
  35168. */
  35169. isReady(): boolean;
  35170. private _soundLoaded;
  35171. /**
  35172. * Sets the data of the sound from an audiobuffer
  35173. * @param audioBuffer The audioBuffer containing the data
  35174. */
  35175. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35176. /**
  35177. * Updates the current sounds options such as maxdistance, loop...
  35178. * @param options A JSON object containing values named as the object properties
  35179. */
  35180. updateOptions(options: any): void;
  35181. private _createSpatialParameters;
  35182. private _updateSpatialParameters;
  35183. /**
  35184. * Switch the panning model to HRTF:
  35185. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35187. */
  35188. switchPanningModelToHRTF(): void;
  35189. /**
  35190. * Switch the panning model to Equal Power:
  35191. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35193. */
  35194. switchPanningModelToEqualPower(): void;
  35195. private _switchPanningModel;
  35196. /**
  35197. * Connect this sound to a sound track audio node like gain...
  35198. * @param soundTrackAudioNode the sound track audio node to connect to
  35199. */
  35200. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35201. /**
  35202. * Transform this sound into a directional source
  35203. * @param coneInnerAngle Size of the inner cone in degree
  35204. * @param coneOuterAngle Size of the outer cone in degree
  35205. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35206. */
  35207. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35208. /**
  35209. * Gets or sets the inner angle for the directional cone.
  35210. */
  35211. /**
  35212. * Gets or sets the inner angle for the directional cone.
  35213. */
  35214. directionalConeInnerAngle: number;
  35215. /**
  35216. * Gets or sets the outer angle for the directional cone.
  35217. */
  35218. /**
  35219. * Gets or sets the outer angle for the directional cone.
  35220. */
  35221. directionalConeOuterAngle: number;
  35222. /**
  35223. * Sets the position of the emitter if spatial sound is enabled
  35224. * @param newPosition Defines the new posisiton
  35225. */
  35226. setPosition(newPosition: Vector3): void;
  35227. /**
  35228. * Sets the local direction of the emitter if spatial sound is enabled
  35229. * @param newLocalDirection Defines the new local direction
  35230. */
  35231. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35232. private _updateDirection;
  35233. /** @hidden */
  35234. updateDistanceFromListener(): void;
  35235. /**
  35236. * Sets a new custom attenuation function for the sound.
  35237. * @param callback Defines the function used for the attenuation
  35238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35239. */
  35240. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35241. /**
  35242. * Play the sound
  35243. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35244. * @param offset (optional) Start the sound setting it at a specific time
  35245. */
  35246. play(time?: number, offset?: number): void;
  35247. private _onended;
  35248. /**
  35249. * Stop the sound
  35250. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35251. */
  35252. stop(time?: number): void;
  35253. /**
  35254. * Put the sound in pause
  35255. */
  35256. pause(): void;
  35257. /**
  35258. * Sets a dedicated volume for this sounds
  35259. * @param newVolume Define the new volume of the sound
  35260. * @param time Define in how long the sound should be at this value
  35261. */
  35262. setVolume(newVolume: number, time?: number): void;
  35263. /**
  35264. * Set the sound play back rate
  35265. * @param newPlaybackRate Define the playback rate the sound should be played at
  35266. */
  35267. setPlaybackRate(newPlaybackRate: number): void;
  35268. /**
  35269. * Gets the volume of the sound.
  35270. * @returns the volume of the sound
  35271. */
  35272. getVolume(): number;
  35273. /**
  35274. * Attach the sound to a dedicated mesh
  35275. * @param transformNode The transform node to connect the sound with
  35276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35277. */
  35278. attachToMesh(transformNode: TransformNode): void;
  35279. /**
  35280. * Detach the sound from the previously attached mesh
  35281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35282. */
  35283. detachFromMesh(): void;
  35284. private _onRegisterAfterWorldMatrixUpdate;
  35285. /**
  35286. * Clone the current sound in the scene.
  35287. * @returns the new sound clone
  35288. */
  35289. clone(): Nullable<Sound>;
  35290. /**
  35291. * Gets the current underlying audio buffer containing the data
  35292. * @returns the audio buffer
  35293. */
  35294. getAudioBuffer(): Nullable<AudioBuffer>;
  35295. /**
  35296. * Serializes the Sound in a JSON representation
  35297. * @returns the JSON representation of the sound
  35298. */
  35299. serialize(): any;
  35300. /**
  35301. * Parse a JSON representation of a sound to innstantiate in a given scene
  35302. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35303. * @param scene Define the scene the new parsed sound should be created in
  35304. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35305. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35306. * @returns the newly parsed sound
  35307. */
  35308. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35309. }
  35310. }
  35311. declare module "babylonjs/Actions/directAudioActions" {
  35312. import { Action } from "babylonjs/Actions/action";
  35313. import { Condition } from "babylonjs/Actions/condition";
  35314. import { Sound } from "babylonjs/Audio/sound";
  35315. /**
  35316. * This defines an action helpful to play a defined sound on a triggered action.
  35317. */
  35318. export class PlaySoundAction extends Action {
  35319. private _sound;
  35320. /**
  35321. * Instantiate the action
  35322. * @param triggerOptions defines the trigger options
  35323. * @param sound defines the sound to play
  35324. * @param condition defines the trigger related conditions
  35325. */
  35326. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35327. /** @hidden */
  35328. _prepare(): void;
  35329. /**
  35330. * Execute the action and play the sound.
  35331. */
  35332. execute(): void;
  35333. /**
  35334. * Serializes the actions and its related information.
  35335. * @param parent defines the object to serialize in
  35336. * @returns the serialized object
  35337. */
  35338. serialize(parent: any): any;
  35339. }
  35340. /**
  35341. * This defines an action helpful to stop a defined sound on a triggered action.
  35342. */
  35343. export class StopSoundAction extends Action {
  35344. private _sound;
  35345. /**
  35346. * Instantiate the action
  35347. * @param triggerOptions defines the trigger options
  35348. * @param sound defines the sound to stop
  35349. * @param condition defines the trigger related conditions
  35350. */
  35351. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35352. /** @hidden */
  35353. _prepare(): void;
  35354. /**
  35355. * Execute the action and stop the sound.
  35356. */
  35357. execute(): void;
  35358. /**
  35359. * Serializes the actions and its related information.
  35360. * @param parent defines the object to serialize in
  35361. * @returns the serialized object
  35362. */
  35363. serialize(parent: any): any;
  35364. }
  35365. }
  35366. declare module "babylonjs/Actions/interpolateValueAction" {
  35367. import { Action } from "babylonjs/Actions/action";
  35368. import { Condition } from "babylonjs/Actions/condition";
  35369. import { Observable } from "babylonjs/Misc/observable";
  35370. /**
  35371. * This defines an action responsible to change the value of a property
  35372. * by interpolating between its current value and the newly set one once triggered.
  35373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35374. */
  35375. export class InterpolateValueAction extends Action {
  35376. /**
  35377. * Defines the path of the property where the value should be interpolated
  35378. */
  35379. propertyPath: string;
  35380. /**
  35381. * Defines the target value at the end of the interpolation.
  35382. */
  35383. value: any;
  35384. /**
  35385. * Defines the time it will take for the property to interpolate to the value.
  35386. */
  35387. duration: number;
  35388. /**
  35389. * Defines if the other scene animations should be stopped when the action has been triggered
  35390. */
  35391. stopOtherAnimations?: boolean;
  35392. /**
  35393. * Defines a callback raised once the interpolation animation has been done.
  35394. */
  35395. onInterpolationDone?: () => void;
  35396. /**
  35397. * Observable triggered once the interpolation animation has been done.
  35398. */
  35399. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35400. private _target;
  35401. private _effectiveTarget;
  35402. private _property;
  35403. /**
  35404. * Instantiate the action
  35405. * @param triggerOptions defines the trigger options
  35406. * @param target defines the object containing the value to interpolate
  35407. * @param propertyPath defines the path to the property in the target object
  35408. * @param value defines the target value at the end of the interpolation
  35409. * @param duration deines the time it will take for the property to interpolate to the value.
  35410. * @param condition defines the trigger related conditions
  35411. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35412. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35413. */
  35414. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35415. /** @hidden */
  35416. _prepare(): void;
  35417. /**
  35418. * Execute the action starts the value interpolation.
  35419. */
  35420. execute(): void;
  35421. /**
  35422. * Serializes the actions and its related information.
  35423. * @param parent defines the object to serialize in
  35424. * @returns the serialized object
  35425. */
  35426. serialize(parent: any): any;
  35427. }
  35428. }
  35429. declare module "babylonjs/Actions/index" {
  35430. export * from "babylonjs/Actions/action";
  35431. export * from "babylonjs/Actions/actionEvent";
  35432. export * from "babylonjs/Actions/actionManager";
  35433. export * from "babylonjs/Actions/condition";
  35434. export * from "babylonjs/Actions/directActions";
  35435. export * from "babylonjs/Actions/directAudioActions";
  35436. export * from "babylonjs/Actions/interpolateValueAction";
  35437. }
  35438. declare module "babylonjs/Animations/index" {
  35439. export * from "babylonjs/Animations/animatable";
  35440. export * from "babylonjs/Animations/animation";
  35441. export * from "babylonjs/Animations/animationGroup";
  35442. export * from "babylonjs/Animations/animationPropertiesOverride";
  35443. export * from "babylonjs/Animations/easing";
  35444. export * from "babylonjs/Animations/runtimeAnimation";
  35445. export * from "babylonjs/Animations/animationEvent";
  35446. export * from "babylonjs/Animations/animationGroup";
  35447. export * from "babylonjs/Animations/animationKey";
  35448. export * from "babylonjs/Animations/animationRange";
  35449. }
  35450. declare module "babylonjs/Audio/soundTrack" {
  35451. import { Sound } from "babylonjs/Audio/sound";
  35452. import { Analyser } from "babylonjs/Audio/analyser";
  35453. import { Scene } from "babylonjs/scene";
  35454. /**
  35455. * Options allowed during the creation of a sound track.
  35456. */
  35457. export interface ISoundTrackOptions {
  35458. /**
  35459. * The volume the sound track should take during creation
  35460. */
  35461. volume?: number;
  35462. /**
  35463. * Define if the sound track is the main sound track of the scene
  35464. */
  35465. mainTrack?: boolean;
  35466. }
  35467. /**
  35468. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35469. * It will be also used in a future release to apply effects on a specific track.
  35470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35471. */
  35472. export class SoundTrack {
  35473. /**
  35474. * The unique identifier of the sound track in the scene.
  35475. */
  35476. id: number;
  35477. /**
  35478. * The list of sounds included in the sound track.
  35479. */
  35480. soundCollection: Array<Sound>;
  35481. private _outputAudioNode;
  35482. private _scene;
  35483. private _isMainTrack;
  35484. private _connectedAnalyser;
  35485. private _options;
  35486. private _isInitialized;
  35487. /**
  35488. * Creates a new sound track.
  35489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35490. * @param scene Define the scene the sound track belongs to
  35491. * @param options
  35492. */
  35493. constructor(scene: Scene, options?: ISoundTrackOptions);
  35494. private _initializeSoundTrackAudioGraph;
  35495. /**
  35496. * Release the sound track and its associated resources
  35497. */
  35498. dispose(): void;
  35499. /**
  35500. * Adds a sound to this sound track
  35501. * @param sound define the cound to add
  35502. * @ignoreNaming
  35503. */
  35504. AddSound(sound: Sound): void;
  35505. /**
  35506. * Removes a sound to this sound track
  35507. * @param sound define the cound to remove
  35508. * @ignoreNaming
  35509. */
  35510. RemoveSound(sound: Sound): void;
  35511. /**
  35512. * Set a global volume for the full sound track.
  35513. * @param newVolume Define the new volume of the sound track
  35514. */
  35515. setVolume(newVolume: number): void;
  35516. /**
  35517. * Switch the panning model to HRTF:
  35518. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35520. */
  35521. switchPanningModelToHRTF(): void;
  35522. /**
  35523. * Switch the panning model to Equal Power:
  35524. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35526. */
  35527. switchPanningModelToEqualPower(): void;
  35528. /**
  35529. * Connect the sound track to an audio analyser allowing some amazing
  35530. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35532. * @param analyser The analyser to connect to the engine
  35533. */
  35534. connectToAnalyser(analyser: Analyser): void;
  35535. }
  35536. }
  35537. declare module "babylonjs/Audio/audioSceneComponent" {
  35538. import { Sound } from "babylonjs/Audio/sound";
  35539. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35540. import { Nullable } from "babylonjs/types";
  35541. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35542. import { Scene } from "babylonjs/scene";
  35543. import { AbstractScene } from "babylonjs/abstractScene";
  35544. module "babylonjs/abstractScene" {
  35545. interface AbstractScene {
  35546. /**
  35547. * The list of sounds used in the scene.
  35548. */
  35549. sounds: Nullable<Array<Sound>>;
  35550. }
  35551. }
  35552. module "babylonjs/scene" {
  35553. interface Scene {
  35554. /**
  35555. * @hidden
  35556. * Backing field
  35557. */
  35558. _mainSoundTrack: SoundTrack;
  35559. /**
  35560. * The main sound track played by the scene.
  35561. * It cotains your primary collection of sounds.
  35562. */
  35563. mainSoundTrack: SoundTrack;
  35564. /**
  35565. * The list of sound tracks added to the scene
  35566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35567. */
  35568. soundTracks: Nullable<Array<SoundTrack>>;
  35569. /**
  35570. * Gets a sound using a given name
  35571. * @param name defines the name to search for
  35572. * @return the found sound or null if not found at all.
  35573. */
  35574. getSoundByName(name: string): Nullable<Sound>;
  35575. /**
  35576. * Gets or sets if audio support is enabled
  35577. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35578. */
  35579. audioEnabled: boolean;
  35580. /**
  35581. * Gets or sets if audio will be output to headphones
  35582. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35583. */
  35584. headphone: boolean;
  35585. }
  35586. }
  35587. /**
  35588. * Defines the sound scene component responsible to manage any sounds
  35589. * in a given scene.
  35590. */
  35591. export class AudioSceneComponent implements ISceneSerializableComponent {
  35592. /**
  35593. * The component name helpfull to identify the component in the list of scene components.
  35594. */
  35595. readonly name: string;
  35596. /**
  35597. * The scene the component belongs to.
  35598. */
  35599. scene: Scene;
  35600. private _audioEnabled;
  35601. /**
  35602. * Gets whether audio is enabled or not.
  35603. * Please use related enable/disable method to switch state.
  35604. */
  35605. readonly audioEnabled: boolean;
  35606. private _headphone;
  35607. /**
  35608. * Gets whether audio is outputing to headphone or not.
  35609. * Please use the according Switch methods to change output.
  35610. */
  35611. readonly headphone: boolean;
  35612. /**
  35613. * Creates a new instance of the component for the given scene
  35614. * @param scene Defines the scene to register the component in
  35615. */
  35616. constructor(scene: Scene);
  35617. /**
  35618. * Registers the component in a given scene
  35619. */
  35620. register(): void;
  35621. /**
  35622. * Rebuilds the elements related to this component in case of
  35623. * context lost for instance.
  35624. */
  35625. rebuild(): void;
  35626. /**
  35627. * Serializes the component data to the specified json object
  35628. * @param serializationObject The object to serialize to
  35629. */
  35630. serialize(serializationObject: any): void;
  35631. /**
  35632. * Adds all the elements from the container to the scene
  35633. * @param container the container holding the elements
  35634. */
  35635. addFromContainer(container: AbstractScene): void;
  35636. /**
  35637. * Removes all the elements in the container from the scene
  35638. * @param container contains the elements to remove
  35639. * @param dispose if the removed element should be disposed (default: false)
  35640. */
  35641. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35642. /**
  35643. * Disposes the component and the associated ressources.
  35644. */
  35645. dispose(): void;
  35646. /**
  35647. * Disables audio in the associated scene.
  35648. */
  35649. disableAudio(): void;
  35650. /**
  35651. * Enables audio in the associated scene.
  35652. */
  35653. enableAudio(): void;
  35654. /**
  35655. * Switch audio to headphone output.
  35656. */
  35657. switchAudioModeForHeadphones(): void;
  35658. /**
  35659. * Switch audio to normal speakers.
  35660. */
  35661. switchAudioModeForNormalSpeakers(): void;
  35662. private _afterRender;
  35663. }
  35664. }
  35665. declare module "babylonjs/Audio/weightedsound" {
  35666. import { Sound } from "babylonjs/Audio/sound";
  35667. /**
  35668. * Wraps one or more Sound objects and selects one with random weight for playback.
  35669. */
  35670. export class WeightedSound {
  35671. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35672. loop: boolean;
  35673. private _coneInnerAngle;
  35674. private _coneOuterAngle;
  35675. private _volume;
  35676. /** A Sound is currently playing. */
  35677. isPlaying: boolean;
  35678. /** A Sound is currently paused. */
  35679. isPaused: boolean;
  35680. private _sounds;
  35681. private _weights;
  35682. private _currentIndex?;
  35683. /**
  35684. * Creates a new WeightedSound from the list of sounds given.
  35685. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35686. * @param sounds Array of Sounds that will be selected from.
  35687. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35688. */
  35689. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35690. /**
  35691. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35692. */
  35693. /**
  35694. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35695. */
  35696. directionalConeInnerAngle: number;
  35697. /**
  35698. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35699. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35700. */
  35701. /**
  35702. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35703. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35704. */
  35705. directionalConeOuterAngle: number;
  35706. /**
  35707. * Playback volume.
  35708. */
  35709. /**
  35710. * Playback volume.
  35711. */
  35712. volume: number;
  35713. private _onended;
  35714. /**
  35715. * Suspend playback
  35716. */
  35717. pause(): void;
  35718. /**
  35719. * Stop playback
  35720. */
  35721. stop(): void;
  35722. /**
  35723. * Start playback.
  35724. * @param startOffset Position the clip head at a specific time in seconds.
  35725. */
  35726. play(startOffset?: number): void;
  35727. }
  35728. }
  35729. declare module "babylonjs/Audio/index" {
  35730. export * from "babylonjs/Audio/analyser";
  35731. export * from "babylonjs/Audio/audioEngine";
  35732. export * from "babylonjs/Audio/audioSceneComponent";
  35733. export * from "babylonjs/Audio/sound";
  35734. export * from "babylonjs/Audio/soundTrack";
  35735. export * from "babylonjs/Audio/weightedsound";
  35736. }
  35737. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35738. import { Behavior } from "babylonjs/Behaviors/behavior";
  35739. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35740. import { BackEase } from "babylonjs/Animations/easing";
  35741. /**
  35742. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35743. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35744. */
  35745. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35746. /**
  35747. * Gets the name of the behavior.
  35748. */
  35749. readonly name: string;
  35750. /**
  35751. * The easing function used by animations
  35752. */
  35753. static EasingFunction: BackEase;
  35754. /**
  35755. * The easing mode used by animations
  35756. */
  35757. static EasingMode: number;
  35758. /**
  35759. * The duration of the animation, in milliseconds
  35760. */
  35761. transitionDuration: number;
  35762. /**
  35763. * Length of the distance animated by the transition when lower radius is reached
  35764. */
  35765. lowerRadiusTransitionRange: number;
  35766. /**
  35767. * Length of the distance animated by the transition when upper radius is reached
  35768. */
  35769. upperRadiusTransitionRange: number;
  35770. private _autoTransitionRange;
  35771. /**
  35772. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35773. */
  35774. /**
  35775. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35776. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35777. */
  35778. autoTransitionRange: boolean;
  35779. private _attachedCamera;
  35780. private _onAfterCheckInputsObserver;
  35781. private _onMeshTargetChangedObserver;
  35782. /**
  35783. * Initializes the behavior.
  35784. */
  35785. init(): void;
  35786. /**
  35787. * Attaches the behavior to its arc rotate camera.
  35788. * @param camera Defines the camera to attach the behavior to
  35789. */
  35790. attach(camera: ArcRotateCamera): void;
  35791. /**
  35792. * Detaches the behavior from its current arc rotate camera.
  35793. */
  35794. detach(): void;
  35795. private _radiusIsAnimating;
  35796. private _radiusBounceTransition;
  35797. private _animatables;
  35798. private _cachedWheelPrecision;
  35799. /**
  35800. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35801. * @param radiusLimit The limit to check against.
  35802. * @return Bool to indicate if at limit.
  35803. */
  35804. private _isRadiusAtLimit;
  35805. /**
  35806. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35807. * @param radiusDelta The delta by which to animate to. Can be negative.
  35808. */
  35809. private _applyBoundRadiusAnimation;
  35810. /**
  35811. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35812. */
  35813. protected _clearAnimationLocks(): void;
  35814. /**
  35815. * Stops and removes all animations that have been applied to the camera
  35816. */
  35817. stopAllAnimations(): void;
  35818. }
  35819. }
  35820. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35821. import { Behavior } from "babylonjs/Behaviors/behavior";
  35822. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35823. import { ExponentialEase } from "babylonjs/Animations/easing";
  35824. import { Nullable } from "babylonjs/types";
  35825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35826. import { Vector3 } from "babylonjs/Maths/math";
  35827. /**
  35828. * 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.
  35829. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35830. */
  35831. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35832. /**
  35833. * Gets the name of the behavior.
  35834. */
  35835. readonly name: string;
  35836. private _mode;
  35837. private _radiusScale;
  35838. private _positionScale;
  35839. private _defaultElevation;
  35840. private _elevationReturnTime;
  35841. private _elevationReturnWaitTime;
  35842. private _zoomStopsAnimation;
  35843. private _framingTime;
  35844. /**
  35845. * The easing function used by animations
  35846. */
  35847. static EasingFunction: ExponentialEase;
  35848. /**
  35849. * The easing mode used by animations
  35850. */
  35851. static EasingMode: number;
  35852. /**
  35853. * Sets the current mode used by the behavior
  35854. */
  35855. /**
  35856. * Gets current mode used by the behavior.
  35857. */
  35858. mode: number;
  35859. /**
  35860. * Sets the scale applied to the radius (1 by default)
  35861. */
  35862. /**
  35863. * Gets the scale applied to the radius
  35864. */
  35865. radiusScale: number;
  35866. /**
  35867. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35868. */
  35869. /**
  35870. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35871. */
  35872. positionScale: number;
  35873. /**
  35874. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35875. * behaviour is triggered, in radians.
  35876. */
  35877. /**
  35878. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35879. * behaviour is triggered, in radians.
  35880. */
  35881. defaultElevation: number;
  35882. /**
  35883. * Sets the time (in milliseconds) taken to return to the default beta position.
  35884. * Negative value indicates camera should not return to default.
  35885. */
  35886. /**
  35887. * Gets the time (in milliseconds) taken to return to the default beta position.
  35888. * Negative value indicates camera should not return to default.
  35889. */
  35890. elevationReturnTime: number;
  35891. /**
  35892. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35893. */
  35894. /**
  35895. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35896. */
  35897. elevationReturnWaitTime: number;
  35898. /**
  35899. * Sets the flag that indicates if user zooming should stop animation.
  35900. */
  35901. /**
  35902. * Gets the flag that indicates if user zooming should stop animation.
  35903. */
  35904. zoomStopsAnimation: boolean;
  35905. /**
  35906. * Sets the transition time when framing the mesh, in milliseconds
  35907. */
  35908. /**
  35909. * Gets the transition time when framing the mesh, in milliseconds
  35910. */
  35911. framingTime: number;
  35912. /**
  35913. * Define if the behavior should automatically change the configured
  35914. * camera limits and sensibilities.
  35915. */
  35916. autoCorrectCameraLimitsAndSensibility: boolean;
  35917. private _onPrePointerObservableObserver;
  35918. private _onAfterCheckInputsObserver;
  35919. private _onMeshTargetChangedObserver;
  35920. private _attachedCamera;
  35921. private _isPointerDown;
  35922. private _lastInteractionTime;
  35923. /**
  35924. * Initializes the behavior.
  35925. */
  35926. init(): void;
  35927. /**
  35928. * Attaches the behavior to its arc rotate camera.
  35929. * @param camera Defines the camera to attach the behavior to
  35930. */
  35931. attach(camera: ArcRotateCamera): void;
  35932. /**
  35933. * Detaches the behavior from its current arc rotate camera.
  35934. */
  35935. detach(): void;
  35936. private _animatables;
  35937. private _betaIsAnimating;
  35938. private _betaTransition;
  35939. private _radiusTransition;
  35940. private _vectorTransition;
  35941. /**
  35942. * Targets the given mesh and updates zoom level accordingly.
  35943. * @param mesh The mesh to target.
  35944. * @param radius Optional. If a cached radius position already exists, overrides default.
  35945. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35946. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35947. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35948. */
  35949. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35950. /**
  35951. * Targets the given mesh with its children and updates zoom level accordingly.
  35952. * @param mesh The mesh to target.
  35953. * @param radius Optional. If a cached radius position already exists, overrides default.
  35954. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35955. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35956. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35957. */
  35958. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35959. /**
  35960. * Targets the given meshes with their children and updates zoom level accordingly.
  35961. * @param meshes The mesh to target.
  35962. * @param radius Optional. If a cached radius position already exists, overrides default.
  35963. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35964. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35965. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35966. */
  35967. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35968. /**
  35969. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35970. * @param minimumWorld Determines the smaller position of the bounding box extend
  35971. * @param maximumWorld Determines the bigger position of the bounding box extend
  35972. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35973. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35974. */
  35975. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35976. /**
  35977. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35978. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35979. * frustum width.
  35980. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35981. * to fully enclose the mesh in the viewing frustum.
  35982. */
  35983. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35984. /**
  35985. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35986. * is automatically returned to its default position (expected to be above ground plane).
  35987. */
  35988. private _maintainCameraAboveGround;
  35989. /**
  35990. * Returns the frustum slope based on the canvas ratio and camera FOV
  35991. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35992. */
  35993. private _getFrustumSlope;
  35994. /**
  35995. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35996. */
  35997. private _clearAnimationLocks;
  35998. /**
  35999. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36000. */
  36001. private _applyUserInteraction;
  36002. /**
  36003. * Stops and removes all animations that have been applied to the camera
  36004. */
  36005. stopAllAnimations(): void;
  36006. /**
  36007. * Gets a value indicating if the user is moving the camera
  36008. */
  36009. readonly isUserIsMoving: boolean;
  36010. /**
  36011. * The camera can move all the way towards the mesh.
  36012. */
  36013. static IgnoreBoundsSizeMode: number;
  36014. /**
  36015. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36016. */
  36017. static FitFrustumSidesMode: number;
  36018. }
  36019. }
  36020. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36021. import { Nullable } from "babylonjs/types";
  36022. import { Camera } from "babylonjs/Cameras/camera";
  36023. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36024. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36025. /**
  36026. * Base class for Camera Pointer Inputs.
  36027. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36028. * for example usage.
  36029. */
  36030. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36031. /**
  36032. * Defines the camera the input is attached to.
  36033. */
  36034. abstract camera: Camera;
  36035. /**
  36036. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36037. */
  36038. protected _altKey: boolean;
  36039. protected _ctrlKey: boolean;
  36040. protected _metaKey: boolean;
  36041. protected _shiftKey: boolean;
  36042. /**
  36043. * Which mouse buttons were pressed at time of last mouse event.
  36044. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36045. */
  36046. protected _buttonsPressed: number;
  36047. /**
  36048. * Defines the buttons associated with the input to handle camera move.
  36049. */
  36050. buttons: number[];
  36051. /**
  36052. * Attach the input controls to a specific dom element to get the input from.
  36053. * @param element Defines the element the controls should be listened from
  36054. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36055. */
  36056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36057. /**
  36058. * Detach the current controls from the specified dom element.
  36059. * @param element Defines the element to stop listening the inputs from
  36060. */
  36061. detachControl(element: Nullable<HTMLElement>): void;
  36062. /**
  36063. * Gets the class name of the current input.
  36064. * @returns the class name
  36065. */
  36066. getClassName(): string;
  36067. /**
  36068. * Get the friendly name associated with the input class.
  36069. * @returns the input friendly name
  36070. */
  36071. getSimpleName(): string;
  36072. /**
  36073. * Called on pointer POINTERDOUBLETAP event.
  36074. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36075. */
  36076. protected onDoubleTap(type: string): void;
  36077. /**
  36078. * Called on pointer POINTERMOVE event if only a single touch is active.
  36079. * Override this method to provide functionality.
  36080. */
  36081. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36082. /**
  36083. * Called on pointer POINTERMOVE event if multiple touches are active.
  36084. * Override this method to provide functionality.
  36085. */
  36086. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36087. /**
  36088. * Called on JS contextmenu event.
  36089. * Override this method to provide functionality.
  36090. */
  36091. protected onContextMenu(evt: PointerEvent): void;
  36092. /**
  36093. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36094. * press.
  36095. * Override this method to provide functionality.
  36096. */
  36097. protected onButtonDown(evt: PointerEvent): void;
  36098. /**
  36099. * Called each time a new POINTERUP event occurs. Ie, for each button
  36100. * release.
  36101. * Override this method to provide functionality.
  36102. */
  36103. protected onButtonUp(evt: PointerEvent): void;
  36104. /**
  36105. * Called when window becomes inactive.
  36106. * Override this method to provide functionality.
  36107. */
  36108. protected onLostFocus(): void;
  36109. private _pointerInput;
  36110. private _observer;
  36111. private _onLostFocus;
  36112. private pointA;
  36113. private pointB;
  36114. }
  36115. }
  36116. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36117. import { Nullable } from "babylonjs/types";
  36118. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36119. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36120. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36121. /**
  36122. * Manage the pointers inputs to control an arc rotate camera.
  36123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36124. */
  36125. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36126. /**
  36127. * Defines the camera the input is attached to.
  36128. */
  36129. camera: ArcRotateCamera;
  36130. /**
  36131. * Gets the class name of the current input.
  36132. * @returns the class name
  36133. */
  36134. getClassName(): string;
  36135. /**
  36136. * Defines the buttons associated with the input to handle camera move.
  36137. */
  36138. buttons: number[];
  36139. /**
  36140. * Defines the pointer angular sensibility along the X axis or how fast is
  36141. * the camera rotating.
  36142. */
  36143. angularSensibilityX: number;
  36144. /**
  36145. * Defines the pointer angular sensibility along the Y axis or how fast is
  36146. * the camera rotating.
  36147. */
  36148. angularSensibilityY: number;
  36149. /**
  36150. * Defines the pointer pinch precision or how fast is the camera zooming.
  36151. */
  36152. pinchPrecision: number;
  36153. /**
  36154. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36155. * from 0.
  36156. * It defines the percentage of current camera.radius to use as delta when
  36157. * pinch zoom is used.
  36158. */
  36159. pinchDeltaPercentage: number;
  36160. /**
  36161. * Defines the pointer panning sensibility or how fast is the camera moving.
  36162. */
  36163. panningSensibility: number;
  36164. /**
  36165. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36166. */
  36167. multiTouchPanning: boolean;
  36168. /**
  36169. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36170. * zoom (pinch) through multitouch.
  36171. */
  36172. multiTouchPanAndZoom: boolean;
  36173. /**
  36174. * Revers pinch action direction.
  36175. */
  36176. pinchInwards: boolean;
  36177. private _isPanClick;
  36178. private _twoFingerActivityCount;
  36179. private _isPinching;
  36180. /**
  36181. * Called on pointer POINTERMOVE event if only a single touch is active.
  36182. */
  36183. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36184. /**
  36185. * Called on pointer POINTERDOUBLETAP event.
  36186. */
  36187. protected onDoubleTap(type: string): void;
  36188. /**
  36189. * Called on pointer POINTERMOVE event if multiple touches are active.
  36190. */
  36191. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36192. /**
  36193. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36194. * press.
  36195. */
  36196. protected onButtonDown(evt: PointerEvent): void;
  36197. /**
  36198. * Called each time a new POINTERUP event occurs. Ie, for each button
  36199. * release.
  36200. */
  36201. protected onButtonUp(evt: PointerEvent): void;
  36202. /**
  36203. * Called when window becomes inactive.
  36204. */
  36205. protected onLostFocus(): void;
  36206. }
  36207. }
  36208. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36209. import { Nullable } from "babylonjs/types";
  36210. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36211. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36212. /**
  36213. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36215. */
  36216. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36217. /**
  36218. * Defines the camera the input is attached to.
  36219. */
  36220. camera: ArcRotateCamera;
  36221. /**
  36222. * Defines the list of key codes associated with the up action (increase alpha)
  36223. */
  36224. keysUp: number[];
  36225. /**
  36226. * Defines the list of key codes associated with the down action (decrease alpha)
  36227. */
  36228. keysDown: number[];
  36229. /**
  36230. * Defines the list of key codes associated with the left action (increase beta)
  36231. */
  36232. keysLeft: number[];
  36233. /**
  36234. * Defines the list of key codes associated with the right action (decrease beta)
  36235. */
  36236. keysRight: number[];
  36237. /**
  36238. * Defines the list of key codes associated with the reset action.
  36239. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36240. */
  36241. keysReset: number[];
  36242. /**
  36243. * Defines the panning sensibility of the inputs.
  36244. * (How fast is the camera paning)
  36245. */
  36246. panningSensibility: number;
  36247. /**
  36248. * Defines the zooming sensibility of the inputs.
  36249. * (How fast is the camera zooming)
  36250. */
  36251. zoomingSensibility: number;
  36252. /**
  36253. * Defines wether maintaining the alt key down switch the movement mode from
  36254. * orientation to zoom.
  36255. */
  36256. useAltToZoom: boolean;
  36257. /**
  36258. * Rotation speed of the camera
  36259. */
  36260. angularSpeed: number;
  36261. private _keys;
  36262. private _ctrlPressed;
  36263. private _altPressed;
  36264. private _onCanvasBlurObserver;
  36265. private _onKeyboardObserver;
  36266. private _engine;
  36267. private _scene;
  36268. /**
  36269. * Attach the input controls to a specific dom element to get the input from.
  36270. * @param element Defines the element the controls should be listened from
  36271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36272. */
  36273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36274. /**
  36275. * Detach the current controls from the specified dom element.
  36276. * @param element Defines the element to stop listening the inputs from
  36277. */
  36278. detachControl(element: Nullable<HTMLElement>): void;
  36279. /**
  36280. * Update the current camera state depending on the inputs that have been used this frame.
  36281. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36282. */
  36283. checkInputs(): void;
  36284. /**
  36285. * Gets the class name of the current intput.
  36286. * @returns the class name
  36287. */
  36288. getClassName(): string;
  36289. /**
  36290. * Get the friendly name associated with the input class.
  36291. * @returns the input friendly name
  36292. */
  36293. getSimpleName(): string;
  36294. }
  36295. }
  36296. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36297. import { Nullable } from "babylonjs/types";
  36298. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36299. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36300. /**
  36301. * Manage the mouse wheel inputs to control an arc rotate camera.
  36302. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36303. */
  36304. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36305. /**
  36306. * Defines the camera the input is attached to.
  36307. */
  36308. camera: ArcRotateCamera;
  36309. /**
  36310. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36311. */
  36312. wheelPrecision: number;
  36313. /**
  36314. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36315. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36316. */
  36317. wheelDeltaPercentage: number;
  36318. private _wheel;
  36319. private _observer;
  36320. private computeDeltaFromMouseWheelLegacyEvent;
  36321. /**
  36322. * Attach the input controls to a specific dom element to get the input from.
  36323. * @param element Defines the element the controls should be listened from
  36324. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36325. */
  36326. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36327. /**
  36328. * Detach the current controls from the specified dom element.
  36329. * @param element Defines the element to stop listening the inputs from
  36330. */
  36331. detachControl(element: Nullable<HTMLElement>): void;
  36332. /**
  36333. * Gets the class name of the current intput.
  36334. * @returns the class name
  36335. */
  36336. getClassName(): string;
  36337. /**
  36338. * Get the friendly name associated with the input class.
  36339. * @returns the input friendly name
  36340. */
  36341. getSimpleName(): string;
  36342. }
  36343. }
  36344. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36345. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36346. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36347. /**
  36348. * Default Inputs manager for the ArcRotateCamera.
  36349. * It groups all the default supported inputs for ease of use.
  36350. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36351. */
  36352. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36353. /**
  36354. * Instantiates a new ArcRotateCameraInputsManager.
  36355. * @param camera Defines the camera the inputs belong to
  36356. */
  36357. constructor(camera: ArcRotateCamera);
  36358. /**
  36359. * Add mouse wheel input support to the input manager.
  36360. * @returns the current input manager
  36361. */
  36362. addMouseWheel(): ArcRotateCameraInputsManager;
  36363. /**
  36364. * Add pointers input support to the input manager.
  36365. * @returns the current input manager
  36366. */
  36367. addPointers(): ArcRotateCameraInputsManager;
  36368. /**
  36369. * Add keyboard input support to the input manager.
  36370. * @returns the current input manager
  36371. */
  36372. addKeyboard(): ArcRotateCameraInputsManager;
  36373. }
  36374. }
  36375. declare module "babylonjs/Cameras/arcRotateCamera" {
  36376. import { Observable } from "babylonjs/Misc/observable";
  36377. import { Nullable } from "babylonjs/types";
  36378. import { Scene } from "babylonjs/scene";
  36379. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36381. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36382. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36383. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36384. import { Camera } from "babylonjs/Cameras/camera";
  36385. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36386. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36387. import { Collider } from "babylonjs/Collisions/collider";
  36388. /**
  36389. * This represents an orbital type of camera.
  36390. *
  36391. * 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.
  36392. * 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.
  36393. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36394. */
  36395. export class ArcRotateCamera extends TargetCamera {
  36396. /**
  36397. * Defines the rotation angle of the camera along the longitudinal axis.
  36398. */
  36399. alpha: number;
  36400. /**
  36401. * Defines the rotation angle of the camera along the latitudinal axis.
  36402. */
  36403. beta: number;
  36404. /**
  36405. * Defines the radius of the camera from it s target point.
  36406. */
  36407. radius: number;
  36408. protected _target: Vector3;
  36409. protected _targetHost: Nullable<AbstractMesh>;
  36410. /**
  36411. * Defines the target point of the camera.
  36412. * The camera looks towards it form the radius distance.
  36413. */
  36414. target: Vector3;
  36415. /**
  36416. * Define the current local position of the camera in the scene
  36417. */
  36418. position: Vector3;
  36419. protected _upVector: Vector3;
  36420. protected _upToYMatrix: Matrix;
  36421. protected _YToUpMatrix: Matrix;
  36422. /**
  36423. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36424. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36425. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36426. */
  36427. upVector: Vector3;
  36428. /**
  36429. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36430. */
  36431. setMatUp(): void;
  36432. /**
  36433. * Current inertia value on the longitudinal axis.
  36434. * The bigger this number the longer it will take for the camera to stop.
  36435. */
  36436. inertialAlphaOffset: number;
  36437. /**
  36438. * Current inertia value on the latitudinal axis.
  36439. * The bigger this number the longer it will take for the camera to stop.
  36440. */
  36441. inertialBetaOffset: number;
  36442. /**
  36443. * Current inertia value on the radius axis.
  36444. * The bigger this number the longer it will take for the camera to stop.
  36445. */
  36446. inertialRadiusOffset: number;
  36447. /**
  36448. * Minimum allowed angle on the longitudinal axis.
  36449. * This can help limiting how the Camera is able to move in the scene.
  36450. */
  36451. lowerAlphaLimit: Nullable<number>;
  36452. /**
  36453. * Maximum allowed angle on the longitudinal axis.
  36454. * This can help limiting how the Camera is able to move in the scene.
  36455. */
  36456. upperAlphaLimit: Nullable<number>;
  36457. /**
  36458. * Minimum allowed angle on the latitudinal axis.
  36459. * This can help limiting how the Camera is able to move in the scene.
  36460. */
  36461. lowerBetaLimit: number;
  36462. /**
  36463. * Maximum allowed angle on the latitudinal axis.
  36464. * This can help limiting how the Camera is able to move in the scene.
  36465. */
  36466. upperBetaLimit: number;
  36467. /**
  36468. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36469. * This can help limiting how the Camera is able to move in the scene.
  36470. */
  36471. lowerRadiusLimit: Nullable<number>;
  36472. /**
  36473. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36474. * This can help limiting how the Camera is able to move in the scene.
  36475. */
  36476. upperRadiusLimit: Nullable<number>;
  36477. /**
  36478. * Defines the current inertia value used during panning of the camera along the X axis.
  36479. */
  36480. inertialPanningX: number;
  36481. /**
  36482. * Defines the current inertia value used during panning of the camera along the Y axis.
  36483. */
  36484. inertialPanningY: number;
  36485. /**
  36486. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36487. * Basically if your fingers moves away from more than this distance you will be considered
  36488. * in pinch mode.
  36489. */
  36490. pinchToPanMaxDistance: number;
  36491. /**
  36492. * Defines the maximum distance the camera can pan.
  36493. * This could help keeping the cammera always in your scene.
  36494. */
  36495. panningDistanceLimit: Nullable<number>;
  36496. /**
  36497. * Defines the target of the camera before paning.
  36498. */
  36499. panningOriginTarget: Vector3;
  36500. /**
  36501. * Defines the value of the inertia used during panning.
  36502. * 0 would mean stop inertia and one would mean no decelleration at all.
  36503. */
  36504. panningInertia: number;
  36505. /**
  36506. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36507. */
  36508. angularSensibilityX: number;
  36509. /**
  36510. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36511. */
  36512. angularSensibilityY: number;
  36513. /**
  36514. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36515. */
  36516. pinchPrecision: number;
  36517. /**
  36518. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36519. * It will be used instead of pinchDeltaPrecision if different from 0.
  36520. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36521. */
  36522. pinchDeltaPercentage: number;
  36523. /**
  36524. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36525. */
  36526. panningSensibility: number;
  36527. /**
  36528. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36529. */
  36530. keysUp: number[];
  36531. /**
  36532. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36533. */
  36534. keysDown: number[];
  36535. /**
  36536. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36537. */
  36538. keysLeft: number[];
  36539. /**
  36540. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36541. */
  36542. keysRight: number[];
  36543. /**
  36544. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36545. */
  36546. wheelPrecision: number;
  36547. /**
  36548. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36549. * It will be used instead of pinchDeltaPrecision if different from 0.
  36550. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36551. */
  36552. wheelDeltaPercentage: number;
  36553. /**
  36554. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36555. */
  36556. zoomOnFactor: number;
  36557. /**
  36558. * Defines a screen offset for the camera position.
  36559. */
  36560. targetScreenOffset: Vector2;
  36561. /**
  36562. * Allows the camera to be completely reversed.
  36563. * If false the camera can not arrive upside down.
  36564. */
  36565. allowUpsideDown: boolean;
  36566. /**
  36567. * Define if double tap/click is used to restore the previously saved state of the camera.
  36568. */
  36569. useInputToRestoreState: boolean;
  36570. /** @hidden */
  36571. _viewMatrix: Matrix;
  36572. /** @hidden */
  36573. _useCtrlForPanning: boolean;
  36574. /** @hidden */
  36575. _panningMouseButton: number;
  36576. /**
  36577. * Defines the input associated to the camera.
  36578. */
  36579. inputs: ArcRotateCameraInputsManager;
  36580. /** @hidden */
  36581. _reset: () => void;
  36582. /**
  36583. * Defines the allowed panning axis.
  36584. */
  36585. panningAxis: Vector3;
  36586. protected _localDirection: Vector3;
  36587. protected _transformedDirection: Vector3;
  36588. private _bouncingBehavior;
  36589. /**
  36590. * Gets the bouncing behavior of the camera if it has been enabled.
  36591. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36592. */
  36593. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36594. /**
  36595. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36596. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36597. */
  36598. useBouncingBehavior: boolean;
  36599. private _framingBehavior;
  36600. /**
  36601. * Gets the framing behavior of the camera if it has been enabled.
  36602. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36603. */
  36604. readonly framingBehavior: Nullable<FramingBehavior>;
  36605. /**
  36606. * Defines if the framing behavior of the camera is enabled on the camera.
  36607. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36608. */
  36609. useFramingBehavior: boolean;
  36610. private _autoRotationBehavior;
  36611. /**
  36612. * Gets the auto rotation behavior of the camera if it has been enabled.
  36613. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36614. */
  36615. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36616. /**
  36617. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36618. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36619. */
  36620. useAutoRotationBehavior: boolean;
  36621. /**
  36622. * Observable triggered when the mesh target has been changed on the camera.
  36623. */
  36624. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36625. /**
  36626. * Event raised when the camera is colliding with a mesh.
  36627. */
  36628. onCollide: (collidedMesh: AbstractMesh) => void;
  36629. /**
  36630. * Defines whether the camera should check collision with the objects oh the scene.
  36631. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36632. */
  36633. checkCollisions: boolean;
  36634. /**
  36635. * Defines the collision radius of the camera.
  36636. * This simulates a sphere around the camera.
  36637. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36638. */
  36639. collisionRadius: Vector3;
  36640. protected _collider: Collider;
  36641. protected _previousPosition: Vector3;
  36642. protected _collisionVelocity: Vector3;
  36643. protected _newPosition: Vector3;
  36644. protected _previousAlpha: number;
  36645. protected _previousBeta: number;
  36646. protected _previousRadius: number;
  36647. protected _collisionTriggered: boolean;
  36648. protected _targetBoundingCenter: Nullable<Vector3>;
  36649. private _computationVector;
  36650. /**
  36651. * Instantiates a new ArcRotateCamera in a given scene
  36652. * @param name Defines the name of the camera
  36653. * @param alpha Defines the camera rotation along the logitudinal axis
  36654. * @param beta Defines the camera rotation along the latitudinal axis
  36655. * @param radius Defines the camera distance from its target
  36656. * @param target Defines the camera target
  36657. * @param scene Defines the scene the camera belongs to
  36658. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36659. */
  36660. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36661. /** @hidden */
  36662. _initCache(): void;
  36663. /** @hidden */
  36664. _updateCache(ignoreParentClass?: boolean): void;
  36665. protected _getTargetPosition(): Vector3;
  36666. private _storedAlpha;
  36667. private _storedBeta;
  36668. private _storedRadius;
  36669. private _storedTarget;
  36670. /**
  36671. * Stores the current state of the camera (alpha, beta, radius and target)
  36672. * @returns the camera itself
  36673. */
  36674. storeState(): Camera;
  36675. /**
  36676. * @hidden
  36677. * Restored camera state. You must call storeState() first
  36678. */
  36679. _restoreStateValues(): boolean;
  36680. /** @hidden */
  36681. _isSynchronizedViewMatrix(): boolean;
  36682. /**
  36683. * Attached controls to the current camera.
  36684. * @param element Defines the element the controls should be listened from
  36685. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36686. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36687. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36688. */
  36689. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36690. /**
  36691. * Detach the current controls from the camera.
  36692. * The camera will stop reacting to inputs.
  36693. * @param element Defines the element to stop listening the inputs from
  36694. */
  36695. detachControl(element: HTMLElement): void;
  36696. /** @hidden */
  36697. _checkInputs(): void;
  36698. protected _checkLimits(): void;
  36699. /**
  36700. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36701. */
  36702. rebuildAnglesAndRadius(): void;
  36703. /**
  36704. * Use a position to define the current camera related information like aplha, beta and radius
  36705. * @param position Defines the position to set the camera at
  36706. */
  36707. setPosition(position: Vector3): void;
  36708. /**
  36709. * Defines the target the camera should look at.
  36710. * This will automatically adapt alpha beta and radius to fit within the new target.
  36711. * @param target Defines the new target as a Vector or a mesh
  36712. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36713. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36714. */
  36715. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36716. /** @hidden */
  36717. _getViewMatrix(): Matrix;
  36718. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36719. /**
  36720. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36721. * @param meshes Defines the mesh to zoom on
  36722. * @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)
  36723. */
  36724. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36725. /**
  36726. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36727. * The target will be changed but the radius
  36728. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36729. * @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)
  36730. */
  36731. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36732. min: Vector3;
  36733. max: Vector3;
  36734. distance: number;
  36735. }, doNotUpdateMaxZ?: boolean): void;
  36736. /**
  36737. * @override
  36738. * Override Camera.createRigCamera
  36739. */
  36740. createRigCamera(name: string, cameraIndex: number): Camera;
  36741. /**
  36742. * @hidden
  36743. * @override
  36744. * Override Camera._updateRigCameras
  36745. */
  36746. _updateRigCameras(): void;
  36747. /**
  36748. * Destroy the camera and release the current resources hold by it.
  36749. */
  36750. dispose(): void;
  36751. /**
  36752. * Gets the current object class name.
  36753. * @return the class name
  36754. */
  36755. getClassName(): string;
  36756. }
  36757. }
  36758. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36759. import { Behavior } from "babylonjs/Behaviors/behavior";
  36760. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36761. /**
  36762. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36763. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36764. */
  36765. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36766. /**
  36767. * Gets the name of the behavior.
  36768. */
  36769. readonly name: string;
  36770. private _zoomStopsAnimation;
  36771. private _idleRotationSpeed;
  36772. private _idleRotationWaitTime;
  36773. private _idleRotationSpinupTime;
  36774. /**
  36775. * Sets the flag that indicates if user zooming should stop animation.
  36776. */
  36777. /**
  36778. * Gets the flag that indicates if user zooming should stop animation.
  36779. */
  36780. zoomStopsAnimation: boolean;
  36781. /**
  36782. * Sets the default speed at which the camera rotates around the model.
  36783. */
  36784. /**
  36785. * Gets the default speed at which the camera rotates around the model.
  36786. */
  36787. idleRotationSpeed: number;
  36788. /**
  36789. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36790. */
  36791. /**
  36792. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36793. */
  36794. idleRotationWaitTime: number;
  36795. /**
  36796. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36797. */
  36798. /**
  36799. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36800. */
  36801. idleRotationSpinupTime: number;
  36802. /**
  36803. * Gets a value indicating if the camera is currently rotating because of this behavior
  36804. */
  36805. readonly rotationInProgress: boolean;
  36806. private _onPrePointerObservableObserver;
  36807. private _onAfterCheckInputsObserver;
  36808. private _attachedCamera;
  36809. private _isPointerDown;
  36810. private _lastFrameTime;
  36811. private _lastInteractionTime;
  36812. private _cameraRotationSpeed;
  36813. /**
  36814. * Initializes the behavior.
  36815. */
  36816. init(): void;
  36817. /**
  36818. * Attaches the behavior to its arc rotate camera.
  36819. * @param camera Defines the camera to attach the behavior to
  36820. */
  36821. attach(camera: ArcRotateCamera): void;
  36822. /**
  36823. * Detaches the behavior from its current arc rotate camera.
  36824. */
  36825. detach(): void;
  36826. /**
  36827. * Returns true if user is scrolling.
  36828. * @return true if user is scrolling.
  36829. */
  36830. private _userIsZooming;
  36831. private _lastFrameRadius;
  36832. private _shouldAnimationStopForInteraction;
  36833. /**
  36834. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36835. */
  36836. private _applyUserInteraction;
  36837. private _userIsMoving;
  36838. }
  36839. }
  36840. declare module "babylonjs/Behaviors/Cameras/index" {
  36841. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36842. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36843. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36844. }
  36845. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36846. import { Mesh } from "babylonjs/Meshes/mesh";
  36847. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36848. import { Behavior } from "babylonjs/Behaviors/behavior";
  36849. /**
  36850. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36851. */
  36852. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36853. private ui;
  36854. /**
  36855. * The name of the behavior
  36856. */
  36857. name: string;
  36858. /**
  36859. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36860. */
  36861. distanceAwayFromFace: number;
  36862. /**
  36863. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36864. */
  36865. distanceAwayFromBottomOfFace: number;
  36866. private _faceVectors;
  36867. private _target;
  36868. private _scene;
  36869. private _onRenderObserver;
  36870. private _tmpMatrix;
  36871. private _tmpVector;
  36872. /**
  36873. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36874. * @param ui The transform node that should be attched to the mesh
  36875. */
  36876. constructor(ui: TransformNode);
  36877. /**
  36878. * Initializes the behavior
  36879. */
  36880. init(): void;
  36881. private _closestFace;
  36882. private _zeroVector;
  36883. private _lookAtTmpMatrix;
  36884. private _lookAtToRef;
  36885. /**
  36886. * Attaches the AttachToBoxBehavior to the passed in mesh
  36887. * @param target The mesh that the specified node will be attached to
  36888. */
  36889. attach(target: Mesh): void;
  36890. /**
  36891. * Detaches the behavior from the mesh
  36892. */
  36893. detach(): void;
  36894. }
  36895. }
  36896. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36897. import { Behavior } from "babylonjs/Behaviors/behavior";
  36898. import { Mesh } from "babylonjs/Meshes/mesh";
  36899. /**
  36900. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36901. */
  36902. export class FadeInOutBehavior implements Behavior<Mesh> {
  36903. /**
  36904. * Time in milliseconds to delay before fading in (Default: 0)
  36905. */
  36906. delay: number;
  36907. /**
  36908. * Time in milliseconds for the mesh to fade in (Default: 300)
  36909. */
  36910. fadeInTime: number;
  36911. private _millisecondsPerFrame;
  36912. private _hovered;
  36913. private _hoverValue;
  36914. private _ownerNode;
  36915. /**
  36916. * Instatiates the FadeInOutBehavior
  36917. */
  36918. constructor();
  36919. /**
  36920. * The name of the behavior
  36921. */
  36922. readonly name: string;
  36923. /**
  36924. * Initializes the behavior
  36925. */
  36926. init(): void;
  36927. /**
  36928. * Attaches the fade behavior on the passed in mesh
  36929. * @param ownerNode The mesh that will be faded in/out once attached
  36930. */
  36931. attach(ownerNode: Mesh): void;
  36932. /**
  36933. * Detaches the behavior from the mesh
  36934. */
  36935. detach(): void;
  36936. /**
  36937. * Triggers the mesh to begin fading in or out
  36938. * @param value if the object should fade in or out (true to fade in)
  36939. */
  36940. fadeIn(value: boolean): void;
  36941. private _update;
  36942. private _setAllVisibility;
  36943. }
  36944. }
  36945. declare module "babylonjs/Misc/pivotTools" {
  36946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36947. /**
  36948. * Class containing a set of static utilities functions for managing Pivots
  36949. * @hidden
  36950. */
  36951. export class PivotTools {
  36952. private static _PivotCached;
  36953. private static _OldPivotPoint;
  36954. private static _PivotTranslation;
  36955. private static _PivotTmpVector;
  36956. /** @hidden */
  36957. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36958. /** @hidden */
  36959. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36960. }
  36961. }
  36962. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36963. import { Scene } from "babylonjs/scene";
  36964. import { Vector4, Plane } from "babylonjs/Maths/math";
  36965. import { Mesh } from "babylonjs/Meshes/mesh";
  36966. import { Nullable } from "babylonjs/types";
  36967. /**
  36968. * Class containing static functions to help procedurally build meshes
  36969. */
  36970. export class PlaneBuilder {
  36971. /**
  36972. * Creates a plane mesh
  36973. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36974. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36975. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36979. * @param name defines the name of the mesh
  36980. * @param options defines the options used to create the mesh
  36981. * @param scene defines the hosting scene
  36982. * @returns the plane mesh
  36983. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36984. */
  36985. static CreatePlane(name: string, options: {
  36986. size?: number;
  36987. width?: number;
  36988. height?: number;
  36989. sideOrientation?: number;
  36990. frontUVs?: Vector4;
  36991. backUVs?: Vector4;
  36992. updatable?: boolean;
  36993. sourcePlane?: Plane;
  36994. }, scene?: Nullable<Scene>): Mesh;
  36995. }
  36996. }
  36997. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36998. import { Behavior } from "babylonjs/Behaviors/behavior";
  36999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37000. import { Observable } from "babylonjs/Misc/observable";
  37001. import { Vector3 } from "babylonjs/Maths/math";
  37002. import { Ray } from "babylonjs/Culling/ray";
  37003. import "babylonjs/Meshes/Builders/planeBuilder";
  37004. /**
  37005. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37006. */
  37007. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37008. private static _AnyMouseID;
  37009. /**
  37010. * Abstract mesh the behavior is set on
  37011. */
  37012. attachedNode: AbstractMesh;
  37013. private _dragPlane;
  37014. private _scene;
  37015. private _pointerObserver;
  37016. private _beforeRenderObserver;
  37017. private static _planeScene;
  37018. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37019. /**
  37020. * 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)
  37021. */
  37022. maxDragAngle: number;
  37023. /**
  37024. * @hidden
  37025. */
  37026. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37027. /**
  37028. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37029. */
  37030. currentDraggingPointerID: number;
  37031. /**
  37032. * The last position where the pointer hit the drag plane in world space
  37033. */
  37034. lastDragPosition: Vector3;
  37035. /**
  37036. * If the behavior is currently in a dragging state
  37037. */
  37038. dragging: boolean;
  37039. /**
  37040. * 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)
  37041. */
  37042. dragDeltaRatio: number;
  37043. /**
  37044. * If the drag plane orientation should be updated during the dragging (Default: true)
  37045. */
  37046. updateDragPlane: boolean;
  37047. private _debugMode;
  37048. private _moving;
  37049. /**
  37050. * Fires each time the attached mesh is dragged with the pointer
  37051. * * delta between last drag position and current drag position in world space
  37052. * * dragDistance along the drag axis
  37053. * * dragPlaneNormal normal of the current drag plane used during the drag
  37054. * * dragPlanePoint in world space where the drag intersects the drag plane
  37055. */
  37056. onDragObservable: Observable<{
  37057. delta: Vector3;
  37058. dragPlanePoint: Vector3;
  37059. dragPlaneNormal: Vector3;
  37060. dragDistance: number;
  37061. pointerId: number;
  37062. }>;
  37063. /**
  37064. * Fires each time a drag begins (eg. mouse down on mesh)
  37065. */
  37066. onDragStartObservable: Observable<{
  37067. dragPlanePoint: Vector3;
  37068. pointerId: number;
  37069. }>;
  37070. /**
  37071. * Fires each time a drag ends (eg. mouse release after drag)
  37072. */
  37073. onDragEndObservable: Observable<{
  37074. dragPlanePoint: Vector3;
  37075. pointerId: number;
  37076. }>;
  37077. /**
  37078. * If the attached mesh should be moved when dragged
  37079. */
  37080. moveAttached: boolean;
  37081. /**
  37082. * If the drag behavior will react to drag events (Default: true)
  37083. */
  37084. enabled: boolean;
  37085. /**
  37086. * If camera controls should be detached during the drag
  37087. */
  37088. detachCameraControls: boolean;
  37089. /**
  37090. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37091. */
  37092. useObjectOrienationForDragging: boolean;
  37093. private _options;
  37094. /**
  37095. * Creates a pointer drag behavior that can be attached to a mesh
  37096. * @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)
  37097. */
  37098. constructor(options?: {
  37099. dragAxis?: Vector3;
  37100. dragPlaneNormal?: Vector3;
  37101. });
  37102. /**
  37103. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37104. */
  37105. validateDrag: (targetPosition: Vector3) => boolean;
  37106. /**
  37107. * The name of the behavior
  37108. */
  37109. readonly name: string;
  37110. /**
  37111. * Initializes the behavior
  37112. */
  37113. init(): void;
  37114. private _tmpVector;
  37115. private _alternatePickedPoint;
  37116. private _worldDragAxis;
  37117. private _targetPosition;
  37118. private _attachedElement;
  37119. /**
  37120. * Attaches the drag behavior the passed in mesh
  37121. * @param ownerNode The mesh that will be dragged around once attached
  37122. */
  37123. attach(ownerNode: AbstractMesh): void;
  37124. /**
  37125. * Force relase the drag action by code.
  37126. */
  37127. releaseDrag(): void;
  37128. private _startDragRay;
  37129. private _lastPointerRay;
  37130. /**
  37131. * Simulates the start of a pointer drag event on the behavior
  37132. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37133. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37134. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37135. */
  37136. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37137. private _startDrag;
  37138. private _dragDelta;
  37139. private _moveDrag;
  37140. private _pickWithRayOnDragPlane;
  37141. private _pointA;
  37142. private _pointB;
  37143. private _pointC;
  37144. private _lineA;
  37145. private _lineB;
  37146. private _localAxis;
  37147. private _lookAt;
  37148. private _updateDragPlanePosition;
  37149. /**
  37150. * Detaches the behavior from the mesh
  37151. */
  37152. detach(): void;
  37153. }
  37154. }
  37155. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37156. import { Mesh } from "babylonjs/Meshes/mesh";
  37157. import { Behavior } from "babylonjs/Behaviors/behavior";
  37158. /**
  37159. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37160. */
  37161. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37162. private _dragBehaviorA;
  37163. private _dragBehaviorB;
  37164. private _startDistance;
  37165. private _initialScale;
  37166. private _targetScale;
  37167. private _ownerNode;
  37168. private _sceneRenderObserver;
  37169. /**
  37170. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37171. */
  37172. constructor();
  37173. /**
  37174. * The name of the behavior
  37175. */
  37176. readonly name: string;
  37177. /**
  37178. * Initializes the behavior
  37179. */
  37180. init(): void;
  37181. private _getCurrentDistance;
  37182. /**
  37183. * Attaches the scale behavior the passed in mesh
  37184. * @param ownerNode The mesh that will be scaled around once attached
  37185. */
  37186. attach(ownerNode: Mesh): void;
  37187. /**
  37188. * Detaches the behavior from the mesh
  37189. */
  37190. detach(): void;
  37191. }
  37192. }
  37193. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37194. import { Behavior } from "babylonjs/Behaviors/behavior";
  37195. import { Mesh } from "babylonjs/Meshes/mesh";
  37196. import { Observable } from "babylonjs/Misc/observable";
  37197. /**
  37198. * 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
  37199. */
  37200. export class SixDofDragBehavior implements Behavior<Mesh> {
  37201. private static _virtualScene;
  37202. private _ownerNode;
  37203. private _sceneRenderObserver;
  37204. private _scene;
  37205. private _targetPosition;
  37206. private _virtualOriginMesh;
  37207. private _virtualDragMesh;
  37208. private _pointerObserver;
  37209. private _moving;
  37210. private _startingOrientation;
  37211. /**
  37212. * 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)
  37213. */
  37214. private zDragFactor;
  37215. /**
  37216. * If the object should rotate to face the drag origin
  37217. */
  37218. rotateDraggedObject: boolean;
  37219. /**
  37220. * If the behavior is currently in a dragging state
  37221. */
  37222. dragging: boolean;
  37223. /**
  37224. * 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)
  37225. */
  37226. dragDeltaRatio: number;
  37227. /**
  37228. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37229. */
  37230. currentDraggingPointerID: number;
  37231. /**
  37232. * If camera controls should be detached during the drag
  37233. */
  37234. detachCameraControls: boolean;
  37235. /**
  37236. * Fires each time a drag starts
  37237. */
  37238. onDragStartObservable: Observable<{}>;
  37239. /**
  37240. * Fires each time a drag ends (eg. mouse release after drag)
  37241. */
  37242. onDragEndObservable: Observable<{}>;
  37243. /**
  37244. * 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
  37245. */
  37246. constructor();
  37247. /**
  37248. * The name of the behavior
  37249. */
  37250. readonly name: string;
  37251. /**
  37252. * Initializes the behavior
  37253. */
  37254. init(): void;
  37255. /**
  37256. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37257. */
  37258. private readonly _pointerCamera;
  37259. /**
  37260. * Attaches the scale behavior the passed in mesh
  37261. * @param ownerNode The mesh that will be scaled around once attached
  37262. */
  37263. attach(ownerNode: Mesh): void;
  37264. /**
  37265. * Detaches the behavior from the mesh
  37266. */
  37267. detach(): void;
  37268. }
  37269. }
  37270. declare module "babylonjs/Behaviors/Meshes/index" {
  37271. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37272. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37273. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37274. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37275. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37276. }
  37277. declare module "babylonjs/Behaviors/index" {
  37278. export * from "babylonjs/Behaviors/behavior";
  37279. export * from "babylonjs/Behaviors/Cameras/index";
  37280. export * from "babylonjs/Behaviors/Meshes/index";
  37281. }
  37282. declare module "babylonjs/Bones/boneIKController" {
  37283. import { Bone } from "babylonjs/Bones/bone";
  37284. import { Vector3 } from "babylonjs/Maths/math";
  37285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37286. import { Nullable } from "babylonjs/types";
  37287. /**
  37288. * Class used to apply inverse kinematics to bones
  37289. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37290. */
  37291. export class BoneIKController {
  37292. private static _tmpVecs;
  37293. private static _tmpQuat;
  37294. private static _tmpMats;
  37295. /**
  37296. * Gets or sets the target mesh
  37297. */
  37298. targetMesh: AbstractMesh;
  37299. /** Gets or sets the mesh used as pole */
  37300. poleTargetMesh: AbstractMesh;
  37301. /**
  37302. * Gets or sets the bone used as pole
  37303. */
  37304. poleTargetBone: Nullable<Bone>;
  37305. /**
  37306. * Gets or sets the target position
  37307. */
  37308. targetPosition: Vector3;
  37309. /**
  37310. * Gets or sets the pole target position
  37311. */
  37312. poleTargetPosition: Vector3;
  37313. /**
  37314. * Gets or sets the pole target local offset
  37315. */
  37316. poleTargetLocalOffset: Vector3;
  37317. /**
  37318. * Gets or sets the pole angle
  37319. */
  37320. poleAngle: number;
  37321. /**
  37322. * Gets or sets the mesh associated with the controller
  37323. */
  37324. mesh: AbstractMesh;
  37325. /**
  37326. * 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)
  37327. */
  37328. slerpAmount: number;
  37329. private _bone1Quat;
  37330. private _bone1Mat;
  37331. private _bone2Ang;
  37332. private _bone1;
  37333. private _bone2;
  37334. private _bone1Length;
  37335. private _bone2Length;
  37336. private _maxAngle;
  37337. private _maxReach;
  37338. private _rightHandedSystem;
  37339. private _bendAxis;
  37340. private _slerping;
  37341. private _adjustRoll;
  37342. /**
  37343. * Gets or sets maximum allowed angle
  37344. */
  37345. maxAngle: number;
  37346. /**
  37347. * Creates a new BoneIKController
  37348. * @param mesh defines the mesh to control
  37349. * @param bone defines the bone to control
  37350. * @param options defines options to set up the controller
  37351. */
  37352. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37353. targetMesh?: AbstractMesh;
  37354. poleTargetMesh?: AbstractMesh;
  37355. poleTargetBone?: Bone;
  37356. poleTargetLocalOffset?: Vector3;
  37357. poleAngle?: number;
  37358. bendAxis?: Vector3;
  37359. maxAngle?: number;
  37360. slerpAmount?: number;
  37361. });
  37362. private _setMaxAngle;
  37363. /**
  37364. * Force the controller to update the bones
  37365. */
  37366. update(): void;
  37367. }
  37368. }
  37369. declare module "babylonjs/Bones/boneLookController" {
  37370. import { Vector3, Space } from "babylonjs/Maths/math";
  37371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37372. import { Bone } from "babylonjs/Bones/bone";
  37373. /**
  37374. * Class used to make a bone look toward a point in space
  37375. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37376. */
  37377. export class BoneLookController {
  37378. private static _tmpVecs;
  37379. private static _tmpQuat;
  37380. private static _tmpMats;
  37381. /**
  37382. * The target Vector3 that the bone will look at
  37383. */
  37384. target: Vector3;
  37385. /**
  37386. * The mesh that the bone is attached to
  37387. */
  37388. mesh: AbstractMesh;
  37389. /**
  37390. * The bone that will be looking to the target
  37391. */
  37392. bone: Bone;
  37393. /**
  37394. * The up axis of the coordinate system that is used when the bone is rotated
  37395. */
  37396. upAxis: Vector3;
  37397. /**
  37398. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37399. */
  37400. upAxisSpace: Space;
  37401. /**
  37402. * Used to make an adjustment to the yaw of the bone
  37403. */
  37404. adjustYaw: number;
  37405. /**
  37406. * Used to make an adjustment to the pitch of the bone
  37407. */
  37408. adjustPitch: number;
  37409. /**
  37410. * Used to make an adjustment to the roll of the bone
  37411. */
  37412. adjustRoll: number;
  37413. /**
  37414. * 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)
  37415. */
  37416. slerpAmount: number;
  37417. private _minYaw;
  37418. private _maxYaw;
  37419. private _minPitch;
  37420. private _maxPitch;
  37421. private _minYawSin;
  37422. private _minYawCos;
  37423. private _maxYawSin;
  37424. private _maxYawCos;
  37425. private _midYawConstraint;
  37426. private _minPitchTan;
  37427. private _maxPitchTan;
  37428. private _boneQuat;
  37429. private _slerping;
  37430. private _transformYawPitch;
  37431. private _transformYawPitchInv;
  37432. private _firstFrameSkipped;
  37433. private _yawRange;
  37434. private _fowardAxis;
  37435. /**
  37436. * Gets or sets the minimum yaw angle that the bone can look to
  37437. */
  37438. minYaw: number;
  37439. /**
  37440. * Gets or sets the maximum yaw angle that the bone can look to
  37441. */
  37442. maxYaw: number;
  37443. /**
  37444. * Gets or sets the minimum pitch angle that the bone can look to
  37445. */
  37446. minPitch: number;
  37447. /**
  37448. * Gets or sets the maximum pitch angle that the bone can look to
  37449. */
  37450. maxPitch: number;
  37451. /**
  37452. * Create a BoneLookController
  37453. * @param mesh the mesh that the bone belongs to
  37454. * @param bone the bone that will be looking to the target
  37455. * @param target the target Vector3 to look at
  37456. * @param options optional settings:
  37457. * * maxYaw: the maximum angle the bone will yaw to
  37458. * * minYaw: the minimum angle the bone will yaw to
  37459. * * maxPitch: the maximum angle the bone will pitch to
  37460. * * minPitch: the minimum angle the bone will yaw to
  37461. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37462. * * upAxis: the up axis of the coordinate system
  37463. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37464. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37465. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37466. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37467. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37468. * * adjustRoll: used to make an adjustment to the roll of the bone
  37469. **/
  37470. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37471. maxYaw?: number;
  37472. minYaw?: number;
  37473. maxPitch?: number;
  37474. minPitch?: number;
  37475. slerpAmount?: number;
  37476. upAxis?: Vector3;
  37477. upAxisSpace?: Space;
  37478. yawAxis?: Vector3;
  37479. pitchAxis?: Vector3;
  37480. adjustYaw?: number;
  37481. adjustPitch?: number;
  37482. adjustRoll?: number;
  37483. });
  37484. /**
  37485. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37486. */
  37487. update(): void;
  37488. private _getAngleDiff;
  37489. private _getAngleBetween;
  37490. private _isAngleBetween;
  37491. }
  37492. }
  37493. declare module "babylonjs/Bones/index" {
  37494. export * from "babylonjs/Bones/bone";
  37495. export * from "babylonjs/Bones/boneIKController";
  37496. export * from "babylonjs/Bones/boneLookController";
  37497. export * from "babylonjs/Bones/skeleton";
  37498. }
  37499. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37500. import { Nullable } from "babylonjs/types";
  37501. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37502. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37503. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37504. /**
  37505. * Manage the gamepad inputs to control an arc rotate camera.
  37506. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37507. */
  37508. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37509. /**
  37510. * Defines the camera the input is attached to.
  37511. */
  37512. camera: ArcRotateCamera;
  37513. /**
  37514. * Defines the gamepad the input is gathering event from.
  37515. */
  37516. gamepad: Nullable<Gamepad>;
  37517. /**
  37518. * Defines the gamepad rotation sensiblity.
  37519. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37520. */
  37521. gamepadRotationSensibility: number;
  37522. /**
  37523. * Defines the gamepad move sensiblity.
  37524. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37525. */
  37526. gamepadMoveSensibility: number;
  37527. private _onGamepadConnectedObserver;
  37528. private _onGamepadDisconnectedObserver;
  37529. /**
  37530. * Attach the input controls to a specific dom element to get the input from.
  37531. * @param element Defines the element the controls should be listened from
  37532. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37533. */
  37534. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37535. /**
  37536. * Detach the current controls from the specified dom element.
  37537. * @param element Defines the element to stop listening the inputs from
  37538. */
  37539. detachControl(element: Nullable<HTMLElement>): void;
  37540. /**
  37541. * Update the current camera state depending on the inputs that have been used this frame.
  37542. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37543. */
  37544. checkInputs(): void;
  37545. /**
  37546. * Gets the class name of the current intput.
  37547. * @returns the class name
  37548. */
  37549. getClassName(): string;
  37550. /**
  37551. * Get the friendly name associated with the input class.
  37552. * @returns the input friendly name
  37553. */
  37554. getSimpleName(): string;
  37555. }
  37556. }
  37557. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37558. import { Nullable } from "babylonjs/types";
  37559. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37560. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37561. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37562. interface ArcRotateCameraInputsManager {
  37563. /**
  37564. * Add orientation input support to the input manager.
  37565. * @returns the current input manager
  37566. */
  37567. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37568. }
  37569. }
  37570. /**
  37571. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37572. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37573. */
  37574. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37575. /**
  37576. * Defines the camera the input is attached to.
  37577. */
  37578. camera: ArcRotateCamera;
  37579. /**
  37580. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37581. */
  37582. alphaCorrection: number;
  37583. /**
  37584. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37585. */
  37586. gammaCorrection: number;
  37587. private _alpha;
  37588. private _gamma;
  37589. private _dirty;
  37590. private _deviceOrientationHandler;
  37591. /**
  37592. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37593. */
  37594. constructor();
  37595. /**
  37596. * Attach the input controls to a specific dom element to get the input from.
  37597. * @param element Defines the element the controls should be listened from
  37598. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37599. */
  37600. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37601. /** @hidden */
  37602. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37603. /**
  37604. * Update the current camera state depending on the inputs that have been used this frame.
  37605. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37606. */
  37607. checkInputs(): void;
  37608. /**
  37609. * Detach the current controls from the specified dom element.
  37610. * @param element Defines the element to stop listening the inputs from
  37611. */
  37612. detachControl(element: Nullable<HTMLElement>): void;
  37613. /**
  37614. * Gets the class name of the current intput.
  37615. * @returns the class name
  37616. */
  37617. getClassName(): string;
  37618. /**
  37619. * Get the friendly name associated with the input class.
  37620. * @returns the input friendly name
  37621. */
  37622. getSimpleName(): string;
  37623. }
  37624. }
  37625. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37626. import { Nullable } from "babylonjs/types";
  37627. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37628. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37629. /**
  37630. * Listen to mouse events to control the camera.
  37631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37632. */
  37633. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37634. /**
  37635. * Defines the camera the input is attached to.
  37636. */
  37637. camera: FlyCamera;
  37638. /**
  37639. * Defines if touch is enabled. (Default is true.)
  37640. */
  37641. touchEnabled: boolean;
  37642. /**
  37643. * Defines the buttons associated with the input to handle camera rotation.
  37644. */
  37645. buttons: number[];
  37646. /**
  37647. * Assign buttons for Yaw control.
  37648. */
  37649. buttonsYaw: number[];
  37650. /**
  37651. * Assign buttons for Pitch control.
  37652. */
  37653. buttonsPitch: number[];
  37654. /**
  37655. * Assign buttons for Roll control.
  37656. */
  37657. buttonsRoll: number[];
  37658. /**
  37659. * Detect if any button is being pressed while mouse is moved.
  37660. * -1 = Mouse locked.
  37661. * 0 = Left button.
  37662. * 1 = Middle Button.
  37663. * 2 = Right Button.
  37664. */
  37665. activeButton: number;
  37666. /**
  37667. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37668. * Higher values reduce its sensitivity.
  37669. */
  37670. angularSensibility: number;
  37671. private _mousemoveCallback;
  37672. private _observer;
  37673. private _rollObserver;
  37674. private previousPosition;
  37675. private noPreventDefault;
  37676. private element;
  37677. /**
  37678. * Listen to mouse events to control the camera.
  37679. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37681. */
  37682. constructor(touchEnabled?: boolean);
  37683. /**
  37684. * Attach the mouse control to the HTML DOM element.
  37685. * @param element Defines the element that listens to the input events.
  37686. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37687. */
  37688. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37689. /**
  37690. * Detach the current controls from the specified dom element.
  37691. * @param element Defines the element to stop listening the inputs from
  37692. */
  37693. detachControl(element: Nullable<HTMLElement>): void;
  37694. /**
  37695. * Gets the class name of the current input.
  37696. * @returns the class name.
  37697. */
  37698. getClassName(): string;
  37699. /**
  37700. * Get the friendly name associated with the input class.
  37701. * @returns the input's friendly name.
  37702. */
  37703. getSimpleName(): string;
  37704. private _pointerInput;
  37705. private _onMouseMove;
  37706. /**
  37707. * Rotate camera by mouse offset.
  37708. */
  37709. private rotateCamera;
  37710. }
  37711. }
  37712. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37713. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37714. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37715. /**
  37716. * Default Inputs manager for the FlyCamera.
  37717. * It groups all the default supported inputs for ease of use.
  37718. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37719. */
  37720. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37721. /**
  37722. * Instantiates a new FlyCameraInputsManager.
  37723. * @param camera Defines the camera the inputs belong to.
  37724. */
  37725. constructor(camera: FlyCamera);
  37726. /**
  37727. * Add keyboard input support to the input manager.
  37728. * @returns the new FlyCameraKeyboardMoveInput().
  37729. */
  37730. addKeyboard(): FlyCameraInputsManager;
  37731. /**
  37732. * Add mouse input support to the input manager.
  37733. * @param touchEnabled Enable touch screen support.
  37734. * @returns the new FlyCameraMouseInput().
  37735. */
  37736. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37737. }
  37738. }
  37739. declare module "babylonjs/Cameras/flyCamera" {
  37740. import { Scene } from "babylonjs/scene";
  37741. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37743. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37744. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37745. /**
  37746. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37747. * such as in a 3D Space Shooter or a Flight Simulator.
  37748. */
  37749. export class FlyCamera extends TargetCamera {
  37750. /**
  37751. * Define the collision ellipsoid of the camera.
  37752. * This is helpful for simulating a camera body, like a player's body.
  37753. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37754. */
  37755. ellipsoid: Vector3;
  37756. /**
  37757. * Define an offset for the position of the ellipsoid around the camera.
  37758. * This can be helpful if the camera is attached away from the player's body center,
  37759. * such as at its head.
  37760. */
  37761. ellipsoidOffset: Vector3;
  37762. /**
  37763. * Enable or disable collisions of the camera with the rest of the scene objects.
  37764. */
  37765. checkCollisions: boolean;
  37766. /**
  37767. * Enable or disable gravity on the camera.
  37768. */
  37769. applyGravity: boolean;
  37770. /**
  37771. * Define the current direction the camera is moving to.
  37772. */
  37773. cameraDirection: Vector3;
  37774. /**
  37775. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37776. * This overrides and empties cameraRotation.
  37777. */
  37778. rotationQuaternion: Quaternion;
  37779. /**
  37780. * Track Roll to maintain the wanted Rolling when looking around.
  37781. */
  37782. _trackRoll: number;
  37783. /**
  37784. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37785. */
  37786. rollCorrect: number;
  37787. /**
  37788. * Mimic a banked turn, Rolling the camera when Yawing.
  37789. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37790. */
  37791. bankedTurn: boolean;
  37792. /**
  37793. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37794. */
  37795. bankedTurnLimit: number;
  37796. /**
  37797. * Value of 0 disables the banked Roll.
  37798. * Value of 1 is equal to the Yaw angle in radians.
  37799. */
  37800. bankedTurnMultiplier: number;
  37801. /**
  37802. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37803. */
  37804. inputs: FlyCameraInputsManager;
  37805. /**
  37806. * Gets the input sensibility for mouse input.
  37807. * Higher values reduce sensitivity.
  37808. */
  37809. /**
  37810. * Sets the input sensibility for a mouse input.
  37811. * Higher values reduce sensitivity.
  37812. */
  37813. angularSensibility: number;
  37814. /**
  37815. * Get the keys for camera movement forward.
  37816. */
  37817. /**
  37818. * Set the keys for camera movement forward.
  37819. */
  37820. keysForward: number[];
  37821. /**
  37822. * Get the keys for camera movement backward.
  37823. */
  37824. keysBackward: number[];
  37825. /**
  37826. * Get the keys for camera movement up.
  37827. */
  37828. /**
  37829. * Set the keys for camera movement up.
  37830. */
  37831. keysUp: number[];
  37832. /**
  37833. * Get the keys for camera movement down.
  37834. */
  37835. /**
  37836. * Set the keys for camera movement down.
  37837. */
  37838. keysDown: number[];
  37839. /**
  37840. * Get the keys for camera movement left.
  37841. */
  37842. /**
  37843. * Set the keys for camera movement left.
  37844. */
  37845. keysLeft: number[];
  37846. /**
  37847. * Set the keys for camera movement right.
  37848. */
  37849. /**
  37850. * Set the keys for camera movement right.
  37851. */
  37852. keysRight: number[];
  37853. /**
  37854. * Event raised when the camera collides with a mesh in the scene.
  37855. */
  37856. onCollide: (collidedMesh: AbstractMesh) => void;
  37857. private _collider;
  37858. private _needMoveForGravity;
  37859. private _oldPosition;
  37860. private _diffPosition;
  37861. private _newPosition;
  37862. /** @hidden */
  37863. _localDirection: Vector3;
  37864. /** @hidden */
  37865. _transformedDirection: Vector3;
  37866. /**
  37867. * Instantiates a FlyCamera.
  37868. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37869. * such as in a 3D Space Shooter or a Flight Simulator.
  37870. * @param name Define the name of the camera in the scene.
  37871. * @param position Define the starting position of the camera in the scene.
  37872. * @param scene Define the scene the camera belongs to.
  37873. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37874. */
  37875. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37876. /**
  37877. * Attach a control to the HTML DOM element.
  37878. * @param element Defines the element that listens to the input events.
  37879. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37880. */
  37881. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37882. /**
  37883. * Detach a control from the HTML DOM element.
  37884. * The camera will stop reacting to that input.
  37885. * @param element Defines the element that listens to the input events.
  37886. */
  37887. detachControl(element: HTMLElement): void;
  37888. private _collisionMask;
  37889. /**
  37890. * Get the mask that the camera ignores in collision events.
  37891. */
  37892. /**
  37893. * Set the mask that the camera ignores in collision events.
  37894. */
  37895. collisionMask: number;
  37896. /** @hidden */
  37897. _collideWithWorld(displacement: Vector3): void;
  37898. /** @hidden */
  37899. private _onCollisionPositionChange;
  37900. /** @hidden */
  37901. _checkInputs(): void;
  37902. /** @hidden */
  37903. _decideIfNeedsToMove(): boolean;
  37904. /** @hidden */
  37905. _updatePosition(): void;
  37906. /**
  37907. * Restore the Roll to its target value at the rate specified.
  37908. * @param rate - Higher means slower restoring.
  37909. * @hidden
  37910. */
  37911. restoreRoll(rate: number): void;
  37912. /**
  37913. * Destroy the camera and release the current resources held by it.
  37914. */
  37915. dispose(): void;
  37916. /**
  37917. * Get the current object class name.
  37918. * @returns the class name.
  37919. */
  37920. getClassName(): string;
  37921. }
  37922. }
  37923. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37924. import { Nullable } from "babylonjs/types";
  37925. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37926. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37927. /**
  37928. * Listen to keyboard events to control the camera.
  37929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37930. */
  37931. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37932. /**
  37933. * Defines the camera the input is attached to.
  37934. */
  37935. camera: FlyCamera;
  37936. /**
  37937. * The list of keyboard keys used to control the forward move of the camera.
  37938. */
  37939. keysForward: number[];
  37940. /**
  37941. * The list of keyboard keys used to control the backward move of the camera.
  37942. */
  37943. keysBackward: number[];
  37944. /**
  37945. * The list of keyboard keys used to control the forward move of the camera.
  37946. */
  37947. keysUp: number[];
  37948. /**
  37949. * The list of keyboard keys used to control the backward move of the camera.
  37950. */
  37951. keysDown: number[];
  37952. /**
  37953. * The list of keyboard keys used to control the right strafe move of the camera.
  37954. */
  37955. keysRight: number[];
  37956. /**
  37957. * The list of keyboard keys used to control the left strafe move of the camera.
  37958. */
  37959. keysLeft: number[];
  37960. private _keys;
  37961. private _onCanvasBlurObserver;
  37962. private _onKeyboardObserver;
  37963. private _engine;
  37964. private _scene;
  37965. /**
  37966. * Attach the input controls to a specific dom element to get the input from.
  37967. * @param element Defines the element the controls should be listened from
  37968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37969. */
  37970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37971. /**
  37972. * Detach the current controls from the specified dom element.
  37973. * @param element Defines the element to stop listening the inputs from
  37974. */
  37975. detachControl(element: Nullable<HTMLElement>): void;
  37976. /**
  37977. * Gets the class name of the current intput.
  37978. * @returns the class name
  37979. */
  37980. getClassName(): string;
  37981. /** @hidden */
  37982. _onLostFocus(e: FocusEvent): void;
  37983. /**
  37984. * Get the friendly name associated with the input class.
  37985. * @returns the input friendly name
  37986. */
  37987. getSimpleName(): string;
  37988. /**
  37989. * Update the current camera state depending on the inputs that have been used this frame.
  37990. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37991. */
  37992. checkInputs(): void;
  37993. }
  37994. }
  37995. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37996. import { Nullable } from "babylonjs/types";
  37997. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37998. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37999. /**
  38000. * Manage the mouse wheel inputs to control a follow camera.
  38001. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38002. */
  38003. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38004. /**
  38005. * Defines the camera the input is attached to.
  38006. */
  38007. camera: FollowCamera;
  38008. /**
  38009. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38010. */
  38011. axisControlRadius: boolean;
  38012. /**
  38013. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38014. */
  38015. axisControlHeight: boolean;
  38016. /**
  38017. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38018. */
  38019. axisControlRotation: boolean;
  38020. /**
  38021. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38022. * relation to mouseWheel events.
  38023. */
  38024. wheelPrecision: number;
  38025. /**
  38026. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38027. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38028. */
  38029. wheelDeltaPercentage: number;
  38030. private _wheel;
  38031. private _observer;
  38032. /**
  38033. * Attach the input controls to a specific dom element to get the input from.
  38034. * @param element Defines the element the controls should be listened from
  38035. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38036. */
  38037. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38038. /**
  38039. * Detach the current controls from the specified dom element.
  38040. * @param element Defines the element to stop listening the inputs from
  38041. */
  38042. detachControl(element: Nullable<HTMLElement>): void;
  38043. /**
  38044. * Gets the class name of the current intput.
  38045. * @returns the class name
  38046. */
  38047. getClassName(): string;
  38048. /**
  38049. * Get the friendly name associated with the input class.
  38050. * @returns the input friendly name
  38051. */
  38052. getSimpleName(): string;
  38053. }
  38054. }
  38055. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38056. import { Nullable } from "babylonjs/types";
  38057. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38058. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38059. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38060. /**
  38061. * Manage the pointers inputs to control an follow camera.
  38062. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38063. */
  38064. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38065. /**
  38066. * Defines the camera the input is attached to.
  38067. */
  38068. camera: FollowCamera;
  38069. /**
  38070. * Gets the class name of the current input.
  38071. * @returns the class name
  38072. */
  38073. getClassName(): string;
  38074. /**
  38075. * Defines the pointer angular sensibility along the X axis or how fast is
  38076. * the camera rotating.
  38077. * A negative number will reverse the axis direction.
  38078. */
  38079. angularSensibilityX: number;
  38080. /**
  38081. * Defines the pointer angular sensibility along the Y axis or how fast is
  38082. * the camera rotating.
  38083. * A negative number will reverse the axis direction.
  38084. */
  38085. angularSensibilityY: number;
  38086. /**
  38087. * Defines the pointer pinch precision or how fast is the camera zooming.
  38088. * A negative number will reverse the axis direction.
  38089. */
  38090. pinchPrecision: number;
  38091. /**
  38092. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38093. * from 0.
  38094. * It defines the percentage of current camera.radius to use as delta when
  38095. * pinch zoom is used.
  38096. */
  38097. pinchDeltaPercentage: number;
  38098. /**
  38099. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38100. */
  38101. axisXControlRadius: boolean;
  38102. /**
  38103. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38104. */
  38105. axisXControlHeight: boolean;
  38106. /**
  38107. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38108. */
  38109. axisXControlRotation: boolean;
  38110. /**
  38111. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38112. */
  38113. axisYControlRadius: boolean;
  38114. /**
  38115. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38116. */
  38117. axisYControlHeight: boolean;
  38118. /**
  38119. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38120. */
  38121. axisYControlRotation: boolean;
  38122. /**
  38123. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38124. */
  38125. axisPinchControlRadius: boolean;
  38126. /**
  38127. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38128. */
  38129. axisPinchControlHeight: boolean;
  38130. /**
  38131. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38132. */
  38133. axisPinchControlRotation: boolean;
  38134. /**
  38135. * Log error messages if basic misconfiguration has occurred.
  38136. */
  38137. warningEnable: boolean;
  38138. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38139. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38140. private _warningCounter;
  38141. private _warning;
  38142. }
  38143. }
  38144. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38145. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38146. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38147. /**
  38148. * Default Inputs manager for the FollowCamera.
  38149. * It groups all the default supported inputs for ease of use.
  38150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38151. */
  38152. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38153. /**
  38154. * Instantiates a new FollowCameraInputsManager.
  38155. * @param camera Defines the camera the inputs belong to
  38156. */
  38157. constructor(camera: FollowCamera);
  38158. /**
  38159. * Add keyboard input support to the input manager.
  38160. * @returns the current input manager
  38161. */
  38162. addKeyboard(): FollowCameraInputsManager;
  38163. /**
  38164. * Add mouse wheel input support to the input manager.
  38165. * @returns the current input manager
  38166. */
  38167. addMouseWheel(): FollowCameraInputsManager;
  38168. /**
  38169. * Add pointers input support to the input manager.
  38170. * @returns the current input manager
  38171. */
  38172. addPointers(): FollowCameraInputsManager;
  38173. /**
  38174. * Add orientation input support to the input manager.
  38175. * @returns the current input manager
  38176. */
  38177. addVRDeviceOrientation(): FollowCameraInputsManager;
  38178. }
  38179. }
  38180. declare module "babylonjs/Cameras/followCamera" {
  38181. import { Nullable } from "babylonjs/types";
  38182. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38183. import { Scene } from "babylonjs/scene";
  38184. import { Vector3 } from "babylonjs/Maths/math";
  38185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38186. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38187. /**
  38188. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38189. * an arc rotate version arcFollowCamera are available.
  38190. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38191. */
  38192. export class FollowCamera extends TargetCamera {
  38193. /**
  38194. * Distance the follow camera should follow an object at
  38195. */
  38196. radius: number;
  38197. /**
  38198. * Minimum allowed distance of the camera to the axis of rotation
  38199. * (The camera can not get closer).
  38200. * This can help limiting how the Camera is able to move in the scene.
  38201. */
  38202. lowerRadiusLimit: Nullable<number>;
  38203. /**
  38204. * Maximum allowed distance of the camera to the axis of rotation
  38205. * (The camera can not get further).
  38206. * This can help limiting how the Camera is able to move in the scene.
  38207. */
  38208. upperRadiusLimit: Nullable<number>;
  38209. /**
  38210. * Define a rotation offset between the camera and the object it follows
  38211. */
  38212. rotationOffset: number;
  38213. /**
  38214. * Minimum allowed angle to camera position relative to target object.
  38215. * This can help limiting how the Camera is able to move in the scene.
  38216. */
  38217. lowerRotationOffsetLimit: Nullable<number>;
  38218. /**
  38219. * Maximum allowed angle to camera position relative to target object.
  38220. * This can help limiting how the Camera is able to move in the scene.
  38221. */
  38222. upperRotationOffsetLimit: Nullable<number>;
  38223. /**
  38224. * Define a height offset between the camera and the object it follows.
  38225. * It can help following an object from the top (like a car chaing a plane)
  38226. */
  38227. heightOffset: number;
  38228. /**
  38229. * Minimum allowed height of camera position relative to target object.
  38230. * This can help limiting how the Camera is able to move in the scene.
  38231. */
  38232. lowerHeightOffsetLimit: Nullable<number>;
  38233. /**
  38234. * Maximum allowed height of camera position relative to target object.
  38235. * This can help limiting how the Camera is able to move in the scene.
  38236. */
  38237. upperHeightOffsetLimit: Nullable<number>;
  38238. /**
  38239. * Define how fast the camera can accelerate to follow it s target.
  38240. */
  38241. cameraAcceleration: number;
  38242. /**
  38243. * Define the speed limit of the camera following an object.
  38244. */
  38245. maxCameraSpeed: number;
  38246. /**
  38247. * Define the target of the camera.
  38248. */
  38249. lockedTarget: Nullable<AbstractMesh>;
  38250. /**
  38251. * Defines the input associated with the camera.
  38252. */
  38253. inputs: FollowCameraInputsManager;
  38254. /**
  38255. * Instantiates the follow camera.
  38256. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38257. * @param name Define the name of the camera in the scene
  38258. * @param position Define the position of the camera
  38259. * @param scene Define the scene the camera belong to
  38260. * @param lockedTarget Define the target of the camera
  38261. */
  38262. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38263. private _follow;
  38264. /**
  38265. * Attached controls to the current camera.
  38266. * @param element Defines the element the controls should be listened from
  38267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38268. */
  38269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38270. /**
  38271. * Detach the current controls from the camera.
  38272. * The camera will stop reacting to inputs.
  38273. * @param element Defines the element to stop listening the inputs from
  38274. */
  38275. detachControl(element: HTMLElement): void;
  38276. /** @hidden */
  38277. _checkInputs(): void;
  38278. private _checkLimits;
  38279. /**
  38280. * Gets the camera class name.
  38281. * @returns the class name
  38282. */
  38283. getClassName(): string;
  38284. }
  38285. /**
  38286. * Arc Rotate version of the follow camera.
  38287. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38288. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38289. */
  38290. export class ArcFollowCamera extends TargetCamera {
  38291. /** The longitudinal angle of the camera */
  38292. alpha: number;
  38293. /** The latitudinal angle of the camera */
  38294. beta: number;
  38295. /** The radius of the camera from its target */
  38296. radius: number;
  38297. /** Define the camera target (the messh it should follow) */
  38298. target: Nullable<AbstractMesh>;
  38299. private _cartesianCoordinates;
  38300. /**
  38301. * Instantiates a new ArcFollowCamera
  38302. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38303. * @param name Define the name of the camera
  38304. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38305. * @param beta Define the rotation angle of the camera around the elevation axis
  38306. * @param radius Define the radius of the camera from its target point
  38307. * @param target Define the target of the camera
  38308. * @param scene Define the scene the camera belongs to
  38309. */
  38310. constructor(name: string,
  38311. /** The longitudinal angle of the camera */
  38312. alpha: number,
  38313. /** The latitudinal angle of the camera */
  38314. beta: number,
  38315. /** The radius of the camera from its target */
  38316. radius: number,
  38317. /** Define the camera target (the messh it should follow) */
  38318. target: Nullable<AbstractMesh>, scene: Scene);
  38319. private _follow;
  38320. /** @hidden */
  38321. _checkInputs(): void;
  38322. /**
  38323. * Returns the class name of the object.
  38324. * It is mostly used internally for serialization purposes.
  38325. */
  38326. getClassName(): string;
  38327. }
  38328. }
  38329. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38330. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38331. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38332. import { Nullable } from "babylonjs/types";
  38333. /**
  38334. * Manage the keyboard inputs to control the movement of a follow camera.
  38335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38336. */
  38337. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38338. /**
  38339. * Defines the camera the input is attached to.
  38340. */
  38341. camera: FollowCamera;
  38342. /**
  38343. * Defines the list of key codes associated with the up action (increase heightOffset)
  38344. */
  38345. keysHeightOffsetIncr: number[];
  38346. /**
  38347. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38348. */
  38349. keysHeightOffsetDecr: number[];
  38350. /**
  38351. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38352. */
  38353. keysHeightOffsetModifierAlt: boolean;
  38354. /**
  38355. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38356. */
  38357. keysHeightOffsetModifierCtrl: boolean;
  38358. /**
  38359. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38360. */
  38361. keysHeightOffsetModifierShift: boolean;
  38362. /**
  38363. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38364. */
  38365. keysRotationOffsetIncr: number[];
  38366. /**
  38367. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38368. */
  38369. keysRotationOffsetDecr: number[];
  38370. /**
  38371. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38372. */
  38373. keysRotationOffsetModifierAlt: boolean;
  38374. /**
  38375. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38376. */
  38377. keysRotationOffsetModifierCtrl: boolean;
  38378. /**
  38379. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38380. */
  38381. keysRotationOffsetModifierShift: boolean;
  38382. /**
  38383. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38384. */
  38385. keysRadiusIncr: number[];
  38386. /**
  38387. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38388. */
  38389. keysRadiusDecr: number[];
  38390. /**
  38391. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38392. */
  38393. keysRadiusModifierAlt: boolean;
  38394. /**
  38395. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38396. */
  38397. keysRadiusModifierCtrl: boolean;
  38398. /**
  38399. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38400. */
  38401. keysRadiusModifierShift: boolean;
  38402. /**
  38403. * Defines the rate of change of heightOffset.
  38404. */
  38405. heightSensibility: number;
  38406. /**
  38407. * Defines the rate of change of rotationOffset.
  38408. */
  38409. rotationSensibility: number;
  38410. /**
  38411. * Defines the rate of change of radius.
  38412. */
  38413. radiusSensibility: number;
  38414. private _keys;
  38415. private _ctrlPressed;
  38416. private _altPressed;
  38417. private _shiftPressed;
  38418. private _onCanvasBlurObserver;
  38419. private _onKeyboardObserver;
  38420. private _engine;
  38421. private _scene;
  38422. /**
  38423. * Attach the input controls to a specific dom element to get the input from.
  38424. * @param element Defines the element the controls should be listened from
  38425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38426. */
  38427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38428. /**
  38429. * Detach the current controls from the specified dom element.
  38430. * @param element Defines the element to stop listening the inputs from
  38431. */
  38432. detachControl(element: Nullable<HTMLElement>): void;
  38433. /**
  38434. * Update the current camera state depending on the inputs that have been used this frame.
  38435. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38436. */
  38437. checkInputs(): void;
  38438. /**
  38439. * Gets the class name of the current input.
  38440. * @returns the class name
  38441. */
  38442. getClassName(): string;
  38443. /**
  38444. * Get the friendly name associated with the input class.
  38445. * @returns the input friendly name
  38446. */
  38447. getSimpleName(): string;
  38448. /**
  38449. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38450. * allow modification of the heightOffset value.
  38451. */
  38452. private _modifierHeightOffset;
  38453. /**
  38454. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38455. * allow modification of the rotationOffset value.
  38456. */
  38457. private _modifierRotationOffset;
  38458. /**
  38459. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38460. * allow modification of the radius value.
  38461. */
  38462. private _modifierRadius;
  38463. }
  38464. }
  38465. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38466. import { Nullable } from "babylonjs/types";
  38467. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38468. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38469. import { Observable } from "babylonjs/Misc/observable";
  38470. module "babylonjs/Cameras/freeCameraInputsManager" {
  38471. interface FreeCameraInputsManager {
  38472. /**
  38473. * @hidden
  38474. */
  38475. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38476. /**
  38477. * Add orientation input support to the input manager.
  38478. * @returns the current input manager
  38479. */
  38480. addDeviceOrientation(): FreeCameraInputsManager;
  38481. }
  38482. }
  38483. /**
  38484. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38485. * Screen rotation is taken into account.
  38486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38487. */
  38488. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38489. private _camera;
  38490. private _screenOrientationAngle;
  38491. private _constantTranform;
  38492. private _screenQuaternion;
  38493. private _alpha;
  38494. private _beta;
  38495. private _gamma;
  38496. /**
  38497. * Can be used to detect if a device orientation sensor is availible on a device
  38498. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38499. * @returns a promise that will resolve on orientation change
  38500. */
  38501. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38502. /**
  38503. * @hidden
  38504. */
  38505. _onDeviceOrientationChangedObservable: Observable<void>;
  38506. /**
  38507. * Instantiates a new input
  38508. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38509. */
  38510. constructor();
  38511. /**
  38512. * Define the camera controlled by the input.
  38513. */
  38514. camera: FreeCamera;
  38515. /**
  38516. * Attach the input controls to a specific dom element to get the input from.
  38517. * @param element Defines the element the controls should be listened from
  38518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38519. */
  38520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38521. private _orientationChanged;
  38522. private _deviceOrientation;
  38523. /**
  38524. * Detach the current controls from the specified dom element.
  38525. * @param element Defines the element to stop listening the inputs from
  38526. */
  38527. detachControl(element: Nullable<HTMLElement>): void;
  38528. /**
  38529. * Update the current camera state depending on the inputs that have been used this frame.
  38530. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38531. */
  38532. checkInputs(): void;
  38533. /**
  38534. * Gets the class name of the current intput.
  38535. * @returns the class name
  38536. */
  38537. getClassName(): string;
  38538. /**
  38539. * Get the friendly name associated with the input class.
  38540. * @returns the input friendly name
  38541. */
  38542. getSimpleName(): string;
  38543. }
  38544. }
  38545. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38546. import { Nullable } from "babylonjs/types";
  38547. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38548. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38549. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38550. /**
  38551. * Manage the gamepad inputs to control a free camera.
  38552. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38553. */
  38554. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38555. /**
  38556. * Define the camera the input is attached to.
  38557. */
  38558. camera: FreeCamera;
  38559. /**
  38560. * Define the Gamepad controlling the input
  38561. */
  38562. gamepad: Nullable<Gamepad>;
  38563. /**
  38564. * Defines the gamepad rotation sensiblity.
  38565. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38566. */
  38567. gamepadAngularSensibility: number;
  38568. /**
  38569. * Defines the gamepad move sensiblity.
  38570. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38571. */
  38572. gamepadMoveSensibility: number;
  38573. private _onGamepadConnectedObserver;
  38574. private _onGamepadDisconnectedObserver;
  38575. private _cameraTransform;
  38576. private _deltaTransform;
  38577. private _vector3;
  38578. private _vector2;
  38579. /**
  38580. * Attach the input controls to a specific dom element to get the input from.
  38581. * @param element Defines the element the controls should be listened from
  38582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38583. */
  38584. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38585. /**
  38586. * Detach the current controls from the specified dom element.
  38587. * @param element Defines the element to stop listening the inputs from
  38588. */
  38589. detachControl(element: Nullable<HTMLElement>): void;
  38590. /**
  38591. * Update the current camera state depending on the inputs that have been used this frame.
  38592. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38593. */
  38594. checkInputs(): void;
  38595. /**
  38596. * Gets the class name of the current intput.
  38597. * @returns the class name
  38598. */
  38599. getClassName(): string;
  38600. /**
  38601. * Get the friendly name associated with the input class.
  38602. * @returns the input friendly name
  38603. */
  38604. getSimpleName(): string;
  38605. }
  38606. }
  38607. declare module "babylonjs/Misc/virtualJoystick" {
  38608. import { Nullable } from "babylonjs/types";
  38609. import { Vector3 } from "babylonjs/Maths/math";
  38610. /**
  38611. * Defines the potential axis of a Joystick
  38612. */
  38613. export enum JoystickAxis {
  38614. /** X axis */
  38615. X = 0,
  38616. /** Y axis */
  38617. Y = 1,
  38618. /** Z axis */
  38619. Z = 2
  38620. }
  38621. /**
  38622. * Class used to define virtual joystick (used in touch mode)
  38623. */
  38624. export class VirtualJoystick {
  38625. /**
  38626. * Gets or sets a boolean indicating that left and right values must be inverted
  38627. */
  38628. reverseLeftRight: boolean;
  38629. /**
  38630. * Gets or sets a boolean indicating that up and down values must be inverted
  38631. */
  38632. reverseUpDown: boolean;
  38633. /**
  38634. * Gets the offset value for the position (ie. the change of the position value)
  38635. */
  38636. deltaPosition: Vector3;
  38637. /**
  38638. * Gets a boolean indicating if the virtual joystick was pressed
  38639. */
  38640. pressed: boolean;
  38641. /**
  38642. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38643. */
  38644. static Canvas: Nullable<HTMLCanvasElement>;
  38645. private static _globalJoystickIndex;
  38646. private static vjCanvasContext;
  38647. private static vjCanvasWidth;
  38648. private static vjCanvasHeight;
  38649. private static halfWidth;
  38650. private _action;
  38651. private _axisTargetedByLeftAndRight;
  38652. private _axisTargetedByUpAndDown;
  38653. private _joystickSensibility;
  38654. private _inversedSensibility;
  38655. private _joystickPointerID;
  38656. private _joystickColor;
  38657. private _joystickPointerPos;
  38658. private _joystickPreviousPointerPos;
  38659. private _joystickPointerStartPos;
  38660. private _deltaJoystickVector;
  38661. private _leftJoystick;
  38662. private _touches;
  38663. private _onPointerDownHandlerRef;
  38664. private _onPointerMoveHandlerRef;
  38665. private _onPointerUpHandlerRef;
  38666. private _onResize;
  38667. /**
  38668. * Creates a new virtual joystick
  38669. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38670. */
  38671. constructor(leftJoystick?: boolean);
  38672. /**
  38673. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38674. * @param newJoystickSensibility defines the new sensibility
  38675. */
  38676. setJoystickSensibility(newJoystickSensibility: number): void;
  38677. private _onPointerDown;
  38678. private _onPointerMove;
  38679. private _onPointerUp;
  38680. /**
  38681. * Change the color of the virtual joystick
  38682. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38683. */
  38684. setJoystickColor(newColor: string): void;
  38685. /**
  38686. * Defines a callback to call when the joystick is touched
  38687. * @param action defines the callback
  38688. */
  38689. setActionOnTouch(action: () => any): void;
  38690. /**
  38691. * Defines which axis you'd like to control for left & right
  38692. * @param axis defines the axis to use
  38693. */
  38694. setAxisForLeftRight(axis: JoystickAxis): void;
  38695. /**
  38696. * Defines which axis you'd like to control for up & down
  38697. * @param axis defines the axis to use
  38698. */
  38699. setAxisForUpDown(axis: JoystickAxis): void;
  38700. private _drawVirtualJoystick;
  38701. /**
  38702. * Release internal HTML canvas
  38703. */
  38704. releaseCanvas(): void;
  38705. }
  38706. }
  38707. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38708. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38709. import { Nullable } from "babylonjs/types";
  38710. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38711. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38712. module "babylonjs/Cameras/freeCameraInputsManager" {
  38713. interface FreeCameraInputsManager {
  38714. /**
  38715. * Add virtual joystick input support to the input manager.
  38716. * @returns the current input manager
  38717. */
  38718. addVirtualJoystick(): FreeCameraInputsManager;
  38719. }
  38720. }
  38721. /**
  38722. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38724. */
  38725. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38726. /**
  38727. * Defines the camera the input is attached to.
  38728. */
  38729. camera: FreeCamera;
  38730. private _leftjoystick;
  38731. private _rightjoystick;
  38732. /**
  38733. * Gets the left stick of the virtual joystick.
  38734. * @returns The virtual Joystick
  38735. */
  38736. getLeftJoystick(): VirtualJoystick;
  38737. /**
  38738. * Gets the right stick of the virtual joystick.
  38739. * @returns The virtual Joystick
  38740. */
  38741. getRightJoystick(): VirtualJoystick;
  38742. /**
  38743. * Update the current camera state depending on the inputs that have been used this frame.
  38744. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38745. */
  38746. checkInputs(): void;
  38747. /**
  38748. * Attach the input controls to a specific dom element to get the input from.
  38749. * @param element Defines the element the controls should be listened from
  38750. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38751. */
  38752. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38753. /**
  38754. * Detach the current controls from the specified dom element.
  38755. * @param element Defines the element to stop listening the inputs from
  38756. */
  38757. detachControl(element: Nullable<HTMLElement>): void;
  38758. /**
  38759. * Gets the class name of the current intput.
  38760. * @returns the class name
  38761. */
  38762. getClassName(): string;
  38763. /**
  38764. * Get the friendly name associated with the input class.
  38765. * @returns the input friendly name
  38766. */
  38767. getSimpleName(): string;
  38768. }
  38769. }
  38770. declare module "babylonjs/Cameras/Inputs/index" {
  38771. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38772. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38773. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38774. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38775. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38776. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38777. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38778. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38779. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38780. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38781. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38782. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38783. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38784. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38785. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38786. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38787. }
  38788. declare module "babylonjs/Cameras/touchCamera" {
  38789. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38790. import { Scene } from "babylonjs/scene";
  38791. import { Vector3 } from "babylonjs/Maths/math";
  38792. /**
  38793. * This represents a FPS type of camera controlled by touch.
  38794. * This is like a universal camera minus the Gamepad controls.
  38795. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38796. */
  38797. export class TouchCamera extends FreeCamera {
  38798. /**
  38799. * Defines the touch sensibility for rotation.
  38800. * The higher the faster.
  38801. */
  38802. touchAngularSensibility: number;
  38803. /**
  38804. * Defines the touch sensibility for move.
  38805. * The higher the faster.
  38806. */
  38807. touchMoveSensibility: number;
  38808. /**
  38809. * Instantiates a new touch camera.
  38810. * This represents a FPS type of camera controlled by touch.
  38811. * This is like a universal camera minus the Gamepad controls.
  38812. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38813. * @param name Define the name of the camera in the scene
  38814. * @param position Define the start position of the camera in the scene
  38815. * @param scene Define the scene the camera belongs to
  38816. */
  38817. constructor(name: string, position: Vector3, scene: Scene);
  38818. /**
  38819. * Gets the current object class name.
  38820. * @return the class name
  38821. */
  38822. getClassName(): string;
  38823. /** @hidden */
  38824. _setupInputs(): void;
  38825. }
  38826. }
  38827. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38828. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38829. import { Scene } from "babylonjs/scene";
  38830. import { Vector3, Axis } from "babylonjs/Maths/math";
  38831. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38832. /**
  38833. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38834. * being tilted forward or back and left or right.
  38835. */
  38836. export class DeviceOrientationCamera extends FreeCamera {
  38837. private _initialQuaternion;
  38838. private _quaternionCache;
  38839. private _tmpDragQuaternion;
  38840. /**
  38841. * Creates a new device orientation camera
  38842. * @param name The name of the camera
  38843. * @param position The start position camera
  38844. * @param scene The scene the camera belongs to
  38845. */
  38846. constructor(name: string, position: Vector3, scene: Scene);
  38847. /**
  38848. * @hidden
  38849. * Disabled pointer input on first orientation sensor update (Default: true)
  38850. */
  38851. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38852. private _dragFactor;
  38853. /**
  38854. * Enabled turning on the y axis when the orientation sensor is active
  38855. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38856. */
  38857. enableHorizontalDragging(dragFactor?: number): void;
  38858. /**
  38859. * Gets the current instance class name ("DeviceOrientationCamera").
  38860. * This helps avoiding instanceof at run time.
  38861. * @returns the class name
  38862. */
  38863. getClassName(): string;
  38864. /**
  38865. * @hidden
  38866. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38867. */
  38868. _checkInputs(): void;
  38869. /**
  38870. * Reset the camera to its default orientation on the specified axis only.
  38871. * @param axis The axis to reset
  38872. */
  38873. resetToCurrentRotation(axis?: Axis): void;
  38874. }
  38875. }
  38876. declare module "babylonjs/Gamepads/xboxGamepad" {
  38877. import { Observable } from "babylonjs/Misc/observable";
  38878. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38879. /**
  38880. * Defines supported buttons for XBox360 compatible gamepads
  38881. */
  38882. export enum Xbox360Button {
  38883. /** A */
  38884. A = 0,
  38885. /** B */
  38886. B = 1,
  38887. /** X */
  38888. X = 2,
  38889. /** Y */
  38890. Y = 3,
  38891. /** Start */
  38892. Start = 4,
  38893. /** Back */
  38894. Back = 5,
  38895. /** Left button */
  38896. LB = 6,
  38897. /** Right button */
  38898. RB = 7,
  38899. /** Left stick */
  38900. LeftStick = 8,
  38901. /** Right stick */
  38902. RightStick = 9
  38903. }
  38904. /** Defines values for XBox360 DPad */
  38905. export enum Xbox360Dpad {
  38906. /** Up */
  38907. Up = 0,
  38908. /** Down */
  38909. Down = 1,
  38910. /** Left */
  38911. Left = 2,
  38912. /** Right */
  38913. Right = 3
  38914. }
  38915. /**
  38916. * Defines a XBox360 gamepad
  38917. */
  38918. export class Xbox360Pad extends Gamepad {
  38919. private _leftTrigger;
  38920. private _rightTrigger;
  38921. private _onlefttriggerchanged;
  38922. private _onrighttriggerchanged;
  38923. private _onbuttondown;
  38924. private _onbuttonup;
  38925. private _ondpaddown;
  38926. private _ondpadup;
  38927. /** Observable raised when a button is pressed */
  38928. onButtonDownObservable: Observable<Xbox360Button>;
  38929. /** Observable raised when a button is released */
  38930. onButtonUpObservable: Observable<Xbox360Button>;
  38931. /** Observable raised when a pad is pressed */
  38932. onPadDownObservable: Observable<Xbox360Dpad>;
  38933. /** Observable raised when a pad is released */
  38934. onPadUpObservable: Observable<Xbox360Dpad>;
  38935. private _buttonA;
  38936. private _buttonB;
  38937. private _buttonX;
  38938. private _buttonY;
  38939. private _buttonBack;
  38940. private _buttonStart;
  38941. private _buttonLB;
  38942. private _buttonRB;
  38943. private _buttonLeftStick;
  38944. private _buttonRightStick;
  38945. private _dPadUp;
  38946. private _dPadDown;
  38947. private _dPadLeft;
  38948. private _dPadRight;
  38949. private _isXboxOnePad;
  38950. /**
  38951. * Creates a new XBox360 gamepad object
  38952. * @param id defines the id of this gamepad
  38953. * @param index defines its index
  38954. * @param gamepad defines the internal HTML gamepad object
  38955. * @param xboxOne defines if it is a XBox One gamepad
  38956. */
  38957. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38958. /**
  38959. * Defines the callback to call when left trigger is pressed
  38960. * @param callback defines the callback to use
  38961. */
  38962. onlefttriggerchanged(callback: (value: number) => void): void;
  38963. /**
  38964. * Defines the callback to call when right trigger is pressed
  38965. * @param callback defines the callback to use
  38966. */
  38967. onrighttriggerchanged(callback: (value: number) => void): void;
  38968. /**
  38969. * Gets the left trigger value
  38970. */
  38971. /**
  38972. * Sets the left trigger value
  38973. */
  38974. leftTrigger: number;
  38975. /**
  38976. * Gets the right trigger value
  38977. */
  38978. /**
  38979. * Sets the right trigger value
  38980. */
  38981. rightTrigger: number;
  38982. /**
  38983. * Defines the callback to call when a button is pressed
  38984. * @param callback defines the callback to use
  38985. */
  38986. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38987. /**
  38988. * Defines the callback to call when a button is released
  38989. * @param callback defines the callback to use
  38990. */
  38991. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38992. /**
  38993. * Defines the callback to call when a pad is pressed
  38994. * @param callback defines the callback to use
  38995. */
  38996. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38997. /**
  38998. * Defines the callback to call when a pad is released
  38999. * @param callback defines the callback to use
  39000. */
  39001. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39002. private _setButtonValue;
  39003. private _setDPadValue;
  39004. /**
  39005. * Gets the value of the `A` button
  39006. */
  39007. /**
  39008. * Sets the value of the `A` button
  39009. */
  39010. buttonA: number;
  39011. /**
  39012. * Gets the value of the `B` button
  39013. */
  39014. /**
  39015. * Sets the value of the `B` button
  39016. */
  39017. buttonB: number;
  39018. /**
  39019. * Gets the value of the `X` button
  39020. */
  39021. /**
  39022. * Sets the value of the `X` button
  39023. */
  39024. buttonX: number;
  39025. /**
  39026. * Gets the value of the `Y` button
  39027. */
  39028. /**
  39029. * Sets the value of the `Y` button
  39030. */
  39031. buttonY: number;
  39032. /**
  39033. * Gets the value of the `Start` button
  39034. */
  39035. /**
  39036. * Sets the value of the `Start` button
  39037. */
  39038. buttonStart: number;
  39039. /**
  39040. * Gets the value of the `Back` button
  39041. */
  39042. /**
  39043. * Sets the value of the `Back` button
  39044. */
  39045. buttonBack: number;
  39046. /**
  39047. * Gets the value of the `Left` button
  39048. */
  39049. /**
  39050. * Sets the value of the `Left` button
  39051. */
  39052. buttonLB: number;
  39053. /**
  39054. * Gets the value of the `Right` button
  39055. */
  39056. /**
  39057. * Sets the value of the `Right` button
  39058. */
  39059. buttonRB: number;
  39060. /**
  39061. * Gets the value of the Left joystick
  39062. */
  39063. /**
  39064. * Sets the value of the Left joystick
  39065. */
  39066. buttonLeftStick: number;
  39067. /**
  39068. * Gets the value of the Right joystick
  39069. */
  39070. /**
  39071. * Sets the value of the Right joystick
  39072. */
  39073. buttonRightStick: number;
  39074. /**
  39075. * Gets the value of D-pad up
  39076. */
  39077. /**
  39078. * Sets the value of D-pad up
  39079. */
  39080. dPadUp: number;
  39081. /**
  39082. * Gets the value of D-pad down
  39083. */
  39084. /**
  39085. * Sets the value of D-pad down
  39086. */
  39087. dPadDown: number;
  39088. /**
  39089. * Gets the value of D-pad left
  39090. */
  39091. /**
  39092. * Sets the value of D-pad left
  39093. */
  39094. dPadLeft: number;
  39095. /**
  39096. * Gets the value of D-pad right
  39097. */
  39098. /**
  39099. * Sets the value of D-pad right
  39100. */
  39101. dPadRight: number;
  39102. /**
  39103. * Force the gamepad to synchronize with device values
  39104. */
  39105. update(): void;
  39106. /**
  39107. * Disposes the gamepad
  39108. */
  39109. dispose(): void;
  39110. }
  39111. }
  39112. declare module "babylonjs/Gamepads/gamepadManager" {
  39113. import { Observable } from "babylonjs/Misc/observable";
  39114. import { Nullable } from "babylonjs/types";
  39115. import { Scene } from "babylonjs/scene";
  39116. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39117. /**
  39118. * Manager for handling gamepads
  39119. */
  39120. export class GamepadManager {
  39121. private _scene?;
  39122. private _babylonGamepads;
  39123. private _oneGamepadConnected;
  39124. /** @hidden */
  39125. _isMonitoring: boolean;
  39126. private _gamepadEventSupported;
  39127. private _gamepadSupport;
  39128. /**
  39129. * observable to be triggered when the gamepad controller has been connected
  39130. */
  39131. onGamepadConnectedObservable: Observable<Gamepad>;
  39132. /**
  39133. * observable to be triggered when the gamepad controller has been disconnected
  39134. */
  39135. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39136. private _onGamepadConnectedEvent;
  39137. private _onGamepadDisconnectedEvent;
  39138. /**
  39139. * Initializes the gamepad manager
  39140. * @param _scene BabylonJS scene
  39141. */
  39142. constructor(_scene?: Scene | undefined);
  39143. /**
  39144. * The gamepads in the game pad manager
  39145. */
  39146. readonly gamepads: Gamepad[];
  39147. /**
  39148. * Get the gamepad controllers based on type
  39149. * @param type The type of gamepad controller
  39150. * @returns Nullable gamepad
  39151. */
  39152. getGamepadByType(type?: number): Nullable<Gamepad>;
  39153. /**
  39154. * Disposes the gamepad manager
  39155. */
  39156. dispose(): void;
  39157. private _addNewGamepad;
  39158. private _startMonitoringGamepads;
  39159. private _stopMonitoringGamepads;
  39160. /** @hidden */
  39161. _checkGamepadsStatus(): void;
  39162. private _updateGamepadObjects;
  39163. }
  39164. }
  39165. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39166. import { Nullable } from "babylonjs/types";
  39167. import { Scene } from "babylonjs/scene";
  39168. import { ISceneComponent } from "babylonjs/sceneComponent";
  39169. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39170. module "babylonjs/scene" {
  39171. interface Scene {
  39172. /** @hidden */
  39173. _gamepadManager: Nullable<GamepadManager>;
  39174. /**
  39175. * Gets the gamepad manager associated with the scene
  39176. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39177. */
  39178. gamepadManager: GamepadManager;
  39179. }
  39180. }
  39181. module "babylonjs/Cameras/freeCameraInputsManager" {
  39182. /**
  39183. * Interface representing a free camera inputs manager
  39184. */
  39185. interface FreeCameraInputsManager {
  39186. /**
  39187. * Adds gamepad input support to the FreeCameraInputsManager.
  39188. * @returns the FreeCameraInputsManager
  39189. */
  39190. addGamepad(): FreeCameraInputsManager;
  39191. }
  39192. }
  39193. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39194. /**
  39195. * Interface representing an arc rotate camera inputs manager
  39196. */
  39197. interface ArcRotateCameraInputsManager {
  39198. /**
  39199. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39200. * @returns the camera inputs manager
  39201. */
  39202. addGamepad(): ArcRotateCameraInputsManager;
  39203. }
  39204. }
  39205. /**
  39206. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39207. */
  39208. export class GamepadSystemSceneComponent implements ISceneComponent {
  39209. /**
  39210. * The component name helpfull to identify the component in the list of scene components.
  39211. */
  39212. readonly name: string;
  39213. /**
  39214. * The scene the component belongs to.
  39215. */
  39216. scene: Scene;
  39217. /**
  39218. * Creates a new instance of the component for the given scene
  39219. * @param scene Defines the scene to register the component in
  39220. */
  39221. constructor(scene: Scene);
  39222. /**
  39223. * Registers the component in a given scene
  39224. */
  39225. register(): void;
  39226. /**
  39227. * Rebuilds the elements related to this component in case of
  39228. * context lost for instance.
  39229. */
  39230. rebuild(): void;
  39231. /**
  39232. * Disposes the component and the associated ressources
  39233. */
  39234. dispose(): void;
  39235. private _beforeCameraUpdate;
  39236. }
  39237. }
  39238. declare module "babylonjs/Cameras/universalCamera" {
  39239. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39240. import { Scene } from "babylonjs/scene";
  39241. import { Vector3 } from "babylonjs/Maths/math";
  39242. import "babylonjs/Gamepads/gamepadSceneComponent";
  39243. /**
  39244. * 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,
  39245. * which still works and will still be found in many Playgrounds.
  39246. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39247. */
  39248. export class UniversalCamera extends TouchCamera {
  39249. /**
  39250. * Defines the gamepad rotation sensiblity.
  39251. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39252. */
  39253. gamepadAngularSensibility: number;
  39254. /**
  39255. * Defines the gamepad move sensiblity.
  39256. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39257. */
  39258. gamepadMoveSensibility: number;
  39259. /**
  39260. * 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,
  39261. * which still works and will still be found in many Playgrounds.
  39262. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39263. * @param name Define the name of the camera in the scene
  39264. * @param position Define the start position of the camera in the scene
  39265. * @param scene Define the scene the camera belongs to
  39266. */
  39267. constructor(name: string, position: Vector3, scene: Scene);
  39268. /**
  39269. * Gets the current object class name.
  39270. * @return the class name
  39271. */
  39272. getClassName(): string;
  39273. }
  39274. }
  39275. declare module "babylonjs/Cameras/gamepadCamera" {
  39276. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39277. import { Scene } from "babylonjs/scene";
  39278. import { Vector3 } from "babylonjs/Maths/math";
  39279. /**
  39280. * This represents a FPS type of camera. This is only here for back compat purpose.
  39281. * Please use the UniversalCamera instead as both are identical.
  39282. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39283. */
  39284. export class GamepadCamera extends UniversalCamera {
  39285. /**
  39286. * Instantiates a new Gamepad Camera
  39287. * This represents a FPS type of camera. This is only here for back compat purpose.
  39288. * Please use the UniversalCamera instead as both are identical.
  39289. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39290. * @param name Define the name of the camera in the scene
  39291. * @param position Define the start position of the camera in the scene
  39292. * @param scene Define the scene the camera belongs to
  39293. */
  39294. constructor(name: string, position: Vector3, scene: Scene);
  39295. /**
  39296. * Gets the current object class name.
  39297. * @return the class name
  39298. */
  39299. getClassName(): string;
  39300. }
  39301. }
  39302. declare module "babylonjs/Shaders/pass.fragment" {
  39303. /** @hidden */
  39304. export var passPixelShader: {
  39305. name: string;
  39306. shader: string;
  39307. };
  39308. }
  39309. declare module "babylonjs/Shaders/passCube.fragment" {
  39310. /** @hidden */
  39311. export var passCubePixelShader: {
  39312. name: string;
  39313. shader: string;
  39314. };
  39315. }
  39316. declare module "babylonjs/PostProcesses/passPostProcess" {
  39317. import { Nullable } from "babylonjs/types";
  39318. import { Camera } from "babylonjs/Cameras/camera";
  39319. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39320. import { Engine } from "babylonjs/Engines/engine";
  39321. import "babylonjs/Shaders/pass.fragment";
  39322. import "babylonjs/Shaders/passCube.fragment";
  39323. /**
  39324. * PassPostProcess which produces an output the same as it's input
  39325. */
  39326. export class PassPostProcess extends PostProcess {
  39327. /**
  39328. * Creates the PassPostProcess
  39329. * @param name The name of the effect.
  39330. * @param options The required width/height ratio to downsize to before computing the render pass.
  39331. * @param camera The camera to apply the render pass to.
  39332. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39333. * @param engine The engine which the post process will be applied. (default: current engine)
  39334. * @param reusable If the post process can be reused on the same frame. (default: false)
  39335. * @param textureType The type of texture to be used when performing the post processing.
  39336. * @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)
  39337. */
  39338. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39339. }
  39340. /**
  39341. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39342. */
  39343. export class PassCubePostProcess extends PostProcess {
  39344. private _face;
  39345. /**
  39346. * Gets or sets the cube face to display.
  39347. * * 0 is +X
  39348. * * 1 is -X
  39349. * * 2 is +Y
  39350. * * 3 is -Y
  39351. * * 4 is +Z
  39352. * * 5 is -Z
  39353. */
  39354. face: number;
  39355. /**
  39356. * Creates the PassCubePostProcess
  39357. * @param name The name of the effect.
  39358. * @param options The required width/height ratio to downsize to before computing the render pass.
  39359. * @param camera The camera to apply the render pass to.
  39360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39361. * @param engine The engine which the post process will be applied. (default: current engine)
  39362. * @param reusable If the post process can be reused on the same frame. (default: false)
  39363. * @param textureType The type of texture to be used when performing the post processing.
  39364. * @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)
  39365. */
  39366. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39367. }
  39368. }
  39369. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39370. /** @hidden */
  39371. export var anaglyphPixelShader: {
  39372. name: string;
  39373. shader: string;
  39374. };
  39375. }
  39376. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39377. import { Engine } from "babylonjs/Engines/engine";
  39378. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39379. import { Camera } from "babylonjs/Cameras/camera";
  39380. import "babylonjs/Shaders/anaglyph.fragment";
  39381. /**
  39382. * Postprocess used to generate anaglyphic rendering
  39383. */
  39384. export class AnaglyphPostProcess extends PostProcess {
  39385. private _passedProcess;
  39386. /**
  39387. * Creates a new AnaglyphPostProcess
  39388. * @param name defines postprocess name
  39389. * @param options defines creation options or target ratio scale
  39390. * @param rigCameras defines cameras using this postprocess
  39391. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39392. * @param engine defines hosting engine
  39393. * @param reusable defines if the postprocess will be reused multiple times per frame
  39394. */
  39395. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39396. }
  39397. }
  39398. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39399. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39400. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39401. import { Scene } from "babylonjs/scene";
  39402. import { Vector3 } from "babylonjs/Maths/math";
  39403. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39404. /**
  39405. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39406. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39407. */
  39408. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39409. /**
  39410. * Creates a new AnaglyphArcRotateCamera
  39411. * @param name defines camera name
  39412. * @param alpha defines alpha angle (in radians)
  39413. * @param beta defines beta angle (in radians)
  39414. * @param radius defines radius
  39415. * @param target defines camera target
  39416. * @param interaxialDistance defines distance between each color axis
  39417. * @param scene defines the hosting scene
  39418. */
  39419. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39420. /**
  39421. * Gets camera class name
  39422. * @returns AnaglyphArcRotateCamera
  39423. */
  39424. getClassName(): string;
  39425. }
  39426. }
  39427. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39428. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39429. import { Scene } from "babylonjs/scene";
  39430. import { Vector3 } from "babylonjs/Maths/math";
  39431. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39432. /**
  39433. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39434. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39435. */
  39436. export class AnaglyphFreeCamera extends FreeCamera {
  39437. /**
  39438. * Creates a new AnaglyphFreeCamera
  39439. * @param name defines camera name
  39440. * @param position defines initial position
  39441. * @param interaxialDistance defines distance between each color axis
  39442. * @param scene defines the hosting scene
  39443. */
  39444. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39445. /**
  39446. * Gets camera class name
  39447. * @returns AnaglyphFreeCamera
  39448. */
  39449. getClassName(): string;
  39450. }
  39451. }
  39452. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39453. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39454. import { Scene } from "babylonjs/scene";
  39455. import { Vector3 } from "babylonjs/Maths/math";
  39456. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39457. /**
  39458. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39459. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39460. */
  39461. export class AnaglyphGamepadCamera extends GamepadCamera {
  39462. /**
  39463. * Creates a new AnaglyphGamepadCamera
  39464. * @param name defines camera name
  39465. * @param position defines initial position
  39466. * @param interaxialDistance defines distance between each color axis
  39467. * @param scene defines the hosting scene
  39468. */
  39469. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39470. /**
  39471. * Gets camera class name
  39472. * @returns AnaglyphGamepadCamera
  39473. */
  39474. getClassName(): string;
  39475. }
  39476. }
  39477. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39478. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39479. import { Scene } from "babylonjs/scene";
  39480. import { Vector3 } from "babylonjs/Maths/math";
  39481. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39482. /**
  39483. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39484. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39485. */
  39486. export class AnaglyphUniversalCamera extends UniversalCamera {
  39487. /**
  39488. * Creates a new AnaglyphUniversalCamera
  39489. * @param name defines camera name
  39490. * @param position defines initial position
  39491. * @param interaxialDistance defines distance between each color axis
  39492. * @param scene defines the hosting scene
  39493. */
  39494. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39495. /**
  39496. * Gets camera class name
  39497. * @returns AnaglyphUniversalCamera
  39498. */
  39499. getClassName(): string;
  39500. }
  39501. }
  39502. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39503. /** @hidden */
  39504. export var stereoscopicInterlacePixelShader: {
  39505. name: string;
  39506. shader: string;
  39507. };
  39508. }
  39509. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39510. import { Camera } from "babylonjs/Cameras/camera";
  39511. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39512. import { Engine } from "babylonjs/Engines/engine";
  39513. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39514. /**
  39515. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39516. */
  39517. export class StereoscopicInterlacePostProcess extends PostProcess {
  39518. private _stepSize;
  39519. private _passedProcess;
  39520. /**
  39521. * Initializes a StereoscopicInterlacePostProcess
  39522. * @param name The name of the effect.
  39523. * @param rigCameras The rig cameras to be appled to the post process
  39524. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39525. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39526. * @param engine The engine which the post process will be applied. (default: current engine)
  39527. * @param reusable If the post process can be reused on the same frame. (default: false)
  39528. */
  39529. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39530. }
  39531. }
  39532. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39533. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39534. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39535. import { Scene } from "babylonjs/scene";
  39536. import { Vector3 } from "babylonjs/Maths/math";
  39537. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39538. /**
  39539. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39540. * @see http://doc.babylonjs.com/features/cameras
  39541. */
  39542. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39543. /**
  39544. * Creates a new StereoscopicArcRotateCamera
  39545. * @param name defines camera name
  39546. * @param alpha defines alpha angle (in radians)
  39547. * @param beta defines beta angle (in radians)
  39548. * @param radius defines radius
  39549. * @param target defines camera target
  39550. * @param interaxialDistance defines distance between each color axis
  39551. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39552. * @param scene defines the hosting scene
  39553. */
  39554. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39555. /**
  39556. * Gets camera class name
  39557. * @returns StereoscopicArcRotateCamera
  39558. */
  39559. getClassName(): string;
  39560. }
  39561. }
  39562. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39563. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39564. import { Scene } from "babylonjs/scene";
  39565. import { Vector3 } from "babylonjs/Maths/math";
  39566. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39567. /**
  39568. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39569. * @see http://doc.babylonjs.com/features/cameras
  39570. */
  39571. export class StereoscopicFreeCamera extends FreeCamera {
  39572. /**
  39573. * Creates a new StereoscopicFreeCamera
  39574. * @param name defines camera name
  39575. * @param position defines initial position
  39576. * @param interaxialDistance defines distance between each color axis
  39577. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39578. * @param scene defines the hosting scene
  39579. */
  39580. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39581. /**
  39582. * Gets camera class name
  39583. * @returns StereoscopicFreeCamera
  39584. */
  39585. getClassName(): string;
  39586. }
  39587. }
  39588. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39589. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39590. import { Scene } from "babylonjs/scene";
  39591. import { Vector3 } from "babylonjs/Maths/math";
  39592. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39593. /**
  39594. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39595. * @see http://doc.babylonjs.com/features/cameras
  39596. */
  39597. export class StereoscopicGamepadCamera extends GamepadCamera {
  39598. /**
  39599. * Creates a new StereoscopicGamepadCamera
  39600. * @param name defines camera name
  39601. * @param position defines initial position
  39602. * @param interaxialDistance defines distance between each color axis
  39603. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39604. * @param scene defines the hosting scene
  39605. */
  39606. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39607. /**
  39608. * Gets camera class name
  39609. * @returns StereoscopicGamepadCamera
  39610. */
  39611. getClassName(): string;
  39612. }
  39613. }
  39614. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39615. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39616. import { Scene } from "babylonjs/scene";
  39617. import { Vector3 } from "babylonjs/Maths/math";
  39618. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39619. /**
  39620. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39621. * @see http://doc.babylonjs.com/features/cameras
  39622. */
  39623. export class StereoscopicUniversalCamera extends UniversalCamera {
  39624. /**
  39625. * Creates a new StereoscopicUniversalCamera
  39626. * @param name defines camera name
  39627. * @param position defines initial position
  39628. * @param interaxialDistance defines distance between each color axis
  39629. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39630. * @param scene defines the hosting scene
  39631. */
  39632. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39633. /**
  39634. * Gets camera class name
  39635. * @returns StereoscopicUniversalCamera
  39636. */
  39637. getClassName(): string;
  39638. }
  39639. }
  39640. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39641. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39642. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39643. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39644. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39645. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39646. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39647. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39648. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39649. }
  39650. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39651. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39652. import { Scene } from "babylonjs/scene";
  39653. import { Vector3 } from "babylonjs/Maths/math";
  39654. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39655. /**
  39656. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39657. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39658. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39659. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39660. */
  39661. export class VirtualJoysticksCamera extends FreeCamera {
  39662. /**
  39663. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39664. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39665. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39666. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39667. * @param name Define the name of the camera in the scene
  39668. * @param position Define the start position of the camera in the scene
  39669. * @param scene Define the scene the camera belongs to
  39670. */
  39671. constructor(name: string, position: Vector3, scene: Scene);
  39672. /**
  39673. * Gets the current object class name.
  39674. * @return the class name
  39675. */
  39676. getClassName(): string;
  39677. }
  39678. }
  39679. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39680. import { Matrix } from "babylonjs/Maths/math";
  39681. /**
  39682. * This represents all the required metrics to create a VR camera.
  39683. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39684. */
  39685. export class VRCameraMetrics {
  39686. /**
  39687. * Define the horizontal resolution off the screen.
  39688. */
  39689. hResolution: number;
  39690. /**
  39691. * Define the vertical resolution off the screen.
  39692. */
  39693. vResolution: number;
  39694. /**
  39695. * Define the horizontal screen size.
  39696. */
  39697. hScreenSize: number;
  39698. /**
  39699. * Define the vertical screen size.
  39700. */
  39701. vScreenSize: number;
  39702. /**
  39703. * Define the vertical screen center position.
  39704. */
  39705. vScreenCenter: number;
  39706. /**
  39707. * Define the distance of the eyes to the screen.
  39708. */
  39709. eyeToScreenDistance: number;
  39710. /**
  39711. * Define the distance between both lenses
  39712. */
  39713. lensSeparationDistance: number;
  39714. /**
  39715. * Define the distance between both viewer's eyes.
  39716. */
  39717. interpupillaryDistance: number;
  39718. /**
  39719. * Define the distortion factor of the VR postprocess.
  39720. * Please, touch with care.
  39721. */
  39722. distortionK: number[];
  39723. /**
  39724. * Define the chromatic aberration correction factors for the VR post process.
  39725. */
  39726. chromaAbCorrection: number[];
  39727. /**
  39728. * Define the scale factor of the post process.
  39729. * The smaller the better but the slower.
  39730. */
  39731. postProcessScaleFactor: number;
  39732. /**
  39733. * Define an offset for the lens center.
  39734. */
  39735. lensCenterOffset: number;
  39736. /**
  39737. * Define if the current vr camera should compensate the distortion of the lense or not.
  39738. */
  39739. compensateDistortion: boolean;
  39740. /**
  39741. * Defines if multiview should be enabled when rendering (Default: false)
  39742. */
  39743. multiviewEnabled: boolean;
  39744. /**
  39745. * Gets the rendering aspect ratio based on the provided resolutions.
  39746. */
  39747. readonly aspectRatio: number;
  39748. /**
  39749. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39750. */
  39751. readonly aspectRatioFov: number;
  39752. /**
  39753. * @hidden
  39754. */
  39755. readonly leftHMatrix: Matrix;
  39756. /**
  39757. * @hidden
  39758. */
  39759. readonly rightHMatrix: Matrix;
  39760. /**
  39761. * @hidden
  39762. */
  39763. readonly leftPreViewMatrix: Matrix;
  39764. /**
  39765. * @hidden
  39766. */
  39767. readonly rightPreViewMatrix: Matrix;
  39768. /**
  39769. * Get the default VRMetrics based on the most generic setup.
  39770. * @returns the default vr metrics
  39771. */
  39772. static GetDefault(): VRCameraMetrics;
  39773. }
  39774. }
  39775. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39776. /** @hidden */
  39777. export var vrDistortionCorrectionPixelShader: {
  39778. name: string;
  39779. shader: string;
  39780. };
  39781. }
  39782. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39783. import { Camera } from "babylonjs/Cameras/camera";
  39784. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39785. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39786. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39787. /**
  39788. * VRDistortionCorrectionPostProcess used for mobile VR
  39789. */
  39790. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39791. private _isRightEye;
  39792. private _distortionFactors;
  39793. private _postProcessScaleFactor;
  39794. private _lensCenterOffset;
  39795. private _scaleIn;
  39796. private _scaleFactor;
  39797. private _lensCenter;
  39798. /**
  39799. * Initializes the VRDistortionCorrectionPostProcess
  39800. * @param name The name of the effect.
  39801. * @param camera The camera to apply the render pass to.
  39802. * @param isRightEye If this is for the right eye distortion
  39803. * @param vrMetrics All the required metrics for the VR camera
  39804. */
  39805. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39806. }
  39807. }
  39808. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39809. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39810. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39811. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39812. import { Scene } from "babylonjs/scene";
  39813. import { Vector3 } from "babylonjs/Maths/math";
  39814. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39815. import "babylonjs/Cameras/RigModes/vrRigMode";
  39816. /**
  39817. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39818. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39819. */
  39820. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39821. /**
  39822. * Creates a new VRDeviceOrientationArcRotateCamera
  39823. * @param name defines camera name
  39824. * @param alpha defines the camera rotation along the logitudinal axis
  39825. * @param beta defines the camera rotation along the latitudinal axis
  39826. * @param radius defines the camera distance from its target
  39827. * @param target defines the camera target
  39828. * @param scene defines the scene the camera belongs to
  39829. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39830. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39831. */
  39832. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39833. /**
  39834. * Gets camera class name
  39835. * @returns VRDeviceOrientationArcRotateCamera
  39836. */
  39837. getClassName(): string;
  39838. }
  39839. }
  39840. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39841. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39842. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39843. import { Scene } from "babylonjs/scene";
  39844. import { Vector3 } from "babylonjs/Maths/math";
  39845. import "babylonjs/Cameras/RigModes/vrRigMode";
  39846. /**
  39847. * Camera used to simulate VR rendering (based on FreeCamera)
  39848. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39849. */
  39850. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39851. /**
  39852. * Creates a new VRDeviceOrientationFreeCamera
  39853. * @param name defines camera name
  39854. * @param position defines the start position of the camera
  39855. * @param scene defines the scene the camera belongs to
  39856. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39857. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39858. */
  39859. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39860. /**
  39861. * Gets camera class name
  39862. * @returns VRDeviceOrientationFreeCamera
  39863. */
  39864. getClassName(): string;
  39865. }
  39866. }
  39867. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39868. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39869. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39870. import { Scene } from "babylonjs/scene";
  39871. import { Vector3 } from "babylonjs/Maths/math";
  39872. import "babylonjs/Gamepads/gamepadSceneComponent";
  39873. /**
  39874. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39875. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39876. */
  39877. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39878. /**
  39879. * Creates a new VRDeviceOrientationGamepadCamera
  39880. * @param name defines camera name
  39881. * @param position defines the start position of the camera
  39882. * @param scene defines the scene the camera belongs to
  39883. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39884. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39885. */
  39886. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39887. /**
  39888. * Gets camera class name
  39889. * @returns VRDeviceOrientationGamepadCamera
  39890. */
  39891. getClassName(): string;
  39892. }
  39893. }
  39894. declare module "babylonjs/Materials/pushMaterial" {
  39895. import { Nullable } from "babylonjs/types";
  39896. import { Scene } from "babylonjs/scene";
  39897. import { Matrix } from "babylonjs/Maths/math";
  39898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39899. import { Mesh } from "babylonjs/Meshes/mesh";
  39900. import { Material } from "babylonjs/Materials/material";
  39901. import { Effect } from "babylonjs/Materials/effect";
  39902. /**
  39903. * Base class of materials working in push mode in babylon JS
  39904. * @hidden
  39905. */
  39906. export class PushMaterial extends Material {
  39907. protected _activeEffect: Effect;
  39908. protected _normalMatrix: Matrix;
  39909. /**
  39910. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39911. * This means that the material can keep using a previous shader while a new one is being compiled.
  39912. * This is mostly used when shader parallel compilation is supported (true by default)
  39913. */
  39914. allowShaderHotSwapping: boolean;
  39915. constructor(name: string, scene: Scene);
  39916. getEffect(): Effect;
  39917. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39918. /**
  39919. * Binds the given world matrix to the active effect
  39920. *
  39921. * @param world the matrix to bind
  39922. */
  39923. bindOnlyWorldMatrix(world: Matrix): void;
  39924. /**
  39925. * Binds the given normal matrix to the active effect
  39926. *
  39927. * @param normalMatrix the matrix to bind
  39928. */
  39929. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39930. bind(world: Matrix, mesh?: Mesh): void;
  39931. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39932. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39933. }
  39934. }
  39935. declare module "babylonjs/Materials/materialFlags" {
  39936. /**
  39937. * This groups all the flags used to control the materials channel.
  39938. */
  39939. export class MaterialFlags {
  39940. private static _DiffuseTextureEnabled;
  39941. /**
  39942. * Are diffuse textures enabled in the application.
  39943. */
  39944. static DiffuseTextureEnabled: boolean;
  39945. private static _AmbientTextureEnabled;
  39946. /**
  39947. * Are ambient textures enabled in the application.
  39948. */
  39949. static AmbientTextureEnabled: boolean;
  39950. private static _OpacityTextureEnabled;
  39951. /**
  39952. * Are opacity textures enabled in the application.
  39953. */
  39954. static OpacityTextureEnabled: boolean;
  39955. private static _ReflectionTextureEnabled;
  39956. /**
  39957. * Are reflection textures enabled in the application.
  39958. */
  39959. static ReflectionTextureEnabled: boolean;
  39960. private static _EmissiveTextureEnabled;
  39961. /**
  39962. * Are emissive textures enabled in the application.
  39963. */
  39964. static EmissiveTextureEnabled: boolean;
  39965. private static _SpecularTextureEnabled;
  39966. /**
  39967. * Are specular textures enabled in the application.
  39968. */
  39969. static SpecularTextureEnabled: boolean;
  39970. private static _BumpTextureEnabled;
  39971. /**
  39972. * Are bump textures enabled in the application.
  39973. */
  39974. static BumpTextureEnabled: boolean;
  39975. private static _LightmapTextureEnabled;
  39976. /**
  39977. * Are lightmap textures enabled in the application.
  39978. */
  39979. static LightmapTextureEnabled: boolean;
  39980. private static _RefractionTextureEnabled;
  39981. /**
  39982. * Are refraction textures enabled in the application.
  39983. */
  39984. static RefractionTextureEnabled: boolean;
  39985. private static _ColorGradingTextureEnabled;
  39986. /**
  39987. * Are color grading textures enabled in the application.
  39988. */
  39989. static ColorGradingTextureEnabled: boolean;
  39990. private static _FresnelEnabled;
  39991. /**
  39992. * Are fresnels enabled in the application.
  39993. */
  39994. static FresnelEnabled: boolean;
  39995. private static _ClearCoatTextureEnabled;
  39996. /**
  39997. * Are clear coat textures enabled in the application.
  39998. */
  39999. static ClearCoatTextureEnabled: boolean;
  40000. private static _ClearCoatBumpTextureEnabled;
  40001. /**
  40002. * Are clear coat bump textures enabled in the application.
  40003. */
  40004. static ClearCoatBumpTextureEnabled: boolean;
  40005. private static _ClearCoatTintTextureEnabled;
  40006. /**
  40007. * Are clear coat tint textures enabled in the application.
  40008. */
  40009. static ClearCoatTintTextureEnabled: boolean;
  40010. private static _SheenTextureEnabled;
  40011. /**
  40012. * Are sheen textures enabled in the application.
  40013. */
  40014. static SheenTextureEnabled: boolean;
  40015. private static _AnisotropicTextureEnabled;
  40016. /**
  40017. * Are anisotropic textures enabled in the application.
  40018. */
  40019. static AnisotropicTextureEnabled: boolean;
  40020. private static _ThicknessTextureEnabled;
  40021. /**
  40022. * Are thickness textures enabled in the application.
  40023. */
  40024. static ThicknessTextureEnabled: boolean;
  40025. }
  40026. }
  40027. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40028. /** @hidden */
  40029. export var defaultFragmentDeclaration: {
  40030. name: string;
  40031. shader: string;
  40032. };
  40033. }
  40034. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40035. /** @hidden */
  40036. export var defaultUboDeclaration: {
  40037. name: string;
  40038. shader: string;
  40039. };
  40040. }
  40041. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40042. /** @hidden */
  40043. export var lightFragmentDeclaration: {
  40044. name: string;
  40045. shader: string;
  40046. };
  40047. }
  40048. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40049. /** @hidden */
  40050. export var lightUboDeclaration: {
  40051. name: string;
  40052. shader: string;
  40053. };
  40054. }
  40055. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40056. /** @hidden */
  40057. export var lightsFragmentFunctions: {
  40058. name: string;
  40059. shader: string;
  40060. };
  40061. }
  40062. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40063. /** @hidden */
  40064. export var shadowsFragmentFunctions: {
  40065. name: string;
  40066. shader: string;
  40067. };
  40068. }
  40069. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40070. /** @hidden */
  40071. export var fresnelFunction: {
  40072. name: string;
  40073. shader: string;
  40074. };
  40075. }
  40076. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40077. /** @hidden */
  40078. export var reflectionFunction: {
  40079. name: string;
  40080. shader: string;
  40081. };
  40082. }
  40083. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40084. /** @hidden */
  40085. export var bumpFragmentFunctions: {
  40086. name: string;
  40087. shader: string;
  40088. };
  40089. }
  40090. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40091. /** @hidden */
  40092. export var logDepthDeclaration: {
  40093. name: string;
  40094. shader: string;
  40095. };
  40096. }
  40097. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40098. /** @hidden */
  40099. export var bumpFragment: {
  40100. name: string;
  40101. shader: string;
  40102. };
  40103. }
  40104. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40105. /** @hidden */
  40106. export var depthPrePass: {
  40107. name: string;
  40108. shader: string;
  40109. };
  40110. }
  40111. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40112. /** @hidden */
  40113. export var lightFragment: {
  40114. name: string;
  40115. shader: string;
  40116. };
  40117. }
  40118. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40119. /** @hidden */
  40120. export var logDepthFragment: {
  40121. name: string;
  40122. shader: string;
  40123. };
  40124. }
  40125. declare module "babylonjs/Shaders/default.fragment" {
  40126. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40127. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40128. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40129. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40130. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40131. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40132. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40133. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40134. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40135. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40136. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40137. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40138. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40139. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40140. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40141. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40142. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40143. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40144. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40145. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40146. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40147. /** @hidden */
  40148. export var defaultPixelShader: {
  40149. name: string;
  40150. shader: string;
  40151. };
  40152. }
  40153. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40154. /** @hidden */
  40155. export var defaultVertexDeclaration: {
  40156. name: string;
  40157. shader: string;
  40158. };
  40159. }
  40160. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40161. /** @hidden */
  40162. export var bumpVertexDeclaration: {
  40163. name: string;
  40164. shader: string;
  40165. };
  40166. }
  40167. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40168. /** @hidden */
  40169. export var bumpVertex: {
  40170. name: string;
  40171. shader: string;
  40172. };
  40173. }
  40174. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40175. /** @hidden */
  40176. export var fogVertex: {
  40177. name: string;
  40178. shader: string;
  40179. };
  40180. }
  40181. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40182. /** @hidden */
  40183. export var shadowsVertex: {
  40184. name: string;
  40185. shader: string;
  40186. };
  40187. }
  40188. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40189. /** @hidden */
  40190. export var pointCloudVertex: {
  40191. name: string;
  40192. shader: string;
  40193. };
  40194. }
  40195. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40196. /** @hidden */
  40197. export var logDepthVertex: {
  40198. name: string;
  40199. shader: string;
  40200. };
  40201. }
  40202. declare module "babylonjs/Shaders/default.vertex" {
  40203. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40204. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40205. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40206. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40207. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40208. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40209. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40210. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40211. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40212. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40213. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40214. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40215. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40216. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40217. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40218. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40219. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40220. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40221. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40222. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40223. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40224. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40225. /** @hidden */
  40226. export var defaultVertexShader: {
  40227. name: string;
  40228. shader: string;
  40229. };
  40230. }
  40231. declare module "babylonjs/Materials/standardMaterial" {
  40232. import { SmartArray } from "babylonjs/Misc/smartArray";
  40233. import { IAnimatable } from "babylonjs/Misc/tools";
  40234. import { Nullable } from "babylonjs/types";
  40235. import { Scene } from "babylonjs/scene";
  40236. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40237. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40239. import { Mesh } from "babylonjs/Meshes/mesh";
  40240. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40241. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40242. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40243. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40244. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40245. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40246. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40247. import "babylonjs/Shaders/default.fragment";
  40248. import "babylonjs/Shaders/default.vertex";
  40249. /** @hidden */
  40250. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40251. MAINUV1: boolean;
  40252. MAINUV2: boolean;
  40253. DIFFUSE: boolean;
  40254. DIFFUSEDIRECTUV: number;
  40255. AMBIENT: boolean;
  40256. AMBIENTDIRECTUV: number;
  40257. OPACITY: boolean;
  40258. OPACITYDIRECTUV: number;
  40259. OPACITYRGB: boolean;
  40260. REFLECTION: boolean;
  40261. EMISSIVE: boolean;
  40262. EMISSIVEDIRECTUV: number;
  40263. SPECULAR: boolean;
  40264. SPECULARDIRECTUV: number;
  40265. BUMP: boolean;
  40266. BUMPDIRECTUV: number;
  40267. PARALLAX: boolean;
  40268. PARALLAXOCCLUSION: boolean;
  40269. SPECULAROVERALPHA: boolean;
  40270. CLIPPLANE: boolean;
  40271. CLIPPLANE2: boolean;
  40272. CLIPPLANE3: boolean;
  40273. CLIPPLANE4: boolean;
  40274. ALPHATEST: boolean;
  40275. DEPTHPREPASS: boolean;
  40276. ALPHAFROMDIFFUSE: boolean;
  40277. POINTSIZE: boolean;
  40278. FOG: boolean;
  40279. SPECULARTERM: boolean;
  40280. DIFFUSEFRESNEL: boolean;
  40281. OPACITYFRESNEL: boolean;
  40282. REFLECTIONFRESNEL: boolean;
  40283. REFRACTIONFRESNEL: boolean;
  40284. EMISSIVEFRESNEL: boolean;
  40285. FRESNEL: boolean;
  40286. NORMAL: boolean;
  40287. UV1: boolean;
  40288. UV2: boolean;
  40289. VERTEXCOLOR: boolean;
  40290. VERTEXALPHA: boolean;
  40291. NUM_BONE_INFLUENCERS: number;
  40292. BonesPerMesh: number;
  40293. BONETEXTURE: boolean;
  40294. INSTANCES: boolean;
  40295. GLOSSINESS: boolean;
  40296. ROUGHNESS: boolean;
  40297. EMISSIVEASILLUMINATION: boolean;
  40298. LINKEMISSIVEWITHDIFFUSE: boolean;
  40299. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40300. LIGHTMAP: boolean;
  40301. LIGHTMAPDIRECTUV: number;
  40302. OBJECTSPACE_NORMALMAP: boolean;
  40303. USELIGHTMAPASSHADOWMAP: boolean;
  40304. REFLECTIONMAP_3D: boolean;
  40305. REFLECTIONMAP_SPHERICAL: boolean;
  40306. REFLECTIONMAP_PLANAR: boolean;
  40307. REFLECTIONMAP_CUBIC: boolean;
  40308. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40309. REFLECTIONMAP_PROJECTION: boolean;
  40310. REFLECTIONMAP_SKYBOX: boolean;
  40311. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40312. REFLECTIONMAP_EXPLICIT: boolean;
  40313. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40314. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40315. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40316. INVERTCUBICMAP: boolean;
  40317. LOGARITHMICDEPTH: boolean;
  40318. REFRACTION: boolean;
  40319. REFRACTIONMAP_3D: boolean;
  40320. REFLECTIONOVERALPHA: boolean;
  40321. TWOSIDEDLIGHTING: boolean;
  40322. SHADOWFLOAT: boolean;
  40323. MORPHTARGETS: boolean;
  40324. MORPHTARGETS_NORMAL: boolean;
  40325. MORPHTARGETS_TANGENT: boolean;
  40326. NUM_MORPH_INFLUENCERS: number;
  40327. NONUNIFORMSCALING: boolean;
  40328. PREMULTIPLYALPHA: boolean;
  40329. IMAGEPROCESSING: boolean;
  40330. VIGNETTE: boolean;
  40331. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40332. VIGNETTEBLENDMODEOPAQUE: boolean;
  40333. TONEMAPPING: boolean;
  40334. TONEMAPPING_ACES: boolean;
  40335. CONTRAST: boolean;
  40336. COLORCURVES: boolean;
  40337. COLORGRADING: boolean;
  40338. COLORGRADING3D: boolean;
  40339. SAMPLER3DGREENDEPTH: boolean;
  40340. SAMPLER3DBGRMAP: boolean;
  40341. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40342. MULTIVIEW: boolean;
  40343. /**
  40344. * If the reflection texture on this material is in linear color space
  40345. * @hidden
  40346. */
  40347. IS_REFLECTION_LINEAR: boolean;
  40348. /**
  40349. * If the refraction texture on this material is in linear color space
  40350. * @hidden
  40351. */
  40352. IS_REFRACTION_LINEAR: boolean;
  40353. EXPOSURE: boolean;
  40354. constructor();
  40355. setReflectionMode(modeToEnable: string): void;
  40356. }
  40357. /**
  40358. * This is the default material used in Babylon. It is the best trade off between quality
  40359. * and performances.
  40360. * @see http://doc.babylonjs.com/babylon101/materials
  40361. */
  40362. export class StandardMaterial extends PushMaterial {
  40363. private _diffuseTexture;
  40364. /**
  40365. * The basic texture of the material as viewed under a light.
  40366. */
  40367. diffuseTexture: Nullable<BaseTexture>;
  40368. private _ambientTexture;
  40369. /**
  40370. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40371. */
  40372. ambientTexture: Nullable<BaseTexture>;
  40373. private _opacityTexture;
  40374. /**
  40375. * Define the transparency of the material from a texture.
  40376. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40377. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40378. */
  40379. opacityTexture: Nullable<BaseTexture>;
  40380. private _reflectionTexture;
  40381. /**
  40382. * Define the texture used to display the reflection.
  40383. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40384. */
  40385. reflectionTexture: Nullable<BaseTexture>;
  40386. private _emissiveTexture;
  40387. /**
  40388. * Define texture of the material as if self lit.
  40389. * This will be mixed in the final result even in the absence of light.
  40390. */
  40391. emissiveTexture: Nullable<BaseTexture>;
  40392. private _specularTexture;
  40393. /**
  40394. * Define how the color and intensity of the highlight given by the light in the material.
  40395. */
  40396. specularTexture: Nullable<BaseTexture>;
  40397. private _bumpTexture;
  40398. /**
  40399. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40400. * 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.
  40401. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40402. */
  40403. bumpTexture: Nullable<BaseTexture>;
  40404. private _lightmapTexture;
  40405. /**
  40406. * Complex lighting can be computationally expensive to compute at runtime.
  40407. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40408. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40409. */
  40410. lightmapTexture: Nullable<BaseTexture>;
  40411. private _refractionTexture;
  40412. /**
  40413. * Define the texture used to display the refraction.
  40414. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40415. */
  40416. refractionTexture: Nullable<BaseTexture>;
  40417. /**
  40418. * The color of the material lit by the environmental background lighting.
  40419. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40420. */
  40421. ambientColor: Color3;
  40422. /**
  40423. * The basic color of the material as viewed under a light.
  40424. */
  40425. diffuseColor: Color3;
  40426. /**
  40427. * Define how the color and intensity of the highlight given by the light in the material.
  40428. */
  40429. specularColor: Color3;
  40430. /**
  40431. * Define the color of the material as if self lit.
  40432. * This will be mixed in the final result even in the absence of light.
  40433. */
  40434. emissiveColor: Color3;
  40435. /**
  40436. * Defines how sharp are the highlights in the material.
  40437. * The bigger the value the sharper giving a more glossy feeling to the result.
  40438. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40439. */
  40440. specularPower: number;
  40441. private _useAlphaFromDiffuseTexture;
  40442. /**
  40443. * Does the transparency come from the diffuse texture alpha channel.
  40444. */
  40445. useAlphaFromDiffuseTexture: boolean;
  40446. private _useEmissiveAsIllumination;
  40447. /**
  40448. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40449. */
  40450. useEmissiveAsIllumination: boolean;
  40451. private _linkEmissiveWithDiffuse;
  40452. /**
  40453. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40454. * the emissive level when the final color is close to one.
  40455. */
  40456. linkEmissiveWithDiffuse: boolean;
  40457. private _useSpecularOverAlpha;
  40458. /**
  40459. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40460. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40461. */
  40462. useSpecularOverAlpha: boolean;
  40463. private _useReflectionOverAlpha;
  40464. /**
  40465. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40466. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40467. */
  40468. useReflectionOverAlpha: boolean;
  40469. private _disableLighting;
  40470. /**
  40471. * Does lights from the scene impacts this material.
  40472. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40473. */
  40474. disableLighting: boolean;
  40475. private _useObjectSpaceNormalMap;
  40476. /**
  40477. * Allows using an object space normal map (instead of tangent space).
  40478. */
  40479. useObjectSpaceNormalMap: boolean;
  40480. private _useParallax;
  40481. /**
  40482. * Is parallax enabled or not.
  40483. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40484. */
  40485. useParallax: boolean;
  40486. private _useParallaxOcclusion;
  40487. /**
  40488. * Is parallax occlusion enabled or not.
  40489. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40490. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40491. */
  40492. useParallaxOcclusion: boolean;
  40493. /**
  40494. * 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.
  40495. */
  40496. parallaxScaleBias: number;
  40497. private _roughness;
  40498. /**
  40499. * Helps to define how blurry the reflections should appears in the material.
  40500. */
  40501. roughness: number;
  40502. /**
  40503. * In case of refraction, define the value of the index of refraction.
  40504. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40505. */
  40506. indexOfRefraction: number;
  40507. /**
  40508. * Invert the refraction texture alongside the y axis.
  40509. * It can be useful with procedural textures or probe for instance.
  40510. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40511. */
  40512. invertRefractionY: boolean;
  40513. /**
  40514. * Defines the alpha limits in alpha test mode.
  40515. */
  40516. alphaCutOff: number;
  40517. private _useLightmapAsShadowmap;
  40518. /**
  40519. * In case of light mapping, define whether the map contains light or shadow informations.
  40520. */
  40521. useLightmapAsShadowmap: boolean;
  40522. private _diffuseFresnelParameters;
  40523. /**
  40524. * Define the diffuse fresnel parameters of the material.
  40525. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40526. */
  40527. diffuseFresnelParameters: FresnelParameters;
  40528. private _opacityFresnelParameters;
  40529. /**
  40530. * Define the opacity fresnel parameters of the material.
  40531. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40532. */
  40533. opacityFresnelParameters: FresnelParameters;
  40534. private _reflectionFresnelParameters;
  40535. /**
  40536. * Define the reflection fresnel parameters of the material.
  40537. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40538. */
  40539. reflectionFresnelParameters: FresnelParameters;
  40540. private _refractionFresnelParameters;
  40541. /**
  40542. * Define the refraction fresnel parameters of the material.
  40543. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40544. */
  40545. refractionFresnelParameters: FresnelParameters;
  40546. private _emissiveFresnelParameters;
  40547. /**
  40548. * Define the emissive fresnel parameters of the material.
  40549. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40550. */
  40551. emissiveFresnelParameters: FresnelParameters;
  40552. private _useReflectionFresnelFromSpecular;
  40553. /**
  40554. * If true automatically deducts the fresnels values from the material specularity.
  40555. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40556. */
  40557. useReflectionFresnelFromSpecular: boolean;
  40558. private _useGlossinessFromSpecularMapAlpha;
  40559. /**
  40560. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40561. */
  40562. useGlossinessFromSpecularMapAlpha: boolean;
  40563. private _maxSimultaneousLights;
  40564. /**
  40565. * Defines the maximum number of lights that can be used in the material
  40566. */
  40567. maxSimultaneousLights: number;
  40568. private _invertNormalMapX;
  40569. /**
  40570. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40571. */
  40572. invertNormalMapX: boolean;
  40573. private _invertNormalMapY;
  40574. /**
  40575. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40576. */
  40577. invertNormalMapY: boolean;
  40578. private _twoSidedLighting;
  40579. /**
  40580. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40581. */
  40582. twoSidedLighting: boolean;
  40583. /**
  40584. * Default configuration related to image processing available in the standard Material.
  40585. */
  40586. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40587. /**
  40588. * Gets the image processing configuration used either in this material.
  40589. */
  40590. /**
  40591. * Sets the Default image processing configuration used either in the this material.
  40592. *
  40593. * If sets to null, the scene one is in use.
  40594. */
  40595. imageProcessingConfiguration: ImageProcessingConfiguration;
  40596. /**
  40597. * Keep track of the image processing observer to allow dispose and replace.
  40598. */
  40599. private _imageProcessingObserver;
  40600. /**
  40601. * Attaches a new image processing configuration to the Standard Material.
  40602. * @param configuration
  40603. */
  40604. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40605. /**
  40606. * Gets wether the color curves effect is enabled.
  40607. */
  40608. /**
  40609. * Sets wether the color curves effect is enabled.
  40610. */
  40611. cameraColorCurvesEnabled: boolean;
  40612. /**
  40613. * Gets wether the color grading effect is enabled.
  40614. */
  40615. /**
  40616. * Gets wether the color grading effect is enabled.
  40617. */
  40618. cameraColorGradingEnabled: boolean;
  40619. /**
  40620. * Gets wether tonemapping is enabled or not.
  40621. */
  40622. /**
  40623. * Sets wether tonemapping is enabled or not
  40624. */
  40625. cameraToneMappingEnabled: boolean;
  40626. /**
  40627. * The camera exposure used on this material.
  40628. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40629. * This corresponds to a photographic exposure.
  40630. */
  40631. /**
  40632. * The camera exposure used on this material.
  40633. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40634. * This corresponds to a photographic exposure.
  40635. */
  40636. cameraExposure: number;
  40637. /**
  40638. * Gets The camera contrast used on this material.
  40639. */
  40640. /**
  40641. * Sets The camera contrast used on this material.
  40642. */
  40643. cameraContrast: number;
  40644. /**
  40645. * Gets the Color Grading 2D Lookup Texture.
  40646. */
  40647. /**
  40648. * Sets the Color Grading 2D Lookup Texture.
  40649. */
  40650. cameraColorGradingTexture: Nullable<BaseTexture>;
  40651. /**
  40652. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40653. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40654. * 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;
  40655. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40656. */
  40657. /**
  40658. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40659. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40660. * 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;
  40661. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40662. */
  40663. cameraColorCurves: Nullable<ColorCurves>;
  40664. /**
  40665. * Custom callback helping to override the default shader used in the material.
  40666. */
  40667. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40668. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40669. protected _worldViewProjectionMatrix: Matrix;
  40670. protected _globalAmbientColor: Color3;
  40671. protected _useLogarithmicDepth: boolean;
  40672. /**
  40673. * Instantiates a new standard material.
  40674. * This is the default material used in Babylon. It is the best trade off between quality
  40675. * and performances.
  40676. * @see http://doc.babylonjs.com/babylon101/materials
  40677. * @param name Define the name of the material in the scene
  40678. * @param scene Define the scene the material belong to
  40679. */
  40680. constructor(name: string, scene: Scene);
  40681. /**
  40682. * Gets a boolean indicating that current material needs to register RTT
  40683. */
  40684. readonly hasRenderTargetTextures: boolean;
  40685. /**
  40686. * Gets the current class name of the material e.g. "StandardMaterial"
  40687. * Mainly use in serialization.
  40688. * @returns the class name
  40689. */
  40690. getClassName(): string;
  40691. /**
  40692. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40693. * You can try switching to logarithmic depth.
  40694. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40695. */
  40696. useLogarithmicDepth: boolean;
  40697. /**
  40698. * Specifies if the material will require alpha blending
  40699. * @returns a boolean specifying if alpha blending is needed
  40700. */
  40701. needAlphaBlending(): boolean;
  40702. /**
  40703. * Specifies if this material should be rendered in alpha test mode
  40704. * @returns a boolean specifying if an alpha test is needed.
  40705. */
  40706. needAlphaTesting(): boolean;
  40707. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40708. /**
  40709. * Get the texture used for alpha test purpose.
  40710. * @returns the diffuse texture in case of the standard material.
  40711. */
  40712. getAlphaTestTexture(): Nullable<BaseTexture>;
  40713. /**
  40714. * Get if the submesh is ready to be used and all its information available.
  40715. * Child classes can use it to update shaders
  40716. * @param mesh defines the mesh to check
  40717. * @param subMesh defines which submesh to check
  40718. * @param useInstances specifies that instances should be used
  40719. * @returns a boolean indicating that the submesh is ready or not
  40720. */
  40721. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40722. /**
  40723. * Builds the material UBO layouts.
  40724. * Used internally during the effect preparation.
  40725. */
  40726. buildUniformLayout(): void;
  40727. /**
  40728. * Unbinds the material from the mesh
  40729. */
  40730. unbind(): void;
  40731. /**
  40732. * Binds the submesh to this material by preparing the effect and shader to draw
  40733. * @param world defines the world transformation matrix
  40734. * @param mesh defines the mesh containing the submesh
  40735. * @param subMesh defines the submesh to bind the material to
  40736. */
  40737. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40738. /**
  40739. * Get the list of animatables in the material.
  40740. * @returns the list of animatables object used in the material
  40741. */
  40742. getAnimatables(): IAnimatable[];
  40743. /**
  40744. * Gets the active textures from the material
  40745. * @returns an array of textures
  40746. */
  40747. getActiveTextures(): BaseTexture[];
  40748. /**
  40749. * Specifies if the material uses a texture
  40750. * @param texture defines the texture to check against the material
  40751. * @returns a boolean specifying if the material uses the texture
  40752. */
  40753. hasTexture(texture: BaseTexture): boolean;
  40754. /**
  40755. * Disposes the material
  40756. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40757. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40758. */
  40759. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40760. /**
  40761. * Makes a duplicate of the material, and gives it a new name
  40762. * @param name defines the new name for the duplicated material
  40763. * @returns the cloned material
  40764. */
  40765. clone(name: string): StandardMaterial;
  40766. /**
  40767. * Serializes this material in a JSON representation
  40768. * @returns the serialized material object
  40769. */
  40770. serialize(): any;
  40771. /**
  40772. * Creates a standard material from parsed material data
  40773. * @param source defines the JSON representation of the material
  40774. * @param scene defines the hosting scene
  40775. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40776. * @returns a new standard material
  40777. */
  40778. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40779. /**
  40780. * Are diffuse textures enabled in the application.
  40781. */
  40782. static DiffuseTextureEnabled: boolean;
  40783. /**
  40784. * Are ambient textures enabled in the application.
  40785. */
  40786. static AmbientTextureEnabled: boolean;
  40787. /**
  40788. * Are opacity textures enabled in the application.
  40789. */
  40790. static OpacityTextureEnabled: boolean;
  40791. /**
  40792. * Are reflection textures enabled in the application.
  40793. */
  40794. static ReflectionTextureEnabled: boolean;
  40795. /**
  40796. * Are emissive textures enabled in the application.
  40797. */
  40798. static EmissiveTextureEnabled: boolean;
  40799. /**
  40800. * Are specular textures enabled in the application.
  40801. */
  40802. static SpecularTextureEnabled: boolean;
  40803. /**
  40804. * Are bump textures enabled in the application.
  40805. */
  40806. static BumpTextureEnabled: boolean;
  40807. /**
  40808. * Are lightmap textures enabled in the application.
  40809. */
  40810. static LightmapTextureEnabled: boolean;
  40811. /**
  40812. * Are refraction textures enabled in the application.
  40813. */
  40814. static RefractionTextureEnabled: boolean;
  40815. /**
  40816. * Are color grading textures enabled in the application.
  40817. */
  40818. static ColorGradingTextureEnabled: boolean;
  40819. /**
  40820. * Are fresnels enabled in the application.
  40821. */
  40822. static FresnelEnabled: boolean;
  40823. }
  40824. }
  40825. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40826. import { Scene } from "babylonjs/scene";
  40827. import { Texture } from "babylonjs/Materials/Textures/texture";
  40828. /**
  40829. * A class extending Texture allowing drawing on a texture
  40830. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40831. */
  40832. export class DynamicTexture extends Texture {
  40833. private _generateMipMaps;
  40834. private _canvas;
  40835. private _context;
  40836. private _engine;
  40837. /**
  40838. * Creates a DynamicTexture
  40839. * @param name defines the name of the texture
  40840. * @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
  40841. * @param scene defines the scene where you want the texture
  40842. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40843. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40844. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40845. */
  40846. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40847. /**
  40848. * Get the current class name of the texture useful for serialization or dynamic coding.
  40849. * @returns "DynamicTexture"
  40850. */
  40851. getClassName(): string;
  40852. /**
  40853. * Gets the current state of canRescale
  40854. */
  40855. readonly canRescale: boolean;
  40856. private _recreate;
  40857. /**
  40858. * Scales the texture
  40859. * @param ratio the scale factor to apply to both width and height
  40860. */
  40861. scale(ratio: number): void;
  40862. /**
  40863. * Resizes the texture
  40864. * @param width the new width
  40865. * @param height the new height
  40866. */
  40867. scaleTo(width: number, height: number): void;
  40868. /**
  40869. * Gets the context of the canvas used by the texture
  40870. * @returns the canvas context of the dynamic texture
  40871. */
  40872. getContext(): CanvasRenderingContext2D;
  40873. /**
  40874. * Clears the texture
  40875. */
  40876. clear(): void;
  40877. /**
  40878. * Updates the texture
  40879. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40880. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40881. */
  40882. update(invertY?: boolean, premulAlpha?: boolean): void;
  40883. /**
  40884. * Draws text onto the texture
  40885. * @param text defines the text to be drawn
  40886. * @param x defines the placement of the text from the left
  40887. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40888. * @param font defines the font to be used with font-style, font-size, font-name
  40889. * @param color defines the color used for the text
  40890. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40891. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40892. * @param update defines whether texture is immediately update (default is true)
  40893. */
  40894. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40895. /**
  40896. * Clones the texture
  40897. * @returns the clone of the texture.
  40898. */
  40899. clone(): DynamicTexture;
  40900. /**
  40901. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40902. * @returns a serialized dynamic texture object
  40903. */
  40904. serialize(): any;
  40905. /** @hidden */
  40906. _rebuild(): void;
  40907. }
  40908. }
  40909. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40910. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40911. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40912. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40913. /** @hidden */
  40914. export var imageProcessingPixelShader: {
  40915. name: string;
  40916. shader: string;
  40917. };
  40918. }
  40919. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40920. import { Nullable } from "babylonjs/types";
  40921. import { Color4 } from "babylonjs/Maths/math";
  40922. import { Camera } from "babylonjs/Cameras/camera";
  40923. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40924. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40925. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40926. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40927. import { Engine } from "babylonjs/Engines/engine";
  40928. import "babylonjs/Shaders/imageProcessing.fragment";
  40929. import "babylonjs/Shaders/postprocess.vertex";
  40930. /**
  40931. * ImageProcessingPostProcess
  40932. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40933. */
  40934. export class ImageProcessingPostProcess extends PostProcess {
  40935. /**
  40936. * Default configuration related to image processing available in the PBR Material.
  40937. */
  40938. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40939. /**
  40940. * Gets the image processing configuration used either in this material.
  40941. */
  40942. /**
  40943. * Sets the Default image processing configuration used either in the this material.
  40944. *
  40945. * If sets to null, the scene one is in use.
  40946. */
  40947. imageProcessingConfiguration: ImageProcessingConfiguration;
  40948. /**
  40949. * Keep track of the image processing observer to allow dispose and replace.
  40950. */
  40951. private _imageProcessingObserver;
  40952. /**
  40953. * Attaches a new image processing configuration to the PBR Material.
  40954. * @param configuration
  40955. */
  40956. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40957. /**
  40958. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40959. */
  40960. /**
  40961. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40962. */
  40963. colorCurves: Nullable<ColorCurves>;
  40964. /**
  40965. * Gets wether the color curves effect is enabled.
  40966. */
  40967. /**
  40968. * Sets wether the color curves effect is enabled.
  40969. */
  40970. colorCurvesEnabled: boolean;
  40971. /**
  40972. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40973. */
  40974. /**
  40975. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40976. */
  40977. colorGradingTexture: Nullable<BaseTexture>;
  40978. /**
  40979. * Gets wether the color grading effect is enabled.
  40980. */
  40981. /**
  40982. * Gets wether the color grading effect is enabled.
  40983. */
  40984. colorGradingEnabled: boolean;
  40985. /**
  40986. * Gets exposure used in the effect.
  40987. */
  40988. /**
  40989. * Sets exposure used in the effect.
  40990. */
  40991. exposure: number;
  40992. /**
  40993. * Gets wether tonemapping is enabled or not.
  40994. */
  40995. /**
  40996. * Sets wether tonemapping is enabled or not
  40997. */
  40998. toneMappingEnabled: boolean;
  40999. /**
  41000. * Gets the type of tone mapping effect.
  41001. */
  41002. /**
  41003. * Sets the type of tone mapping effect.
  41004. */
  41005. toneMappingType: number;
  41006. /**
  41007. * Gets contrast used in the effect.
  41008. */
  41009. /**
  41010. * Sets contrast used in the effect.
  41011. */
  41012. contrast: number;
  41013. /**
  41014. * Gets Vignette stretch size.
  41015. */
  41016. /**
  41017. * Sets Vignette stretch size.
  41018. */
  41019. vignetteStretch: number;
  41020. /**
  41021. * Gets Vignette centre X Offset.
  41022. */
  41023. /**
  41024. * Sets Vignette centre X Offset.
  41025. */
  41026. vignetteCentreX: number;
  41027. /**
  41028. * Gets Vignette centre Y Offset.
  41029. */
  41030. /**
  41031. * Sets Vignette centre Y Offset.
  41032. */
  41033. vignetteCentreY: number;
  41034. /**
  41035. * Gets Vignette weight or intensity of the vignette effect.
  41036. */
  41037. /**
  41038. * Sets Vignette weight or intensity of the vignette effect.
  41039. */
  41040. vignetteWeight: number;
  41041. /**
  41042. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41043. * if vignetteEnabled is set to true.
  41044. */
  41045. /**
  41046. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41047. * if vignetteEnabled is set to true.
  41048. */
  41049. vignetteColor: Color4;
  41050. /**
  41051. * Gets Camera field of view used by the Vignette effect.
  41052. */
  41053. /**
  41054. * Sets Camera field of view used by the Vignette effect.
  41055. */
  41056. vignetteCameraFov: number;
  41057. /**
  41058. * Gets the vignette blend mode allowing different kind of effect.
  41059. */
  41060. /**
  41061. * Sets the vignette blend mode allowing different kind of effect.
  41062. */
  41063. vignetteBlendMode: number;
  41064. /**
  41065. * Gets wether the vignette effect is enabled.
  41066. */
  41067. /**
  41068. * Sets wether the vignette effect is enabled.
  41069. */
  41070. vignetteEnabled: boolean;
  41071. private _fromLinearSpace;
  41072. /**
  41073. * Gets wether the input of the processing is in Gamma or Linear Space.
  41074. */
  41075. /**
  41076. * Sets wether the input of the processing is in Gamma or Linear Space.
  41077. */
  41078. fromLinearSpace: boolean;
  41079. /**
  41080. * Defines cache preventing GC.
  41081. */
  41082. private _defines;
  41083. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41084. /**
  41085. * "ImageProcessingPostProcess"
  41086. * @returns "ImageProcessingPostProcess"
  41087. */
  41088. getClassName(): string;
  41089. protected _updateParameters(): void;
  41090. dispose(camera?: Camera): void;
  41091. }
  41092. }
  41093. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41094. import { Scene } from "babylonjs/scene";
  41095. import { Color3 } from "babylonjs/Maths/math";
  41096. import { Mesh } from "babylonjs/Meshes/mesh";
  41097. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41098. import { Nullable } from "babylonjs/types";
  41099. /**
  41100. * Class containing static functions to help procedurally build meshes
  41101. */
  41102. export class GroundBuilder {
  41103. /**
  41104. * Creates a ground mesh
  41105. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41106. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41108. * @param name defines the name of the mesh
  41109. * @param options defines the options used to create the mesh
  41110. * @param scene defines the hosting scene
  41111. * @returns the ground mesh
  41112. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41113. */
  41114. static CreateGround(name: string, options: {
  41115. width?: number;
  41116. height?: number;
  41117. subdivisions?: number;
  41118. subdivisionsX?: number;
  41119. subdivisionsY?: number;
  41120. updatable?: boolean;
  41121. }, scene: any): Mesh;
  41122. /**
  41123. * Creates a tiled ground mesh
  41124. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41125. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41126. * * 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
  41127. * * 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
  41128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41129. * @param name defines the name of the mesh
  41130. * @param options defines the options used to create the mesh
  41131. * @param scene defines the hosting scene
  41132. * @returns the tiled ground mesh
  41133. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41134. */
  41135. static CreateTiledGround(name: string, options: {
  41136. xmin: number;
  41137. zmin: number;
  41138. xmax: number;
  41139. zmax: number;
  41140. subdivisions?: {
  41141. w: number;
  41142. h: number;
  41143. };
  41144. precision?: {
  41145. w: number;
  41146. h: number;
  41147. };
  41148. updatable?: boolean;
  41149. }, scene?: Nullable<Scene>): Mesh;
  41150. /**
  41151. * Creates a ground mesh from a height map
  41152. * * The parameter `url` sets the URL of the height map image resource.
  41153. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41154. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41155. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41156. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41157. * * 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.
  41158. * * 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).
  41159. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41161. * @param name defines the name of the mesh
  41162. * @param url defines the url to the height map
  41163. * @param options defines the options used to create the mesh
  41164. * @param scene defines the hosting scene
  41165. * @returns the ground mesh
  41166. * @see https://doc.babylonjs.com/babylon101/height_map
  41167. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41168. */
  41169. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41170. width?: number;
  41171. height?: number;
  41172. subdivisions?: number;
  41173. minHeight?: number;
  41174. maxHeight?: number;
  41175. colorFilter?: Color3;
  41176. alphaFilter?: number;
  41177. updatable?: boolean;
  41178. onReady?: (mesh: GroundMesh) => void;
  41179. }, scene?: Nullable<Scene>): GroundMesh;
  41180. }
  41181. }
  41182. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41183. import { Vector4 } from "babylonjs/Maths/math";
  41184. import { Mesh } from "babylonjs/Meshes/mesh";
  41185. /**
  41186. * Class containing static functions to help procedurally build meshes
  41187. */
  41188. export class TorusBuilder {
  41189. /**
  41190. * Creates a torus mesh
  41191. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41192. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41193. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41197. * @param name defines the name of the mesh
  41198. * @param options defines the options used to create the mesh
  41199. * @param scene defines the hosting scene
  41200. * @returns the torus mesh
  41201. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41202. */
  41203. static CreateTorus(name: string, options: {
  41204. diameter?: number;
  41205. thickness?: number;
  41206. tessellation?: number;
  41207. updatable?: boolean;
  41208. sideOrientation?: number;
  41209. frontUVs?: Vector4;
  41210. backUVs?: Vector4;
  41211. }, scene: any): Mesh;
  41212. }
  41213. }
  41214. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41215. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41216. import { Mesh } from "babylonjs/Meshes/mesh";
  41217. /**
  41218. * Class containing static functions to help procedurally build meshes
  41219. */
  41220. export class CylinderBuilder {
  41221. /**
  41222. * Creates a cylinder or a cone mesh
  41223. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41224. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41225. * * 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.
  41226. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41227. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41228. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41229. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41230. * * 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).
  41231. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41232. * * 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).
  41233. * * 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
  41234. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41235. * * 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
  41236. * * 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.
  41237. * * If `enclose` is false, a ring surface is one element.
  41238. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41239. * * 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
  41240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41243. * @param name defines the name of the mesh
  41244. * @param options defines the options used to create the mesh
  41245. * @param scene defines the hosting scene
  41246. * @returns the cylinder mesh
  41247. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41248. */
  41249. static CreateCylinder(name: string, options: {
  41250. height?: number;
  41251. diameterTop?: number;
  41252. diameterBottom?: number;
  41253. diameter?: number;
  41254. tessellation?: number;
  41255. subdivisions?: number;
  41256. arc?: number;
  41257. faceColors?: Color4[];
  41258. faceUV?: Vector4[];
  41259. updatable?: boolean;
  41260. hasRings?: boolean;
  41261. enclose?: boolean;
  41262. cap?: number;
  41263. sideOrientation?: number;
  41264. frontUVs?: Vector4;
  41265. backUVs?: Vector4;
  41266. }, scene: any): Mesh;
  41267. }
  41268. }
  41269. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41270. import { Observable } from "babylonjs/Misc/observable";
  41271. import { Nullable } from "babylonjs/types";
  41272. import { Camera } from "babylonjs/Cameras/camera";
  41273. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41274. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41275. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41276. import { Scene } from "babylonjs/scene";
  41277. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41278. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41280. import { Mesh } from "babylonjs/Meshes/mesh";
  41281. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41282. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41283. import "babylonjs/Meshes/Builders/groundBuilder";
  41284. import "babylonjs/Meshes/Builders/torusBuilder";
  41285. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41286. import "babylonjs/Gamepads/gamepadSceneComponent";
  41287. import "babylonjs/Animations/animatable";
  41288. /**
  41289. * Options to modify the vr teleportation behavior.
  41290. */
  41291. export interface VRTeleportationOptions {
  41292. /**
  41293. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41294. */
  41295. floorMeshName?: string;
  41296. /**
  41297. * A list of meshes to be used as the teleportation floor. (default: empty)
  41298. */
  41299. floorMeshes?: Mesh[];
  41300. }
  41301. /**
  41302. * Options to modify the vr experience helper's behavior.
  41303. */
  41304. export interface VRExperienceHelperOptions extends WebVROptions {
  41305. /**
  41306. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41307. */
  41308. createDeviceOrientationCamera?: boolean;
  41309. /**
  41310. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41311. */
  41312. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41313. /**
  41314. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41315. */
  41316. laserToggle?: boolean;
  41317. /**
  41318. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41319. */
  41320. floorMeshes?: Mesh[];
  41321. /**
  41322. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41323. */
  41324. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41325. }
  41326. /**
  41327. * Event containing information after VR has been entered
  41328. */
  41329. export class OnAfterEnteringVRObservableEvent {
  41330. /**
  41331. * If entering vr was successful
  41332. */
  41333. success: boolean;
  41334. }
  41335. /**
  41336. * Helps to quickly add VR support to an existing scene.
  41337. * See http://doc.babylonjs.com/how_to/webvr_helper
  41338. */
  41339. export class VRExperienceHelper {
  41340. /** Options to modify the vr experience helper's behavior. */
  41341. webVROptions: VRExperienceHelperOptions;
  41342. private _scene;
  41343. private _position;
  41344. private _btnVR;
  41345. private _btnVRDisplayed;
  41346. private _webVRsupported;
  41347. private _webVRready;
  41348. private _webVRrequesting;
  41349. private _webVRpresenting;
  41350. private _hasEnteredVR;
  41351. private _fullscreenVRpresenting;
  41352. private _canvas;
  41353. private _webVRCamera;
  41354. private _vrDeviceOrientationCamera;
  41355. private _deviceOrientationCamera;
  41356. private _existingCamera;
  41357. private _onKeyDown;
  41358. private _onVrDisplayPresentChange;
  41359. private _onVRDisplayChanged;
  41360. private _onVRRequestPresentStart;
  41361. private _onVRRequestPresentComplete;
  41362. /**
  41363. * Observable raised right before entering VR.
  41364. */
  41365. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41366. /**
  41367. * Observable raised when entering VR has completed.
  41368. */
  41369. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41370. /**
  41371. * Observable raised when exiting VR.
  41372. */
  41373. onExitingVRObservable: Observable<VRExperienceHelper>;
  41374. /**
  41375. * Observable raised when controller mesh is loaded.
  41376. */
  41377. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41378. /** Return this.onEnteringVRObservable
  41379. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41380. */
  41381. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41382. /** Return this.onExitingVRObservable
  41383. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41384. */
  41385. readonly onExitingVR: Observable<VRExperienceHelper>;
  41386. /** Return this.onControllerMeshLoadedObservable
  41387. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41388. */
  41389. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41390. private _rayLength;
  41391. private _useCustomVRButton;
  41392. private _teleportationRequested;
  41393. private _teleportActive;
  41394. private _floorMeshName;
  41395. private _floorMeshesCollection;
  41396. private _rotationAllowed;
  41397. private _teleportBackwardsVector;
  41398. private _teleportationTarget;
  41399. private _isDefaultTeleportationTarget;
  41400. private _postProcessMove;
  41401. private _teleportationFillColor;
  41402. private _teleportationBorderColor;
  41403. private _rotationAngle;
  41404. private _haloCenter;
  41405. private _cameraGazer;
  41406. private _padSensibilityUp;
  41407. private _padSensibilityDown;
  41408. private _leftController;
  41409. private _rightController;
  41410. /**
  41411. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41412. */
  41413. onNewMeshSelected: Observable<AbstractMesh>;
  41414. /**
  41415. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41416. */
  41417. onNewMeshPicked: Observable<PickingInfo>;
  41418. private _circleEase;
  41419. /**
  41420. * Observable raised before camera teleportation
  41421. */
  41422. onBeforeCameraTeleport: Observable<Vector3>;
  41423. /**
  41424. * Observable raised after camera teleportation
  41425. */
  41426. onAfterCameraTeleport: Observable<Vector3>;
  41427. /**
  41428. * Observable raised when current selected mesh gets unselected
  41429. */
  41430. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41431. private _raySelectionPredicate;
  41432. /**
  41433. * To be optionaly changed by user to define custom ray selection
  41434. */
  41435. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41436. /**
  41437. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41438. */
  41439. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41440. /**
  41441. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41442. */
  41443. teleportationEnabled: boolean;
  41444. private _defaultHeight;
  41445. private _teleportationInitialized;
  41446. private _interactionsEnabled;
  41447. private _interactionsRequested;
  41448. private _displayGaze;
  41449. private _displayLaserPointer;
  41450. /**
  41451. * The mesh used to display where the user is going to teleport.
  41452. */
  41453. /**
  41454. * Sets the mesh to be used to display where the user is going to teleport.
  41455. */
  41456. teleportationTarget: Mesh;
  41457. /**
  41458. * 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
  41459. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41460. * See http://doc.babylonjs.com/resources/baking_transformations
  41461. */
  41462. gazeTrackerMesh: Mesh;
  41463. /**
  41464. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41465. */
  41466. updateGazeTrackerScale: boolean;
  41467. /**
  41468. * If the gaze trackers color should be updated when selecting meshes
  41469. */
  41470. updateGazeTrackerColor: boolean;
  41471. /**
  41472. * The gaze tracking mesh corresponding to the left controller
  41473. */
  41474. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41475. /**
  41476. * The gaze tracking mesh corresponding to the right controller
  41477. */
  41478. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41479. /**
  41480. * If the ray of the gaze should be displayed.
  41481. */
  41482. /**
  41483. * Sets if the ray of the gaze should be displayed.
  41484. */
  41485. displayGaze: boolean;
  41486. /**
  41487. * If the ray of the LaserPointer should be displayed.
  41488. */
  41489. /**
  41490. * Sets if the ray of the LaserPointer should be displayed.
  41491. */
  41492. displayLaserPointer: boolean;
  41493. /**
  41494. * The deviceOrientationCamera used as the camera when not in VR.
  41495. */
  41496. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41497. /**
  41498. * Based on the current WebVR support, returns the current VR camera used.
  41499. */
  41500. readonly currentVRCamera: Nullable<Camera>;
  41501. /**
  41502. * The webVRCamera which is used when in VR.
  41503. */
  41504. readonly webVRCamera: WebVRFreeCamera;
  41505. /**
  41506. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41507. */
  41508. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41509. private readonly _teleportationRequestInitiated;
  41510. /**
  41511. * Defines wether or not Pointer lock should be requested when switching to
  41512. * full screen.
  41513. */
  41514. requestPointerLockOnFullScreen: boolean;
  41515. /**
  41516. * Instantiates a VRExperienceHelper.
  41517. * Helps to quickly add VR support to an existing scene.
  41518. * @param scene The scene the VRExperienceHelper belongs to.
  41519. * @param webVROptions Options to modify the vr experience helper's behavior.
  41520. */
  41521. constructor(scene: Scene,
  41522. /** Options to modify the vr experience helper's behavior. */
  41523. webVROptions?: VRExperienceHelperOptions);
  41524. private _onDefaultMeshLoaded;
  41525. private _onResize;
  41526. private _onFullscreenChange;
  41527. /**
  41528. * Gets a value indicating if we are currently in VR mode.
  41529. */
  41530. readonly isInVRMode: boolean;
  41531. private onVrDisplayPresentChange;
  41532. private onVRDisplayChanged;
  41533. private moveButtonToBottomRight;
  41534. private displayVRButton;
  41535. private updateButtonVisibility;
  41536. private _cachedAngularSensibility;
  41537. /**
  41538. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41539. * Otherwise, will use the fullscreen API.
  41540. */
  41541. enterVR(): void;
  41542. /**
  41543. * Attempt to exit VR, or fullscreen.
  41544. */
  41545. exitVR(): void;
  41546. /**
  41547. * The position of the vr experience helper.
  41548. */
  41549. /**
  41550. * Sets the position of the vr experience helper.
  41551. */
  41552. position: Vector3;
  41553. /**
  41554. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41555. */
  41556. enableInteractions(): void;
  41557. private readonly _noControllerIsActive;
  41558. private beforeRender;
  41559. private _isTeleportationFloor;
  41560. /**
  41561. * Adds a floor mesh to be used for teleportation.
  41562. * @param floorMesh the mesh to be used for teleportation.
  41563. */
  41564. addFloorMesh(floorMesh: Mesh): void;
  41565. /**
  41566. * Removes a floor mesh from being used for teleportation.
  41567. * @param floorMesh the mesh to be removed.
  41568. */
  41569. removeFloorMesh(floorMesh: Mesh): void;
  41570. /**
  41571. * Enables interactions and teleportation using the VR controllers and gaze.
  41572. * @param vrTeleportationOptions options to modify teleportation behavior.
  41573. */
  41574. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41575. private _onNewGamepadConnected;
  41576. private _tryEnableInteractionOnController;
  41577. private _onNewGamepadDisconnected;
  41578. private _enableInteractionOnController;
  41579. private _checkTeleportWithRay;
  41580. private _checkRotate;
  41581. private _checkTeleportBackwards;
  41582. private _enableTeleportationOnController;
  41583. private _createTeleportationCircles;
  41584. private _displayTeleportationTarget;
  41585. private _hideTeleportationTarget;
  41586. private _rotateCamera;
  41587. private _moveTeleportationSelectorTo;
  41588. private _workingVector;
  41589. private _workingQuaternion;
  41590. private _workingMatrix;
  41591. /**
  41592. * Teleports the users feet to the desired location
  41593. * @param location The location where the user's feet should be placed
  41594. */
  41595. teleportCamera(location: Vector3): void;
  41596. private _convertNormalToDirectionOfRay;
  41597. private _castRayAndSelectObject;
  41598. private _notifySelectedMeshUnselected;
  41599. /**
  41600. * Sets the color of the laser ray from the vr controllers.
  41601. * @param color new color for the ray.
  41602. */
  41603. changeLaserColor(color: Color3): void;
  41604. /**
  41605. * Sets the color of the ray from the vr headsets gaze.
  41606. * @param color new color for the ray.
  41607. */
  41608. changeGazeColor(color: Color3): void;
  41609. /**
  41610. * Exits VR and disposes of the vr experience helper
  41611. */
  41612. dispose(): void;
  41613. /**
  41614. * Gets the name of the VRExperienceHelper class
  41615. * @returns "VRExperienceHelper"
  41616. */
  41617. getClassName(): string;
  41618. }
  41619. }
  41620. declare module "babylonjs/Cameras/VR/index" {
  41621. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41622. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41623. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41624. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41625. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41626. export * from "babylonjs/Cameras/VR/webVRCamera";
  41627. }
  41628. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41629. import { Observable } from "babylonjs/Misc/observable";
  41630. import { Nullable } from "babylonjs/types";
  41631. import { IDisposable, Scene } from "babylonjs/scene";
  41632. import { Vector3 } from "babylonjs/Maths/math";
  41633. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41634. import { Ray } from "babylonjs/Culling/ray";
  41635. /**
  41636. * Manages an XRSession
  41637. * @see https://doc.babylonjs.com/how_to/webxr
  41638. */
  41639. export class WebXRSessionManager implements IDisposable {
  41640. private scene;
  41641. /**
  41642. * Fires every time a new xrFrame arrives which can be used to update the camera
  41643. */
  41644. onXRFrameObservable: Observable<any>;
  41645. /**
  41646. * Fires when the xr session is ended either by the device or manually done
  41647. */
  41648. onXRSessionEnded: Observable<any>;
  41649. /** @hidden */
  41650. _xrSession: XRSession;
  41651. /** @hidden */
  41652. _frameOfReference: XRFrameOfReference;
  41653. /** @hidden */
  41654. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41655. /** @hidden */
  41656. _currentXRFrame: Nullable<XRFrame>;
  41657. private _xrNavigator;
  41658. private _xrDevice;
  41659. private _tmpMatrix;
  41660. /**
  41661. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41662. * @param scene The scene which the session should be created for
  41663. */
  41664. constructor(scene: Scene);
  41665. /**
  41666. * Initializes the manager
  41667. * After initialization enterXR can be called to start an XR session
  41668. * @returns Promise which resolves after it is initialized
  41669. */
  41670. initializeAsync(): Promise<void>;
  41671. /**
  41672. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41673. * @param sessionCreationOptions xr options to create the session with
  41674. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41675. * @returns Promise which resolves after it enters XR
  41676. */
  41677. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41678. /**
  41679. * Stops the xrSession and restores the renderloop
  41680. * @returns Promise which resolves after it exits XR
  41681. */
  41682. exitXRAsync(): Promise<void>;
  41683. /**
  41684. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41685. * @param ray ray to cast into the environment
  41686. * @returns Promise which resolves with a collision point in the environment if it exists
  41687. */
  41688. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41689. /**
  41690. * Checks if a session would be supported for the creation options specified
  41691. * @param options creation options to check if they are supported
  41692. * @returns true if supported
  41693. */
  41694. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41695. /**
  41696. * @hidden
  41697. * Converts the render layer of xrSession to a render target
  41698. * @param session session to create render target for
  41699. * @param scene scene the new render target should be created for
  41700. */
  41701. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41702. /**
  41703. * Disposes of the session manager
  41704. */
  41705. dispose(): void;
  41706. }
  41707. }
  41708. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41709. import { Scene } from "babylonjs/scene";
  41710. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41711. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41712. /**
  41713. * WebXR Camera which holds the views for the xrSession
  41714. * @see https://doc.babylonjs.com/how_to/webxr
  41715. */
  41716. export class WebXRCamera extends FreeCamera {
  41717. private static _TmpMatrix;
  41718. /**
  41719. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41720. * @param name the name of the camera
  41721. * @param scene the scene to add the camera to
  41722. */
  41723. constructor(name: string, scene: Scene);
  41724. private _updateNumberOfRigCameras;
  41725. /** @hidden */
  41726. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41727. /**
  41728. * Updates the cameras position from the current pose information of the XR session
  41729. * @param xrSessionManager the session containing pose information
  41730. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41731. */
  41732. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41733. }
  41734. }
  41735. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41736. import { Nullable } from "babylonjs/types";
  41737. import { Observable } from "babylonjs/Misc/observable";
  41738. import { IDisposable, Scene } from "babylonjs/scene";
  41739. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41741. import { Ray } from "babylonjs/Culling/ray";
  41742. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41743. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41744. /**
  41745. * States of the webXR experience
  41746. */
  41747. export enum WebXRState {
  41748. /**
  41749. * Transitioning to being in XR mode
  41750. */
  41751. ENTERING_XR = 0,
  41752. /**
  41753. * Transitioning to non XR mode
  41754. */
  41755. EXITING_XR = 1,
  41756. /**
  41757. * In XR mode and presenting
  41758. */
  41759. IN_XR = 2,
  41760. /**
  41761. * Not entered XR mode
  41762. */
  41763. NOT_IN_XR = 3
  41764. }
  41765. /**
  41766. * Helper class used to enable XR
  41767. * @see https://doc.babylonjs.com/how_to/webxr
  41768. */
  41769. export class WebXRExperienceHelper implements IDisposable {
  41770. private scene;
  41771. /**
  41772. * 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
  41773. */
  41774. container: AbstractMesh;
  41775. /**
  41776. * Camera used to render xr content
  41777. */
  41778. camera: WebXRCamera;
  41779. /**
  41780. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41781. */
  41782. state: WebXRState;
  41783. private _setState;
  41784. private static _TmpVector;
  41785. /**
  41786. * Fires when the state of the experience helper has changed
  41787. */
  41788. onStateChangedObservable: Observable<WebXRState>;
  41789. /** @hidden */
  41790. _sessionManager: WebXRSessionManager;
  41791. private _nonVRCamera;
  41792. private _originalSceneAutoClear;
  41793. private _supported;
  41794. /**
  41795. * Creates the experience helper
  41796. * @param scene the scene to attach the experience helper to
  41797. * @returns a promise for the experience helper
  41798. */
  41799. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41800. /**
  41801. * Creates a WebXRExperienceHelper
  41802. * @param scene The scene the helper should be created in
  41803. */
  41804. private constructor();
  41805. /**
  41806. * Exits XR mode and returns the scene to its original state
  41807. * @returns promise that resolves after xr mode has exited
  41808. */
  41809. exitXRAsync(): Promise<void>;
  41810. /**
  41811. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41812. * @param sessionCreationOptions options for the XR session
  41813. * @param frameOfReference frame of reference of the XR session
  41814. * @returns promise that resolves after xr mode has entered
  41815. */
  41816. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41817. /**
  41818. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41819. * @param ray ray to cast into the environment
  41820. * @returns Promise which resolves with a collision point in the environment if it exists
  41821. */
  41822. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41823. /**
  41824. * Updates the global position of the camera by moving the camera's container
  41825. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41826. * @param position The desired global position of the camera
  41827. */
  41828. setPositionOfCameraUsingContainer(position: Vector3): void;
  41829. /**
  41830. * Rotates the xr camera by rotating the camera's container around the camera's position
  41831. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41832. * @param rotation the desired quaternion rotation to apply to the camera
  41833. */
  41834. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41835. /**
  41836. * Checks if the creation options are supported by the xr session
  41837. * @param options creation options
  41838. * @returns true if supported
  41839. */
  41840. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41841. /**
  41842. * Disposes of the experience helper
  41843. */
  41844. dispose(): void;
  41845. }
  41846. }
  41847. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41848. import { Nullable } from "babylonjs/types";
  41849. import { Observable } from "babylonjs/Misc/observable";
  41850. import { IDisposable, Scene } from "babylonjs/scene";
  41851. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41852. /**
  41853. * Button which can be used to enter a different mode of XR
  41854. */
  41855. export class WebXREnterExitUIButton {
  41856. /** button element */
  41857. element: HTMLElement;
  41858. /** XR initialization options for the button */
  41859. initializationOptions: XRSessionCreationOptions;
  41860. /**
  41861. * Creates a WebXREnterExitUIButton
  41862. * @param element button element
  41863. * @param initializationOptions XR initialization options for the button
  41864. */
  41865. constructor(
  41866. /** button element */
  41867. element: HTMLElement,
  41868. /** XR initialization options for the button */
  41869. initializationOptions: XRSessionCreationOptions);
  41870. /**
  41871. * Overwritable function which can be used to update the button's visuals when the state changes
  41872. * @param activeButton the current active button in the UI
  41873. */
  41874. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41875. }
  41876. /**
  41877. * Options to create the webXR UI
  41878. */
  41879. export class WebXREnterExitUIOptions {
  41880. /**
  41881. * Context to enter xr with
  41882. */
  41883. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41884. /**
  41885. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41886. */
  41887. customButtons?: Array<WebXREnterExitUIButton>;
  41888. }
  41889. /**
  41890. * UI to allow the user to enter/exit XR mode
  41891. */
  41892. export class WebXREnterExitUI implements IDisposable {
  41893. private scene;
  41894. private _overlay;
  41895. private _buttons;
  41896. private _activeButton;
  41897. /**
  41898. * Fired every time the active button is changed.
  41899. *
  41900. * When xr is entered via a button that launches xr that button will be the callback parameter
  41901. *
  41902. * When exiting xr the callback parameter will be null)
  41903. */
  41904. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41905. /**
  41906. * Creates UI to allow the user to enter/exit XR mode
  41907. * @param scene the scene to add the ui to
  41908. * @param helper the xr experience helper to enter/exit xr with
  41909. * @param options options to configure the UI
  41910. * @returns the created ui
  41911. */
  41912. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41913. private constructor();
  41914. private _updateButtons;
  41915. /**
  41916. * Disposes of the object
  41917. */
  41918. dispose(): void;
  41919. }
  41920. }
  41921. declare module "babylonjs/Cameras/XR/webXRInput" {
  41922. import { IDisposable, Scene } from "babylonjs/scene";
  41923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41924. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41925. /**
  41926. * Represents an XR input
  41927. */
  41928. export class WebXRController {
  41929. /**
  41930. * 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
  41931. */
  41932. grip?: AbstractMesh;
  41933. /**
  41934. * Pointer which can be used to select objects or attach a visible laser to
  41935. */
  41936. pointer: AbstractMesh;
  41937. /**
  41938. * Creates the controller
  41939. * @see https://doc.babylonjs.com/how_to/webxr
  41940. * @param scene the scene which the controller should be associated to
  41941. */
  41942. constructor(scene: Scene);
  41943. /**
  41944. * Disposes of the object
  41945. */
  41946. dispose(): void;
  41947. }
  41948. /**
  41949. * XR input used to track XR inputs such as controllers/rays
  41950. */
  41951. export class WebXRInput implements IDisposable {
  41952. private helper;
  41953. /**
  41954. * XR controllers being tracked
  41955. */
  41956. controllers: Array<WebXRController>;
  41957. private _tmpMatrix;
  41958. private _frameObserver;
  41959. /**
  41960. * Initializes the WebXRInput
  41961. * @param helper experience helper which the input should be created for
  41962. */
  41963. constructor(helper: WebXRExperienceHelper);
  41964. /**
  41965. * Disposes of the object
  41966. */
  41967. dispose(): void;
  41968. }
  41969. }
  41970. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41971. import { Nullable } from "babylonjs/types";
  41972. import { IDisposable } from "babylonjs/scene";
  41973. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41974. /**
  41975. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41976. */
  41977. export class WebXRManagedOutputCanvas implements IDisposable {
  41978. private _canvas;
  41979. /**
  41980. * xrpresent context of the canvas which can be used to display/mirror xr content
  41981. */
  41982. canvasContext: Nullable<WebGLRenderingContext>;
  41983. /**
  41984. * Initializes the canvas to be added/removed upon entering/exiting xr
  41985. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41986. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41987. */
  41988. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41989. /**
  41990. * Disposes of the object
  41991. */
  41992. dispose(): void;
  41993. private _setManagedOutputCanvas;
  41994. private _addCanvas;
  41995. private _removeCanvas;
  41996. }
  41997. }
  41998. declare module "babylonjs/Cameras/XR/index" {
  41999. export * from "babylonjs/Cameras/XR/webXRCamera";
  42000. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  42001. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42002. export * from "babylonjs/Cameras/XR/webXRInput";
  42003. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42004. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  42005. }
  42006. declare module "babylonjs/Cameras/RigModes/index" {
  42007. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42008. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42009. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  42010. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  42011. }
  42012. declare module "babylonjs/Cameras/index" {
  42013. export * from "babylonjs/Cameras/Inputs/index";
  42014. export * from "babylonjs/Cameras/cameraInputsManager";
  42015. export * from "babylonjs/Cameras/camera";
  42016. export * from "babylonjs/Cameras/targetCamera";
  42017. export * from "babylonjs/Cameras/freeCamera";
  42018. export * from "babylonjs/Cameras/freeCameraInputsManager";
  42019. export * from "babylonjs/Cameras/touchCamera";
  42020. export * from "babylonjs/Cameras/arcRotateCamera";
  42021. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  42022. export * from "babylonjs/Cameras/deviceOrientationCamera";
  42023. export * from "babylonjs/Cameras/flyCamera";
  42024. export * from "babylonjs/Cameras/flyCameraInputsManager";
  42025. export * from "babylonjs/Cameras/followCamera";
  42026. export * from "babylonjs/Cameras/gamepadCamera";
  42027. export * from "babylonjs/Cameras/Stereoscopic/index";
  42028. export * from "babylonjs/Cameras/universalCamera";
  42029. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  42030. export * from "babylonjs/Cameras/VR/index";
  42031. export * from "babylonjs/Cameras/XR/index";
  42032. export * from "babylonjs/Cameras/RigModes/index";
  42033. }
  42034. declare module "babylonjs/Collisions/index" {
  42035. export * from "babylonjs/Collisions/collider";
  42036. export * from "babylonjs/Collisions/collisionCoordinator";
  42037. export * from "babylonjs/Collisions/pickingInfo";
  42038. export * from "babylonjs/Collisions/intersectionInfo";
  42039. export * from "babylonjs/Collisions/meshCollisionData";
  42040. }
  42041. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  42042. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  42043. import { Vector3, Plane } from "babylonjs/Maths/math";
  42044. import { Ray } from "babylonjs/Culling/ray";
  42045. /**
  42046. * Contains an array of blocks representing the octree
  42047. */
  42048. export interface IOctreeContainer<T> {
  42049. /**
  42050. * Blocks within the octree
  42051. */
  42052. blocks: Array<OctreeBlock<T>>;
  42053. }
  42054. /**
  42055. * Class used to store a cell in an octree
  42056. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42057. */
  42058. export class OctreeBlock<T> {
  42059. /**
  42060. * Gets the content of the current block
  42061. */
  42062. entries: T[];
  42063. /**
  42064. * Gets the list of block children
  42065. */
  42066. blocks: Array<OctreeBlock<T>>;
  42067. private _depth;
  42068. private _maxDepth;
  42069. private _capacity;
  42070. private _minPoint;
  42071. private _maxPoint;
  42072. private _boundingVectors;
  42073. private _creationFunc;
  42074. /**
  42075. * Creates a new block
  42076. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42077. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42078. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42079. * @param depth defines the current depth of this block in the octree
  42080. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42081. * @param creationFunc defines a callback to call when an element is added to the block
  42082. */
  42083. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42084. /**
  42085. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42086. */
  42087. readonly capacity: number;
  42088. /**
  42089. * Gets the minimum vector (in world space) of the block's bounding box
  42090. */
  42091. readonly minPoint: Vector3;
  42092. /**
  42093. * Gets the maximum vector (in world space) of the block's bounding box
  42094. */
  42095. readonly maxPoint: Vector3;
  42096. /**
  42097. * Add a new element to this block
  42098. * @param entry defines the element to add
  42099. */
  42100. addEntry(entry: T): void;
  42101. /**
  42102. * Remove an element from this block
  42103. * @param entry defines the element to remove
  42104. */
  42105. removeEntry(entry: T): void;
  42106. /**
  42107. * Add an array of elements to this block
  42108. * @param entries defines the array of elements to add
  42109. */
  42110. addEntries(entries: T[]): void;
  42111. /**
  42112. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42113. * @param frustumPlanes defines the frustum planes to test
  42114. * @param selection defines the array to store current content if selection is positive
  42115. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42116. */
  42117. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42118. /**
  42119. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42120. * @param sphereCenter defines the bounding sphere center
  42121. * @param sphereRadius defines the bounding sphere radius
  42122. * @param selection defines the array to store current content if selection is positive
  42123. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42124. */
  42125. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42126. /**
  42127. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42128. * @param ray defines the ray to test with
  42129. * @param selection defines the array to store current content if selection is positive
  42130. */
  42131. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42132. /**
  42133. * Subdivide the content into child blocks (this block will then be empty)
  42134. */
  42135. createInnerBlocks(): void;
  42136. /**
  42137. * @hidden
  42138. */
  42139. 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;
  42140. }
  42141. }
  42142. declare module "babylonjs/Culling/Octrees/octree" {
  42143. import { SmartArray } from "babylonjs/Misc/smartArray";
  42144. import { Vector3, Plane } from "babylonjs/Maths/math";
  42145. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42147. import { Ray } from "babylonjs/Culling/ray";
  42148. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  42149. /**
  42150. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42151. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42152. */
  42153. export class Octree<T> {
  42154. /** 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.) */
  42155. maxDepth: number;
  42156. /**
  42157. * Blocks within the octree containing objects
  42158. */
  42159. blocks: Array<OctreeBlock<T>>;
  42160. /**
  42161. * Content stored in the octree
  42162. */
  42163. dynamicContent: T[];
  42164. private _maxBlockCapacity;
  42165. private _selectionContent;
  42166. private _creationFunc;
  42167. /**
  42168. * Creates a octree
  42169. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42170. * @param creationFunc function to be used to instatiate the octree
  42171. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42172. * @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.)
  42173. */
  42174. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42175. /** 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.) */
  42176. maxDepth?: number);
  42177. /**
  42178. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42179. * @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);
  42180. * @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);
  42181. * @param entries meshes to be added to the octree blocks
  42182. */
  42183. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42184. /**
  42185. * Adds a mesh to the octree
  42186. * @param entry Mesh to add to the octree
  42187. */
  42188. addMesh(entry: T): void;
  42189. /**
  42190. * Remove an element from the octree
  42191. * @param entry defines the element to remove
  42192. */
  42193. removeMesh(entry: T): void;
  42194. /**
  42195. * Selects an array of meshes within the frustum
  42196. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42197. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42198. * @returns array of meshes within the frustum
  42199. */
  42200. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42201. /**
  42202. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42203. * @param sphereCenter defines the bounding sphere center
  42204. * @param sphereRadius defines the bounding sphere radius
  42205. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42206. * @returns an array of objects that intersect the sphere
  42207. */
  42208. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42209. /**
  42210. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42211. * @param ray defines the ray to test with
  42212. * @returns array of intersected objects
  42213. */
  42214. intersectsRay(ray: Ray): SmartArray<T>;
  42215. /**
  42216. * Adds a mesh into the octree block if it intersects the block
  42217. */
  42218. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42219. /**
  42220. * Adds a submesh into the octree block if it intersects the block
  42221. */
  42222. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42223. }
  42224. }
  42225. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  42226. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  42227. import { Scene } from "babylonjs/scene";
  42228. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42230. import { Ray } from "babylonjs/Culling/ray";
  42231. import { Octree } from "babylonjs/Culling/Octrees/octree";
  42232. import { Collider } from "babylonjs/Collisions/collider";
  42233. module "babylonjs/scene" {
  42234. interface Scene {
  42235. /**
  42236. * @hidden
  42237. * Backing Filed
  42238. */
  42239. _selectionOctree: Octree<AbstractMesh>;
  42240. /**
  42241. * Gets the octree used to boost mesh selection (picking)
  42242. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42243. */
  42244. selectionOctree: Octree<AbstractMesh>;
  42245. /**
  42246. * Creates or updates the octree used to boost selection (picking)
  42247. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42248. * @param maxCapacity defines the maximum capacity per leaf
  42249. * @param maxDepth defines the maximum depth of the octree
  42250. * @returns an octree of AbstractMesh
  42251. */
  42252. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42253. }
  42254. }
  42255. module "babylonjs/Meshes/abstractMesh" {
  42256. interface AbstractMesh {
  42257. /**
  42258. * @hidden
  42259. * Backing Field
  42260. */
  42261. _submeshesOctree: Octree<SubMesh>;
  42262. /**
  42263. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42264. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42265. * @param maxCapacity defines the maximum size of each block (64 by default)
  42266. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42267. * @returns the new octree
  42268. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42269. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42270. */
  42271. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42272. }
  42273. }
  42274. /**
  42275. * Defines the octree scene component responsible to manage any octrees
  42276. * in a given scene.
  42277. */
  42278. export class OctreeSceneComponent {
  42279. /**
  42280. * The component name help to identify the component in the list of scene components.
  42281. */
  42282. readonly name: string;
  42283. /**
  42284. * The scene the component belongs to.
  42285. */
  42286. scene: Scene;
  42287. /**
  42288. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42289. */
  42290. readonly checksIsEnabled: boolean;
  42291. /**
  42292. * Creates a new instance of the component for the given scene
  42293. * @param scene Defines the scene to register the component in
  42294. */
  42295. constructor(scene: Scene);
  42296. /**
  42297. * Registers the component in a given scene
  42298. */
  42299. register(): void;
  42300. /**
  42301. * Return the list of active meshes
  42302. * @returns the list of active meshes
  42303. */
  42304. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42305. /**
  42306. * Return the list of active sub meshes
  42307. * @param mesh The mesh to get the candidates sub meshes from
  42308. * @returns the list of active sub meshes
  42309. */
  42310. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42311. private _tempRay;
  42312. /**
  42313. * Return the list of sub meshes intersecting with a given local ray
  42314. * @param mesh defines the mesh to find the submesh for
  42315. * @param localRay defines the ray in local space
  42316. * @returns the list of intersecting sub meshes
  42317. */
  42318. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42319. /**
  42320. * Return the list of sub meshes colliding with a collider
  42321. * @param mesh defines the mesh to find the submesh for
  42322. * @param collider defines the collider to evaluate the collision against
  42323. * @returns the list of colliding sub meshes
  42324. */
  42325. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42326. /**
  42327. * Rebuilds the elements related to this component in case of
  42328. * context lost for instance.
  42329. */
  42330. rebuild(): void;
  42331. /**
  42332. * Disposes the component and the associated ressources.
  42333. */
  42334. dispose(): void;
  42335. }
  42336. }
  42337. declare module "babylonjs/Culling/Octrees/index" {
  42338. export * from "babylonjs/Culling/Octrees/octree";
  42339. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42340. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42341. }
  42342. declare module "babylonjs/Culling/index" {
  42343. export * from "babylonjs/Culling/boundingBox";
  42344. export * from "babylonjs/Culling/boundingInfo";
  42345. export * from "babylonjs/Culling/boundingSphere";
  42346. export * from "babylonjs/Culling/Octrees/index";
  42347. export * from "babylonjs/Culling/ray";
  42348. }
  42349. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42350. import { IDisposable, Scene } from "babylonjs/scene";
  42351. import { Nullable } from "babylonjs/types";
  42352. import { Observable } from "babylonjs/Misc/observable";
  42353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42354. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42355. import { Camera } from "babylonjs/Cameras/camera";
  42356. /**
  42357. * Renders a layer on top of an existing scene
  42358. */
  42359. export class UtilityLayerRenderer implements IDisposable {
  42360. /** the original scene that will be rendered on top of */
  42361. originalScene: Scene;
  42362. private _pointerCaptures;
  42363. private _lastPointerEvents;
  42364. private static _DefaultUtilityLayer;
  42365. private static _DefaultKeepDepthUtilityLayer;
  42366. private _sharedGizmoLight;
  42367. private _renderCamera;
  42368. /**
  42369. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42370. * @returns the camera that is used when rendering the utility layer
  42371. */
  42372. getRenderCamera(): Nullable<Camera>;
  42373. /**
  42374. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42375. * @param cam the camera that should be used when rendering the utility layer
  42376. */
  42377. setRenderCamera(cam: Nullable<Camera>): void;
  42378. /**
  42379. * @hidden
  42380. * Light which used by gizmos to get light shading
  42381. */
  42382. _getSharedGizmoLight(): HemisphericLight;
  42383. /**
  42384. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42385. */
  42386. pickUtilitySceneFirst: boolean;
  42387. /**
  42388. * 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)
  42389. */
  42390. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42391. /**
  42392. * 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)
  42393. */
  42394. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42395. /**
  42396. * The scene that is rendered on top of the original scene
  42397. */
  42398. utilityLayerScene: Scene;
  42399. /**
  42400. * If the utility layer should automatically be rendered on top of existing scene
  42401. */
  42402. shouldRender: boolean;
  42403. /**
  42404. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42405. */
  42406. onlyCheckPointerDownEvents: boolean;
  42407. /**
  42408. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42409. */
  42410. processAllEvents: boolean;
  42411. /**
  42412. * Observable raised when the pointer move from the utility layer scene to the main scene
  42413. */
  42414. onPointerOutObservable: Observable<number>;
  42415. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42416. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42417. private _afterRenderObserver;
  42418. private _sceneDisposeObserver;
  42419. private _originalPointerObserver;
  42420. /**
  42421. * Instantiates a UtilityLayerRenderer
  42422. * @param originalScene the original scene that will be rendered on top of
  42423. * @param handleEvents boolean indicating if the utility layer should handle events
  42424. */
  42425. constructor(
  42426. /** the original scene that will be rendered on top of */
  42427. originalScene: Scene, handleEvents?: boolean);
  42428. private _notifyObservers;
  42429. /**
  42430. * Renders the utility layers scene on top of the original scene
  42431. */
  42432. render(): void;
  42433. /**
  42434. * Disposes of the renderer
  42435. */
  42436. dispose(): void;
  42437. private _updateCamera;
  42438. }
  42439. }
  42440. declare module "babylonjs/Gizmos/gizmo" {
  42441. import { Nullable } from "babylonjs/types";
  42442. import { IDisposable } from "babylonjs/scene";
  42443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42444. import { Mesh } from "babylonjs/Meshes/mesh";
  42445. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42446. /**
  42447. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42448. */
  42449. export class Gizmo implements IDisposable {
  42450. /** The utility layer the gizmo will be added to */
  42451. gizmoLayer: UtilityLayerRenderer;
  42452. /**
  42453. * The root mesh of the gizmo
  42454. */
  42455. _rootMesh: Mesh;
  42456. private _attachedMesh;
  42457. /**
  42458. * Ratio for the scale of the gizmo (Default: 1)
  42459. */
  42460. scaleRatio: number;
  42461. /**
  42462. * If a custom mesh has been set (Default: false)
  42463. */
  42464. protected _customMeshSet: boolean;
  42465. /**
  42466. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42467. * * When set, interactions will be enabled
  42468. */
  42469. attachedMesh: Nullable<AbstractMesh>;
  42470. /**
  42471. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42472. * @param mesh The mesh to replace the default mesh of the gizmo
  42473. */
  42474. setCustomMesh(mesh: Mesh): void;
  42475. /**
  42476. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42477. */
  42478. updateGizmoRotationToMatchAttachedMesh: boolean;
  42479. /**
  42480. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42481. */
  42482. updateGizmoPositionToMatchAttachedMesh: boolean;
  42483. /**
  42484. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42485. */
  42486. protected _updateScale: boolean;
  42487. protected _interactionsEnabled: boolean;
  42488. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42489. private _beforeRenderObserver;
  42490. private _tempVector;
  42491. /**
  42492. * Creates a gizmo
  42493. * @param gizmoLayer The utility layer the gizmo will be added to
  42494. */
  42495. constructor(
  42496. /** The utility layer the gizmo will be added to */
  42497. gizmoLayer?: UtilityLayerRenderer);
  42498. /**
  42499. * Updates the gizmo to match the attached mesh's position/rotation
  42500. */
  42501. protected _update(): void;
  42502. /**
  42503. * Disposes of the gizmo
  42504. */
  42505. dispose(): void;
  42506. }
  42507. }
  42508. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42509. import { Observable } from "babylonjs/Misc/observable";
  42510. import { Nullable } from "babylonjs/types";
  42511. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42512. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42514. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42515. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42516. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42517. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42518. import { Scene } from "babylonjs/scene";
  42519. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42520. /**
  42521. * Single plane drag gizmo
  42522. */
  42523. export class PlaneDragGizmo extends Gizmo {
  42524. /**
  42525. * Drag behavior responsible for the gizmos dragging interactions
  42526. */
  42527. dragBehavior: PointerDragBehavior;
  42528. private _pointerObserver;
  42529. /**
  42530. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42531. */
  42532. snapDistance: number;
  42533. /**
  42534. * Event that fires each time the gizmo snaps to a new location.
  42535. * * snapDistance is the the change in distance
  42536. */
  42537. onSnapObservable: Observable<{
  42538. snapDistance: number;
  42539. }>;
  42540. private _plane;
  42541. private _coloredMaterial;
  42542. private _hoverMaterial;
  42543. private _isEnabled;
  42544. private _parent;
  42545. /** @hidden */
  42546. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42547. /** @hidden */
  42548. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42549. /**
  42550. * Creates a PlaneDragGizmo
  42551. * @param gizmoLayer The utility layer the gizmo will be added to
  42552. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42553. * @param color The color of the gizmo
  42554. */
  42555. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42556. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42557. /**
  42558. * If the gizmo is enabled
  42559. */
  42560. isEnabled: boolean;
  42561. /**
  42562. * Disposes of the gizmo
  42563. */
  42564. dispose(): void;
  42565. }
  42566. }
  42567. declare module "babylonjs/Gizmos/positionGizmo" {
  42568. import { Observable } from "babylonjs/Misc/observable";
  42569. import { Nullable } from "babylonjs/types";
  42570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42571. import { Mesh } from "babylonjs/Meshes/mesh";
  42572. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42573. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42574. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42575. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42576. /**
  42577. * Gizmo that enables dragging a mesh along 3 axis
  42578. */
  42579. export class PositionGizmo extends Gizmo {
  42580. /**
  42581. * Internal gizmo used for interactions on the x axis
  42582. */
  42583. xGizmo: AxisDragGizmo;
  42584. /**
  42585. * Internal gizmo used for interactions on the y axis
  42586. */
  42587. yGizmo: AxisDragGizmo;
  42588. /**
  42589. * Internal gizmo used for interactions on the z axis
  42590. */
  42591. zGizmo: AxisDragGizmo;
  42592. /**
  42593. * Internal gizmo used for interactions on the yz plane
  42594. */
  42595. xPlaneGizmo: PlaneDragGizmo;
  42596. /**
  42597. * Internal gizmo used for interactions on the xz plane
  42598. */
  42599. yPlaneGizmo: PlaneDragGizmo;
  42600. /**
  42601. * Internal gizmo used for interactions on the xy plane
  42602. */
  42603. zPlaneGizmo: PlaneDragGizmo;
  42604. /**
  42605. * private variables
  42606. */
  42607. private _meshAttached;
  42608. private _updateGizmoRotationToMatchAttachedMesh;
  42609. private _snapDistance;
  42610. private _scaleRatio;
  42611. /** Fires an event when any of it's sub gizmos are dragged */
  42612. onDragStartObservable: Observable<unknown>;
  42613. /** Fires an event when any of it's sub gizmos are released from dragging */
  42614. onDragEndObservable: Observable<unknown>;
  42615. /**
  42616. * If set to true, planar drag is enabled
  42617. */
  42618. private _planarGizmoEnabled;
  42619. attachedMesh: Nullable<AbstractMesh>;
  42620. /**
  42621. * Creates a PositionGizmo
  42622. * @param gizmoLayer The utility layer the gizmo will be added to
  42623. */
  42624. constructor(gizmoLayer?: UtilityLayerRenderer);
  42625. /**
  42626. * If the planar drag gizmo is enabled
  42627. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42628. */
  42629. planarGizmoEnabled: boolean;
  42630. updateGizmoRotationToMatchAttachedMesh: boolean;
  42631. /**
  42632. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42633. */
  42634. snapDistance: number;
  42635. /**
  42636. * Ratio for the scale of the gizmo (Default: 1)
  42637. */
  42638. scaleRatio: number;
  42639. /**
  42640. * Disposes of the gizmo
  42641. */
  42642. dispose(): void;
  42643. /**
  42644. * CustomMeshes are not supported by this gizmo
  42645. * @param mesh The mesh to replace the default mesh of the gizmo
  42646. */
  42647. setCustomMesh(mesh: Mesh): void;
  42648. }
  42649. }
  42650. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42651. import { Observable } from "babylonjs/Misc/observable";
  42652. import { Nullable } from "babylonjs/types";
  42653. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42654. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42656. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42657. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42658. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42659. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42660. import { Scene } from "babylonjs/scene";
  42661. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42662. /**
  42663. * Single axis drag gizmo
  42664. */
  42665. export class AxisDragGizmo extends Gizmo {
  42666. /**
  42667. * Drag behavior responsible for the gizmos dragging interactions
  42668. */
  42669. dragBehavior: PointerDragBehavior;
  42670. private _pointerObserver;
  42671. /**
  42672. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42673. */
  42674. snapDistance: number;
  42675. /**
  42676. * Event that fires each time the gizmo snaps to a new location.
  42677. * * snapDistance is the the change in distance
  42678. */
  42679. onSnapObservable: Observable<{
  42680. snapDistance: number;
  42681. }>;
  42682. private _isEnabled;
  42683. private _parent;
  42684. private _arrow;
  42685. private _coloredMaterial;
  42686. private _hoverMaterial;
  42687. /** @hidden */
  42688. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42689. /** @hidden */
  42690. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42691. /**
  42692. * Creates an AxisDragGizmo
  42693. * @param gizmoLayer The utility layer the gizmo will be added to
  42694. * @param dragAxis The axis which the gizmo will be able to drag on
  42695. * @param color The color of the gizmo
  42696. */
  42697. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42698. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42699. /**
  42700. * If the gizmo is enabled
  42701. */
  42702. isEnabled: boolean;
  42703. /**
  42704. * Disposes of the gizmo
  42705. */
  42706. dispose(): void;
  42707. }
  42708. }
  42709. declare module "babylonjs/Debug/axesViewer" {
  42710. import { Vector3 } from "babylonjs/Maths/math";
  42711. import { Nullable } from "babylonjs/types";
  42712. import { Scene } from "babylonjs/scene";
  42713. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42714. /**
  42715. * The Axes viewer will show 3 axes in a specific point in space
  42716. */
  42717. export class AxesViewer {
  42718. private _xAxis;
  42719. private _yAxis;
  42720. private _zAxis;
  42721. private _scaleLinesFactor;
  42722. private _instanced;
  42723. /**
  42724. * Gets the hosting scene
  42725. */
  42726. scene: Scene;
  42727. /**
  42728. * Gets or sets a number used to scale line length
  42729. */
  42730. scaleLines: number;
  42731. /** Gets the node hierarchy used to render x-axis */
  42732. readonly xAxis: TransformNode;
  42733. /** Gets the node hierarchy used to render y-axis */
  42734. readonly yAxis: TransformNode;
  42735. /** Gets the node hierarchy used to render z-axis */
  42736. readonly zAxis: TransformNode;
  42737. /**
  42738. * Creates a new AxesViewer
  42739. * @param scene defines the hosting scene
  42740. * @param scaleLines defines a number used to scale line length (1 by default)
  42741. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42742. * @param xAxis defines the node hierarchy used to render the x-axis
  42743. * @param yAxis defines the node hierarchy used to render the y-axis
  42744. * @param zAxis defines the node hierarchy used to render the z-axis
  42745. */
  42746. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42747. /**
  42748. * Force the viewer to update
  42749. * @param position defines the position of the viewer
  42750. * @param xaxis defines the x axis of the viewer
  42751. * @param yaxis defines the y axis of the viewer
  42752. * @param zaxis defines the z axis of the viewer
  42753. */
  42754. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42755. /**
  42756. * Creates an instance of this axes viewer.
  42757. * @returns a new axes viewer with instanced meshes
  42758. */
  42759. createInstance(): AxesViewer;
  42760. /** Releases resources */
  42761. dispose(): void;
  42762. private static _SetRenderingGroupId;
  42763. }
  42764. }
  42765. declare module "babylonjs/Debug/boneAxesViewer" {
  42766. import { Nullable } from "babylonjs/types";
  42767. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42768. import { Vector3 } from "babylonjs/Maths/math";
  42769. import { Mesh } from "babylonjs/Meshes/mesh";
  42770. import { Bone } from "babylonjs/Bones/bone";
  42771. import { Scene } from "babylonjs/scene";
  42772. /**
  42773. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42774. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42775. */
  42776. export class BoneAxesViewer extends AxesViewer {
  42777. /**
  42778. * Gets or sets the target mesh where to display the axes viewer
  42779. */
  42780. mesh: Nullable<Mesh>;
  42781. /**
  42782. * Gets or sets the target bone where to display the axes viewer
  42783. */
  42784. bone: Nullable<Bone>;
  42785. /** Gets current position */
  42786. pos: Vector3;
  42787. /** Gets direction of X axis */
  42788. xaxis: Vector3;
  42789. /** Gets direction of Y axis */
  42790. yaxis: Vector3;
  42791. /** Gets direction of Z axis */
  42792. zaxis: Vector3;
  42793. /**
  42794. * Creates a new BoneAxesViewer
  42795. * @param scene defines the hosting scene
  42796. * @param bone defines the target bone
  42797. * @param mesh defines the target mesh
  42798. * @param scaleLines defines a scaling factor for line length (1 by default)
  42799. */
  42800. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42801. /**
  42802. * Force the viewer to update
  42803. */
  42804. update(): void;
  42805. /** Releases resources */
  42806. dispose(): void;
  42807. }
  42808. }
  42809. declare module "babylonjs/Debug/debugLayer" {
  42810. import { Observable } from "babylonjs/Misc/observable";
  42811. import { Scene } from "babylonjs/scene";
  42812. /**
  42813. * Interface used to define scene explorer extensibility option
  42814. */
  42815. export interface IExplorerExtensibilityOption {
  42816. /**
  42817. * Define the option label
  42818. */
  42819. label: string;
  42820. /**
  42821. * Defines the action to execute on click
  42822. */
  42823. action: (entity: any) => void;
  42824. }
  42825. /**
  42826. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42827. */
  42828. export interface IExplorerExtensibilityGroup {
  42829. /**
  42830. * Defines a predicate to test if a given type mut be extended
  42831. */
  42832. predicate: (entity: any) => boolean;
  42833. /**
  42834. * Gets the list of options added to a type
  42835. */
  42836. entries: IExplorerExtensibilityOption[];
  42837. }
  42838. /**
  42839. * Interface used to define the options to use to create the Inspector
  42840. */
  42841. export interface IInspectorOptions {
  42842. /**
  42843. * Display in overlay mode (default: false)
  42844. */
  42845. overlay?: boolean;
  42846. /**
  42847. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42848. */
  42849. globalRoot?: HTMLElement;
  42850. /**
  42851. * Display the Scene explorer
  42852. */
  42853. showExplorer?: boolean;
  42854. /**
  42855. * Display the property inspector
  42856. */
  42857. showInspector?: boolean;
  42858. /**
  42859. * Display in embed mode (both panes on the right)
  42860. */
  42861. embedMode?: boolean;
  42862. /**
  42863. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42864. */
  42865. handleResize?: boolean;
  42866. /**
  42867. * Allow the panes to popup (default: true)
  42868. */
  42869. enablePopup?: boolean;
  42870. /**
  42871. * Allow the panes to be closed by users (default: true)
  42872. */
  42873. enableClose?: boolean;
  42874. /**
  42875. * Optional list of extensibility entries
  42876. */
  42877. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42878. /**
  42879. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42880. */
  42881. inspectorURL?: string;
  42882. }
  42883. module "babylonjs/scene" {
  42884. interface Scene {
  42885. /**
  42886. * @hidden
  42887. * Backing field
  42888. */
  42889. _debugLayer: DebugLayer;
  42890. /**
  42891. * Gets the debug layer (aka Inspector) associated with the scene
  42892. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42893. */
  42894. debugLayer: DebugLayer;
  42895. }
  42896. }
  42897. /**
  42898. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42899. * what is happening in your scene
  42900. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42901. */
  42902. export class DebugLayer {
  42903. /**
  42904. * Define the url to get the inspector script from.
  42905. * By default it uses the babylonjs CDN.
  42906. * @ignoreNaming
  42907. */
  42908. static InspectorURL: string;
  42909. private _scene;
  42910. private BJSINSPECTOR;
  42911. /**
  42912. * Observable triggered when a property is changed through the inspector.
  42913. */
  42914. onPropertyChangedObservable: Observable<{
  42915. object: any;
  42916. property: string;
  42917. value: any;
  42918. initialValue: any;
  42919. }>;
  42920. /**
  42921. * Instantiates a new debug layer.
  42922. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42923. * what is happening in your scene
  42924. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42925. * @param scene Defines the scene to inspect
  42926. */
  42927. constructor(scene: Scene);
  42928. /** Creates the inspector window. */
  42929. private _createInspector;
  42930. /**
  42931. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42932. * @param entity defines the entity to select
  42933. * @param lineContainerTitle defines the specific block to highlight
  42934. */
  42935. select(entity: any, lineContainerTitle?: string): void;
  42936. /** Get the inspector from bundle or global */
  42937. private _getGlobalInspector;
  42938. /**
  42939. * Get if the inspector is visible or not.
  42940. * @returns true if visible otherwise, false
  42941. */
  42942. isVisible(): boolean;
  42943. /**
  42944. * Hide the inspector and close its window.
  42945. */
  42946. hide(): void;
  42947. /**
  42948. * Launch the debugLayer.
  42949. * @param config Define the configuration of the inspector
  42950. * @return a promise fulfilled when the debug layer is visible
  42951. */
  42952. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42953. }
  42954. }
  42955. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42956. import { Nullable } from "babylonjs/types";
  42957. import { Scene } from "babylonjs/scene";
  42958. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42959. import { Mesh } from "babylonjs/Meshes/mesh";
  42960. /**
  42961. * Class containing static functions to help procedurally build meshes
  42962. */
  42963. export class BoxBuilder {
  42964. /**
  42965. * Creates a box mesh
  42966. * * The parameter `size` sets the size (float) of each box side (default 1)
  42967. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42968. * * 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)
  42969. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42973. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42974. * @param name defines the name of the mesh
  42975. * @param options defines the options used to create the mesh
  42976. * @param scene defines the hosting scene
  42977. * @returns the box mesh
  42978. */
  42979. static CreateBox(name: string, options: {
  42980. size?: number;
  42981. width?: number;
  42982. height?: number;
  42983. depth?: number;
  42984. faceUV?: Vector4[];
  42985. faceColors?: Color4[];
  42986. sideOrientation?: number;
  42987. frontUVs?: Vector4;
  42988. backUVs?: Vector4;
  42989. wrap?: boolean;
  42990. topBaseAt?: number;
  42991. bottomBaseAt?: number;
  42992. updatable?: boolean;
  42993. }, scene?: Nullable<Scene>): Mesh;
  42994. }
  42995. }
  42996. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42997. import { Vector4 } from "babylonjs/Maths/math";
  42998. import { Mesh } from "babylonjs/Meshes/mesh";
  42999. /**
  43000. * Class containing static functions to help procedurally build meshes
  43001. */
  43002. export class SphereBuilder {
  43003. /**
  43004. * Creates a sphere mesh
  43005. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43006. * * 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`)
  43007. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43008. * * 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
  43009. * * 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)
  43010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43013. * @param name defines the name of the mesh
  43014. * @param options defines the options used to create the mesh
  43015. * @param scene defines the hosting scene
  43016. * @returns the sphere mesh
  43017. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43018. */
  43019. static CreateSphere(name: string, options: {
  43020. segments?: number;
  43021. diameter?: number;
  43022. diameterX?: number;
  43023. diameterY?: number;
  43024. diameterZ?: number;
  43025. arc?: number;
  43026. slice?: number;
  43027. sideOrientation?: number;
  43028. frontUVs?: Vector4;
  43029. backUVs?: Vector4;
  43030. updatable?: boolean;
  43031. }, scene: any): Mesh;
  43032. }
  43033. }
  43034. declare module "babylonjs/Debug/physicsViewer" {
  43035. import { Nullable } from "babylonjs/types";
  43036. import { Scene } from "babylonjs/scene";
  43037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43038. import { Mesh } from "babylonjs/Meshes/mesh";
  43039. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  43040. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  43041. /**
  43042. * Used to show the physics impostor around the specific mesh
  43043. */
  43044. export class PhysicsViewer {
  43045. /** @hidden */
  43046. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43047. /** @hidden */
  43048. protected _meshes: Array<Nullable<AbstractMesh>>;
  43049. /** @hidden */
  43050. protected _scene: Nullable<Scene>;
  43051. /** @hidden */
  43052. protected _numMeshes: number;
  43053. /** @hidden */
  43054. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43055. private _renderFunction;
  43056. private _utilityLayer;
  43057. private _debugBoxMesh;
  43058. private _debugSphereMesh;
  43059. private _debugCylinderMesh;
  43060. private _debugMaterial;
  43061. private _debugMeshMeshes;
  43062. /**
  43063. * Creates a new PhysicsViewer
  43064. * @param scene defines the hosting scene
  43065. */
  43066. constructor(scene: Scene);
  43067. /** @hidden */
  43068. protected _updateDebugMeshes(): void;
  43069. /**
  43070. * Renders a specified physic impostor
  43071. * @param impostor defines the impostor to render
  43072. * @param targetMesh defines the mesh represented by the impostor
  43073. * @returns the new debug mesh used to render the impostor
  43074. */
  43075. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43076. /**
  43077. * Hides a specified physic impostor
  43078. * @param impostor defines the impostor to hide
  43079. */
  43080. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43081. private _getDebugMaterial;
  43082. private _getDebugBoxMesh;
  43083. private _getDebugSphereMesh;
  43084. private _getDebugCylinderMesh;
  43085. private _getDebugMeshMesh;
  43086. private _getDebugMesh;
  43087. /** Releases all resources */
  43088. dispose(): void;
  43089. }
  43090. }
  43091. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  43092. import { Vector3, Color4 } from "babylonjs/Maths/math";
  43093. import { Nullable } from "babylonjs/types";
  43094. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43095. import { Scene } from "babylonjs/scene";
  43096. /**
  43097. * Class containing static functions to help procedurally build meshes
  43098. */
  43099. export class LinesBuilder {
  43100. /**
  43101. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43102. * * 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
  43103. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43104. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43105. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43106. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43107. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43108. * * 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
  43109. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43111. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43112. * @param name defines the name of the new line system
  43113. * @param options defines the options used to create the line system
  43114. * @param scene defines the hosting scene
  43115. * @returns a new line system mesh
  43116. */
  43117. static CreateLineSystem(name: string, options: {
  43118. lines: Vector3[][];
  43119. updatable?: boolean;
  43120. instance?: Nullable<LinesMesh>;
  43121. colors?: Nullable<Color4[][]>;
  43122. useVertexAlpha?: boolean;
  43123. }, scene: Nullable<Scene>): LinesMesh;
  43124. /**
  43125. * Creates a line mesh
  43126. * 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
  43127. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43128. * * The parameter `points` is an array successive Vector3
  43129. * * 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
  43130. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43131. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43132. * * When updating an instance, remember that only point positions can change, not the number of points
  43133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43134. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43135. * @param name defines the name of the new line system
  43136. * @param options defines the options used to create the line system
  43137. * @param scene defines the hosting scene
  43138. * @returns a new line mesh
  43139. */
  43140. static CreateLines(name: string, options: {
  43141. points: Vector3[];
  43142. updatable?: boolean;
  43143. instance?: Nullable<LinesMesh>;
  43144. colors?: Color4[];
  43145. useVertexAlpha?: boolean;
  43146. }, scene?: Nullable<Scene>): LinesMesh;
  43147. /**
  43148. * Creates a dashed line mesh
  43149. * * 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
  43150. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43151. * * The parameter `points` is an array successive Vector3
  43152. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43153. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43154. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43155. * * 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
  43156. * * When updating an instance, remember that only point positions can change, not the number of points
  43157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43158. * @param name defines the name of the mesh
  43159. * @param options defines the options used to create the mesh
  43160. * @param scene defines the hosting scene
  43161. * @returns the dashed line mesh
  43162. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43163. */
  43164. static CreateDashedLines(name: string, options: {
  43165. points: Vector3[];
  43166. dashSize?: number;
  43167. gapSize?: number;
  43168. dashNb?: number;
  43169. updatable?: boolean;
  43170. instance?: LinesMesh;
  43171. }, scene?: Nullable<Scene>): LinesMesh;
  43172. }
  43173. }
  43174. declare module "babylonjs/Debug/rayHelper" {
  43175. import { Nullable } from "babylonjs/types";
  43176. import { Ray } from "babylonjs/Culling/ray";
  43177. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43178. import { Scene } from "babylonjs/scene";
  43179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43180. import "babylonjs/Meshes/Builders/linesBuilder";
  43181. /**
  43182. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43183. * in order to better appreciate the issue one might have.
  43184. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43185. */
  43186. export class RayHelper {
  43187. /**
  43188. * Defines the ray we are currently tryin to visualize.
  43189. */
  43190. ray: Nullable<Ray>;
  43191. private _renderPoints;
  43192. private _renderLine;
  43193. private _renderFunction;
  43194. private _scene;
  43195. private _updateToMeshFunction;
  43196. private _attachedToMesh;
  43197. private _meshSpaceDirection;
  43198. private _meshSpaceOrigin;
  43199. /**
  43200. * Helper function to create a colored helper in a scene in one line.
  43201. * @param ray Defines the ray we are currently tryin to visualize
  43202. * @param scene Defines the scene the ray is used in
  43203. * @param color Defines the color we want to see the ray in
  43204. * @returns The newly created ray helper.
  43205. */
  43206. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43207. /**
  43208. * Instantiate a new ray helper.
  43209. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43210. * in order to better appreciate the issue one might have.
  43211. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43212. * @param ray Defines the ray we are currently tryin to visualize
  43213. */
  43214. constructor(ray: Ray);
  43215. /**
  43216. * Shows the ray we are willing to debug.
  43217. * @param scene Defines the scene the ray needs to be rendered in
  43218. * @param color Defines the color the ray needs to be rendered in
  43219. */
  43220. show(scene: Scene, color?: Color3): void;
  43221. /**
  43222. * Hides the ray we are debugging.
  43223. */
  43224. hide(): void;
  43225. private _render;
  43226. /**
  43227. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43228. * @param mesh Defines the mesh we want the helper attached to
  43229. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43230. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43231. * @param length Defines the length of the ray
  43232. */
  43233. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43234. /**
  43235. * Detach the ray helper from the mesh it has previously been attached to.
  43236. */
  43237. detachFromMesh(): void;
  43238. private _updateToMesh;
  43239. /**
  43240. * Dispose the helper and release its associated resources.
  43241. */
  43242. dispose(): void;
  43243. }
  43244. }
  43245. declare module "babylonjs/Debug/skeletonViewer" {
  43246. import { Color3 } from "babylonjs/Maths/math";
  43247. import { Scene } from "babylonjs/scene";
  43248. import { Nullable } from "babylonjs/types";
  43249. import { Skeleton } from "babylonjs/Bones/skeleton";
  43250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43251. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43252. /**
  43253. * Class used to render a debug view of a given skeleton
  43254. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43255. */
  43256. export class SkeletonViewer {
  43257. /** defines the skeleton to render */
  43258. skeleton: Skeleton;
  43259. /** defines the mesh attached to the skeleton */
  43260. mesh: AbstractMesh;
  43261. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43262. autoUpdateBonesMatrices: boolean;
  43263. /** defines the rendering group id to use with the viewer */
  43264. renderingGroupId: number;
  43265. /** Gets or sets the color used to render the skeleton */
  43266. color: Color3;
  43267. private _scene;
  43268. private _debugLines;
  43269. private _debugMesh;
  43270. private _isEnabled;
  43271. private _renderFunction;
  43272. private _utilityLayer;
  43273. /**
  43274. * Returns the mesh used to render the bones
  43275. */
  43276. readonly debugMesh: Nullable<LinesMesh>;
  43277. /**
  43278. * Creates a new SkeletonViewer
  43279. * @param skeleton defines the skeleton to render
  43280. * @param mesh defines the mesh attached to the skeleton
  43281. * @param scene defines the hosting scene
  43282. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43283. * @param renderingGroupId defines the rendering group id to use with the viewer
  43284. */
  43285. constructor(
  43286. /** defines the skeleton to render */
  43287. skeleton: Skeleton,
  43288. /** defines the mesh attached to the skeleton */
  43289. mesh: AbstractMesh, scene: Scene,
  43290. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43291. autoUpdateBonesMatrices?: boolean,
  43292. /** defines the rendering group id to use with the viewer */
  43293. renderingGroupId?: number);
  43294. /** Gets or sets a boolean indicating if the viewer is enabled */
  43295. isEnabled: boolean;
  43296. private _getBonePosition;
  43297. private _getLinesForBonesWithLength;
  43298. private _getLinesForBonesNoLength;
  43299. /** Update the viewer to sync with current skeleton state */
  43300. update(): void;
  43301. /** Release associated resources */
  43302. dispose(): void;
  43303. }
  43304. }
  43305. declare module "babylonjs/Debug/index" {
  43306. export * from "babylonjs/Debug/axesViewer";
  43307. export * from "babylonjs/Debug/boneAxesViewer";
  43308. export * from "babylonjs/Debug/debugLayer";
  43309. export * from "babylonjs/Debug/physicsViewer";
  43310. export * from "babylonjs/Debug/rayHelper";
  43311. export * from "babylonjs/Debug/skeletonViewer";
  43312. }
  43313. declare module "babylonjs/Engines/nullEngine" {
  43314. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43315. import { Scene } from "babylonjs/scene";
  43316. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43317. import { Engine } from "babylonjs/Engines/engine";
  43318. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43319. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43320. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43321. import { Effect } from "babylonjs/Materials/effect";
  43322. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43323. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43324. /**
  43325. * Options to create the null engine
  43326. */
  43327. export class NullEngineOptions {
  43328. /**
  43329. * Render width (Default: 512)
  43330. */
  43331. renderWidth: number;
  43332. /**
  43333. * Render height (Default: 256)
  43334. */
  43335. renderHeight: number;
  43336. /**
  43337. * Texture size (Default: 512)
  43338. */
  43339. textureSize: number;
  43340. /**
  43341. * If delta time between frames should be constant
  43342. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43343. */
  43344. deterministicLockstep: boolean;
  43345. /**
  43346. * Maximum about of steps between frames (Default: 4)
  43347. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43348. */
  43349. lockstepMaxSteps: number;
  43350. }
  43351. /**
  43352. * The null engine class provides support for headless version of babylon.js.
  43353. * This can be used in server side scenario or for testing purposes
  43354. */
  43355. export class NullEngine extends Engine {
  43356. private _options;
  43357. /**
  43358. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43359. */
  43360. isDeterministicLockStep(): boolean;
  43361. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43362. getLockstepMaxSteps(): number;
  43363. /**
  43364. * Sets hardware scaling, used to save performance if needed
  43365. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43366. */
  43367. getHardwareScalingLevel(): number;
  43368. constructor(options?: NullEngineOptions);
  43369. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43370. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43371. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43372. getRenderWidth(useScreen?: boolean): number;
  43373. getRenderHeight(useScreen?: boolean): number;
  43374. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43375. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43376. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43377. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43378. bindSamplers(effect: Effect): void;
  43379. enableEffect(effect: Effect): void;
  43380. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43381. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43382. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43383. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43384. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43385. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43386. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43387. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43388. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43389. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43390. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43391. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43392. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43393. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43394. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43395. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43396. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43397. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43398. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43399. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43400. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43401. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43402. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43403. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43404. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43405. bindBuffers(vertexBuffers: {
  43406. [key: string]: VertexBuffer;
  43407. }, indexBuffer: DataBuffer, effect: Effect): void;
  43408. wipeCaches(bruteForce?: boolean): void;
  43409. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43410. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43411. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43412. /** @hidden */
  43413. _createTexture(): WebGLTexture;
  43414. /** @hidden */
  43415. _releaseTexture(texture: InternalTexture): void;
  43416. 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;
  43417. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43418. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43419. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43420. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43421. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43422. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43423. areAllEffectsReady(): boolean;
  43424. /**
  43425. * @hidden
  43426. * Get the current error code of the webGL context
  43427. * @returns the error code
  43428. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43429. */
  43430. getError(): number;
  43431. /** @hidden */
  43432. _getUnpackAlignement(): number;
  43433. /** @hidden */
  43434. _unpackFlipY(value: boolean): void;
  43435. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43436. /**
  43437. * Updates a dynamic vertex buffer.
  43438. * @param vertexBuffer the vertex buffer to update
  43439. * @param data the data used to update the vertex buffer
  43440. * @param byteOffset the byte offset of the data (optional)
  43441. * @param byteLength the byte length of the data (optional)
  43442. */
  43443. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43444. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43445. /** @hidden */
  43446. _bindTexture(channel: number, texture: InternalTexture): void;
  43447. /** @hidden */
  43448. _releaseBuffer(buffer: DataBuffer): boolean;
  43449. releaseEffects(): void;
  43450. displayLoadingUI(): void;
  43451. hideLoadingUI(): void;
  43452. /** @hidden */
  43453. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43454. /** @hidden */
  43455. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43456. /** @hidden */
  43457. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43458. /** @hidden */
  43459. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43460. }
  43461. }
  43462. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43463. import { Nullable, int } from "babylonjs/types";
  43464. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43465. /** @hidden */
  43466. export class _OcclusionDataStorage {
  43467. /** @hidden */
  43468. occlusionInternalRetryCounter: number;
  43469. /** @hidden */
  43470. isOcclusionQueryInProgress: boolean;
  43471. /** @hidden */
  43472. isOccluded: boolean;
  43473. /** @hidden */
  43474. occlusionRetryCount: number;
  43475. /** @hidden */
  43476. occlusionType: number;
  43477. /** @hidden */
  43478. occlusionQueryAlgorithmType: number;
  43479. }
  43480. module "babylonjs/Engines/engine" {
  43481. interface Engine {
  43482. /**
  43483. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43484. * @return the new query
  43485. */
  43486. createQuery(): WebGLQuery;
  43487. /**
  43488. * Delete and release a webGL query
  43489. * @param query defines the query to delete
  43490. * @return the current engine
  43491. */
  43492. deleteQuery(query: WebGLQuery): Engine;
  43493. /**
  43494. * Check if a given query has resolved and got its value
  43495. * @param query defines the query to check
  43496. * @returns true if the query got its value
  43497. */
  43498. isQueryResultAvailable(query: WebGLQuery): boolean;
  43499. /**
  43500. * Gets the value of a given query
  43501. * @param query defines the query to check
  43502. * @returns the value of the query
  43503. */
  43504. getQueryResult(query: WebGLQuery): number;
  43505. /**
  43506. * Initiates an occlusion query
  43507. * @param algorithmType defines the algorithm to use
  43508. * @param query defines the query to use
  43509. * @returns the current engine
  43510. * @see http://doc.babylonjs.com/features/occlusionquery
  43511. */
  43512. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43513. /**
  43514. * Ends an occlusion query
  43515. * @see http://doc.babylonjs.com/features/occlusionquery
  43516. * @param algorithmType defines the algorithm to use
  43517. * @returns the current engine
  43518. */
  43519. endOcclusionQuery(algorithmType: number): Engine;
  43520. /**
  43521. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43522. * Please note that only one query can be issued at a time
  43523. * @returns a time token used to track the time span
  43524. */
  43525. startTimeQuery(): Nullable<_TimeToken>;
  43526. /**
  43527. * Ends a time query
  43528. * @param token defines the token used to measure the time span
  43529. * @returns the time spent (in ns)
  43530. */
  43531. endTimeQuery(token: _TimeToken): int;
  43532. /** @hidden */
  43533. _currentNonTimestampToken: Nullable<_TimeToken>;
  43534. /** @hidden */
  43535. _createTimeQuery(): WebGLQuery;
  43536. /** @hidden */
  43537. _deleteTimeQuery(query: WebGLQuery): void;
  43538. /** @hidden */
  43539. _getGlAlgorithmType(algorithmType: number): number;
  43540. /** @hidden */
  43541. _getTimeQueryResult(query: WebGLQuery): any;
  43542. /** @hidden */
  43543. _getTimeQueryAvailability(query: WebGLQuery): any;
  43544. }
  43545. }
  43546. module "babylonjs/Meshes/abstractMesh" {
  43547. interface AbstractMesh {
  43548. /**
  43549. * Backing filed
  43550. * @hidden
  43551. */
  43552. __occlusionDataStorage: _OcclusionDataStorage;
  43553. /**
  43554. * Access property
  43555. * @hidden
  43556. */
  43557. _occlusionDataStorage: _OcclusionDataStorage;
  43558. /**
  43559. * 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.
  43560. * The default value is -1 which means don't break the query and wait till the result
  43561. * @see http://doc.babylonjs.com/features/occlusionquery
  43562. */
  43563. occlusionRetryCount: number;
  43564. /**
  43565. * 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:
  43566. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43567. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43568. * * 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.
  43569. * @see http://doc.babylonjs.com/features/occlusionquery
  43570. */
  43571. occlusionType: number;
  43572. /**
  43573. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43574. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43575. * * 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.
  43576. * @see http://doc.babylonjs.com/features/occlusionquery
  43577. */
  43578. occlusionQueryAlgorithmType: number;
  43579. /**
  43580. * 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
  43581. * @see http://doc.babylonjs.com/features/occlusionquery
  43582. */
  43583. isOccluded: boolean;
  43584. /**
  43585. * Flag to check the progress status of the query
  43586. * @see http://doc.babylonjs.com/features/occlusionquery
  43587. */
  43588. isOcclusionQueryInProgress: boolean;
  43589. }
  43590. }
  43591. }
  43592. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43593. import { Nullable } from "babylonjs/types";
  43594. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43595. /** @hidden */
  43596. export var _forceTransformFeedbackToBundle: boolean;
  43597. module "babylonjs/Engines/engine" {
  43598. interface Engine {
  43599. /**
  43600. * Creates a webGL transform feedback object
  43601. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43602. * @returns the webGL transform feedback object
  43603. */
  43604. createTransformFeedback(): WebGLTransformFeedback;
  43605. /**
  43606. * Delete a webGL transform feedback object
  43607. * @param value defines the webGL transform feedback object to delete
  43608. */
  43609. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43610. /**
  43611. * Bind a webGL transform feedback object to the webgl context
  43612. * @param value defines the webGL transform feedback object to bind
  43613. */
  43614. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43615. /**
  43616. * Begins a transform feedback operation
  43617. * @param usePoints defines if points or triangles must be used
  43618. */
  43619. beginTransformFeedback(usePoints: boolean): void;
  43620. /**
  43621. * Ends a transform feedback operation
  43622. */
  43623. endTransformFeedback(): void;
  43624. /**
  43625. * Specify the varyings to use with transform feedback
  43626. * @param program defines the associated webGL program
  43627. * @param value defines the list of strings representing the varying names
  43628. */
  43629. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43630. /**
  43631. * Bind a webGL buffer for a transform feedback operation
  43632. * @param value defines the webGL buffer to bind
  43633. */
  43634. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43635. }
  43636. }
  43637. }
  43638. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43639. import { Scene } from "babylonjs/scene";
  43640. import { Engine } from "babylonjs/Engines/engine";
  43641. import { Texture } from "babylonjs/Materials/Textures/texture";
  43642. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43643. import "babylonjs/Engines/Extensions/engine.multiRender";
  43644. /**
  43645. * Creation options of the multi render target texture.
  43646. */
  43647. export interface IMultiRenderTargetOptions {
  43648. /**
  43649. * Define if the texture needs to create mip maps after render.
  43650. */
  43651. generateMipMaps?: boolean;
  43652. /**
  43653. * Define the types of all the draw buffers we want to create
  43654. */
  43655. types?: number[];
  43656. /**
  43657. * Define the sampling modes of all the draw buffers we want to create
  43658. */
  43659. samplingModes?: number[];
  43660. /**
  43661. * Define if a depth buffer is required
  43662. */
  43663. generateDepthBuffer?: boolean;
  43664. /**
  43665. * Define if a stencil buffer is required
  43666. */
  43667. generateStencilBuffer?: boolean;
  43668. /**
  43669. * Define if a depth texture is required instead of a depth buffer
  43670. */
  43671. generateDepthTexture?: boolean;
  43672. /**
  43673. * Define the number of desired draw buffers
  43674. */
  43675. textureCount?: number;
  43676. /**
  43677. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43678. */
  43679. doNotChangeAspectRatio?: boolean;
  43680. /**
  43681. * Define the default type of the buffers we are creating
  43682. */
  43683. defaultType?: number;
  43684. }
  43685. /**
  43686. * A multi render target, like a render target provides the ability to render to a texture.
  43687. * Unlike the render target, it can render to several draw buffers in one draw.
  43688. * This is specially interesting in deferred rendering or for any effects requiring more than
  43689. * just one color from a single pass.
  43690. */
  43691. export class MultiRenderTarget extends RenderTargetTexture {
  43692. private _internalTextures;
  43693. private _textures;
  43694. private _multiRenderTargetOptions;
  43695. /**
  43696. * Get if draw buffers are currently supported by the used hardware and browser.
  43697. */
  43698. readonly isSupported: boolean;
  43699. /**
  43700. * Get the list of textures generated by the multi render target.
  43701. */
  43702. readonly textures: Texture[];
  43703. /**
  43704. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43705. */
  43706. readonly depthTexture: Texture;
  43707. /**
  43708. * Set the wrapping mode on U of all the textures we are rendering to.
  43709. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43710. */
  43711. wrapU: number;
  43712. /**
  43713. * Set the wrapping mode on V of all the textures we are rendering to.
  43714. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43715. */
  43716. wrapV: number;
  43717. /**
  43718. * Instantiate a new multi render target texture.
  43719. * A multi render target, like a render target provides the ability to render to a texture.
  43720. * Unlike the render target, it can render to several draw buffers in one draw.
  43721. * This is specially interesting in deferred rendering or for any effects requiring more than
  43722. * just one color from a single pass.
  43723. * @param name Define the name of the texture
  43724. * @param size Define the size of the buffers to render to
  43725. * @param count Define the number of target we are rendering into
  43726. * @param scene Define the scene the texture belongs to
  43727. * @param options Define the options used to create the multi render target
  43728. */
  43729. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43730. /** @hidden */
  43731. _rebuild(): void;
  43732. private _createInternalTextures;
  43733. private _createTextures;
  43734. /**
  43735. * Define the number of samples used if MSAA is enabled.
  43736. */
  43737. samples: number;
  43738. /**
  43739. * Resize all the textures in the multi render target.
  43740. * Be carrefull as it will recreate all the data in the new texture.
  43741. * @param size Define the new size
  43742. */
  43743. resize(size: any): void;
  43744. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43745. /**
  43746. * Dispose the render targets and their associated resources
  43747. */
  43748. dispose(): void;
  43749. /**
  43750. * Release all the underlying texture used as draw buffers.
  43751. */
  43752. releaseInternalTextures(): void;
  43753. }
  43754. }
  43755. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43756. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43757. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43758. import { Nullable } from "babylonjs/types";
  43759. module "babylonjs/Engines/engine" {
  43760. interface Engine {
  43761. /**
  43762. * Unbind a list of render target textures from the webGL context
  43763. * This is used only when drawBuffer extension or webGL2 are active
  43764. * @param textures defines the render target textures to unbind
  43765. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43766. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43767. */
  43768. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43769. /**
  43770. * Create a multi render target texture
  43771. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43772. * @param size defines the size of the texture
  43773. * @param options defines the creation options
  43774. * @returns the cube texture as an InternalTexture
  43775. */
  43776. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43777. /**
  43778. * Update the sample count for a given multiple render target texture
  43779. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43780. * @param textures defines the textures to update
  43781. * @param samples defines the sample count to set
  43782. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43783. */
  43784. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43785. }
  43786. }
  43787. }
  43788. declare module "babylonjs/Engines/Extensions/index" {
  43789. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43790. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43791. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43792. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43793. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43794. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43795. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43796. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43797. }
  43798. declare module "babylonjs/Engines/index" {
  43799. export * from "babylonjs/Engines/constants";
  43800. export * from "babylonjs/Engines/engine";
  43801. export * from "babylonjs/Engines/engineStore";
  43802. export * from "babylonjs/Engines/nullEngine";
  43803. export * from "babylonjs/Engines/Extensions/index";
  43804. export * from "babylonjs/Engines/IPipelineContext";
  43805. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43806. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  43807. }
  43808. declare module "babylonjs/Events/clipboardEvents" {
  43809. /**
  43810. * Gather the list of clipboard event types as constants.
  43811. */
  43812. export class ClipboardEventTypes {
  43813. /**
  43814. * The clipboard event is fired when a copy command is active (pressed).
  43815. */
  43816. static readonly COPY: number;
  43817. /**
  43818. * The clipboard event is fired when a cut command is active (pressed).
  43819. */
  43820. static readonly CUT: number;
  43821. /**
  43822. * The clipboard event is fired when a paste command is active (pressed).
  43823. */
  43824. static readonly PASTE: number;
  43825. }
  43826. /**
  43827. * This class is used to store clipboard related info for the onClipboardObservable event.
  43828. */
  43829. export class ClipboardInfo {
  43830. /**
  43831. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43832. */
  43833. type: number;
  43834. /**
  43835. * Defines the related dom event
  43836. */
  43837. event: ClipboardEvent;
  43838. /**
  43839. *Creates an instance of ClipboardInfo.
  43840. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43841. * @param event Defines the related dom event
  43842. */
  43843. constructor(
  43844. /**
  43845. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43846. */
  43847. type: number,
  43848. /**
  43849. * Defines the related dom event
  43850. */
  43851. event: ClipboardEvent);
  43852. /**
  43853. * Get the clipboard event's type from the keycode.
  43854. * @param keyCode Defines the keyCode for the current keyboard event.
  43855. * @return {number}
  43856. */
  43857. static GetTypeFromCharacter(keyCode: number): number;
  43858. }
  43859. }
  43860. declare module "babylonjs/Events/index" {
  43861. export * from "babylonjs/Events/keyboardEvents";
  43862. export * from "babylonjs/Events/pointerEvents";
  43863. export * from "babylonjs/Events/clipboardEvents";
  43864. }
  43865. declare module "babylonjs/Loading/sceneLoader" {
  43866. import { Observable } from "babylonjs/Misc/observable";
  43867. import { Nullable } from "babylonjs/types";
  43868. import { Scene } from "babylonjs/scene";
  43869. import { Engine } from "babylonjs/Engines/engine";
  43870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43871. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43872. import { AssetContainer } from "babylonjs/assetContainer";
  43873. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43874. import { Skeleton } from "babylonjs/Bones/skeleton";
  43875. /**
  43876. * Class used to represent data loading progression
  43877. */
  43878. export class SceneLoaderProgressEvent {
  43879. /** defines if data length to load can be evaluated */
  43880. readonly lengthComputable: boolean;
  43881. /** defines the loaded data length */
  43882. readonly loaded: number;
  43883. /** defines the data length to load */
  43884. readonly total: number;
  43885. /**
  43886. * Create a new progress event
  43887. * @param lengthComputable defines if data length to load can be evaluated
  43888. * @param loaded defines the loaded data length
  43889. * @param total defines the data length to load
  43890. */
  43891. constructor(
  43892. /** defines if data length to load can be evaluated */
  43893. lengthComputable: boolean,
  43894. /** defines the loaded data length */
  43895. loaded: number,
  43896. /** defines the data length to load */
  43897. total: number);
  43898. /**
  43899. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43900. * @param event defines the source event
  43901. * @returns a new SceneLoaderProgressEvent
  43902. */
  43903. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43904. }
  43905. /**
  43906. * Interface used by SceneLoader plugins to define supported file extensions
  43907. */
  43908. export interface ISceneLoaderPluginExtensions {
  43909. /**
  43910. * Defines the list of supported extensions
  43911. */
  43912. [extension: string]: {
  43913. isBinary: boolean;
  43914. };
  43915. }
  43916. /**
  43917. * Interface used by SceneLoader plugin factory
  43918. */
  43919. export interface ISceneLoaderPluginFactory {
  43920. /**
  43921. * Defines the name of the factory
  43922. */
  43923. name: string;
  43924. /**
  43925. * Function called to create a new plugin
  43926. * @return the new plugin
  43927. */
  43928. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43929. /**
  43930. * Boolean indicating if the plugin can direct load specific data
  43931. */
  43932. canDirectLoad?: (data: string) => boolean;
  43933. }
  43934. /**
  43935. * Interface used to define a SceneLoader plugin
  43936. */
  43937. export interface ISceneLoaderPlugin {
  43938. /**
  43939. * The friendly name of this plugin.
  43940. */
  43941. name: string;
  43942. /**
  43943. * The file extensions supported by this plugin.
  43944. */
  43945. extensions: string | ISceneLoaderPluginExtensions;
  43946. /**
  43947. * Import meshes into a scene.
  43948. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43949. * @param scene The scene to import into
  43950. * @param data The data to import
  43951. * @param rootUrl The root url for scene and resources
  43952. * @param meshes The meshes array to import into
  43953. * @param particleSystems The particle systems array to import into
  43954. * @param skeletons The skeletons array to import into
  43955. * @param onError The callback when import fails
  43956. * @returns True if successful or false otherwise
  43957. */
  43958. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43959. /**
  43960. * Load into a scene.
  43961. * @param scene The scene to load into
  43962. * @param data The data to import
  43963. * @param rootUrl The root url for scene and resources
  43964. * @param onError The callback when import fails
  43965. * @returns true if successful or false otherwise
  43966. */
  43967. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43968. /**
  43969. * The callback that returns true if the data can be directly loaded.
  43970. */
  43971. canDirectLoad?: (data: string) => boolean;
  43972. /**
  43973. * The callback that allows custom handling of the root url based on the response url.
  43974. */
  43975. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43976. /**
  43977. * Load into an asset container.
  43978. * @param scene The scene to load into
  43979. * @param data The data to import
  43980. * @param rootUrl The root url for scene and resources
  43981. * @param onError The callback when import fails
  43982. * @returns The loaded asset container
  43983. */
  43984. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43985. }
  43986. /**
  43987. * Interface used to define an async SceneLoader plugin
  43988. */
  43989. export interface ISceneLoaderPluginAsync {
  43990. /**
  43991. * The friendly name of this plugin.
  43992. */
  43993. name: string;
  43994. /**
  43995. * The file extensions supported by this plugin.
  43996. */
  43997. extensions: string | ISceneLoaderPluginExtensions;
  43998. /**
  43999. * Import meshes into a scene.
  44000. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44001. * @param scene The scene to import into
  44002. * @param data The data to import
  44003. * @param rootUrl The root url for scene and resources
  44004. * @param onProgress The callback when the load progresses
  44005. * @param fileName Defines the name of the file to load
  44006. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44007. */
  44008. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44009. meshes: AbstractMesh[];
  44010. particleSystems: IParticleSystem[];
  44011. skeletons: Skeleton[];
  44012. animationGroups: AnimationGroup[];
  44013. }>;
  44014. /**
  44015. * Load into a scene.
  44016. * @param scene The scene to load into
  44017. * @param data The data to import
  44018. * @param rootUrl The root url for scene and resources
  44019. * @param onProgress The callback when the load progresses
  44020. * @param fileName Defines the name of the file to load
  44021. * @returns Nothing
  44022. */
  44023. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44024. /**
  44025. * The callback that returns true if the data can be directly loaded.
  44026. */
  44027. canDirectLoad?: (data: string) => boolean;
  44028. /**
  44029. * The callback that allows custom handling of the root url based on the response url.
  44030. */
  44031. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44032. /**
  44033. * Load into an asset container.
  44034. * @param scene The scene to load into
  44035. * @param data The data to import
  44036. * @param rootUrl The root url for scene and resources
  44037. * @param onProgress The callback when the load progresses
  44038. * @param fileName Defines the name of the file to load
  44039. * @returns The loaded asset container
  44040. */
  44041. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44042. }
  44043. /**
  44044. * Class used to load scene from various file formats using registered plugins
  44045. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44046. */
  44047. export class SceneLoader {
  44048. /**
  44049. * No logging while loading
  44050. */
  44051. static readonly NO_LOGGING: number;
  44052. /**
  44053. * Minimal logging while loading
  44054. */
  44055. static readonly MINIMAL_LOGGING: number;
  44056. /**
  44057. * Summary logging while loading
  44058. */
  44059. static readonly SUMMARY_LOGGING: number;
  44060. /**
  44061. * Detailled logging while loading
  44062. */
  44063. static readonly DETAILED_LOGGING: number;
  44064. /**
  44065. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44066. */
  44067. static ForceFullSceneLoadingForIncremental: boolean;
  44068. /**
  44069. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44070. */
  44071. static ShowLoadingScreen: boolean;
  44072. /**
  44073. * Defines the current logging level (while loading the scene)
  44074. * @ignorenaming
  44075. */
  44076. static loggingLevel: number;
  44077. /**
  44078. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44079. */
  44080. static CleanBoneMatrixWeights: boolean;
  44081. /**
  44082. * Event raised when a plugin is used to load a scene
  44083. */
  44084. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44085. private static _registeredPlugins;
  44086. private static _getDefaultPlugin;
  44087. private static _getPluginForExtension;
  44088. private static _getPluginForDirectLoad;
  44089. private static _getPluginForFilename;
  44090. private static _getDirectLoad;
  44091. private static _loadData;
  44092. private static _getFileInfo;
  44093. /**
  44094. * Gets a plugin that can load the given extension
  44095. * @param extension defines the extension to load
  44096. * @returns a plugin or null if none works
  44097. */
  44098. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44099. /**
  44100. * Gets a boolean indicating that the given extension can be loaded
  44101. * @param extension defines the extension to load
  44102. * @returns true if the extension is supported
  44103. */
  44104. static IsPluginForExtensionAvailable(extension: string): boolean;
  44105. /**
  44106. * Adds a new plugin to the list of registered plugins
  44107. * @param plugin defines the plugin to add
  44108. */
  44109. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44110. /**
  44111. * Import meshes into a scene
  44112. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44113. * @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)
  44114. * @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)
  44115. * @param scene the instance of BABYLON.Scene to append to
  44116. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44117. * @param onProgress a callback with a progress event for each file being loaded
  44118. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44119. * @param pluginExtension the extension used to determine the plugin
  44120. * @returns The loaded plugin
  44121. */
  44122. 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>;
  44123. /**
  44124. * Import meshes into a scene
  44125. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44126. * @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)
  44127. * @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)
  44128. * @param scene the instance of BABYLON.Scene to append to
  44129. * @param onProgress a callback with a progress event for each file being loaded
  44130. * @param pluginExtension the extension used to determine the plugin
  44131. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44132. */
  44133. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44134. meshes: AbstractMesh[];
  44135. particleSystems: IParticleSystem[];
  44136. skeletons: Skeleton[];
  44137. animationGroups: AnimationGroup[];
  44138. }>;
  44139. /**
  44140. * Load a scene
  44141. * @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)
  44142. * @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)
  44143. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44144. * @param onSuccess a callback with the scene when import succeeds
  44145. * @param onProgress a callback with a progress event for each file being loaded
  44146. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44147. * @param pluginExtension the extension used to determine the plugin
  44148. * @returns The loaded plugin
  44149. */
  44150. 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>;
  44151. /**
  44152. * Load a scene
  44153. * @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)
  44154. * @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)
  44155. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44156. * @param onProgress a callback with a progress event for each file being loaded
  44157. * @param pluginExtension the extension used to determine the plugin
  44158. * @returns The loaded scene
  44159. */
  44160. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44161. /**
  44162. * Append a scene
  44163. * @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)
  44164. * @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)
  44165. * @param scene is the instance of BABYLON.Scene to append to
  44166. * @param onSuccess a callback with the scene when import succeeds
  44167. * @param onProgress a callback with a progress event for each file being loaded
  44168. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44169. * @param pluginExtension the extension used to determine the plugin
  44170. * @returns The loaded plugin
  44171. */
  44172. 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>;
  44173. /**
  44174. * Append a scene
  44175. * @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)
  44176. * @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)
  44177. * @param scene is the instance of BABYLON.Scene to append to
  44178. * @param onProgress a callback with a progress event for each file being loaded
  44179. * @param pluginExtension the extension used to determine the plugin
  44180. * @returns The given scene
  44181. */
  44182. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44183. /**
  44184. * Load a scene into an asset container
  44185. * @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)
  44186. * @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)
  44187. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44188. * @param onSuccess a callback with the scene when import succeeds
  44189. * @param onProgress a callback with a progress event for each file being loaded
  44190. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44191. * @param pluginExtension the extension used to determine the plugin
  44192. * @returns The loaded plugin
  44193. */
  44194. 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>;
  44195. /**
  44196. * Load a scene into an asset container
  44197. * @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)
  44198. * @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)
  44199. * @param scene is the instance of Scene to append to
  44200. * @param onProgress a callback with a progress event for each file being loaded
  44201. * @param pluginExtension the extension used to determine the plugin
  44202. * @returns The loaded asset container
  44203. */
  44204. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44205. }
  44206. }
  44207. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44208. import { Scene } from "babylonjs/scene";
  44209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44210. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44211. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44212. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44213. /**
  44214. * Google Daydream controller
  44215. */
  44216. export class DaydreamController extends WebVRController {
  44217. /**
  44218. * Base Url for the controller model.
  44219. */
  44220. static MODEL_BASE_URL: string;
  44221. /**
  44222. * File name for the controller model.
  44223. */
  44224. static MODEL_FILENAME: string;
  44225. /**
  44226. * Gamepad Id prefix used to identify Daydream Controller.
  44227. */
  44228. static readonly GAMEPAD_ID_PREFIX: string;
  44229. /**
  44230. * Creates a new DaydreamController from a gamepad
  44231. * @param vrGamepad the gamepad that the controller should be created from
  44232. */
  44233. constructor(vrGamepad: any);
  44234. /**
  44235. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44236. * @param scene scene in which to add meshes
  44237. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44238. */
  44239. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44240. /**
  44241. * Called once for each button that changed state since the last frame
  44242. * @param buttonIdx Which button index changed
  44243. * @param state New state of the button
  44244. * @param changes Which properties on the state changed since last frame
  44245. */
  44246. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44247. }
  44248. }
  44249. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44250. import { Scene } from "babylonjs/scene";
  44251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44252. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44253. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44254. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44255. /**
  44256. * Gear VR Controller
  44257. */
  44258. export class GearVRController extends WebVRController {
  44259. /**
  44260. * Base Url for the controller model.
  44261. */
  44262. static MODEL_BASE_URL: string;
  44263. /**
  44264. * File name for the controller model.
  44265. */
  44266. static MODEL_FILENAME: string;
  44267. /**
  44268. * Gamepad Id prefix used to identify this controller.
  44269. */
  44270. static readonly GAMEPAD_ID_PREFIX: string;
  44271. private readonly _buttonIndexToObservableNameMap;
  44272. /**
  44273. * Creates a new GearVRController from a gamepad
  44274. * @param vrGamepad the gamepad that the controller should be created from
  44275. */
  44276. constructor(vrGamepad: any);
  44277. /**
  44278. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44279. * @param scene scene in which to add meshes
  44280. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44281. */
  44282. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44283. /**
  44284. * Called once for each button that changed state since the last frame
  44285. * @param buttonIdx Which button index changed
  44286. * @param state New state of the button
  44287. * @param changes Which properties on the state changed since last frame
  44288. */
  44289. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44290. }
  44291. }
  44292. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44293. import { Scene } from "babylonjs/scene";
  44294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44295. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44296. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44297. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44298. /**
  44299. * Generic Controller
  44300. */
  44301. export class GenericController extends WebVRController {
  44302. /**
  44303. * Base Url for the controller model.
  44304. */
  44305. static readonly MODEL_BASE_URL: string;
  44306. /**
  44307. * File name for the controller model.
  44308. */
  44309. static readonly MODEL_FILENAME: string;
  44310. /**
  44311. * Creates a new GenericController from a gamepad
  44312. * @param vrGamepad the gamepad that the controller should be created from
  44313. */
  44314. constructor(vrGamepad: any);
  44315. /**
  44316. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44317. * @param scene scene in which to add meshes
  44318. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44319. */
  44320. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44321. /**
  44322. * Called once for each button that changed state since the last frame
  44323. * @param buttonIdx Which button index changed
  44324. * @param state New state of the button
  44325. * @param changes Which properties on the state changed since last frame
  44326. */
  44327. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44328. }
  44329. }
  44330. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44331. import { Observable } from "babylonjs/Misc/observable";
  44332. import { Scene } from "babylonjs/scene";
  44333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44334. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44335. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44336. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44337. /**
  44338. * Oculus Touch Controller
  44339. */
  44340. export class OculusTouchController extends WebVRController {
  44341. /**
  44342. * Base Url for the controller model.
  44343. */
  44344. static MODEL_BASE_URL: string;
  44345. /**
  44346. * File name for the left controller model.
  44347. */
  44348. static MODEL_LEFT_FILENAME: string;
  44349. /**
  44350. * File name for the right controller model.
  44351. */
  44352. static MODEL_RIGHT_FILENAME: string;
  44353. /**
  44354. * Fired when the secondary trigger on this controller is modified
  44355. */
  44356. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44357. /**
  44358. * Fired when the thumb rest on this controller is modified
  44359. */
  44360. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44361. /**
  44362. * Creates a new OculusTouchController from a gamepad
  44363. * @param vrGamepad the gamepad that the controller should be created from
  44364. */
  44365. constructor(vrGamepad: any);
  44366. /**
  44367. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44368. * @param scene scene in which to add meshes
  44369. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44370. */
  44371. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44372. /**
  44373. * Fired when the A button on this controller is modified
  44374. */
  44375. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44376. /**
  44377. * Fired when the B button on this controller is modified
  44378. */
  44379. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44380. /**
  44381. * Fired when the X button on this controller is modified
  44382. */
  44383. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44384. /**
  44385. * Fired when the Y button on this controller is modified
  44386. */
  44387. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44388. /**
  44389. * Called once for each button that changed state since the last frame
  44390. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44391. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44392. * 2) secondary trigger (same)
  44393. * 3) A (right) X (left), touch, pressed = value
  44394. * 4) B / Y
  44395. * 5) thumb rest
  44396. * @param buttonIdx Which button index changed
  44397. * @param state New state of the button
  44398. * @param changes Which properties on the state changed since last frame
  44399. */
  44400. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44401. }
  44402. }
  44403. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44404. import { Scene } from "babylonjs/scene";
  44405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44406. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44407. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44408. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44409. import { Observable } from "babylonjs/Misc/observable";
  44410. /**
  44411. * Vive Controller
  44412. */
  44413. export class ViveController extends WebVRController {
  44414. /**
  44415. * Base Url for the controller model.
  44416. */
  44417. static MODEL_BASE_URL: string;
  44418. /**
  44419. * File name for the controller model.
  44420. */
  44421. static MODEL_FILENAME: string;
  44422. /**
  44423. * Creates a new ViveController from a gamepad
  44424. * @param vrGamepad the gamepad that the controller should be created from
  44425. */
  44426. constructor(vrGamepad: any);
  44427. /**
  44428. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44429. * @param scene scene in which to add meshes
  44430. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44431. */
  44432. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44433. /**
  44434. * Fired when the left button on this controller is modified
  44435. */
  44436. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44437. /**
  44438. * Fired when the right button on this controller is modified
  44439. */
  44440. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44441. /**
  44442. * Fired when the menu button on this controller is modified
  44443. */
  44444. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44445. /**
  44446. * Called once for each button that changed state since the last frame
  44447. * Vive mapping:
  44448. * 0: touchpad
  44449. * 1: trigger
  44450. * 2: left AND right buttons
  44451. * 3: menu button
  44452. * @param buttonIdx Which button index changed
  44453. * @param state New state of the button
  44454. * @param changes Which properties on the state changed since last frame
  44455. */
  44456. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44457. }
  44458. }
  44459. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44460. import { Observable } from "babylonjs/Misc/observable";
  44461. import { Scene } from "babylonjs/scene";
  44462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44463. import { Ray } from "babylonjs/Culling/ray";
  44464. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44465. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44466. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44467. /**
  44468. * Defines the WindowsMotionController object that the state of the windows motion controller
  44469. */
  44470. export class WindowsMotionController extends WebVRController {
  44471. /**
  44472. * The base url used to load the left and right controller models
  44473. */
  44474. static MODEL_BASE_URL: string;
  44475. /**
  44476. * The name of the left controller model file
  44477. */
  44478. static MODEL_LEFT_FILENAME: string;
  44479. /**
  44480. * The name of the right controller model file
  44481. */
  44482. static MODEL_RIGHT_FILENAME: string;
  44483. /**
  44484. * The controller name prefix for this controller type
  44485. */
  44486. static readonly GAMEPAD_ID_PREFIX: string;
  44487. /**
  44488. * The controller id pattern for this controller type
  44489. */
  44490. private static readonly GAMEPAD_ID_PATTERN;
  44491. private _loadedMeshInfo;
  44492. private readonly _mapping;
  44493. /**
  44494. * Fired when the trackpad on this controller is clicked
  44495. */
  44496. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44497. /**
  44498. * Fired when the trackpad on this controller is modified
  44499. */
  44500. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44501. /**
  44502. * The current x and y values of this controller's trackpad
  44503. */
  44504. trackpad: StickValues;
  44505. /**
  44506. * Creates a new WindowsMotionController from a gamepad
  44507. * @param vrGamepad the gamepad that the controller should be created from
  44508. */
  44509. constructor(vrGamepad: any);
  44510. /**
  44511. * Fired when the trigger on this controller is modified
  44512. */
  44513. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44514. /**
  44515. * Fired when the menu button on this controller is modified
  44516. */
  44517. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44518. /**
  44519. * Fired when the grip button on this controller is modified
  44520. */
  44521. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44522. /**
  44523. * Fired when the thumbstick button on this controller is modified
  44524. */
  44525. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44526. /**
  44527. * Fired when the touchpad button on this controller is modified
  44528. */
  44529. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44530. /**
  44531. * Fired when the touchpad values on this controller are modified
  44532. */
  44533. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44534. private _updateTrackpad;
  44535. /**
  44536. * Called once per frame by the engine.
  44537. */
  44538. update(): void;
  44539. /**
  44540. * Called once for each button that changed state since the last frame
  44541. * @param buttonIdx Which button index changed
  44542. * @param state New state of the button
  44543. * @param changes Which properties on the state changed since last frame
  44544. */
  44545. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44546. /**
  44547. * Moves the buttons on the controller mesh based on their current state
  44548. * @param buttonName the name of the button to move
  44549. * @param buttonValue the value of the button which determines the buttons new position
  44550. */
  44551. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44552. /**
  44553. * Moves the axis on the controller mesh based on its current state
  44554. * @param axis the index of the axis
  44555. * @param axisValue the value of the axis which determines the meshes new position
  44556. * @hidden
  44557. */
  44558. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44559. /**
  44560. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44561. * @param scene scene in which to add meshes
  44562. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44563. */
  44564. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44565. /**
  44566. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44567. * can be transformed by button presses and axes values, based on this._mapping.
  44568. *
  44569. * @param scene scene in which the meshes exist
  44570. * @param meshes list of meshes that make up the controller model to process
  44571. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44572. */
  44573. private processModel;
  44574. private createMeshInfo;
  44575. /**
  44576. * Gets the ray of the controller in the direction the controller is pointing
  44577. * @param length the length the resulting ray should be
  44578. * @returns a ray in the direction the controller is pointing
  44579. */
  44580. getForwardRay(length?: number): Ray;
  44581. /**
  44582. * Disposes of the controller
  44583. */
  44584. dispose(): void;
  44585. }
  44586. }
  44587. declare module "babylonjs/Gamepads/Controllers/index" {
  44588. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44589. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44590. export * from "babylonjs/Gamepads/Controllers/genericController";
  44591. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44592. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44593. export * from "babylonjs/Gamepads/Controllers/viveController";
  44594. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44595. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44596. }
  44597. declare module "babylonjs/Gamepads/index" {
  44598. export * from "babylonjs/Gamepads/Controllers/index";
  44599. export * from "babylonjs/Gamepads/gamepad";
  44600. export * from "babylonjs/Gamepads/gamepadManager";
  44601. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44602. export * from "babylonjs/Gamepads/xboxGamepad";
  44603. }
  44604. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44605. import { Scene } from "babylonjs/scene";
  44606. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44607. import { Mesh } from "babylonjs/Meshes/mesh";
  44608. import { Nullable } from "babylonjs/types";
  44609. /**
  44610. * Class containing static functions to help procedurally build meshes
  44611. */
  44612. export class PolyhedronBuilder {
  44613. /**
  44614. * Creates a polyhedron mesh
  44615. * * 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
  44616. * * The parameter `size` (positive float, default 1) sets the polygon size
  44617. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44618. * * 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`
  44619. * * 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
  44620. * * 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)`)
  44621. * * 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
  44622. * * 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
  44623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44624. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44626. * @param name defines the name of the mesh
  44627. * @param options defines the options used to create the mesh
  44628. * @param scene defines the hosting scene
  44629. * @returns the polyhedron mesh
  44630. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44631. */
  44632. static CreatePolyhedron(name: string, options: {
  44633. type?: number;
  44634. size?: number;
  44635. sizeX?: number;
  44636. sizeY?: number;
  44637. sizeZ?: number;
  44638. custom?: any;
  44639. faceUV?: Vector4[];
  44640. faceColors?: Color4[];
  44641. flat?: boolean;
  44642. updatable?: boolean;
  44643. sideOrientation?: number;
  44644. frontUVs?: Vector4;
  44645. backUVs?: Vector4;
  44646. }, scene?: Nullable<Scene>): Mesh;
  44647. }
  44648. }
  44649. declare module "babylonjs/Gizmos/scaleGizmo" {
  44650. import { Observable } from "babylonjs/Misc/observable";
  44651. import { Nullable } from "babylonjs/types";
  44652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44653. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44654. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44655. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44656. /**
  44657. * Gizmo that enables scaling a mesh along 3 axis
  44658. */
  44659. export class ScaleGizmo extends Gizmo {
  44660. /**
  44661. * Internal gizmo used for interactions on the x axis
  44662. */
  44663. xGizmo: AxisScaleGizmo;
  44664. /**
  44665. * Internal gizmo used for interactions on the y axis
  44666. */
  44667. yGizmo: AxisScaleGizmo;
  44668. /**
  44669. * Internal gizmo used for interactions on the z axis
  44670. */
  44671. zGizmo: AxisScaleGizmo;
  44672. /**
  44673. * Internal gizmo used to scale all axis equally
  44674. */
  44675. uniformScaleGizmo: AxisScaleGizmo;
  44676. private _meshAttached;
  44677. private _updateGizmoRotationToMatchAttachedMesh;
  44678. private _snapDistance;
  44679. private _scaleRatio;
  44680. private _uniformScalingMesh;
  44681. private _octahedron;
  44682. /** Fires an event when any of it's sub gizmos are dragged */
  44683. onDragStartObservable: Observable<unknown>;
  44684. /** Fires an event when any of it's sub gizmos are released from dragging */
  44685. onDragEndObservable: Observable<unknown>;
  44686. attachedMesh: Nullable<AbstractMesh>;
  44687. /**
  44688. * Creates a ScaleGizmo
  44689. * @param gizmoLayer The utility layer the gizmo will be added to
  44690. */
  44691. constructor(gizmoLayer?: UtilityLayerRenderer);
  44692. updateGizmoRotationToMatchAttachedMesh: boolean;
  44693. /**
  44694. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44695. */
  44696. snapDistance: number;
  44697. /**
  44698. * Ratio for the scale of the gizmo (Default: 1)
  44699. */
  44700. scaleRatio: number;
  44701. /**
  44702. * Disposes of the gizmo
  44703. */
  44704. dispose(): void;
  44705. }
  44706. }
  44707. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44708. import { Observable } from "babylonjs/Misc/observable";
  44709. import { Nullable } from "babylonjs/types";
  44710. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44712. import { Mesh } from "babylonjs/Meshes/mesh";
  44713. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44714. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44715. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44716. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44717. /**
  44718. * Single axis scale gizmo
  44719. */
  44720. export class AxisScaleGizmo extends Gizmo {
  44721. /**
  44722. * Drag behavior responsible for the gizmos dragging interactions
  44723. */
  44724. dragBehavior: PointerDragBehavior;
  44725. private _pointerObserver;
  44726. /**
  44727. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44728. */
  44729. snapDistance: number;
  44730. /**
  44731. * Event that fires each time the gizmo snaps to a new location.
  44732. * * snapDistance is the the change in distance
  44733. */
  44734. onSnapObservable: Observable<{
  44735. snapDistance: number;
  44736. }>;
  44737. /**
  44738. * If the scaling operation should be done on all axis (default: false)
  44739. */
  44740. uniformScaling: boolean;
  44741. private _isEnabled;
  44742. private _parent;
  44743. private _arrow;
  44744. private _coloredMaterial;
  44745. private _hoverMaterial;
  44746. /**
  44747. * Creates an AxisScaleGizmo
  44748. * @param gizmoLayer The utility layer the gizmo will be added to
  44749. * @param dragAxis The axis which the gizmo will be able to scale on
  44750. * @param color The color of the gizmo
  44751. */
  44752. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44753. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44754. /**
  44755. * If the gizmo is enabled
  44756. */
  44757. isEnabled: boolean;
  44758. /**
  44759. * Disposes of the gizmo
  44760. */
  44761. dispose(): void;
  44762. /**
  44763. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44764. * @param mesh The mesh to replace the default mesh of the gizmo
  44765. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44766. */
  44767. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44768. }
  44769. }
  44770. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44771. import { Observable } from "babylonjs/Misc/observable";
  44772. import { Nullable } from "babylonjs/types";
  44773. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44775. import { Mesh } from "babylonjs/Meshes/mesh";
  44776. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44777. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44778. import "babylonjs/Meshes/Builders/boxBuilder";
  44779. /**
  44780. * Bounding box gizmo
  44781. */
  44782. export class BoundingBoxGizmo extends Gizmo {
  44783. private _lineBoundingBox;
  44784. private _rotateSpheresParent;
  44785. private _scaleBoxesParent;
  44786. private _boundingDimensions;
  44787. private _renderObserver;
  44788. private _pointerObserver;
  44789. private _scaleDragSpeed;
  44790. private _tmpQuaternion;
  44791. private _tmpVector;
  44792. private _tmpRotationMatrix;
  44793. /**
  44794. * 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)
  44795. */
  44796. ignoreChildren: boolean;
  44797. /**
  44798. * 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)
  44799. */
  44800. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44801. /**
  44802. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44803. */
  44804. rotationSphereSize: number;
  44805. /**
  44806. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44807. */
  44808. scaleBoxSize: number;
  44809. /**
  44810. * 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)
  44811. */
  44812. fixedDragMeshScreenSize: boolean;
  44813. /**
  44814. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44815. */
  44816. fixedDragMeshScreenSizeDistanceFactor: number;
  44817. /**
  44818. * Fired when a rotation sphere or scale box is dragged
  44819. */
  44820. onDragStartObservable: Observable<{}>;
  44821. /**
  44822. * Fired when a scale box is dragged
  44823. */
  44824. onScaleBoxDragObservable: Observable<{}>;
  44825. /**
  44826. * Fired when a scale box drag is ended
  44827. */
  44828. onScaleBoxDragEndObservable: Observable<{}>;
  44829. /**
  44830. * Fired when a rotation sphere is dragged
  44831. */
  44832. onRotationSphereDragObservable: Observable<{}>;
  44833. /**
  44834. * Fired when a rotation sphere drag is ended
  44835. */
  44836. onRotationSphereDragEndObservable: Observable<{}>;
  44837. /**
  44838. * 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)
  44839. */
  44840. scalePivot: Nullable<Vector3>;
  44841. /**
  44842. * Mesh used as a pivot to rotate the attached mesh
  44843. */
  44844. private _anchorMesh;
  44845. private _existingMeshScale;
  44846. private _dragMesh;
  44847. private pointerDragBehavior;
  44848. private coloredMaterial;
  44849. private hoverColoredMaterial;
  44850. /**
  44851. * Sets the color of the bounding box gizmo
  44852. * @param color the color to set
  44853. */
  44854. setColor(color: Color3): void;
  44855. /**
  44856. * Creates an BoundingBoxGizmo
  44857. * @param gizmoLayer The utility layer the gizmo will be added to
  44858. * @param color The color of the gizmo
  44859. */
  44860. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44861. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44862. private _selectNode;
  44863. /**
  44864. * Updates the bounding box information for the Gizmo
  44865. */
  44866. updateBoundingBox(): void;
  44867. private _updateRotationSpheres;
  44868. private _updateScaleBoxes;
  44869. /**
  44870. * Enables rotation on the specified axis and disables rotation on the others
  44871. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44872. */
  44873. setEnabledRotationAxis(axis: string): void;
  44874. /**
  44875. * Enables/disables scaling
  44876. * @param enable if scaling should be enabled
  44877. */
  44878. setEnabledScaling(enable: boolean): void;
  44879. private _updateDummy;
  44880. /**
  44881. * Enables a pointer drag behavior on the bounding box of the gizmo
  44882. */
  44883. enableDragBehavior(): void;
  44884. /**
  44885. * Disposes of the gizmo
  44886. */
  44887. dispose(): void;
  44888. /**
  44889. * 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)
  44890. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44891. * @returns the bounding box mesh with the passed in mesh as a child
  44892. */
  44893. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44894. /**
  44895. * CustomMeshes are not supported by this gizmo
  44896. * @param mesh The mesh to replace the default mesh of the gizmo
  44897. */
  44898. setCustomMesh(mesh: Mesh): void;
  44899. }
  44900. }
  44901. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44902. import { Observable } from "babylonjs/Misc/observable";
  44903. import { Nullable } from "babylonjs/types";
  44904. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44906. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44907. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44908. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44909. import "babylonjs/Meshes/Builders/linesBuilder";
  44910. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44911. /**
  44912. * Single plane rotation gizmo
  44913. */
  44914. export class PlaneRotationGizmo extends Gizmo {
  44915. /**
  44916. * Drag behavior responsible for the gizmos dragging interactions
  44917. */
  44918. dragBehavior: PointerDragBehavior;
  44919. private _pointerObserver;
  44920. /**
  44921. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44922. */
  44923. snapDistance: number;
  44924. /**
  44925. * Event that fires each time the gizmo snaps to a new location.
  44926. * * snapDistance is the the change in distance
  44927. */
  44928. onSnapObservable: Observable<{
  44929. snapDistance: number;
  44930. }>;
  44931. private _isEnabled;
  44932. private _parent;
  44933. /**
  44934. * Creates a PlaneRotationGizmo
  44935. * @param gizmoLayer The utility layer the gizmo will be added to
  44936. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44937. * @param color The color of the gizmo
  44938. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44939. */
  44940. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  44941. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44942. /**
  44943. * If the gizmo is enabled
  44944. */
  44945. isEnabled: boolean;
  44946. /**
  44947. * Disposes of the gizmo
  44948. */
  44949. dispose(): void;
  44950. }
  44951. }
  44952. declare module "babylonjs/Gizmos/rotationGizmo" {
  44953. import { Observable } from "babylonjs/Misc/observable";
  44954. import { Nullable } from "babylonjs/types";
  44955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44956. import { Mesh } from "babylonjs/Meshes/mesh";
  44957. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44958. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44959. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44960. /**
  44961. * Gizmo that enables rotating a mesh along 3 axis
  44962. */
  44963. export class RotationGizmo extends Gizmo {
  44964. /**
  44965. * Internal gizmo used for interactions on the x axis
  44966. */
  44967. xGizmo: PlaneRotationGizmo;
  44968. /**
  44969. * Internal gizmo used for interactions on the y axis
  44970. */
  44971. yGizmo: PlaneRotationGizmo;
  44972. /**
  44973. * Internal gizmo used for interactions on the z axis
  44974. */
  44975. zGizmo: PlaneRotationGizmo;
  44976. /** Fires an event when any of it's sub gizmos are dragged */
  44977. onDragStartObservable: Observable<unknown>;
  44978. /** Fires an event when any of it's sub gizmos are released from dragging */
  44979. onDragEndObservable: Observable<unknown>;
  44980. private _meshAttached;
  44981. attachedMesh: Nullable<AbstractMesh>;
  44982. /**
  44983. * Creates a RotationGizmo
  44984. * @param gizmoLayer The utility layer the gizmo will be added to
  44985. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44986. */
  44987. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44988. updateGizmoRotationToMatchAttachedMesh: boolean;
  44989. /**
  44990. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44991. */
  44992. snapDistance: number;
  44993. /**
  44994. * Ratio for the scale of the gizmo (Default: 1)
  44995. */
  44996. scaleRatio: number;
  44997. /**
  44998. * Disposes of the gizmo
  44999. */
  45000. dispose(): void;
  45001. /**
  45002. * CustomMeshes are not supported by this gizmo
  45003. * @param mesh The mesh to replace the default mesh of the gizmo
  45004. */
  45005. setCustomMesh(mesh: Mesh): void;
  45006. }
  45007. }
  45008. declare module "babylonjs/Gizmos/gizmoManager" {
  45009. import { Observable } from "babylonjs/Misc/observable";
  45010. import { Nullable } from "babylonjs/types";
  45011. import { Scene, IDisposable } from "babylonjs/scene";
  45012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45013. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45014. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45015. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45016. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45017. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45018. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45019. /**
  45020. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45021. */
  45022. export class GizmoManager implements IDisposable {
  45023. private scene;
  45024. /**
  45025. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45026. */
  45027. gizmos: {
  45028. positionGizmo: Nullable<PositionGizmo>;
  45029. rotationGizmo: Nullable<RotationGizmo>;
  45030. scaleGizmo: Nullable<ScaleGizmo>;
  45031. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45032. };
  45033. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45034. clearGizmoOnEmptyPointerEvent: boolean;
  45035. /** Fires an event when the manager is attached to a mesh */
  45036. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45037. private _gizmosEnabled;
  45038. private _pointerObserver;
  45039. private _attachedMesh;
  45040. private _boundingBoxColor;
  45041. private _defaultUtilityLayer;
  45042. private _defaultKeepDepthUtilityLayer;
  45043. /**
  45044. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45045. */
  45046. boundingBoxDragBehavior: SixDofDragBehavior;
  45047. /**
  45048. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45049. */
  45050. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45051. /**
  45052. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45053. */
  45054. usePointerToAttachGizmos: boolean;
  45055. /**
  45056. * Utility layer that the bounding box gizmo belongs to
  45057. */
  45058. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45059. /**
  45060. * Utility layer that all gizmos besides bounding box belong to
  45061. */
  45062. readonly utilityLayer: UtilityLayerRenderer;
  45063. /**
  45064. * Instatiates a gizmo manager
  45065. * @param scene the scene to overlay the gizmos on top of
  45066. */
  45067. constructor(scene: Scene);
  45068. /**
  45069. * Attaches a set of gizmos to the specified mesh
  45070. * @param mesh The mesh the gizmo's should be attached to
  45071. */
  45072. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45073. /**
  45074. * If the position gizmo is enabled
  45075. */
  45076. positionGizmoEnabled: boolean;
  45077. /**
  45078. * If the rotation gizmo is enabled
  45079. */
  45080. rotationGizmoEnabled: boolean;
  45081. /**
  45082. * If the scale gizmo is enabled
  45083. */
  45084. scaleGizmoEnabled: boolean;
  45085. /**
  45086. * If the boundingBox gizmo is enabled
  45087. */
  45088. boundingBoxGizmoEnabled: boolean;
  45089. /**
  45090. * Disposes of the gizmo manager
  45091. */
  45092. dispose(): void;
  45093. }
  45094. }
  45095. declare module "babylonjs/Lights/directionalLight" {
  45096. import { Camera } from "babylonjs/Cameras/camera";
  45097. import { Scene } from "babylonjs/scene";
  45098. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45100. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45101. import { Effect } from "babylonjs/Materials/effect";
  45102. /**
  45103. * A directional light is defined by a direction (what a surprise!).
  45104. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45105. * 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.
  45106. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45107. */
  45108. export class DirectionalLight extends ShadowLight {
  45109. private _shadowFrustumSize;
  45110. /**
  45111. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45112. */
  45113. /**
  45114. * Specifies a fix frustum size for the shadow generation.
  45115. */
  45116. shadowFrustumSize: number;
  45117. private _shadowOrthoScale;
  45118. /**
  45119. * Gets the shadow projection scale against the optimal computed one.
  45120. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45121. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45122. */
  45123. /**
  45124. * Sets the shadow projection scale against the optimal computed one.
  45125. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45126. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45127. */
  45128. shadowOrthoScale: number;
  45129. /**
  45130. * Automatically compute the projection matrix to best fit (including all the casters)
  45131. * on each frame.
  45132. */
  45133. autoUpdateExtends: boolean;
  45134. private _orthoLeft;
  45135. private _orthoRight;
  45136. private _orthoTop;
  45137. private _orthoBottom;
  45138. /**
  45139. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45140. * The directional light is emitted from everywhere in the given direction.
  45141. * It can cast shadows.
  45142. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45143. * @param name The friendly name of the light
  45144. * @param direction The direction of the light
  45145. * @param scene The scene the light belongs to
  45146. */
  45147. constructor(name: string, direction: Vector3, scene: Scene);
  45148. /**
  45149. * Returns the string "DirectionalLight".
  45150. * @return The class name
  45151. */
  45152. getClassName(): string;
  45153. /**
  45154. * Returns the integer 1.
  45155. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45156. */
  45157. getTypeID(): number;
  45158. /**
  45159. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45160. * Returns the DirectionalLight Shadow projection matrix.
  45161. */
  45162. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45163. /**
  45164. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45165. * Returns the DirectionalLight Shadow projection matrix.
  45166. */
  45167. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45168. /**
  45169. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45170. * Returns the DirectionalLight Shadow projection matrix.
  45171. */
  45172. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45173. protected _buildUniformLayout(): void;
  45174. /**
  45175. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45176. * @param effect The effect to update
  45177. * @param lightIndex The index of the light in the effect to update
  45178. * @returns The directional light
  45179. */
  45180. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45181. /**
  45182. * Gets the minZ used for shadow according to both the scene and the light.
  45183. *
  45184. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45185. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45186. * @param activeCamera The camera we are returning the min for
  45187. * @returns the depth min z
  45188. */
  45189. getDepthMinZ(activeCamera: Camera): number;
  45190. /**
  45191. * Gets the maxZ used for shadow according to both the scene and the light.
  45192. *
  45193. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45194. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45195. * @param activeCamera The camera we are returning the max for
  45196. * @returns the depth max z
  45197. */
  45198. getDepthMaxZ(activeCamera: Camera): number;
  45199. /**
  45200. * Prepares the list of defines specific to the light type.
  45201. * @param defines the list of defines
  45202. * @param lightIndex defines the index of the light for the effect
  45203. */
  45204. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45205. }
  45206. }
  45207. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45208. import { Mesh } from "babylonjs/Meshes/mesh";
  45209. /**
  45210. * Class containing static functions to help procedurally build meshes
  45211. */
  45212. export class HemisphereBuilder {
  45213. /**
  45214. * Creates a hemisphere mesh
  45215. * @param name defines the name of the mesh
  45216. * @param options defines the options used to create the mesh
  45217. * @param scene defines the hosting scene
  45218. * @returns the hemisphere mesh
  45219. */
  45220. static CreateHemisphere(name: string, options: {
  45221. segments?: number;
  45222. diameter?: number;
  45223. sideOrientation?: number;
  45224. }, scene: any): Mesh;
  45225. }
  45226. }
  45227. declare module "babylonjs/Lights/spotLight" {
  45228. import { Nullable } from "babylonjs/types";
  45229. import { Scene } from "babylonjs/scene";
  45230. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45232. import { Effect } from "babylonjs/Materials/effect";
  45233. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45234. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45235. /**
  45236. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45237. * These values define a cone of light starting from the position, emitting toward the direction.
  45238. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45239. * and the exponent defines the speed of the decay of the light with distance (reach).
  45240. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45241. */
  45242. export class SpotLight extends ShadowLight {
  45243. private _angle;
  45244. private _innerAngle;
  45245. private _cosHalfAngle;
  45246. private _lightAngleScale;
  45247. private _lightAngleOffset;
  45248. /**
  45249. * Gets the cone angle of the spot light in Radians.
  45250. */
  45251. /**
  45252. * Sets the cone angle of the spot light in Radians.
  45253. */
  45254. angle: number;
  45255. /**
  45256. * Only used in gltf falloff mode, this defines the angle where
  45257. * the directional falloff will start before cutting at angle which could be seen
  45258. * as outer angle.
  45259. */
  45260. /**
  45261. * Only used in gltf falloff mode, this defines the angle where
  45262. * the directional falloff will start before cutting at angle which could be seen
  45263. * as outer angle.
  45264. */
  45265. innerAngle: number;
  45266. private _shadowAngleScale;
  45267. /**
  45268. * Allows scaling the angle of the light for shadow generation only.
  45269. */
  45270. /**
  45271. * Allows scaling the angle of the light for shadow generation only.
  45272. */
  45273. shadowAngleScale: number;
  45274. /**
  45275. * The light decay speed with the distance from the emission spot.
  45276. */
  45277. exponent: number;
  45278. private _projectionTextureMatrix;
  45279. /**
  45280. * Allows reading the projecton texture
  45281. */
  45282. readonly projectionTextureMatrix: Matrix;
  45283. protected _projectionTextureLightNear: number;
  45284. /**
  45285. * Gets the near clip of the Spotlight for texture projection.
  45286. */
  45287. /**
  45288. * Sets the near clip of the Spotlight for texture projection.
  45289. */
  45290. projectionTextureLightNear: number;
  45291. protected _projectionTextureLightFar: number;
  45292. /**
  45293. * Gets the far clip of the Spotlight for texture projection.
  45294. */
  45295. /**
  45296. * Sets the far clip of the Spotlight for texture projection.
  45297. */
  45298. projectionTextureLightFar: number;
  45299. protected _projectionTextureUpDirection: Vector3;
  45300. /**
  45301. * Gets the Up vector of the Spotlight for texture projection.
  45302. */
  45303. /**
  45304. * Sets the Up vector of the Spotlight for texture projection.
  45305. */
  45306. projectionTextureUpDirection: Vector3;
  45307. private _projectionTexture;
  45308. /**
  45309. * Gets the projection texture of the light.
  45310. */
  45311. /**
  45312. * Sets the projection texture of the light.
  45313. */
  45314. projectionTexture: Nullable<BaseTexture>;
  45315. private _projectionTextureViewLightDirty;
  45316. private _projectionTextureProjectionLightDirty;
  45317. private _projectionTextureDirty;
  45318. private _projectionTextureViewTargetVector;
  45319. private _projectionTextureViewLightMatrix;
  45320. private _projectionTextureProjectionLightMatrix;
  45321. private _projectionTextureScalingMatrix;
  45322. /**
  45323. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45324. * It can cast shadows.
  45325. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45326. * @param name The light friendly name
  45327. * @param position The position of the spot light in the scene
  45328. * @param direction The direction of the light in the scene
  45329. * @param angle The cone angle of the light in Radians
  45330. * @param exponent The light decay speed with the distance from the emission spot
  45331. * @param scene The scene the lights belongs to
  45332. */
  45333. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45334. /**
  45335. * Returns the string "SpotLight".
  45336. * @returns the class name
  45337. */
  45338. getClassName(): string;
  45339. /**
  45340. * Returns the integer 2.
  45341. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45342. */
  45343. getTypeID(): number;
  45344. /**
  45345. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45346. */
  45347. protected _setDirection(value: Vector3): void;
  45348. /**
  45349. * Overrides the position setter to recompute the projection texture view light Matrix.
  45350. */
  45351. protected _setPosition(value: Vector3): void;
  45352. /**
  45353. * 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.
  45354. * Returns the SpotLight.
  45355. */
  45356. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45357. protected _computeProjectionTextureViewLightMatrix(): void;
  45358. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45359. /**
  45360. * Main function for light texture projection matrix computing.
  45361. */
  45362. protected _computeProjectionTextureMatrix(): void;
  45363. protected _buildUniformLayout(): void;
  45364. private _computeAngleValues;
  45365. /**
  45366. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45367. * @param effect The effect to update
  45368. * @param lightIndex The index of the light in the effect to update
  45369. * @returns The spot light
  45370. */
  45371. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45372. /**
  45373. * Disposes the light and the associated resources.
  45374. */
  45375. dispose(): void;
  45376. /**
  45377. * Prepares the list of defines specific to the light type.
  45378. * @param defines the list of defines
  45379. * @param lightIndex defines the index of the light for the effect
  45380. */
  45381. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45382. }
  45383. }
  45384. declare module "babylonjs/Gizmos/lightGizmo" {
  45385. import { Nullable } from "babylonjs/types";
  45386. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45387. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45388. import { Light } from "babylonjs/Lights/light";
  45389. /**
  45390. * Gizmo that enables viewing a light
  45391. */
  45392. export class LightGizmo extends Gizmo {
  45393. private _lightMesh;
  45394. private _material;
  45395. private cachedPosition;
  45396. private cachedForward;
  45397. /**
  45398. * Creates a LightGizmo
  45399. * @param gizmoLayer The utility layer the gizmo will be added to
  45400. */
  45401. constructor(gizmoLayer?: UtilityLayerRenderer);
  45402. private _light;
  45403. /**
  45404. * The light that the gizmo is attached to
  45405. */
  45406. light: Nullable<Light>;
  45407. /**
  45408. * @hidden
  45409. * Updates the gizmo to match the attached mesh's position/rotation
  45410. */
  45411. protected _update(): void;
  45412. private static _Scale;
  45413. /**
  45414. * Creates the lines for a light mesh
  45415. */
  45416. private static _createLightLines;
  45417. /**
  45418. * Disposes of the light gizmo
  45419. */
  45420. dispose(): void;
  45421. private static _CreateHemisphericLightMesh;
  45422. private static _CreatePointLightMesh;
  45423. private static _CreateSpotLightMesh;
  45424. private static _CreateDirectionalLightMesh;
  45425. }
  45426. }
  45427. declare module "babylonjs/Gizmos/index" {
  45428. export * from "babylonjs/Gizmos/axisDragGizmo";
  45429. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45430. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45431. export * from "babylonjs/Gizmos/gizmo";
  45432. export * from "babylonjs/Gizmos/gizmoManager";
  45433. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45434. export * from "babylonjs/Gizmos/positionGizmo";
  45435. export * from "babylonjs/Gizmos/rotationGizmo";
  45436. export * from "babylonjs/Gizmos/scaleGizmo";
  45437. export * from "babylonjs/Gizmos/lightGizmo";
  45438. }
  45439. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45440. /** @hidden */
  45441. export var backgroundFragmentDeclaration: {
  45442. name: string;
  45443. shader: string;
  45444. };
  45445. }
  45446. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45447. /** @hidden */
  45448. export var backgroundUboDeclaration: {
  45449. name: string;
  45450. shader: string;
  45451. };
  45452. }
  45453. declare module "babylonjs/Shaders/background.fragment" {
  45454. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45455. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45456. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45457. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45458. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45459. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45460. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45461. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45462. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45463. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45464. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45465. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45466. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45467. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45468. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45469. /** @hidden */
  45470. export var backgroundPixelShader: {
  45471. name: string;
  45472. shader: string;
  45473. };
  45474. }
  45475. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45476. /** @hidden */
  45477. export var backgroundVertexDeclaration: {
  45478. name: string;
  45479. shader: string;
  45480. };
  45481. }
  45482. declare module "babylonjs/Shaders/background.vertex" {
  45483. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45484. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45485. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45486. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45487. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45488. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45489. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45490. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45491. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45492. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45493. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45494. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45495. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45496. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45497. /** @hidden */
  45498. export var backgroundVertexShader: {
  45499. name: string;
  45500. shader: string;
  45501. };
  45502. }
  45503. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45504. import { Nullable, int, float } from "babylonjs/types";
  45505. import { Scene } from "babylonjs/scene";
  45506. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45507. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45509. import { Mesh } from "babylonjs/Meshes/mesh";
  45510. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45511. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45512. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45513. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45514. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45515. import "babylonjs/Shaders/background.fragment";
  45516. import "babylonjs/Shaders/background.vertex";
  45517. /**
  45518. * Background material used to create an efficient environement around your scene.
  45519. */
  45520. export class BackgroundMaterial extends PushMaterial {
  45521. /**
  45522. * Standard reflectance value at parallel view angle.
  45523. */
  45524. static StandardReflectance0: number;
  45525. /**
  45526. * Standard reflectance value at grazing angle.
  45527. */
  45528. static StandardReflectance90: number;
  45529. protected _primaryColor: Color3;
  45530. /**
  45531. * Key light Color (multiply against the environement texture)
  45532. */
  45533. primaryColor: Color3;
  45534. protected __perceptualColor: Nullable<Color3>;
  45535. /**
  45536. * Experimental Internal Use Only.
  45537. *
  45538. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45539. * This acts as a helper to set the primary color to a more "human friendly" value.
  45540. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45541. * output color as close as possible from the chosen value.
  45542. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45543. * part of lighting setup.)
  45544. */
  45545. _perceptualColor: Nullable<Color3>;
  45546. protected _primaryColorShadowLevel: float;
  45547. /**
  45548. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45549. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45550. */
  45551. primaryColorShadowLevel: float;
  45552. protected _primaryColorHighlightLevel: float;
  45553. /**
  45554. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45555. * The primary color is used at the level chosen to define what the white area would look.
  45556. */
  45557. primaryColorHighlightLevel: float;
  45558. protected _reflectionTexture: Nullable<BaseTexture>;
  45559. /**
  45560. * Reflection Texture used in the material.
  45561. * Should be author in a specific way for the best result (refer to the documentation).
  45562. */
  45563. reflectionTexture: Nullable<BaseTexture>;
  45564. protected _reflectionBlur: float;
  45565. /**
  45566. * Reflection Texture level of blur.
  45567. *
  45568. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45569. * texture twice.
  45570. */
  45571. reflectionBlur: float;
  45572. protected _diffuseTexture: Nullable<BaseTexture>;
  45573. /**
  45574. * Diffuse Texture used in the material.
  45575. * Should be author in a specific way for the best result (refer to the documentation).
  45576. */
  45577. diffuseTexture: Nullable<BaseTexture>;
  45578. protected _shadowLights: Nullable<IShadowLight[]>;
  45579. /**
  45580. * Specify the list of lights casting shadow on the material.
  45581. * All scene shadow lights will be included if null.
  45582. */
  45583. shadowLights: Nullable<IShadowLight[]>;
  45584. protected _shadowLevel: float;
  45585. /**
  45586. * Helps adjusting the shadow to a softer level if required.
  45587. * 0 means black shadows and 1 means no shadows.
  45588. */
  45589. shadowLevel: float;
  45590. protected _sceneCenter: Vector3;
  45591. /**
  45592. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45593. * It is usually zero but might be interesting to modify according to your setup.
  45594. */
  45595. sceneCenter: Vector3;
  45596. protected _opacityFresnel: boolean;
  45597. /**
  45598. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45599. * This helps ensuring a nice transition when the camera goes under the ground.
  45600. */
  45601. opacityFresnel: boolean;
  45602. protected _reflectionFresnel: boolean;
  45603. /**
  45604. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45605. * This helps adding a mirror texture on the ground.
  45606. */
  45607. reflectionFresnel: boolean;
  45608. protected _reflectionFalloffDistance: number;
  45609. /**
  45610. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45611. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45612. */
  45613. reflectionFalloffDistance: number;
  45614. protected _reflectionAmount: number;
  45615. /**
  45616. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45617. */
  45618. reflectionAmount: number;
  45619. protected _reflectionReflectance0: number;
  45620. /**
  45621. * This specifies the weight of the reflection at grazing angle.
  45622. */
  45623. reflectionReflectance0: number;
  45624. protected _reflectionReflectance90: number;
  45625. /**
  45626. * This specifies the weight of the reflection at a perpendicular point of view.
  45627. */
  45628. reflectionReflectance90: number;
  45629. /**
  45630. * Sets the reflection reflectance fresnel values according to the default standard
  45631. * empirically know to work well :-)
  45632. */
  45633. reflectionStandardFresnelWeight: number;
  45634. protected _useRGBColor: boolean;
  45635. /**
  45636. * Helps to directly use the maps channels instead of their level.
  45637. */
  45638. useRGBColor: boolean;
  45639. protected _enableNoise: boolean;
  45640. /**
  45641. * This helps reducing the banding effect that could occur on the background.
  45642. */
  45643. enableNoise: boolean;
  45644. /**
  45645. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45646. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45647. * Recommended to be keep at 1.0 except for special cases.
  45648. */
  45649. fovMultiplier: number;
  45650. private _fovMultiplier;
  45651. /**
  45652. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45653. */
  45654. useEquirectangularFOV: boolean;
  45655. private _maxSimultaneousLights;
  45656. /**
  45657. * Number of Simultaneous lights allowed on the material.
  45658. */
  45659. maxSimultaneousLights: int;
  45660. /**
  45661. * Default configuration related to image processing available in the Background Material.
  45662. */
  45663. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45664. /**
  45665. * Keep track of the image processing observer to allow dispose and replace.
  45666. */
  45667. private _imageProcessingObserver;
  45668. /**
  45669. * Attaches a new image processing configuration to the PBR Material.
  45670. * @param configuration (if null the scene configuration will be use)
  45671. */
  45672. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45673. /**
  45674. * Gets the image processing configuration used either in this material.
  45675. */
  45676. /**
  45677. * Sets the Default image processing configuration used either in the this material.
  45678. *
  45679. * If sets to null, the scene one is in use.
  45680. */
  45681. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45682. /**
  45683. * Gets wether the color curves effect is enabled.
  45684. */
  45685. /**
  45686. * Sets wether the color curves effect is enabled.
  45687. */
  45688. cameraColorCurvesEnabled: boolean;
  45689. /**
  45690. * Gets wether the color grading effect is enabled.
  45691. */
  45692. /**
  45693. * Gets wether the color grading effect is enabled.
  45694. */
  45695. cameraColorGradingEnabled: boolean;
  45696. /**
  45697. * Gets wether tonemapping is enabled or not.
  45698. */
  45699. /**
  45700. * Sets wether tonemapping is enabled or not
  45701. */
  45702. cameraToneMappingEnabled: boolean;
  45703. /**
  45704. * The camera exposure used on this material.
  45705. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45706. * This corresponds to a photographic exposure.
  45707. */
  45708. /**
  45709. * The camera exposure used on this material.
  45710. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45711. * This corresponds to a photographic exposure.
  45712. */
  45713. cameraExposure: float;
  45714. /**
  45715. * Gets The camera contrast used on this material.
  45716. */
  45717. /**
  45718. * Sets The camera contrast used on this material.
  45719. */
  45720. cameraContrast: float;
  45721. /**
  45722. * Gets the Color Grading 2D Lookup Texture.
  45723. */
  45724. /**
  45725. * Sets the Color Grading 2D Lookup Texture.
  45726. */
  45727. cameraColorGradingTexture: Nullable<BaseTexture>;
  45728. /**
  45729. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45730. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45731. * 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;
  45732. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45733. */
  45734. /**
  45735. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45736. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45737. * 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;
  45738. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45739. */
  45740. cameraColorCurves: Nullable<ColorCurves>;
  45741. /**
  45742. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45743. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45744. */
  45745. switchToBGR: boolean;
  45746. private _renderTargets;
  45747. private _reflectionControls;
  45748. private _white;
  45749. private _primaryShadowColor;
  45750. private _primaryHighlightColor;
  45751. /**
  45752. * Instantiates a Background Material in the given scene
  45753. * @param name The friendly name of the material
  45754. * @param scene The scene to add the material to
  45755. */
  45756. constructor(name: string, scene: Scene);
  45757. /**
  45758. * Gets a boolean indicating that current material needs to register RTT
  45759. */
  45760. readonly hasRenderTargetTextures: boolean;
  45761. /**
  45762. * The entire material has been created in order to prevent overdraw.
  45763. * @returns false
  45764. */
  45765. needAlphaTesting(): boolean;
  45766. /**
  45767. * The entire material has been created in order to prevent overdraw.
  45768. * @returns true if blending is enable
  45769. */
  45770. needAlphaBlending(): boolean;
  45771. /**
  45772. * Checks wether the material is ready to be rendered for a given mesh.
  45773. * @param mesh The mesh to render
  45774. * @param subMesh The submesh to check against
  45775. * @param useInstances Specify wether or not the material is used with instances
  45776. * @returns true if all the dependencies are ready (Textures, Effects...)
  45777. */
  45778. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45779. /**
  45780. * Compute the primary color according to the chosen perceptual color.
  45781. */
  45782. private _computePrimaryColorFromPerceptualColor;
  45783. /**
  45784. * Compute the highlights and shadow colors according to their chosen levels.
  45785. */
  45786. private _computePrimaryColors;
  45787. /**
  45788. * Build the uniform buffer used in the material.
  45789. */
  45790. buildUniformLayout(): void;
  45791. /**
  45792. * Unbind the material.
  45793. */
  45794. unbind(): void;
  45795. /**
  45796. * Bind only the world matrix to the material.
  45797. * @param world The world matrix to bind.
  45798. */
  45799. bindOnlyWorldMatrix(world: Matrix): void;
  45800. /**
  45801. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45802. * @param world The world matrix to bind.
  45803. * @param subMesh The submesh to bind for.
  45804. */
  45805. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45806. /**
  45807. * Dispose the material.
  45808. * @param forceDisposeEffect Force disposal of the associated effect.
  45809. * @param forceDisposeTextures Force disposal of the associated textures.
  45810. */
  45811. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45812. /**
  45813. * Clones the material.
  45814. * @param name The cloned name.
  45815. * @returns The cloned material.
  45816. */
  45817. clone(name: string): BackgroundMaterial;
  45818. /**
  45819. * Serializes the current material to its JSON representation.
  45820. * @returns The JSON representation.
  45821. */
  45822. serialize(): any;
  45823. /**
  45824. * Gets the class name of the material
  45825. * @returns "BackgroundMaterial"
  45826. */
  45827. getClassName(): string;
  45828. /**
  45829. * Parse a JSON input to create back a background material.
  45830. * @param source The JSON data to parse
  45831. * @param scene The scene to create the parsed material in
  45832. * @param rootUrl The root url of the assets the material depends upon
  45833. * @returns the instantiated BackgroundMaterial.
  45834. */
  45835. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45836. }
  45837. }
  45838. declare module "babylonjs/Helpers/environmentHelper" {
  45839. import { Observable } from "babylonjs/Misc/observable";
  45840. import { Nullable } from "babylonjs/types";
  45841. import { Scene } from "babylonjs/scene";
  45842. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45844. import { Mesh } from "babylonjs/Meshes/mesh";
  45845. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45846. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45847. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45848. import "babylonjs/Meshes/Builders/planeBuilder";
  45849. import "babylonjs/Meshes/Builders/boxBuilder";
  45850. /**
  45851. * Represents the different options available during the creation of
  45852. * a Environment helper.
  45853. *
  45854. * This can control the default ground, skybox and image processing setup of your scene.
  45855. */
  45856. export interface IEnvironmentHelperOptions {
  45857. /**
  45858. * Specifies wether or not to create a ground.
  45859. * True by default.
  45860. */
  45861. createGround: boolean;
  45862. /**
  45863. * Specifies the ground size.
  45864. * 15 by default.
  45865. */
  45866. groundSize: number;
  45867. /**
  45868. * The texture used on the ground for the main color.
  45869. * Comes from the BabylonJS CDN by default.
  45870. *
  45871. * Remarks: Can be either a texture or a url.
  45872. */
  45873. groundTexture: string | BaseTexture;
  45874. /**
  45875. * The color mixed in the ground texture by default.
  45876. * BabylonJS clearColor by default.
  45877. */
  45878. groundColor: Color3;
  45879. /**
  45880. * Specifies the ground opacity.
  45881. * 1 by default.
  45882. */
  45883. groundOpacity: number;
  45884. /**
  45885. * Enables the ground to receive shadows.
  45886. * True by default.
  45887. */
  45888. enableGroundShadow: boolean;
  45889. /**
  45890. * Helps preventing the shadow to be fully black on the ground.
  45891. * 0.5 by default.
  45892. */
  45893. groundShadowLevel: number;
  45894. /**
  45895. * Creates a mirror texture attach to the ground.
  45896. * false by default.
  45897. */
  45898. enableGroundMirror: boolean;
  45899. /**
  45900. * Specifies the ground mirror size ratio.
  45901. * 0.3 by default as the default kernel is 64.
  45902. */
  45903. groundMirrorSizeRatio: number;
  45904. /**
  45905. * Specifies the ground mirror blur kernel size.
  45906. * 64 by default.
  45907. */
  45908. groundMirrorBlurKernel: number;
  45909. /**
  45910. * Specifies the ground mirror visibility amount.
  45911. * 1 by default
  45912. */
  45913. groundMirrorAmount: number;
  45914. /**
  45915. * Specifies the ground mirror reflectance weight.
  45916. * This uses the standard weight of the background material to setup the fresnel effect
  45917. * of the mirror.
  45918. * 1 by default.
  45919. */
  45920. groundMirrorFresnelWeight: number;
  45921. /**
  45922. * Specifies the ground mirror Falloff distance.
  45923. * This can helps reducing the size of the reflection.
  45924. * 0 by Default.
  45925. */
  45926. groundMirrorFallOffDistance: number;
  45927. /**
  45928. * Specifies the ground mirror texture type.
  45929. * Unsigned Int by Default.
  45930. */
  45931. groundMirrorTextureType: number;
  45932. /**
  45933. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45934. * the shown objects.
  45935. */
  45936. groundYBias: number;
  45937. /**
  45938. * Specifies wether or not to create a skybox.
  45939. * True by default.
  45940. */
  45941. createSkybox: boolean;
  45942. /**
  45943. * Specifies the skybox size.
  45944. * 20 by default.
  45945. */
  45946. skyboxSize: number;
  45947. /**
  45948. * The texture used on the skybox for the main color.
  45949. * Comes from the BabylonJS CDN by default.
  45950. *
  45951. * Remarks: Can be either a texture or a url.
  45952. */
  45953. skyboxTexture: string | BaseTexture;
  45954. /**
  45955. * The color mixed in the skybox texture by default.
  45956. * BabylonJS clearColor by default.
  45957. */
  45958. skyboxColor: Color3;
  45959. /**
  45960. * The background rotation around the Y axis of the scene.
  45961. * This helps aligning the key lights of your scene with the background.
  45962. * 0 by default.
  45963. */
  45964. backgroundYRotation: number;
  45965. /**
  45966. * Compute automatically the size of the elements to best fit with the scene.
  45967. */
  45968. sizeAuto: boolean;
  45969. /**
  45970. * Default position of the rootMesh if autoSize is not true.
  45971. */
  45972. rootPosition: Vector3;
  45973. /**
  45974. * Sets up the image processing in the scene.
  45975. * true by default.
  45976. */
  45977. setupImageProcessing: boolean;
  45978. /**
  45979. * The texture used as your environment texture in the scene.
  45980. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45981. *
  45982. * Remarks: Can be either a texture or a url.
  45983. */
  45984. environmentTexture: string | BaseTexture;
  45985. /**
  45986. * The value of the exposure to apply to the scene.
  45987. * 0.6 by default if setupImageProcessing is true.
  45988. */
  45989. cameraExposure: number;
  45990. /**
  45991. * The value of the contrast to apply to the scene.
  45992. * 1.6 by default if setupImageProcessing is true.
  45993. */
  45994. cameraContrast: number;
  45995. /**
  45996. * Specifies wether or not tonemapping should be enabled in the scene.
  45997. * true by default if setupImageProcessing is true.
  45998. */
  45999. toneMappingEnabled: boolean;
  46000. }
  46001. /**
  46002. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46003. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46004. * It also helps with the default setup of your imageProcessing configuration.
  46005. */
  46006. export class EnvironmentHelper {
  46007. /**
  46008. * Default ground texture URL.
  46009. */
  46010. private static _groundTextureCDNUrl;
  46011. /**
  46012. * Default skybox texture URL.
  46013. */
  46014. private static _skyboxTextureCDNUrl;
  46015. /**
  46016. * Default environment texture URL.
  46017. */
  46018. private static _environmentTextureCDNUrl;
  46019. /**
  46020. * Creates the default options for the helper.
  46021. */
  46022. private static _getDefaultOptions;
  46023. private _rootMesh;
  46024. /**
  46025. * Gets the root mesh created by the helper.
  46026. */
  46027. readonly rootMesh: Mesh;
  46028. private _skybox;
  46029. /**
  46030. * Gets the skybox created by the helper.
  46031. */
  46032. readonly skybox: Nullable<Mesh>;
  46033. private _skyboxTexture;
  46034. /**
  46035. * Gets the skybox texture created by the helper.
  46036. */
  46037. readonly skyboxTexture: Nullable<BaseTexture>;
  46038. private _skyboxMaterial;
  46039. /**
  46040. * Gets the skybox material created by the helper.
  46041. */
  46042. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46043. private _ground;
  46044. /**
  46045. * Gets the ground mesh created by the helper.
  46046. */
  46047. readonly ground: Nullable<Mesh>;
  46048. private _groundTexture;
  46049. /**
  46050. * Gets the ground texture created by the helper.
  46051. */
  46052. readonly groundTexture: Nullable<BaseTexture>;
  46053. private _groundMirror;
  46054. /**
  46055. * Gets the ground mirror created by the helper.
  46056. */
  46057. readonly groundMirror: Nullable<MirrorTexture>;
  46058. /**
  46059. * Gets the ground mirror render list to helps pushing the meshes
  46060. * you wish in the ground reflection.
  46061. */
  46062. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46063. private _groundMaterial;
  46064. /**
  46065. * Gets the ground material created by the helper.
  46066. */
  46067. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46068. /**
  46069. * Stores the creation options.
  46070. */
  46071. private readonly _scene;
  46072. private _options;
  46073. /**
  46074. * This observable will be notified with any error during the creation of the environment,
  46075. * mainly texture creation errors.
  46076. */
  46077. onErrorObservable: Observable<{
  46078. message?: string;
  46079. exception?: any;
  46080. }>;
  46081. /**
  46082. * constructor
  46083. * @param options Defines the options we want to customize the helper
  46084. * @param scene The scene to add the material to
  46085. */
  46086. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46087. /**
  46088. * Updates the background according to the new options
  46089. * @param options
  46090. */
  46091. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46092. /**
  46093. * Sets the primary color of all the available elements.
  46094. * @param color the main color to affect to the ground and the background
  46095. */
  46096. setMainColor(color: Color3): void;
  46097. /**
  46098. * Setup the image processing according to the specified options.
  46099. */
  46100. private _setupImageProcessing;
  46101. /**
  46102. * Setup the environment texture according to the specified options.
  46103. */
  46104. private _setupEnvironmentTexture;
  46105. /**
  46106. * Setup the background according to the specified options.
  46107. */
  46108. private _setupBackground;
  46109. /**
  46110. * Get the scene sizes according to the setup.
  46111. */
  46112. private _getSceneSize;
  46113. /**
  46114. * Setup the ground according to the specified options.
  46115. */
  46116. private _setupGround;
  46117. /**
  46118. * Setup the ground material according to the specified options.
  46119. */
  46120. private _setupGroundMaterial;
  46121. /**
  46122. * Setup the ground diffuse texture according to the specified options.
  46123. */
  46124. private _setupGroundDiffuseTexture;
  46125. /**
  46126. * Setup the ground mirror texture according to the specified options.
  46127. */
  46128. private _setupGroundMirrorTexture;
  46129. /**
  46130. * Setup the ground to receive the mirror texture.
  46131. */
  46132. private _setupMirrorInGroundMaterial;
  46133. /**
  46134. * Setup the skybox according to the specified options.
  46135. */
  46136. private _setupSkybox;
  46137. /**
  46138. * Setup the skybox material according to the specified options.
  46139. */
  46140. private _setupSkyboxMaterial;
  46141. /**
  46142. * Setup the skybox reflection texture according to the specified options.
  46143. */
  46144. private _setupSkyboxReflectionTexture;
  46145. private _errorHandler;
  46146. /**
  46147. * Dispose all the elements created by the Helper.
  46148. */
  46149. dispose(): void;
  46150. }
  46151. }
  46152. declare module "babylonjs/Helpers/photoDome" {
  46153. import { Observable } from "babylonjs/Misc/observable";
  46154. import { Nullable } from "babylonjs/types";
  46155. import { Scene } from "babylonjs/scene";
  46156. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46157. import { Mesh } from "babylonjs/Meshes/mesh";
  46158. import { Texture } from "babylonjs/Materials/Textures/texture";
  46159. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46160. import "babylonjs/Meshes/Builders/sphereBuilder";
  46161. /**
  46162. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46163. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46164. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46165. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46166. */
  46167. export class PhotoDome extends TransformNode {
  46168. /**
  46169. * Define the image as a Monoscopic panoramic 360 image.
  46170. */
  46171. static readonly MODE_MONOSCOPIC: number;
  46172. /**
  46173. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46174. */
  46175. static readonly MODE_TOPBOTTOM: number;
  46176. /**
  46177. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46178. */
  46179. static readonly MODE_SIDEBYSIDE: number;
  46180. private _useDirectMapping;
  46181. /**
  46182. * The texture being displayed on the sphere
  46183. */
  46184. protected _photoTexture: Texture;
  46185. /**
  46186. * Gets or sets the texture being displayed on the sphere
  46187. */
  46188. photoTexture: Texture;
  46189. /**
  46190. * Observable raised when an error occured while loading the 360 image
  46191. */
  46192. onLoadErrorObservable: Observable<string>;
  46193. /**
  46194. * The skybox material
  46195. */
  46196. protected _material: BackgroundMaterial;
  46197. /**
  46198. * The surface used for the skybox
  46199. */
  46200. protected _mesh: Mesh;
  46201. /**
  46202. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46203. * Also see the options.resolution property.
  46204. */
  46205. fovMultiplier: number;
  46206. private _imageMode;
  46207. /**
  46208. * Gets or set the current video mode for the video. It can be:
  46209. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46210. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46211. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46212. */
  46213. imageMode: number;
  46214. /**
  46215. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46216. * @param name Element's name, child elements will append suffixes for their own names.
  46217. * @param urlsOfPhoto defines the url of the photo to display
  46218. * @param options defines an object containing optional or exposed sub element properties
  46219. * @param onError defines a callback called when an error occured while loading the texture
  46220. */
  46221. constructor(name: string, urlOfPhoto: string, options: {
  46222. resolution?: number;
  46223. size?: number;
  46224. useDirectMapping?: boolean;
  46225. faceForward?: boolean;
  46226. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46227. private _onBeforeCameraRenderObserver;
  46228. private _changeImageMode;
  46229. /**
  46230. * Releases resources associated with this node.
  46231. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46232. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46233. */
  46234. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46235. }
  46236. }
  46237. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46238. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46239. /** @hidden */
  46240. export var rgbdDecodePixelShader: {
  46241. name: string;
  46242. shader: string;
  46243. };
  46244. }
  46245. declare module "babylonjs/Misc/brdfTextureTools" {
  46246. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46247. import { Scene } from "babylonjs/scene";
  46248. import "babylonjs/Shaders/rgbdDecode.fragment";
  46249. /**
  46250. * Class used to host texture specific utilities
  46251. */
  46252. export class BRDFTextureTools {
  46253. /**
  46254. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46255. * @param texture the texture to expand.
  46256. */
  46257. private static _ExpandDefaultBRDFTexture;
  46258. /**
  46259. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46260. * @param scene defines the hosting scene
  46261. * @returns the environment BRDF texture
  46262. */
  46263. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46264. private static _environmentBRDFBase64Texture;
  46265. }
  46266. }
  46267. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46268. import { Nullable } from "babylonjs/types";
  46269. import { IAnimatable } from "babylonjs/Misc/tools";
  46270. import { Color3 } from "babylonjs/Maths/math";
  46271. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46272. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46273. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46274. import { Engine } from "babylonjs/Engines/engine";
  46275. import { Scene } from "babylonjs/scene";
  46276. /**
  46277. * @hidden
  46278. */
  46279. export interface IMaterialClearCoatDefines {
  46280. CLEARCOAT: boolean;
  46281. CLEARCOAT_DEFAULTIOR: boolean;
  46282. CLEARCOAT_TEXTURE: boolean;
  46283. CLEARCOAT_TEXTUREDIRECTUV: number;
  46284. CLEARCOAT_BUMP: boolean;
  46285. CLEARCOAT_BUMPDIRECTUV: number;
  46286. CLEARCOAT_TINT: boolean;
  46287. CLEARCOAT_TINT_TEXTURE: boolean;
  46288. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46289. /** @hidden */
  46290. _areTexturesDirty: boolean;
  46291. }
  46292. /**
  46293. * Define the code related to the clear coat parameters of the pbr material.
  46294. */
  46295. export class PBRClearCoatConfiguration {
  46296. /**
  46297. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46298. * The default fits with a polyurethane material.
  46299. */
  46300. private static readonly _DefaultIndexOfRefraction;
  46301. private _isEnabled;
  46302. /**
  46303. * Defines if the clear coat is enabled in the material.
  46304. */
  46305. isEnabled: boolean;
  46306. /**
  46307. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46308. */
  46309. intensity: number;
  46310. /**
  46311. * Defines the clear coat layer roughness.
  46312. */
  46313. roughness: number;
  46314. private _indexOfRefraction;
  46315. /**
  46316. * Defines the index of refraction of the clear coat.
  46317. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46318. * The default fits with a polyurethane material.
  46319. * Changing the default value is more performance intensive.
  46320. */
  46321. indexOfRefraction: number;
  46322. private _texture;
  46323. /**
  46324. * Stores the clear coat values in a texture.
  46325. */
  46326. texture: Nullable<BaseTexture>;
  46327. private _bumpTexture;
  46328. /**
  46329. * Define the clear coat specific bump texture.
  46330. */
  46331. bumpTexture: Nullable<BaseTexture>;
  46332. private _isTintEnabled;
  46333. /**
  46334. * Defines if the clear coat tint is enabled in the material.
  46335. */
  46336. isTintEnabled: boolean;
  46337. /**
  46338. * Defines the clear coat tint of the material.
  46339. * This is only use if tint is enabled
  46340. */
  46341. tintColor: Color3;
  46342. /**
  46343. * Defines the distance at which the tint color should be found in the
  46344. * clear coat media.
  46345. * This is only use if tint is enabled
  46346. */
  46347. tintColorAtDistance: number;
  46348. /**
  46349. * Defines the clear coat layer thickness.
  46350. * This is only use if tint is enabled
  46351. */
  46352. tintThickness: number;
  46353. private _tintTexture;
  46354. /**
  46355. * Stores the clear tint values in a texture.
  46356. * rgb is tint
  46357. * a is a thickness factor
  46358. */
  46359. tintTexture: Nullable<BaseTexture>;
  46360. /** @hidden */
  46361. private _internalMarkAllSubMeshesAsTexturesDirty;
  46362. /** @hidden */
  46363. _markAllSubMeshesAsTexturesDirty(): void;
  46364. /**
  46365. * Instantiate a new istance of clear coat configuration.
  46366. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46367. */
  46368. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46369. /**
  46370. * Gets wehter the submesh is ready to be used or not.
  46371. * @param defines the list of "defines" to update.
  46372. * @param scene defines the scene the material belongs to.
  46373. * @param engine defines the engine the material belongs to.
  46374. * @param disableBumpMap defines wether the material disables bump or not.
  46375. * @returns - boolean indicating that the submesh is ready or not.
  46376. */
  46377. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46378. /**
  46379. * Checks to see if a texture is used in the material.
  46380. * @param defines the list of "defines" to update.
  46381. * @param scene defines the scene to the material belongs to.
  46382. */
  46383. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46384. /**
  46385. * Binds the material data.
  46386. * @param uniformBuffer defines the Uniform buffer to fill in.
  46387. * @param scene defines the scene the material belongs to.
  46388. * @param engine defines the engine the material belongs to.
  46389. * @param disableBumpMap defines wether the material disables bump or not.
  46390. * @param isFrozen defines wether the material is frozen or not.
  46391. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46392. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46393. */
  46394. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46395. /**
  46396. * Checks to see if a texture is used in the material.
  46397. * @param texture - Base texture to use.
  46398. * @returns - Boolean specifying if a texture is used in the material.
  46399. */
  46400. hasTexture(texture: BaseTexture): boolean;
  46401. /**
  46402. * Returns an array of the actively used textures.
  46403. * @param activeTextures Array of BaseTextures
  46404. */
  46405. getActiveTextures(activeTextures: BaseTexture[]): void;
  46406. /**
  46407. * Returns the animatable textures.
  46408. * @param animatables Array of animatable textures.
  46409. */
  46410. getAnimatables(animatables: IAnimatable[]): void;
  46411. /**
  46412. * Disposes the resources of the material.
  46413. * @param forceDisposeTextures - Forces the disposal of all textures.
  46414. */
  46415. dispose(forceDisposeTextures?: boolean): void;
  46416. /**
  46417. * Get the current class name of the texture useful for serialization or dynamic coding.
  46418. * @returns "PBRClearCoatConfiguration"
  46419. */
  46420. getClassName(): string;
  46421. /**
  46422. * Add fallbacks to the effect fallbacks list.
  46423. * @param defines defines the Base texture to use.
  46424. * @param fallbacks defines the current fallback list.
  46425. * @param currentRank defines the current fallback rank.
  46426. * @returns the new fallback rank.
  46427. */
  46428. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46429. /**
  46430. * Add the required uniforms to the current list.
  46431. * @param uniforms defines the current uniform list.
  46432. */
  46433. static AddUniforms(uniforms: string[]): void;
  46434. /**
  46435. * Add the required samplers to the current list.
  46436. * @param samplers defines the current sampler list.
  46437. */
  46438. static AddSamplers(samplers: string[]): void;
  46439. /**
  46440. * Add the required uniforms to the current buffer.
  46441. * @param uniformBuffer defines the current uniform buffer.
  46442. */
  46443. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46444. /**
  46445. * Makes a duplicate of the current configuration into another one.
  46446. * @param clearCoatConfiguration define the config where to copy the info
  46447. */
  46448. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46449. /**
  46450. * Serializes this clear coat configuration.
  46451. * @returns - An object with the serialized config.
  46452. */
  46453. serialize(): any;
  46454. /**
  46455. * Parses a Clear Coat Configuration from a serialized object.
  46456. * @param source - Serialized object.
  46457. */
  46458. parse(source: any): void;
  46459. }
  46460. }
  46461. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46462. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46463. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46465. import { Vector2 } from "babylonjs/Maths/math";
  46466. import { Scene } from "babylonjs/scene";
  46467. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46468. import { IAnimatable } from "babylonjs/Misc/tools";
  46469. import { Nullable } from "babylonjs/types";
  46470. /**
  46471. * @hidden
  46472. */
  46473. export interface IMaterialAnisotropicDefines {
  46474. ANISOTROPIC: boolean;
  46475. ANISOTROPIC_TEXTURE: boolean;
  46476. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46477. MAINUV1: boolean;
  46478. _areTexturesDirty: boolean;
  46479. _needUVs: boolean;
  46480. }
  46481. /**
  46482. * Define the code related to the anisotropic parameters of the pbr material.
  46483. */
  46484. export class PBRAnisotropicConfiguration {
  46485. private _isEnabled;
  46486. /**
  46487. * Defines if the anisotropy is enabled in the material.
  46488. */
  46489. isEnabled: boolean;
  46490. /**
  46491. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46492. */
  46493. intensity: number;
  46494. /**
  46495. * Defines if the effect is along the tangents, bitangents or in between.
  46496. * By default, the effect is "strectching" the highlights along the tangents.
  46497. */
  46498. direction: Vector2;
  46499. private _texture;
  46500. /**
  46501. * Stores the anisotropy values in a texture.
  46502. * rg is direction (like normal from -1 to 1)
  46503. * b is a intensity
  46504. */
  46505. texture: Nullable<BaseTexture>;
  46506. /** @hidden */
  46507. private _internalMarkAllSubMeshesAsTexturesDirty;
  46508. /** @hidden */
  46509. _markAllSubMeshesAsTexturesDirty(): void;
  46510. /**
  46511. * Instantiate a new istance of anisotropy configuration.
  46512. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46513. */
  46514. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46515. /**
  46516. * Specifies that the submesh is ready to be used.
  46517. * @param defines the list of "defines" to update.
  46518. * @param scene defines the scene the material belongs to.
  46519. * @returns - boolean indicating that the submesh is ready or not.
  46520. */
  46521. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46522. /**
  46523. * Checks to see if a texture is used in the material.
  46524. * @param defines the list of "defines" to update.
  46525. * @param mesh the mesh we are preparing the defines for.
  46526. * @param scene defines the scene the material belongs to.
  46527. */
  46528. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46529. /**
  46530. * Binds the material data.
  46531. * @param uniformBuffer defines the Uniform buffer to fill in.
  46532. * @param scene defines the scene the material belongs to.
  46533. * @param isFrozen defines wether the material is frozen or not.
  46534. */
  46535. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46536. /**
  46537. * Checks to see if a texture is used in the material.
  46538. * @param texture - Base texture to use.
  46539. * @returns - Boolean specifying if a texture is used in the material.
  46540. */
  46541. hasTexture(texture: BaseTexture): boolean;
  46542. /**
  46543. * Returns an array of the actively used textures.
  46544. * @param activeTextures Array of BaseTextures
  46545. */
  46546. getActiveTextures(activeTextures: BaseTexture[]): void;
  46547. /**
  46548. * Returns the animatable textures.
  46549. * @param animatables Array of animatable textures.
  46550. */
  46551. getAnimatables(animatables: IAnimatable[]): void;
  46552. /**
  46553. * Disposes the resources of the material.
  46554. * @param forceDisposeTextures - Forces the disposal of all textures.
  46555. */
  46556. dispose(forceDisposeTextures?: boolean): void;
  46557. /**
  46558. * Get the current class name of the texture useful for serialization or dynamic coding.
  46559. * @returns "PBRAnisotropicConfiguration"
  46560. */
  46561. getClassName(): string;
  46562. /**
  46563. * Add fallbacks to the effect fallbacks list.
  46564. * @param defines defines the Base texture to use.
  46565. * @param fallbacks defines the current fallback list.
  46566. * @param currentRank defines the current fallback rank.
  46567. * @returns the new fallback rank.
  46568. */
  46569. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46570. /**
  46571. * Add the required uniforms to the current list.
  46572. * @param uniforms defines the current uniform list.
  46573. */
  46574. static AddUniforms(uniforms: string[]): void;
  46575. /**
  46576. * Add the required uniforms to the current buffer.
  46577. * @param uniformBuffer defines the current uniform buffer.
  46578. */
  46579. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46580. /**
  46581. * Add the required samplers to the current list.
  46582. * @param samplers defines the current sampler list.
  46583. */
  46584. static AddSamplers(samplers: string[]): void;
  46585. /**
  46586. * Makes a duplicate of the current configuration into another one.
  46587. * @param anisotropicConfiguration define the config where to copy the info
  46588. */
  46589. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46590. /**
  46591. * Serializes this anisotropy configuration.
  46592. * @returns - An object with the serialized config.
  46593. */
  46594. serialize(): any;
  46595. /**
  46596. * Parses a anisotropy Configuration from a serialized object.
  46597. * @param source - Serialized object.
  46598. */
  46599. parse(source: any): void;
  46600. }
  46601. }
  46602. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46603. /**
  46604. * @hidden
  46605. */
  46606. export interface IMaterialBRDFDefines {
  46607. BRDF_V_HEIGHT_CORRELATED: boolean;
  46608. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46609. SPHERICAL_HARMONICS: boolean;
  46610. /** @hidden */
  46611. _areMiscDirty: boolean;
  46612. }
  46613. /**
  46614. * Define the code related to the BRDF parameters of the pbr material.
  46615. */
  46616. export class PBRBRDFConfiguration {
  46617. /**
  46618. * Default value used for the energy conservation.
  46619. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46620. */
  46621. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46622. /**
  46623. * Default value used for the Smith Visibility Height Correlated mode.
  46624. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46625. */
  46626. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46627. /**
  46628. * Default value used for the IBL diffuse part.
  46629. * This can help switching back to the polynomials mode globally which is a tiny bit
  46630. * less GPU intensive at the drawback of a lower quality.
  46631. */
  46632. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46633. private _useEnergyConservation;
  46634. /**
  46635. * Defines if the material uses energy conservation.
  46636. */
  46637. useEnergyConservation: boolean;
  46638. private _useSmithVisibilityHeightCorrelated;
  46639. /**
  46640. * LEGACY Mode set to false
  46641. * Defines if the material uses height smith correlated visibility term.
  46642. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46643. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46644. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46645. * Not relying on height correlated will also disable energy conservation.
  46646. */
  46647. useSmithVisibilityHeightCorrelated: boolean;
  46648. private _useSphericalHarmonics;
  46649. /**
  46650. * LEGACY Mode set to false
  46651. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46652. * diffuse part of the IBL.
  46653. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46654. * to the ground truth.
  46655. */
  46656. useSphericalHarmonics: boolean;
  46657. /** @hidden */
  46658. private _internalMarkAllSubMeshesAsMiscDirty;
  46659. /** @hidden */
  46660. _markAllSubMeshesAsMiscDirty(): void;
  46661. /**
  46662. * Instantiate a new istance of clear coat configuration.
  46663. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46664. */
  46665. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46666. /**
  46667. * Checks to see if a texture is used in the material.
  46668. * @param defines the list of "defines" to update.
  46669. */
  46670. prepareDefines(defines: IMaterialBRDFDefines): void;
  46671. /**
  46672. * Get the current class name of the texture useful for serialization or dynamic coding.
  46673. * @returns "PBRClearCoatConfiguration"
  46674. */
  46675. getClassName(): string;
  46676. /**
  46677. * Makes a duplicate of the current configuration into another one.
  46678. * @param brdfConfiguration define the config where to copy the info
  46679. */
  46680. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46681. /**
  46682. * Serializes this BRDF configuration.
  46683. * @returns - An object with the serialized config.
  46684. */
  46685. serialize(): any;
  46686. /**
  46687. * Parses a BRDF Configuration from a serialized object.
  46688. * @param source - Serialized object.
  46689. */
  46690. parse(source: any): void;
  46691. }
  46692. }
  46693. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46694. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46695. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46696. import { Color3 } from "babylonjs/Maths/math";
  46697. import { Scene } from "babylonjs/scene";
  46698. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46699. import { IAnimatable } from "babylonjs/Misc/tools";
  46700. import { Nullable } from "babylonjs/types";
  46701. /**
  46702. * @hidden
  46703. */
  46704. export interface IMaterialSheenDefines {
  46705. SHEEN: boolean;
  46706. SHEEN_TEXTURE: boolean;
  46707. SHEEN_TEXTUREDIRECTUV: number;
  46708. SHEEN_LINKWITHALBEDO: boolean;
  46709. /** @hidden */
  46710. _areTexturesDirty: boolean;
  46711. }
  46712. /**
  46713. * Define the code related to the Sheen parameters of the pbr material.
  46714. */
  46715. export class PBRSheenConfiguration {
  46716. private _isEnabled;
  46717. /**
  46718. * Defines if the material uses sheen.
  46719. */
  46720. isEnabled: boolean;
  46721. private _linkSheenWithAlbedo;
  46722. /**
  46723. * Defines if the sheen is linked to the sheen color.
  46724. */
  46725. linkSheenWithAlbedo: boolean;
  46726. /**
  46727. * Defines the sheen intensity.
  46728. */
  46729. intensity: number;
  46730. /**
  46731. * Defines the sheen color.
  46732. */
  46733. color: Color3;
  46734. private _texture;
  46735. /**
  46736. * Stores the sheen tint values in a texture.
  46737. * rgb is tint
  46738. * a is a intensity
  46739. */
  46740. texture: Nullable<BaseTexture>;
  46741. /** @hidden */
  46742. private _internalMarkAllSubMeshesAsTexturesDirty;
  46743. /** @hidden */
  46744. _markAllSubMeshesAsTexturesDirty(): void;
  46745. /**
  46746. * Instantiate a new istance of clear coat configuration.
  46747. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46748. */
  46749. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46750. /**
  46751. * Specifies that the submesh is ready to be used.
  46752. * @param defines the list of "defines" to update.
  46753. * @param scene defines the scene the material belongs to.
  46754. * @returns - boolean indicating that the submesh is ready or not.
  46755. */
  46756. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46757. /**
  46758. * Checks to see if a texture is used in the material.
  46759. * @param defines the list of "defines" to update.
  46760. * @param scene defines the scene the material belongs to.
  46761. */
  46762. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46763. /**
  46764. * Binds the material data.
  46765. * @param uniformBuffer defines the Uniform buffer to fill in.
  46766. * @param scene defines the scene the material belongs to.
  46767. * @param isFrozen defines wether the material is frozen or not.
  46768. */
  46769. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46770. /**
  46771. * Checks to see if a texture is used in the material.
  46772. * @param texture - Base texture to use.
  46773. * @returns - Boolean specifying if a texture is used in the material.
  46774. */
  46775. hasTexture(texture: BaseTexture): boolean;
  46776. /**
  46777. * Returns an array of the actively used textures.
  46778. * @param activeTextures Array of BaseTextures
  46779. */
  46780. getActiveTextures(activeTextures: BaseTexture[]): void;
  46781. /**
  46782. * Returns the animatable textures.
  46783. * @param animatables Array of animatable textures.
  46784. */
  46785. getAnimatables(animatables: IAnimatable[]): void;
  46786. /**
  46787. * Disposes the resources of the material.
  46788. * @param forceDisposeTextures - Forces the disposal of all textures.
  46789. */
  46790. dispose(forceDisposeTextures?: boolean): void;
  46791. /**
  46792. * Get the current class name of the texture useful for serialization or dynamic coding.
  46793. * @returns "PBRSheenConfiguration"
  46794. */
  46795. getClassName(): string;
  46796. /**
  46797. * Add fallbacks to the effect fallbacks list.
  46798. * @param defines defines the Base texture to use.
  46799. * @param fallbacks defines the current fallback list.
  46800. * @param currentRank defines the current fallback rank.
  46801. * @returns the new fallback rank.
  46802. */
  46803. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46804. /**
  46805. * Add the required uniforms to the current list.
  46806. * @param uniforms defines the current uniform list.
  46807. */
  46808. static AddUniforms(uniforms: string[]): void;
  46809. /**
  46810. * Add the required uniforms to the current buffer.
  46811. * @param uniformBuffer defines the current uniform buffer.
  46812. */
  46813. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46814. /**
  46815. * Add the required samplers to the current list.
  46816. * @param samplers defines the current sampler list.
  46817. */
  46818. static AddSamplers(samplers: string[]): void;
  46819. /**
  46820. * Makes a duplicate of the current configuration into another one.
  46821. * @param sheenConfiguration define the config where to copy the info
  46822. */
  46823. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46824. /**
  46825. * Serializes this BRDF configuration.
  46826. * @returns - An object with the serialized config.
  46827. */
  46828. serialize(): any;
  46829. /**
  46830. * Parses a Sheen Configuration from a serialized object.
  46831. * @param source - Serialized object.
  46832. */
  46833. parse(source: any): void;
  46834. }
  46835. }
  46836. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46837. import { Nullable } from "babylonjs/types";
  46838. import { IAnimatable } from "babylonjs/Misc/tools";
  46839. import { Color3 } from "babylonjs/Maths/math";
  46840. import { SmartArray } from "babylonjs/Misc/smartArray";
  46841. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46842. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46843. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46844. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46845. import { Engine } from "babylonjs/Engines/engine";
  46846. import { Scene } from "babylonjs/scene";
  46847. /**
  46848. * @hidden
  46849. */
  46850. export interface IMaterialSubSurfaceDefines {
  46851. SUBSURFACE: boolean;
  46852. SS_REFRACTION: boolean;
  46853. SS_TRANSLUCENCY: boolean;
  46854. SS_SCATERRING: boolean;
  46855. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46856. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46857. SS_REFRACTIONMAP_3D: boolean;
  46858. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46859. SS_LODINREFRACTIONALPHA: boolean;
  46860. SS_GAMMAREFRACTION: boolean;
  46861. SS_RGBDREFRACTION: boolean;
  46862. SS_LINEARSPECULARREFRACTION: boolean;
  46863. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46864. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46865. /** @hidden */
  46866. _areTexturesDirty: boolean;
  46867. }
  46868. /**
  46869. * Define the code related to the sub surface parameters of the pbr material.
  46870. */
  46871. export class PBRSubSurfaceConfiguration {
  46872. private _isRefractionEnabled;
  46873. /**
  46874. * Defines if the refraction is enabled in the material.
  46875. */
  46876. isRefractionEnabled: boolean;
  46877. private _isTranslucencyEnabled;
  46878. /**
  46879. * Defines if the translucency is enabled in the material.
  46880. */
  46881. isTranslucencyEnabled: boolean;
  46882. private _isScatteringEnabled;
  46883. /**
  46884. * Defines the refraction intensity of the material.
  46885. * The refraction when enabled replaces the Diffuse part of the material.
  46886. * The intensity helps transitionning between diffuse and refraction.
  46887. */
  46888. refractionIntensity: number;
  46889. /**
  46890. * Defines the translucency intensity of the material.
  46891. * When translucency has been enabled, this defines how much of the "translucency"
  46892. * is addded to the diffuse part of the material.
  46893. */
  46894. translucencyIntensity: number;
  46895. /**
  46896. * Defines the scattering intensity of the material.
  46897. * When scattering has been enabled, this defines how much of the "scattered light"
  46898. * is addded to the diffuse part of the material.
  46899. */
  46900. scatteringIntensity: number;
  46901. private _thicknessTexture;
  46902. /**
  46903. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46904. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46905. * 0 would mean minimumThickness
  46906. * 1 would mean maximumThickness
  46907. * The other channels might be use as a mask to vary the different effects intensity.
  46908. */
  46909. thicknessTexture: Nullable<BaseTexture>;
  46910. private _refractionTexture;
  46911. /**
  46912. * Defines the texture to use for refraction.
  46913. */
  46914. refractionTexture: Nullable<BaseTexture>;
  46915. private _indexOfRefraction;
  46916. /**
  46917. * Defines the index of refraction used in the material.
  46918. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46919. */
  46920. indexOfRefraction: number;
  46921. private _invertRefractionY;
  46922. /**
  46923. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46924. */
  46925. invertRefractionY: boolean;
  46926. private _linkRefractionWithTransparency;
  46927. /**
  46928. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46929. * Materials half opaque for instance using refraction could benefit from this control.
  46930. */
  46931. linkRefractionWithTransparency: boolean;
  46932. /**
  46933. * Defines the minimum thickness stored in the thickness map.
  46934. * If no thickness map is defined, this value will be used to simulate thickness.
  46935. */
  46936. minimumThickness: number;
  46937. /**
  46938. * Defines the maximum thickness stored in the thickness map.
  46939. */
  46940. maximumThickness: number;
  46941. /**
  46942. * Defines the volume tint of the material.
  46943. * This is used for both translucency and scattering.
  46944. */
  46945. tintColor: Color3;
  46946. /**
  46947. * Defines the distance at which the tint color should be found in the media.
  46948. * This is used for refraction only.
  46949. */
  46950. tintColorAtDistance: number;
  46951. /**
  46952. * Defines how far each channel transmit through the media.
  46953. * It is defined as a color to simplify it selection.
  46954. */
  46955. diffusionDistance: Color3;
  46956. private _useMaskFromThicknessTexture;
  46957. /**
  46958. * Stores the intensity of the different subsurface effects in the thickness texture.
  46959. * * the green channel is the translucency intensity.
  46960. * * the blue channel is the scattering intensity.
  46961. * * the alpha channel is the refraction intensity.
  46962. */
  46963. useMaskFromThicknessTexture: boolean;
  46964. /** @hidden */
  46965. private _internalMarkAllSubMeshesAsTexturesDirty;
  46966. /** @hidden */
  46967. _markAllSubMeshesAsTexturesDirty(): void;
  46968. /**
  46969. * Instantiate a new istance of sub surface configuration.
  46970. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46971. */
  46972. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46973. /**
  46974. * Gets wehter the submesh is ready to be used or not.
  46975. * @param defines the list of "defines" to update.
  46976. * @param scene defines the scene the material belongs to.
  46977. * @returns - boolean indicating that the submesh is ready or not.
  46978. */
  46979. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46980. /**
  46981. * Checks to see if a texture is used in the material.
  46982. * @param defines the list of "defines" to update.
  46983. * @param scene defines the scene to the material belongs to.
  46984. */
  46985. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46986. /**
  46987. * Binds the material data.
  46988. * @param uniformBuffer defines the Uniform buffer to fill in.
  46989. * @param scene defines the scene the material belongs to.
  46990. * @param engine defines the engine the material belongs to.
  46991. * @param isFrozen defines wether the material is frozen or not.
  46992. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46993. */
  46994. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46995. /**
  46996. * Unbinds the material from the mesh.
  46997. * @param activeEffect defines the effect that should be unbound from.
  46998. * @returns true if unbound, otherwise false
  46999. */
  47000. unbind(activeEffect: Effect): boolean;
  47001. /**
  47002. * Returns the texture used for refraction or null if none is used.
  47003. * @param scene defines the scene the material belongs to.
  47004. * @returns - Refraction texture if present. If no refraction texture and refraction
  47005. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47006. */
  47007. private _getRefractionTexture;
  47008. /**
  47009. * Returns true if alpha blending should be disabled.
  47010. */
  47011. readonly disableAlphaBlending: boolean;
  47012. /**
  47013. * Fills the list of render target textures.
  47014. * @param renderTargets the list of render targets to update
  47015. */
  47016. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47017. /**
  47018. * Checks to see if a texture is used in the material.
  47019. * @param texture - Base texture to use.
  47020. * @returns - Boolean specifying if a texture is used in the material.
  47021. */
  47022. hasTexture(texture: BaseTexture): boolean;
  47023. /**
  47024. * Gets a boolean indicating that current material needs to register RTT
  47025. * @returns true if this uses a render target otherwise false.
  47026. */
  47027. hasRenderTargetTextures(): boolean;
  47028. /**
  47029. * Returns an array of the actively used textures.
  47030. * @param activeTextures Array of BaseTextures
  47031. */
  47032. getActiveTextures(activeTextures: BaseTexture[]): void;
  47033. /**
  47034. * Returns the animatable textures.
  47035. * @param animatables Array of animatable textures.
  47036. */
  47037. getAnimatables(animatables: IAnimatable[]): void;
  47038. /**
  47039. * Disposes the resources of the material.
  47040. * @param forceDisposeTextures - Forces the disposal of all textures.
  47041. */
  47042. dispose(forceDisposeTextures?: boolean): void;
  47043. /**
  47044. * Get the current class name of the texture useful for serialization or dynamic coding.
  47045. * @returns "PBRSubSurfaceConfiguration"
  47046. */
  47047. getClassName(): string;
  47048. /**
  47049. * Add fallbacks to the effect fallbacks list.
  47050. * @param defines defines the Base texture to use.
  47051. * @param fallbacks defines the current fallback list.
  47052. * @param currentRank defines the current fallback rank.
  47053. * @returns the new fallback rank.
  47054. */
  47055. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47056. /**
  47057. * Add the required uniforms to the current list.
  47058. * @param uniforms defines the current uniform list.
  47059. */
  47060. static AddUniforms(uniforms: string[]): void;
  47061. /**
  47062. * Add the required samplers to the current list.
  47063. * @param samplers defines the current sampler list.
  47064. */
  47065. static AddSamplers(samplers: string[]): void;
  47066. /**
  47067. * Add the required uniforms to the current buffer.
  47068. * @param uniformBuffer defines the current uniform buffer.
  47069. */
  47070. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47071. /**
  47072. * Makes a duplicate of the current configuration into another one.
  47073. * @param configuration define the config where to copy the info
  47074. */
  47075. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47076. /**
  47077. * Serializes this Sub Surface configuration.
  47078. * @returns - An object with the serialized config.
  47079. */
  47080. serialize(): any;
  47081. /**
  47082. * Parses a Sub Surface Configuration from a serialized object.
  47083. * @param source - Serialized object.
  47084. */
  47085. parse(source: any): void;
  47086. }
  47087. }
  47088. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47089. /** @hidden */
  47090. export var pbrFragmentDeclaration: {
  47091. name: string;
  47092. shader: string;
  47093. };
  47094. }
  47095. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47096. /** @hidden */
  47097. export var pbrUboDeclaration: {
  47098. name: string;
  47099. shader: string;
  47100. };
  47101. }
  47102. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47103. /** @hidden */
  47104. export var pbrFragmentExtraDeclaration: {
  47105. name: string;
  47106. shader: string;
  47107. };
  47108. }
  47109. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47110. /** @hidden */
  47111. export var pbrFragmentSamplersDeclaration: {
  47112. name: string;
  47113. shader: string;
  47114. };
  47115. }
  47116. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47117. /** @hidden */
  47118. export var pbrHelperFunctions: {
  47119. name: string;
  47120. shader: string;
  47121. };
  47122. }
  47123. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47124. /** @hidden */
  47125. export var harmonicsFunctions: {
  47126. name: string;
  47127. shader: string;
  47128. };
  47129. }
  47130. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47131. /** @hidden */
  47132. export var pbrDirectLightingSetupFunctions: {
  47133. name: string;
  47134. shader: string;
  47135. };
  47136. }
  47137. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47138. /** @hidden */
  47139. export var pbrDirectLightingFalloffFunctions: {
  47140. name: string;
  47141. shader: string;
  47142. };
  47143. }
  47144. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47145. /** @hidden */
  47146. export var pbrBRDFFunctions: {
  47147. name: string;
  47148. shader: string;
  47149. };
  47150. }
  47151. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47152. /** @hidden */
  47153. export var pbrDirectLightingFunctions: {
  47154. name: string;
  47155. shader: string;
  47156. };
  47157. }
  47158. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47159. /** @hidden */
  47160. export var pbrIBLFunctions: {
  47161. name: string;
  47162. shader: string;
  47163. };
  47164. }
  47165. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47166. /** @hidden */
  47167. export var pbrDebug: {
  47168. name: string;
  47169. shader: string;
  47170. };
  47171. }
  47172. declare module "babylonjs/Shaders/pbr.fragment" {
  47173. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47174. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47175. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47176. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47177. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47178. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47179. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47180. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47181. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47182. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47183. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47184. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47185. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47186. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47187. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47188. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47189. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47190. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47191. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47192. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47193. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47194. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47195. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47196. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47197. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47198. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47199. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47200. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47201. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47202. /** @hidden */
  47203. export var pbrPixelShader: {
  47204. name: string;
  47205. shader: string;
  47206. };
  47207. }
  47208. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47209. /** @hidden */
  47210. export var pbrVertexDeclaration: {
  47211. name: string;
  47212. shader: string;
  47213. };
  47214. }
  47215. declare module "babylonjs/Shaders/pbr.vertex" {
  47216. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47217. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47218. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47219. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47220. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47221. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47222. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47223. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47224. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47225. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47226. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47227. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47228. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47229. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47230. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47231. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47232. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47233. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47234. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47235. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47236. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47237. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47238. /** @hidden */
  47239. export var pbrVertexShader: {
  47240. name: string;
  47241. shader: string;
  47242. };
  47243. }
  47244. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47245. import { IAnimatable } from "babylonjs/Misc/tools";
  47246. import { Nullable } from "babylonjs/types";
  47247. import { Scene } from "babylonjs/scene";
  47248. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47249. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47251. import { Mesh } from "babylonjs/Meshes/mesh";
  47252. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47253. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47254. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47255. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47256. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47257. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47258. import { Material } from "babylonjs/Materials/material";
  47259. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47260. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47261. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47262. import "babylonjs/Shaders/pbr.fragment";
  47263. import "babylonjs/Shaders/pbr.vertex";
  47264. /**
  47265. * Manages the defines for the PBR Material.
  47266. * @hidden
  47267. */
  47268. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47269. PBR: boolean;
  47270. MAINUV1: boolean;
  47271. MAINUV2: boolean;
  47272. UV1: boolean;
  47273. UV2: boolean;
  47274. ALBEDO: boolean;
  47275. ALBEDODIRECTUV: number;
  47276. VERTEXCOLOR: boolean;
  47277. AMBIENT: boolean;
  47278. AMBIENTDIRECTUV: number;
  47279. AMBIENTINGRAYSCALE: boolean;
  47280. OPACITY: boolean;
  47281. VERTEXALPHA: boolean;
  47282. OPACITYDIRECTUV: number;
  47283. OPACITYRGB: boolean;
  47284. ALPHATEST: boolean;
  47285. DEPTHPREPASS: boolean;
  47286. ALPHABLEND: boolean;
  47287. ALPHAFROMALBEDO: boolean;
  47288. ALPHATESTVALUE: string;
  47289. SPECULAROVERALPHA: boolean;
  47290. RADIANCEOVERALPHA: boolean;
  47291. ALPHAFRESNEL: boolean;
  47292. LINEARALPHAFRESNEL: boolean;
  47293. PREMULTIPLYALPHA: boolean;
  47294. EMISSIVE: boolean;
  47295. EMISSIVEDIRECTUV: number;
  47296. REFLECTIVITY: boolean;
  47297. REFLECTIVITYDIRECTUV: number;
  47298. SPECULARTERM: boolean;
  47299. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47300. MICROSURFACEAUTOMATIC: boolean;
  47301. LODBASEDMICROSFURACE: boolean;
  47302. MICROSURFACEMAP: boolean;
  47303. MICROSURFACEMAPDIRECTUV: number;
  47304. METALLICWORKFLOW: boolean;
  47305. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47306. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47307. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47308. AOSTOREINMETALMAPRED: boolean;
  47309. ENVIRONMENTBRDF: boolean;
  47310. ENVIRONMENTBRDF_RGBD: boolean;
  47311. NORMAL: boolean;
  47312. TANGENT: boolean;
  47313. BUMP: boolean;
  47314. BUMPDIRECTUV: number;
  47315. OBJECTSPACE_NORMALMAP: boolean;
  47316. PARALLAX: boolean;
  47317. PARALLAXOCCLUSION: boolean;
  47318. NORMALXYSCALE: boolean;
  47319. LIGHTMAP: boolean;
  47320. LIGHTMAPDIRECTUV: number;
  47321. USELIGHTMAPASSHADOWMAP: boolean;
  47322. GAMMALIGHTMAP: boolean;
  47323. REFLECTION: boolean;
  47324. REFLECTIONMAP_3D: boolean;
  47325. REFLECTIONMAP_SPHERICAL: boolean;
  47326. REFLECTIONMAP_PLANAR: boolean;
  47327. REFLECTIONMAP_CUBIC: boolean;
  47328. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47329. REFLECTIONMAP_PROJECTION: boolean;
  47330. REFLECTIONMAP_SKYBOX: boolean;
  47331. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47332. REFLECTIONMAP_EXPLICIT: boolean;
  47333. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47334. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47335. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47336. INVERTCUBICMAP: boolean;
  47337. USESPHERICALFROMREFLECTIONMAP: boolean;
  47338. USEIRRADIANCEMAP: boolean;
  47339. SPHERICAL_HARMONICS: boolean;
  47340. USESPHERICALINVERTEX: boolean;
  47341. REFLECTIONMAP_OPPOSITEZ: boolean;
  47342. LODINREFLECTIONALPHA: boolean;
  47343. GAMMAREFLECTION: boolean;
  47344. RGBDREFLECTION: boolean;
  47345. LINEARSPECULARREFLECTION: boolean;
  47346. RADIANCEOCCLUSION: boolean;
  47347. HORIZONOCCLUSION: boolean;
  47348. INSTANCES: boolean;
  47349. NUM_BONE_INFLUENCERS: number;
  47350. BonesPerMesh: number;
  47351. BONETEXTURE: boolean;
  47352. NONUNIFORMSCALING: boolean;
  47353. MORPHTARGETS: boolean;
  47354. MORPHTARGETS_NORMAL: boolean;
  47355. MORPHTARGETS_TANGENT: boolean;
  47356. NUM_MORPH_INFLUENCERS: number;
  47357. IMAGEPROCESSING: boolean;
  47358. VIGNETTE: boolean;
  47359. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47360. VIGNETTEBLENDMODEOPAQUE: boolean;
  47361. TONEMAPPING: boolean;
  47362. TONEMAPPING_ACES: boolean;
  47363. CONTRAST: boolean;
  47364. COLORCURVES: boolean;
  47365. COLORGRADING: boolean;
  47366. COLORGRADING3D: boolean;
  47367. SAMPLER3DGREENDEPTH: boolean;
  47368. SAMPLER3DBGRMAP: boolean;
  47369. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47370. EXPOSURE: boolean;
  47371. MULTIVIEW: boolean;
  47372. USEPHYSICALLIGHTFALLOFF: boolean;
  47373. USEGLTFLIGHTFALLOFF: boolean;
  47374. TWOSIDEDLIGHTING: boolean;
  47375. SHADOWFLOAT: boolean;
  47376. CLIPPLANE: boolean;
  47377. CLIPPLANE2: boolean;
  47378. CLIPPLANE3: boolean;
  47379. CLIPPLANE4: boolean;
  47380. POINTSIZE: boolean;
  47381. FOG: boolean;
  47382. LOGARITHMICDEPTH: boolean;
  47383. FORCENORMALFORWARD: boolean;
  47384. SPECULARAA: boolean;
  47385. CLEARCOAT: boolean;
  47386. CLEARCOAT_DEFAULTIOR: boolean;
  47387. CLEARCOAT_TEXTURE: boolean;
  47388. CLEARCOAT_TEXTUREDIRECTUV: number;
  47389. CLEARCOAT_BUMP: boolean;
  47390. CLEARCOAT_BUMPDIRECTUV: number;
  47391. CLEARCOAT_TINT: boolean;
  47392. CLEARCOAT_TINT_TEXTURE: boolean;
  47393. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47394. ANISOTROPIC: boolean;
  47395. ANISOTROPIC_TEXTURE: boolean;
  47396. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47397. BRDF_V_HEIGHT_CORRELATED: boolean;
  47398. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47399. SHEEN: boolean;
  47400. SHEEN_TEXTURE: boolean;
  47401. SHEEN_TEXTUREDIRECTUV: number;
  47402. SHEEN_LINKWITHALBEDO: boolean;
  47403. SUBSURFACE: boolean;
  47404. SS_REFRACTION: boolean;
  47405. SS_TRANSLUCENCY: boolean;
  47406. SS_SCATERRING: boolean;
  47407. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47408. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47409. SS_REFRACTIONMAP_3D: boolean;
  47410. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47411. SS_LODINREFRACTIONALPHA: boolean;
  47412. SS_GAMMAREFRACTION: boolean;
  47413. SS_RGBDREFRACTION: boolean;
  47414. SS_LINEARSPECULARREFRACTION: boolean;
  47415. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47416. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47417. UNLIT: boolean;
  47418. DEBUGMODE: number;
  47419. /**
  47420. * Initializes the PBR Material defines.
  47421. */
  47422. constructor();
  47423. /**
  47424. * Resets the PBR Material defines.
  47425. */
  47426. reset(): void;
  47427. }
  47428. /**
  47429. * The Physically based material base class of BJS.
  47430. *
  47431. * This offers the main features of a standard PBR material.
  47432. * For more information, please refer to the documentation :
  47433. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47434. */
  47435. export abstract class PBRBaseMaterial extends PushMaterial {
  47436. /**
  47437. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47438. */
  47439. static readonly PBRMATERIAL_OPAQUE: number;
  47440. /**
  47441. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47442. */
  47443. static readonly PBRMATERIAL_ALPHATEST: number;
  47444. /**
  47445. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47446. */
  47447. static readonly PBRMATERIAL_ALPHABLEND: number;
  47448. /**
  47449. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47450. * They are also discarded below the alpha cutoff threshold to improve performances.
  47451. */
  47452. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47453. /**
  47454. * Defines the default value of how much AO map is occluding the analytical lights
  47455. * (point spot...).
  47456. */
  47457. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47458. /**
  47459. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47460. */
  47461. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47462. /**
  47463. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47464. * to enhance interoperability with other engines.
  47465. */
  47466. static readonly LIGHTFALLOFF_GLTF: number;
  47467. /**
  47468. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47469. * to enhance interoperability with other materials.
  47470. */
  47471. static readonly LIGHTFALLOFF_STANDARD: number;
  47472. /**
  47473. * Intensity of the direct lights e.g. the four lights available in your scene.
  47474. * This impacts both the direct diffuse and specular highlights.
  47475. */
  47476. protected _directIntensity: number;
  47477. /**
  47478. * Intensity of the emissive part of the material.
  47479. * This helps controlling the emissive effect without modifying the emissive color.
  47480. */
  47481. protected _emissiveIntensity: number;
  47482. /**
  47483. * Intensity of the environment e.g. how much the environment will light the object
  47484. * either through harmonics for rough material or through the refelction for shiny ones.
  47485. */
  47486. protected _environmentIntensity: number;
  47487. /**
  47488. * This is a special control allowing the reduction of the specular highlights coming from the
  47489. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47490. */
  47491. protected _specularIntensity: number;
  47492. /**
  47493. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47494. */
  47495. private _lightingInfos;
  47496. /**
  47497. * Debug Control allowing disabling the bump map on this material.
  47498. */
  47499. protected _disableBumpMap: boolean;
  47500. /**
  47501. * AKA Diffuse Texture in standard nomenclature.
  47502. */
  47503. protected _albedoTexture: Nullable<BaseTexture>;
  47504. /**
  47505. * AKA Occlusion Texture in other nomenclature.
  47506. */
  47507. protected _ambientTexture: Nullable<BaseTexture>;
  47508. /**
  47509. * AKA Occlusion Texture Intensity in other nomenclature.
  47510. */
  47511. protected _ambientTextureStrength: number;
  47512. /**
  47513. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47514. * 1 means it completely occludes it
  47515. * 0 mean it has no impact
  47516. */
  47517. protected _ambientTextureImpactOnAnalyticalLights: number;
  47518. /**
  47519. * Stores the alpha values in a texture.
  47520. */
  47521. protected _opacityTexture: Nullable<BaseTexture>;
  47522. /**
  47523. * Stores the reflection values in a texture.
  47524. */
  47525. protected _reflectionTexture: Nullable<BaseTexture>;
  47526. /**
  47527. * Stores the emissive values in a texture.
  47528. */
  47529. protected _emissiveTexture: Nullable<BaseTexture>;
  47530. /**
  47531. * AKA Specular texture in other nomenclature.
  47532. */
  47533. protected _reflectivityTexture: Nullable<BaseTexture>;
  47534. /**
  47535. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47536. */
  47537. protected _metallicTexture: Nullable<BaseTexture>;
  47538. /**
  47539. * Specifies the metallic scalar of the metallic/roughness workflow.
  47540. * Can also be used to scale the metalness values of the metallic texture.
  47541. */
  47542. protected _metallic: Nullable<number>;
  47543. /**
  47544. * Specifies the roughness scalar of the metallic/roughness workflow.
  47545. * Can also be used to scale the roughness values of the metallic texture.
  47546. */
  47547. protected _roughness: Nullable<number>;
  47548. /**
  47549. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47550. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47551. */
  47552. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47553. /**
  47554. * Stores surface normal data used to displace a mesh in a texture.
  47555. */
  47556. protected _bumpTexture: Nullable<BaseTexture>;
  47557. /**
  47558. * Stores the pre-calculated light information of a mesh in a texture.
  47559. */
  47560. protected _lightmapTexture: Nullable<BaseTexture>;
  47561. /**
  47562. * The color of a material in ambient lighting.
  47563. */
  47564. protected _ambientColor: Color3;
  47565. /**
  47566. * AKA Diffuse Color in other nomenclature.
  47567. */
  47568. protected _albedoColor: Color3;
  47569. /**
  47570. * AKA Specular Color in other nomenclature.
  47571. */
  47572. protected _reflectivityColor: Color3;
  47573. /**
  47574. * The color applied when light is reflected from a material.
  47575. */
  47576. protected _reflectionColor: Color3;
  47577. /**
  47578. * The color applied when light is emitted from a material.
  47579. */
  47580. protected _emissiveColor: Color3;
  47581. /**
  47582. * AKA Glossiness in other nomenclature.
  47583. */
  47584. protected _microSurface: number;
  47585. /**
  47586. * Specifies that the material will use the light map as a show map.
  47587. */
  47588. protected _useLightmapAsShadowmap: boolean;
  47589. /**
  47590. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47591. * makes the reflect vector face the model (under horizon).
  47592. */
  47593. protected _useHorizonOcclusion: boolean;
  47594. /**
  47595. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47596. * too much the area relying on ambient texture to define their ambient occlusion.
  47597. */
  47598. protected _useRadianceOcclusion: boolean;
  47599. /**
  47600. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47601. */
  47602. protected _useAlphaFromAlbedoTexture: boolean;
  47603. /**
  47604. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47605. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47606. */
  47607. protected _useSpecularOverAlpha: boolean;
  47608. /**
  47609. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47610. */
  47611. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47612. /**
  47613. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47614. */
  47615. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47616. /**
  47617. * Specifies if the metallic texture contains the roughness information in its green channel.
  47618. */
  47619. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47620. /**
  47621. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47622. */
  47623. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47624. /**
  47625. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47626. */
  47627. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47628. /**
  47629. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47630. */
  47631. protected _useAmbientInGrayScale: boolean;
  47632. /**
  47633. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47634. * The material will try to infer what glossiness each pixel should be.
  47635. */
  47636. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47637. /**
  47638. * Defines the falloff type used in this material.
  47639. * It by default is Physical.
  47640. */
  47641. protected _lightFalloff: number;
  47642. /**
  47643. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47644. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47645. */
  47646. protected _useRadianceOverAlpha: boolean;
  47647. /**
  47648. * Allows using an object space normal map (instead of tangent space).
  47649. */
  47650. protected _useObjectSpaceNormalMap: boolean;
  47651. /**
  47652. * Allows using the bump map in parallax mode.
  47653. */
  47654. protected _useParallax: boolean;
  47655. /**
  47656. * Allows using the bump map in parallax occlusion mode.
  47657. */
  47658. protected _useParallaxOcclusion: boolean;
  47659. /**
  47660. * Controls the scale bias of the parallax mode.
  47661. */
  47662. protected _parallaxScaleBias: number;
  47663. /**
  47664. * If sets to true, disables all the lights affecting the material.
  47665. */
  47666. protected _disableLighting: boolean;
  47667. /**
  47668. * Number of Simultaneous lights allowed on the material.
  47669. */
  47670. protected _maxSimultaneousLights: number;
  47671. /**
  47672. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47673. */
  47674. protected _invertNormalMapX: boolean;
  47675. /**
  47676. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47677. */
  47678. protected _invertNormalMapY: boolean;
  47679. /**
  47680. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47681. */
  47682. protected _twoSidedLighting: boolean;
  47683. /**
  47684. * Defines the alpha limits in alpha test mode.
  47685. */
  47686. protected _alphaCutOff: number;
  47687. /**
  47688. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47689. */
  47690. protected _forceAlphaTest: boolean;
  47691. /**
  47692. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47693. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47694. */
  47695. protected _useAlphaFresnel: boolean;
  47696. /**
  47697. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47698. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47699. */
  47700. protected _useLinearAlphaFresnel: boolean;
  47701. /**
  47702. * The transparency mode of the material.
  47703. */
  47704. protected _transparencyMode: Nullable<number>;
  47705. /**
  47706. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47707. * from cos thetav and roughness:
  47708. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47709. */
  47710. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47711. /**
  47712. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47713. */
  47714. protected _forceIrradianceInFragment: boolean;
  47715. /**
  47716. * Force normal to face away from face.
  47717. */
  47718. protected _forceNormalForward: boolean;
  47719. /**
  47720. * Enables specular anti aliasing in the PBR shader.
  47721. * It will both interacts on the Geometry for analytical and IBL lighting.
  47722. * It also prefilter the roughness map based on the bump values.
  47723. */
  47724. protected _enableSpecularAntiAliasing: boolean;
  47725. /**
  47726. * Default configuration related to image processing available in the PBR Material.
  47727. */
  47728. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47729. /**
  47730. * Keep track of the image processing observer to allow dispose and replace.
  47731. */
  47732. private _imageProcessingObserver;
  47733. /**
  47734. * Attaches a new image processing configuration to the PBR Material.
  47735. * @param configuration
  47736. */
  47737. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47738. /**
  47739. * Stores the available render targets.
  47740. */
  47741. private _renderTargets;
  47742. /**
  47743. * Sets the global ambient color for the material used in lighting calculations.
  47744. */
  47745. private _globalAmbientColor;
  47746. /**
  47747. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47748. */
  47749. private _useLogarithmicDepth;
  47750. /**
  47751. * If set to true, no lighting calculations will be applied.
  47752. */
  47753. private _unlit;
  47754. private _debugMode;
  47755. /**
  47756. * @hidden
  47757. * This is reserved for the inspector.
  47758. * Defines the material debug mode.
  47759. * It helps seeing only some components of the material while troubleshooting.
  47760. */
  47761. debugMode: number;
  47762. /**
  47763. * @hidden
  47764. * This is reserved for the inspector.
  47765. * Specify from where on screen the debug mode should start.
  47766. * The value goes from -1 (full screen) to 1 (not visible)
  47767. * It helps with side by side comparison against the final render
  47768. * This defaults to -1
  47769. */
  47770. private debugLimit;
  47771. /**
  47772. * @hidden
  47773. * This is reserved for the inspector.
  47774. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47775. * You can use the factor to better multiply the final value.
  47776. */
  47777. private debugFactor;
  47778. /**
  47779. * Defines the clear coat layer parameters for the material.
  47780. */
  47781. readonly clearCoat: PBRClearCoatConfiguration;
  47782. /**
  47783. * Defines the anisotropic parameters for the material.
  47784. */
  47785. readonly anisotropy: PBRAnisotropicConfiguration;
  47786. /**
  47787. * Defines the BRDF parameters for the material.
  47788. */
  47789. readonly brdf: PBRBRDFConfiguration;
  47790. /**
  47791. * Defines the Sheen parameters for the material.
  47792. */
  47793. readonly sheen: PBRSheenConfiguration;
  47794. /**
  47795. * Defines the SubSurface parameters for the material.
  47796. */
  47797. readonly subSurface: PBRSubSurfaceConfiguration;
  47798. /**
  47799. * Custom callback helping to override the default shader used in the material.
  47800. */
  47801. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47802. /**
  47803. * Instantiates a new PBRMaterial instance.
  47804. *
  47805. * @param name The material name
  47806. * @param scene The scene the material will be use in.
  47807. */
  47808. constructor(name: string, scene: Scene);
  47809. /**
  47810. * Gets a boolean indicating that current material needs to register RTT
  47811. */
  47812. readonly hasRenderTargetTextures: boolean;
  47813. /**
  47814. * Gets the name of the material class.
  47815. */
  47816. getClassName(): string;
  47817. /**
  47818. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47819. */
  47820. /**
  47821. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47822. */
  47823. useLogarithmicDepth: boolean;
  47824. /**
  47825. * Gets the current transparency mode.
  47826. */
  47827. /**
  47828. * Sets the transparency mode of the material.
  47829. *
  47830. * | Value | Type | Description |
  47831. * | ----- | ----------------------------------- | ----------- |
  47832. * | 0 | OPAQUE | |
  47833. * | 1 | ALPHATEST | |
  47834. * | 2 | ALPHABLEND | |
  47835. * | 3 | ALPHATESTANDBLEND | |
  47836. *
  47837. */
  47838. transparencyMode: Nullable<number>;
  47839. /**
  47840. * Returns true if alpha blending should be disabled.
  47841. */
  47842. private readonly _disableAlphaBlending;
  47843. /**
  47844. * Specifies whether or not this material should be rendered in alpha blend mode.
  47845. */
  47846. needAlphaBlending(): boolean;
  47847. /**
  47848. * Specifies if the mesh will require alpha blending.
  47849. * @param mesh - BJS mesh.
  47850. */
  47851. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47852. /**
  47853. * Specifies whether or not this material should be rendered in alpha test mode.
  47854. */
  47855. needAlphaTesting(): boolean;
  47856. /**
  47857. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47858. */
  47859. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47860. /**
  47861. * Gets the texture used for the alpha test.
  47862. */
  47863. getAlphaTestTexture(): Nullable<BaseTexture>;
  47864. /**
  47865. * Specifies that the submesh is ready to be used.
  47866. * @param mesh - BJS mesh.
  47867. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47868. * @param useInstances - Specifies that instances should be used.
  47869. * @returns - boolean indicating that the submesh is ready or not.
  47870. */
  47871. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47872. /**
  47873. * Specifies if the material uses metallic roughness workflow.
  47874. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47875. */
  47876. isMetallicWorkflow(): boolean;
  47877. private _prepareEffect;
  47878. private _prepareDefines;
  47879. /**
  47880. * Force shader compilation
  47881. */
  47882. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47883. clipPlane: boolean;
  47884. }>): void;
  47885. /**
  47886. * Initializes the uniform buffer layout for the shader.
  47887. */
  47888. buildUniformLayout(): void;
  47889. /**
  47890. * Unbinds the material from the mesh
  47891. */
  47892. unbind(): void;
  47893. /**
  47894. * Binds the submesh data.
  47895. * @param world - The world matrix.
  47896. * @param mesh - The BJS mesh.
  47897. * @param subMesh - A submesh of the BJS mesh.
  47898. */
  47899. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47900. /**
  47901. * Returns the animatable textures.
  47902. * @returns - Array of animatable textures.
  47903. */
  47904. getAnimatables(): IAnimatable[];
  47905. /**
  47906. * Returns the texture used for reflections.
  47907. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47908. */
  47909. private _getReflectionTexture;
  47910. /**
  47911. * Returns an array of the actively used textures.
  47912. * @returns - Array of BaseTextures
  47913. */
  47914. getActiveTextures(): BaseTexture[];
  47915. /**
  47916. * Checks to see if a texture is used in the material.
  47917. * @param texture - Base texture to use.
  47918. * @returns - Boolean specifying if a texture is used in the material.
  47919. */
  47920. hasTexture(texture: BaseTexture): boolean;
  47921. /**
  47922. * Disposes the resources of the material.
  47923. * @param forceDisposeEffect - Forces the disposal of effects.
  47924. * @param forceDisposeTextures - Forces the disposal of all textures.
  47925. */
  47926. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47927. }
  47928. }
  47929. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47930. import { Nullable } from "babylonjs/types";
  47931. import { Scene } from "babylonjs/scene";
  47932. import { Color3 } from "babylonjs/Maths/math";
  47933. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47934. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47935. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47936. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47937. /**
  47938. * The Physically based material of BJS.
  47939. *
  47940. * This offers the main features of a standard PBR material.
  47941. * For more information, please refer to the documentation :
  47942. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47943. */
  47944. export class PBRMaterial extends PBRBaseMaterial {
  47945. /**
  47946. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47947. */
  47948. static readonly PBRMATERIAL_OPAQUE: number;
  47949. /**
  47950. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47951. */
  47952. static readonly PBRMATERIAL_ALPHATEST: number;
  47953. /**
  47954. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47955. */
  47956. static readonly PBRMATERIAL_ALPHABLEND: number;
  47957. /**
  47958. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47959. * They are also discarded below the alpha cutoff threshold to improve performances.
  47960. */
  47961. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47962. /**
  47963. * Defines the default value of how much AO map is occluding the analytical lights
  47964. * (point spot...).
  47965. */
  47966. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47967. /**
  47968. * Intensity of the direct lights e.g. the four lights available in your scene.
  47969. * This impacts both the direct diffuse and specular highlights.
  47970. */
  47971. directIntensity: number;
  47972. /**
  47973. * Intensity of the emissive part of the material.
  47974. * This helps controlling the emissive effect without modifying the emissive color.
  47975. */
  47976. emissiveIntensity: number;
  47977. /**
  47978. * Intensity of the environment e.g. how much the environment will light the object
  47979. * either through harmonics for rough material or through the refelction for shiny ones.
  47980. */
  47981. environmentIntensity: number;
  47982. /**
  47983. * This is a special control allowing the reduction of the specular highlights coming from the
  47984. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47985. */
  47986. specularIntensity: number;
  47987. /**
  47988. * Debug Control allowing disabling the bump map on this material.
  47989. */
  47990. disableBumpMap: boolean;
  47991. /**
  47992. * AKA Diffuse Texture in standard nomenclature.
  47993. */
  47994. albedoTexture: BaseTexture;
  47995. /**
  47996. * AKA Occlusion Texture in other nomenclature.
  47997. */
  47998. ambientTexture: BaseTexture;
  47999. /**
  48000. * AKA Occlusion Texture Intensity in other nomenclature.
  48001. */
  48002. ambientTextureStrength: number;
  48003. /**
  48004. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48005. * 1 means it completely occludes it
  48006. * 0 mean it has no impact
  48007. */
  48008. ambientTextureImpactOnAnalyticalLights: number;
  48009. /**
  48010. * Stores the alpha values in a texture.
  48011. */
  48012. opacityTexture: BaseTexture;
  48013. /**
  48014. * Stores the reflection values in a texture.
  48015. */
  48016. reflectionTexture: Nullable<BaseTexture>;
  48017. /**
  48018. * Stores the emissive values in a texture.
  48019. */
  48020. emissiveTexture: BaseTexture;
  48021. /**
  48022. * AKA Specular texture in other nomenclature.
  48023. */
  48024. reflectivityTexture: BaseTexture;
  48025. /**
  48026. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48027. */
  48028. metallicTexture: BaseTexture;
  48029. /**
  48030. * Specifies the metallic scalar of the metallic/roughness workflow.
  48031. * Can also be used to scale the metalness values of the metallic texture.
  48032. */
  48033. metallic: Nullable<number>;
  48034. /**
  48035. * Specifies the roughness scalar of the metallic/roughness workflow.
  48036. * Can also be used to scale the roughness values of the metallic texture.
  48037. */
  48038. roughness: Nullable<number>;
  48039. /**
  48040. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48041. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48042. */
  48043. microSurfaceTexture: BaseTexture;
  48044. /**
  48045. * Stores surface normal data used to displace a mesh in a texture.
  48046. */
  48047. bumpTexture: BaseTexture;
  48048. /**
  48049. * Stores the pre-calculated light information of a mesh in a texture.
  48050. */
  48051. lightmapTexture: BaseTexture;
  48052. /**
  48053. * Stores the refracted light information in a texture.
  48054. */
  48055. refractionTexture: Nullable<BaseTexture>;
  48056. /**
  48057. * The color of a material in ambient lighting.
  48058. */
  48059. ambientColor: Color3;
  48060. /**
  48061. * AKA Diffuse Color in other nomenclature.
  48062. */
  48063. albedoColor: Color3;
  48064. /**
  48065. * AKA Specular Color in other nomenclature.
  48066. */
  48067. reflectivityColor: Color3;
  48068. /**
  48069. * The color reflected from the material.
  48070. */
  48071. reflectionColor: Color3;
  48072. /**
  48073. * The color emitted from the material.
  48074. */
  48075. emissiveColor: Color3;
  48076. /**
  48077. * AKA Glossiness in other nomenclature.
  48078. */
  48079. microSurface: number;
  48080. /**
  48081. * source material index of refraction (IOR)' / 'destination material IOR.
  48082. */
  48083. indexOfRefraction: number;
  48084. /**
  48085. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48086. */
  48087. invertRefractionY: boolean;
  48088. /**
  48089. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48090. * Materials half opaque for instance using refraction could benefit from this control.
  48091. */
  48092. linkRefractionWithTransparency: boolean;
  48093. /**
  48094. * If true, the light map contains occlusion information instead of lighting info.
  48095. */
  48096. useLightmapAsShadowmap: boolean;
  48097. /**
  48098. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48099. */
  48100. useAlphaFromAlbedoTexture: boolean;
  48101. /**
  48102. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48103. */
  48104. forceAlphaTest: boolean;
  48105. /**
  48106. * Defines the alpha limits in alpha test mode.
  48107. */
  48108. alphaCutOff: number;
  48109. /**
  48110. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48111. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48112. */
  48113. useSpecularOverAlpha: boolean;
  48114. /**
  48115. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48116. */
  48117. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48118. /**
  48119. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48120. */
  48121. useRoughnessFromMetallicTextureAlpha: boolean;
  48122. /**
  48123. * Specifies if the metallic texture contains the roughness information in its green channel.
  48124. */
  48125. useRoughnessFromMetallicTextureGreen: boolean;
  48126. /**
  48127. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48128. */
  48129. useMetallnessFromMetallicTextureBlue: boolean;
  48130. /**
  48131. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48132. */
  48133. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48134. /**
  48135. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48136. */
  48137. useAmbientInGrayScale: boolean;
  48138. /**
  48139. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48140. * The material will try to infer what glossiness each pixel should be.
  48141. */
  48142. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48143. /**
  48144. * BJS is using an harcoded light falloff based on a manually sets up range.
  48145. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48146. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48147. */
  48148. /**
  48149. * BJS is using an harcoded light falloff based on a manually sets up range.
  48150. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48151. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48152. */
  48153. usePhysicalLightFalloff: boolean;
  48154. /**
  48155. * In order to support the falloff compatibility with gltf, a special mode has been added
  48156. * to reproduce the gltf light falloff.
  48157. */
  48158. /**
  48159. * In order to support the falloff compatibility with gltf, a special mode has been added
  48160. * to reproduce the gltf light falloff.
  48161. */
  48162. useGLTFLightFalloff: boolean;
  48163. /**
  48164. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48165. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48166. */
  48167. useRadianceOverAlpha: boolean;
  48168. /**
  48169. * Allows using an object space normal map (instead of tangent space).
  48170. */
  48171. useObjectSpaceNormalMap: boolean;
  48172. /**
  48173. * Allows using the bump map in parallax mode.
  48174. */
  48175. useParallax: boolean;
  48176. /**
  48177. * Allows using the bump map in parallax occlusion mode.
  48178. */
  48179. useParallaxOcclusion: boolean;
  48180. /**
  48181. * Controls the scale bias of the parallax mode.
  48182. */
  48183. parallaxScaleBias: number;
  48184. /**
  48185. * If sets to true, disables all the lights affecting the material.
  48186. */
  48187. disableLighting: boolean;
  48188. /**
  48189. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48190. */
  48191. forceIrradianceInFragment: boolean;
  48192. /**
  48193. * Number of Simultaneous lights allowed on the material.
  48194. */
  48195. maxSimultaneousLights: number;
  48196. /**
  48197. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48198. */
  48199. invertNormalMapX: boolean;
  48200. /**
  48201. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48202. */
  48203. invertNormalMapY: boolean;
  48204. /**
  48205. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48206. */
  48207. twoSidedLighting: boolean;
  48208. /**
  48209. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48210. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48211. */
  48212. useAlphaFresnel: boolean;
  48213. /**
  48214. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48215. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48216. */
  48217. useLinearAlphaFresnel: boolean;
  48218. /**
  48219. * Let user defines the brdf lookup texture used for IBL.
  48220. * A default 8bit version is embedded but you could point at :
  48221. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  48222. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48223. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48224. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48225. */
  48226. environmentBRDFTexture: Nullable<BaseTexture>;
  48227. /**
  48228. * Force normal to face away from face.
  48229. */
  48230. forceNormalForward: boolean;
  48231. /**
  48232. * Enables specular anti aliasing in the PBR shader.
  48233. * It will both interacts on the Geometry for analytical and IBL lighting.
  48234. * It also prefilter the roughness map based on the bump values.
  48235. */
  48236. enableSpecularAntiAliasing: boolean;
  48237. /**
  48238. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48239. * makes the reflect vector face the model (under horizon).
  48240. */
  48241. useHorizonOcclusion: boolean;
  48242. /**
  48243. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48244. * too much the area relying on ambient texture to define their ambient occlusion.
  48245. */
  48246. useRadianceOcclusion: boolean;
  48247. /**
  48248. * If set to true, no lighting calculations will be applied.
  48249. */
  48250. unlit: boolean;
  48251. /**
  48252. * Gets the image processing configuration used either in this material.
  48253. */
  48254. /**
  48255. * Sets the Default image processing configuration used either in the this material.
  48256. *
  48257. * If sets to null, the scene one is in use.
  48258. */
  48259. imageProcessingConfiguration: ImageProcessingConfiguration;
  48260. /**
  48261. * Gets wether the color curves effect is enabled.
  48262. */
  48263. /**
  48264. * Sets wether the color curves effect is enabled.
  48265. */
  48266. cameraColorCurvesEnabled: boolean;
  48267. /**
  48268. * Gets wether the color grading effect is enabled.
  48269. */
  48270. /**
  48271. * Gets wether the color grading effect is enabled.
  48272. */
  48273. cameraColorGradingEnabled: boolean;
  48274. /**
  48275. * Gets wether tonemapping is enabled or not.
  48276. */
  48277. /**
  48278. * Sets wether tonemapping is enabled or not
  48279. */
  48280. cameraToneMappingEnabled: boolean;
  48281. /**
  48282. * The camera exposure used on this material.
  48283. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48284. * This corresponds to a photographic exposure.
  48285. */
  48286. /**
  48287. * The camera exposure used on this material.
  48288. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48289. * This corresponds to a photographic exposure.
  48290. */
  48291. cameraExposure: number;
  48292. /**
  48293. * Gets The camera contrast used on this material.
  48294. */
  48295. /**
  48296. * Sets The camera contrast used on this material.
  48297. */
  48298. cameraContrast: number;
  48299. /**
  48300. * Gets the Color Grading 2D Lookup Texture.
  48301. */
  48302. /**
  48303. * Sets the Color Grading 2D Lookup Texture.
  48304. */
  48305. cameraColorGradingTexture: Nullable<BaseTexture>;
  48306. /**
  48307. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48308. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48309. * 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;
  48310. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48311. */
  48312. /**
  48313. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48314. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48315. * 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;
  48316. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48317. */
  48318. cameraColorCurves: Nullable<ColorCurves>;
  48319. /**
  48320. * Instantiates a new PBRMaterial instance.
  48321. *
  48322. * @param name The material name
  48323. * @param scene The scene the material will be use in.
  48324. */
  48325. constructor(name: string, scene: Scene);
  48326. /**
  48327. * Returns the name of this material class.
  48328. */
  48329. getClassName(): string;
  48330. /**
  48331. * Makes a duplicate of the current material.
  48332. * @param name - name to use for the new material.
  48333. */
  48334. clone(name: string): PBRMaterial;
  48335. /**
  48336. * Serializes this PBR Material.
  48337. * @returns - An object with the serialized material.
  48338. */
  48339. serialize(): any;
  48340. /**
  48341. * Parses a PBR Material from a serialized object.
  48342. * @param source - Serialized object.
  48343. * @param scene - BJS scene instance.
  48344. * @param rootUrl - url for the scene object
  48345. * @returns - PBRMaterial
  48346. */
  48347. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48348. }
  48349. }
  48350. declare module "babylonjs/Misc/dds" {
  48351. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48352. import { Engine } from "babylonjs/Engines/engine";
  48353. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48354. import { Nullable } from "babylonjs/types";
  48355. import { Scene } from "babylonjs/scene";
  48356. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48357. /**
  48358. * Direct draw surface info
  48359. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48360. */
  48361. export interface DDSInfo {
  48362. /**
  48363. * Width of the texture
  48364. */
  48365. width: number;
  48366. /**
  48367. * Width of the texture
  48368. */
  48369. height: number;
  48370. /**
  48371. * Number of Mipmaps for the texture
  48372. * @see https://en.wikipedia.org/wiki/Mipmap
  48373. */
  48374. mipmapCount: number;
  48375. /**
  48376. * If the textures format is a known fourCC format
  48377. * @see https://www.fourcc.org/
  48378. */
  48379. isFourCC: boolean;
  48380. /**
  48381. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48382. */
  48383. isRGB: boolean;
  48384. /**
  48385. * If the texture is a lumincance format
  48386. */
  48387. isLuminance: boolean;
  48388. /**
  48389. * If this is a cube texture
  48390. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48391. */
  48392. isCube: boolean;
  48393. /**
  48394. * If the texture is a compressed format eg. FOURCC_DXT1
  48395. */
  48396. isCompressed: boolean;
  48397. /**
  48398. * The dxgiFormat of the texture
  48399. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48400. */
  48401. dxgiFormat: number;
  48402. /**
  48403. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48404. */
  48405. textureType: number;
  48406. /**
  48407. * Sphericle polynomial created for the dds texture
  48408. */
  48409. sphericalPolynomial?: SphericalPolynomial;
  48410. }
  48411. /**
  48412. * Class used to provide DDS decompression tools
  48413. */
  48414. export class DDSTools {
  48415. /**
  48416. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48417. */
  48418. static StoreLODInAlphaChannel: boolean;
  48419. /**
  48420. * Gets DDS information from an array buffer
  48421. * @param arrayBuffer defines the array buffer to read data from
  48422. * @returns the DDS information
  48423. */
  48424. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48425. private static _FloatView;
  48426. private static _Int32View;
  48427. private static _ToHalfFloat;
  48428. private static _FromHalfFloat;
  48429. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48430. private static _GetHalfFloatRGBAArrayBuffer;
  48431. private static _GetFloatRGBAArrayBuffer;
  48432. private static _GetFloatAsUIntRGBAArrayBuffer;
  48433. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48434. private static _GetRGBAArrayBuffer;
  48435. private static _ExtractLongWordOrder;
  48436. private static _GetRGBArrayBuffer;
  48437. private static _GetLuminanceArrayBuffer;
  48438. /**
  48439. * Uploads DDS Levels to a Babylon Texture
  48440. * @hidden
  48441. */
  48442. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48443. }
  48444. module "babylonjs/Engines/engine" {
  48445. interface Engine {
  48446. /**
  48447. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48448. * @param rootUrl defines the url where the file to load is located
  48449. * @param scene defines the current scene
  48450. * @param lodScale defines scale to apply to the mip map selection
  48451. * @param lodOffset defines offset to apply to the mip map selection
  48452. * @param onLoad defines an optional callback raised when the texture is loaded
  48453. * @param onError defines an optional callback raised if there is an issue to load the texture
  48454. * @param format defines the format of the data
  48455. * @param forcedExtension defines the extension to use to pick the right loader
  48456. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48457. * @returns the cube texture as an InternalTexture
  48458. */
  48459. 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;
  48460. }
  48461. }
  48462. }
  48463. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48464. import { Nullable } from "babylonjs/types";
  48465. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48466. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48467. /**
  48468. * Implementation of the DDS Texture Loader.
  48469. * @hidden
  48470. */
  48471. export class _DDSTextureLoader implements IInternalTextureLoader {
  48472. /**
  48473. * Defines wether the loader supports cascade loading the different faces.
  48474. */
  48475. readonly supportCascades: boolean;
  48476. /**
  48477. * This returns if the loader support the current file information.
  48478. * @param extension defines the file extension of the file being loaded
  48479. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48480. * @param fallback defines the fallback internal texture if any
  48481. * @param isBase64 defines whether the texture is encoded as a base64
  48482. * @param isBuffer defines whether the texture data are stored as a buffer
  48483. * @returns true if the loader can load the specified file
  48484. */
  48485. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48486. /**
  48487. * Transform the url before loading if required.
  48488. * @param rootUrl the url of the texture
  48489. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48490. * @returns the transformed texture
  48491. */
  48492. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48493. /**
  48494. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48495. * @param rootUrl the url of the texture
  48496. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48497. * @returns the fallback texture
  48498. */
  48499. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48500. /**
  48501. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48502. * @param data contains the texture data
  48503. * @param texture defines the BabylonJS internal texture
  48504. * @param createPolynomials will be true if polynomials have been requested
  48505. * @param onLoad defines the callback to trigger once the texture is ready
  48506. * @param onError defines the callback to trigger in case of error
  48507. */
  48508. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48509. /**
  48510. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48511. * @param data contains the texture data
  48512. * @param texture defines the BabylonJS internal texture
  48513. * @param callback defines the method to call once ready to upload
  48514. */
  48515. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48516. }
  48517. }
  48518. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48519. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48520. /** @hidden */
  48521. export var rgbdEncodePixelShader: {
  48522. name: string;
  48523. shader: string;
  48524. };
  48525. }
  48526. declare module "babylonjs/Misc/environmentTextureTools" {
  48527. import { Nullable } from "babylonjs/types";
  48528. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48529. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48530. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48531. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48532. import "babylonjs/Shaders/rgbdEncode.fragment";
  48533. import "babylonjs/Shaders/rgbdDecode.fragment";
  48534. /**
  48535. * Raw texture data and descriptor sufficient for WebGL texture upload
  48536. */
  48537. export interface EnvironmentTextureInfo {
  48538. /**
  48539. * Version of the environment map
  48540. */
  48541. version: number;
  48542. /**
  48543. * Width of image
  48544. */
  48545. width: number;
  48546. /**
  48547. * Irradiance information stored in the file.
  48548. */
  48549. irradiance: any;
  48550. /**
  48551. * Specular information stored in the file.
  48552. */
  48553. specular: any;
  48554. }
  48555. /**
  48556. * Sets of helpers addressing the serialization and deserialization of environment texture
  48557. * stored in a BabylonJS env file.
  48558. * Those files are usually stored as .env files.
  48559. */
  48560. export class EnvironmentTextureTools {
  48561. /**
  48562. * Magic number identifying the env file.
  48563. */
  48564. private static _MagicBytes;
  48565. /**
  48566. * Gets the environment info from an env file.
  48567. * @param data The array buffer containing the .env bytes.
  48568. * @returns the environment file info (the json header) if successfully parsed.
  48569. */
  48570. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48571. /**
  48572. * Creates an environment texture from a loaded cube texture.
  48573. * @param texture defines the cube texture to convert in env file
  48574. * @return a promise containing the environment data if succesfull.
  48575. */
  48576. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48577. /**
  48578. * Creates a JSON representation of the spherical data.
  48579. * @param texture defines the texture containing the polynomials
  48580. * @return the JSON representation of the spherical info
  48581. */
  48582. private static _CreateEnvTextureIrradiance;
  48583. /**
  48584. * Uploads the texture info contained in the env file to the GPU.
  48585. * @param texture defines the internal texture to upload to
  48586. * @param arrayBuffer defines the buffer cotaining the data to load
  48587. * @param info defines the texture info retrieved through the GetEnvInfo method
  48588. * @returns a promise
  48589. */
  48590. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48591. /**
  48592. * Uploads the levels of image data to the GPU.
  48593. * @param texture defines the internal texture to upload to
  48594. * @param imageData defines the array buffer views of image data [mipmap][face]
  48595. * @returns a promise
  48596. */
  48597. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48598. /**
  48599. * Uploads spherical polynomials information to the texture.
  48600. * @param texture defines the texture we are trying to upload the information to
  48601. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48602. */
  48603. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48604. /** @hidden */
  48605. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48606. }
  48607. }
  48608. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48609. import { Nullable } from "babylonjs/types";
  48610. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48611. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48612. /**
  48613. * Implementation of the ENV Texture Loader.
  48614. * @hidden
  48615. */
  48616. export class _ENVTextureLoader implements IInternalTextureLoader {
  48617. /**
  48618. * Defines wether the loader supports cascade loading the different faces.
  48619. */
  48620. readonly supportCascades: boolean;
  48621. /**
  48622. * This returns if the loader support the current file information.
  48623. * @param extension defines the file extension of the file being loaded
  48624. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48625. * @param fallback defines the fallback internal texture if any
  48626. * @param isBase64 defines whether the texture is encoded as a base64
  48627. * @param isBuffer defines whether the texture data are stored as a buffer
  48628. * @returns true if the loader can load the specified file
  48629. */
  48630. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48631. /**
  48632. * Transform the url before loading if required.
  48633. * @param rootUrl the url of the texture
  48634. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48635. * @returns the transformed texture
  48636. */
  48637. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48638. /**
  48639. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48640. * @param rootUrl the url of the texture
  48641. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48642. * @returns the fallback texture
  48643. */
  48644. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48645. /**
  48646. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48647. * @param data contains the texture data
  48648. * @param texture defines the BabylonJS internal texture
  48649. * @param createPolynomials will be true if polynomials have been requested
  48650. * @param onLoad defines the callback to trigger once the texture is ready
  48651. * @param onError defines the callback to trigger in case of error
  48652. */
  48653. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48654. /**
  48655. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48656. * @param data contains the texture data
  48657. * @param texture defines the BabylonJS internal texture
  48658. * @param callback defines the method to call once ready to upload
  48659. */
  48660. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48661. }
  48662. }
  48663. declare module "babylonjs/Misc/khronosTextureContainer" {
  48664. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48665. /**
  48666. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48667. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48668. */
  48669. export class KhronosTextureContainer {
  48670. /** contents of the KTX container file */
  48671. arrayBuffer: any;
  48672. private static HEADER_LEN;
  48673. private static COMPRESSED_2D;
  48674. private static COMPRESSED_3D;
  48675. private static TEX_2D;
  48676. private static TEX_3D;
  48677. /**
  48678. * Gets the openGL type
  48679. */
  48680. glType: number;
  48681. /**
  48682. * Gets the openGL type size
  48683. */
  48684. glTypeSize: number;
  48685. /**
  48686. * Gets the openGL format
  48687. */
  48688. glFormat: number;
  48689. /**
  48690. * Gets the openGL internal format
  48691. */
  48692. glInternalFormat: number;
  48693. /**
  48694. * Gets the base internal format
  48695. */
  48696. glBaseInternalFormat: number;
  48697. /**
  48698. * Gets image width in pixel
  48699. */
  48700. pixelWidth: number;
  48701. /**
  48702. * Gets image height in pixel
  48703. */
  48704. pixelHeight: number;
  48705. /**
  48706. * Gets image depth in pixels
  48707. */
  48708. pixelDepth: number;
  48709. /**
  48710. * Gets the number of array elements
  48711. */
  48712. numberOfArrayElements: number;
  48713. /**
  48714. * Gets the number of faces
  48715. */
  48716. numberOfFaces: number;
  48717. /**
  48718. * Gets the number of mipmap levels
  48719. */
  48720. numberOfMipmapLevels: number;
  48721. /**
  48722. * Gets the bytes of key value data
  48723. */
  48724. bytesOfKeyValueData: number;
  48725. /**
  48726. * Gets the load type
  48727. */
  48728. loadType: number;
  48729. /**
  48730. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48731. */
  48732. isInvalid: boolean;
  48733. /**
  48734. * Creates a new KhronosTextureContainer
  48735. * @param arrayBuffer contents of the KTX container file
  48736. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48737. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48738. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48739. */
  48740. constructor(
  48741. /** contents of the KTX container file */
  48742. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48743. /**
  48744. * Uploads KTX content to a Babylon Texture.
  48745. * It is assumed that the texture has already been created & is currently bound
  48746. * @hidden
  48747. */
  48748. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48749. private _upload2DCompressedLevels;
  48750. }
  48751. }
  48752. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48753. import { Nullable } from "babylonjs/types";
  48754. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48755. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48756. /**
  48757. * Implementation of the KTX Texture Loader.
  48758. * @hidden
  48759. */
  48760. export class _KTXTextureLoader implements IInternalTextureLoader {
  48761. /**
  48762. * Defines wether the loader supports cascade loading the different faces.
  48763. */
  48764. readonly supportCascades: boolean;
  48765. /**
  48766. * This returns if the loader support the current file information.
  48767. * @param extension defines the file extension of the file being loaded
  48768. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48769. * @param fallback defines the fallback internal texture if any
  48770. * @param isBase64 defines whether the texture is encoded as a base64
  48771. * @param isBuffer defines whether the texture data are stored as a buffer
  48772. * @returns true if the loader can load the specified file
  48773. */
  48774. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48775. /**
  48776. * Transform the url before loading if required.
  48777. * @param rootUrl the url of the texture
  48778. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48779. * @returns the transformed texture
  48780. */
  48781. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48782. /**
  48783. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48784. * @param rootUrl the url of the texture
  48785. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48786. * @returns the fallback texture
  48787. */
  48788. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48789. /**
  48790. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48791. * @param data contains the texture data
  48792. * @param texture defines the BabylonJS internal texture
  48793. * @param createPolynomials will be true if polynomials have been requested
  48794. * @param onLoad defines the callback to trigger once the texture is ready
  48795. * @param onError defines the callback to trigger in case of error
  48796. */
  48797. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48798. /**
  48799. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48800. * @param data contains the texture data
  48801. * @param texture defines the BabylonJS internal texture
  48802. * @param callback defines the method to call once ready to upload
  48803. */
  48804. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48805. }
  48806. }
  48807. declare module "babylonjs/Helpers/sceneHelpers" {
  48808. import { Nullable } from "babylonjs/types";
  48809. import { Mesh } from "babylonjs/Meshes/mesh";
  48810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48811. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48812. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48813. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48814. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48815. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48816. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48817. import "babylonjs/Meshes/Builders/boxBuilder";
  48818. /** @hidden */
  48819. export var _forceSceneHelpersToBundle: boolean;
  48820. module "babylonjs/scene" {
  48821. interface Scene {
  48822. /**
  48823. * Creates a default light for the scene.
  48824. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48825. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48826. */
  48827. createDefaultLight(replace?: boolean): void;
  48828. /**
  48829. * Creates a default camera for the scene.
  48830. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48831. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48832. * @param replace has default false, when true replaces the active camera in the scene
  48833. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48834. */
  48835. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48836. /**
  48837. * Creates a default camera and a default light.
  48838. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48839. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48840. * @param replace has the default false, when true replaces the active camera/light in the scene
  48841. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48842. */
  48843. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48844. /**
  48845. * Creates a new sky box
  48846. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48847. * @param environmentTexture defines the texture to use as environment texture
  48848. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48849. * @param scale defines the overall scale of the skybox
  48850. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48851. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48852. * @returns a new mesh holding the sky box
  48853. */
  48854. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48855. /**
  48856. * Creates a new environment
  48857. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48858. * @param options defines the options you can use to configure the environment
  48859. * @returns the new EnvironmentHelper
  48860. */
  48861. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48862. /**
  48863. * Creates a new VREXperienceHelper
  48864. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48865. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48866. * @returns a new VREXperienceHelper
  48867. */
  48868. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48869. /**
  48870. * Creates a new XREXperienceHelper
  48871. * @see http://doc.babylonjs.com/how_to/webxr
  48872. * @returns a promise for a new XREXperienceHelper
  48873. */
  48874. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48875. }
  48876. }
  48877. }
  48878. declare module "babylonjs/Helpers/videoDome" {
  48879. import { Scene } from "babylonjs/scene";
  48880. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48881. import { Mesh } from "babylonjs/Meshes/mesh";
  48882. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48883. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48884. import "babylonjs/Meshes/Builders/sphereBuilder";
  48885. /**
  48886. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48887. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48888. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48889. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48890. */
  48891. export class VideoDome extends TransformNode {
  48892. /**
  48893. * Define the video source as a Monoscopic panoramic 360 video.
  48894. */
  48895. static readonly MODE_MONOSCOPIC: number;
  48896. /**
  48897. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48898. */
  48899. static readonly MODE_TOPBOTTOM: number;
  48900. /**
  48901. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48902. */
  48903. static readonly MODE_SIDEBYSIDE: number;
  48904. private _useDirectMapping;
  48905. /**
  48906. * The video texture being displayed on the sphere
  48907. */
  48908. protected _videoTexture: VideoTexture;
  48909. /**
  48910. * Gets the video texture being displayed on the sphere
  48911. */
  48912. readonly videoTexture: VideoTexture;
  48913. /**
  48914. * The skybox material
  48915. */
  48916. protected _material: BackgroundMaterial;
  48917. /**
  48918. * The surface used for the skybox
  48919. */
  48920. protected _mesh: Mesh;
  48921. /**
  48922. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48923. * Also see the options.resolution property.
  48924. */
  48925. fovMultiplier: number;
  48926. private _videoMode;
  48927. /**
  48928. * Gets or set the current video mode for the video. It can be:
  48929. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48930. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48931. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48932. */
  48933. videoMode: number;
  48934. /**
  48935. * Oberserver used in Stereoscopic VR Mode.
  48936. */
  48937. private _onBeforeCameraRenderObserver;
  48938. /**
  48939. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48940. * @param name Element's name, child elements will append suffixes for their own names.
  48941. * @param urlsOrVideo defines the url(s) or the video element to use
  48942. * @param options An object containing optional or exposed sub element properties
  48943. */
  48944. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48945. resolution?: number;
  48946. clickToPlay?: boolean;
  48947. autoPlay?: boolean;
  48948. loop?: boolean;
  48949. size?: number;
  48950. poster?: string;
  48951. faceForward?: boolean;
  48952. useDirectMapping?: boolean;
  48953. }, scene: Scene);
  48954. private _changeVideoMode;
  48955. /**
  48956. * Releases resources associated with this node.
  48957. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48958. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48959. */
  48960. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48961. }
  48962. }
  48963. declare module "babylonjs/Helpers/index" {
  48964. export * from "babylonjs/Helpers/environmentHelper";
  48965. export * from "babylonjs/Helpers/photoDome";
  48966. export * from "babylonjs/Helpers/sceneHelpers";
  48967. export * from "babylonjs/Helpers/videoDome";
  48968. }
  48969. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48970. import { PerfCounter } from "babylonjs/Misc/tools";
  48971. import { IDisposable } from "babylonjs/scene";
  48972. import { Engine } from "babylonjs/Engines/engine";
  48973. /**
  48974. * This class can be used to get instrumentation data from a Babylon engine
  48975. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48976. */
  48977. export class EngineInstrumentation implements IDisposable {
  48978. /**
  48979. * Define the instrumented engine.
  48980. */
  48981. engine: Engine;
  48982. private _captureGPUFrameTime;
  48983. private _gpuFrameTimeToken;
  48984. private _gpuFrameTime;
  48985. private _captureShaderCompilationTime;
  48986. private _shaderCompilationTime;
  48987. private _onBeginFrameObserver;
  48988. private _onEndFrameObserver;
  48989. private _onBeforeShaderCompilationObserver;
  48990. private _onAfterShaderCompilationObserver;
  48991. /**
  48992. * Gets the perf counter used for GPU frame time
  48993. */
  48994. readonly gpuFrameTimeCounter: PerfCounter;
  48995. /**
  48996. * Gets the GPU frame time capture status
  48997. */
  48998. /**
  48999. * Enable or disable the GPU frame time capture
  49000. */
  49001. captureGPUFrameTime: boolean;
  49002. /**
  49003. * Gets the perf counter used for shader compilation time
  49004. */
  49005. readonly shaderCompilationTimeCounter: PerfCounter;
  49006. /**
  49007. * Gets the shader compilation time capture status
  49008. */
  49009. /**
  49010. * Enable or disable the shader compilation time capture
  49011. */
  49012. captureShaderCompilationTime: boolean;
  49013. /**
  49014. * Instantiates a new engine instrumentation.
  49015. * This class can be used to get instrumentation data from a Babylon engine
  49016. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49017. * @param engine Defines the engine to instrument
  49018. */
  49019. constructor(
  49020. /**
  49021. * Define the instrumented engine.
  49022. */
  49023. engine: Engine);
  49024. /**
  49025. * Dispose and release associated resources.
  49026. */
  49027. dispose(): void;
  49028. }
  49029. }
  49030. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49031. import { PerfCounter } from "babylonjs/Misc/tools";
  49032. import { Scene, IDisposable } from "babylonjs/scene";
  49033. /**
  49034. * This class can be used to get instrumentation data from a Babylon engine
  49035. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49036. */
  49037. export class SceneInstrumentation implements IDisposable {
  49038. /**
  49039. * Defines the scene to instrument
  49040. */
  49041. scene: Scene;
  49042. private _captureActiveMeshesEvaluationTime;
  49043. private _activeMeshesEvaluationTime;
  49044. private _captureRenderTargetsRenderTime;
  49045. private _renderTargetsRenderTime;
  49046. private _captureFrameTime;
  49047. private _frameTime;
  49048. private _captureRenderTime;
  49049. private _renderTime;
  49050. private _captureInterFrameTime;
  49051. private _interFrameTime;
  49052. private _captureParticlesRenderTime;
  49053. private _particlesRenderTime;
  49054. private _captureSpritesRenderTime;
  49055. private _spritesRenderTime;
  49056. private _capturePhysicsTime;
  49057. private _physicsTime;
  49058. private _captureAnimationsTime;
  49059. private _animationsTime;
  49060. private _captureCameraRenderTime;
  49061. private _cameraRenderTime;
  49062. private _onBeforeActiveMeshesEvaluationObserver;
  49063. private _onAfterActiveMeshesEvaluationObserver;
  49064. private _onBeforeRenderTargetsRenderObserver;
  49065. private _onAfterRenderTargetsRenderObserver;
  49066. private _onAfterRenderObserver;
  49067. private _onBeforeDrawPhaseObserver;
  49068. private _onAfterDrawPhaseObserver;
  49069. private _onBeforeAnimationsObserver;
  49070. private _onBeforeParticlesRenderingObserver;
  49071. private _onAfterParticlesRenderingObserver;
  49072. private _onBeforeSpritesRenderingObserver;
  49073. private _onAfterSpritesRenderingObserver;
  49074. private _onBeforePhysicsObserver;
  49075. private _onAfterPhysicsObserver;
  49076. private _onAfterAnimationsObserver;
  49077. private _onBeforeCameraRenderObserver;
  49078. private _onAfterCameraRenderObserver;
  49079. /**
  49080. * Gets the perf counter used for active meshes evaluation time
  49081. */
  49082. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49083. /**
  49084. * Gets the active meshes evaluation time capture status
  49085. */
  49086. /**
  49087. * Enable or disable the active meshes evaluation time capture
  49088. */
  49089. captureActiveMeshesEvaluationTime: boolean;
  49090. /**
  49091. * Gets the perf counter used for render targets render time
  49092. */
  49093. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49094. /**
  49095. * Gets the render targets render time capture status
  49096. */
  49097. /**
  49098. * Enable or disable the render targets render time capture
  49099. */
  49100. captureRenderTargetsRenderTime: boolean;
  49101. /**
  49102. * Gets the perf counter used for particles render time
  49103. */
  49104. readonly particlesRenderTimeCounter: PerfCounter;
  49105. /**
  49106. * Gets the particles render time capture status
  49107. */
  49108. /**
  49109. * Enable or disable the particles render time capture
  49110. */
  49111. captureParticlesRenderTime: boolean;
  49112. /**
  49113. * Gets the perf counter used for sprites render time
  49114. */
  49115. readonly spritesRenderTimeCounter: PerfCounter;
  49116. /**
  49117. * Gets the sprites render time capture status
  49118. */
  49119. /**
  49120. * Enable or disable the sprites render time capture
  49121. */
  49122. captureSpritesRenderTime: boolean;
  49123. /**
  49124. * Gets the perf counter used for physics time
  49125. */
  49126. readonly physicsTimeCounter: PerfCounter;
  49127. /**
  49128. * Gets the physics time capture status
  49129. */
  49130. /**
  49131. * Enable or disable the physics time capture
  49132. */
  49133. capturePhysicsTime: boolean;
  49134. /**
  49135. * Gets the perf counter used for animations time
  49136. */
  49137. readonly animationsTimeCounter: PerfCounter;
  49138. /**
  49139. * Gets the animations time capture status
  49140. */
  49141. /**
  49142. * Enable or disable the animations time capture
  49143. */
  49144. captureAnimationsTime: boolean;
  49145. /**
  49146. * Gets the perf counter used for frame time capture
  49147. */
  49148. readonly frameTimeCounter: PerfCounter;
  49149. /**
  49150. * Gets the frame time capture status
  49151. */
  49152. /**
  49153. * Enable or disable the frame time capture
  49154. */
  49155. captureFrameTime: boolean;
  49156. /**
  49157. * Gets the perf counter used for inter-frames time capture
  49158. */
  49159. readonly interFrameTimeCounter: PerfCounter;
  49160. /**
  49161. * Gets the inter-frames time capture status
  49162. */
  49163. /**
  49164. * Enable or disable the inter-frames time capture
  49165. */
  49166. captureInterFrameTime: boolean;
  49167. /**
  49168. * Gets the perf counter used for render time capture
  49169. */
  49170. readonly renderTimeCounter: PerfCounter;
  49171. /**
  49172. * Gets the render time capture status
  49173. */
  49174. /**
  49175. * Enable or disable the render time capture
  49176. */
  49177. captureRenderTime: boolean;
  49178. /**
  49179. * Gets the perf counter used for camera render time capture
  49180. */
  49181. readonly cameraRenderTimeCounter: PerfCounter;
  49182. /**
  49183. * Gets the camera render time capture status
  49184. */
  49185. /**
  49186. * Enable or disable the camera render time capture
  49187. */
  49188. captureCameraRenderTime: boolean;
  49189. /**
  49190. * Gets the perf counter used for draw calls
  49191. */
  49192. readonly drawCallsCounter: PerfCounter;
  49193. /**
  49194. * Instantiates a new scene instrumentation.
  49195. * This class can be used to get instrumentation data from a Babylon engine
  49196. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49197. * @param scene Defines the scene to instrument
  49198. */
  49199. constructor(
  49200. /**
  49201. * Defines the scene to instrument
  49202. */
  49203. scene: Scene);
  49204. /**
  49205. * Dispose and release associated resources.
  49206. */
  49207. dispose(): void;
  49208. }
  49209. }
  49210. declare module "babylonjs/Instrumentation/index" {
  49211. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49212. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49213. export * from "babylonjs/Instrumentation/timeToken";
  49214. }
  49215. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49216. /** @hidden */
  49217. export var glowMapGenerationPixelShader: {
  49218. name: string;
  49219. shader: string;
  49220. };
  49221. }
  49222. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49223. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49224. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49225. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49226. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49227. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49228. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49229. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49230. /** @hidden */
  49231. export var glowMapGenerationVertexShader: {
  49232. name: string;
  49233. shader: string;
  49234. };
  49235. }
  49236. declare module "babylonjs/Layers/effectLayer" {
  49237. import { Observable } from "babylonjs/Misc/observable";
  49238. import { Nullable } from "babylonjs/types";
  49239. import { Camera } from "babylonjs/Cameras/camera";
  49240. import { Scene } from "babylonjs/scene";
  49241. import { Color4, ISize } from "babylonjs/Maths/math";
  49242. import { Engine } from "babylonjs/Engines/engine";
  49243. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49245. import { Mesh } from "babylonjs/Meshes/mesh";
  49246. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49248. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49249. import { Effect } from "babylonjs/Materials/effect";
  49250. import { Material } from "babylonjs/Materials/material";
  49251. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49252. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49253. /**
  49254. * Effect layer options. This helps customizing the behaviour
  49255. * of the effect layer.
  49256. */
  49257. export interface IEffectLayerOptions {
  49258. /**
  49259. * Multiplication factor apply to the canvas size to compute the render target size
  49260. * used to generated the objects (the smaller the faster).
  49261. */
  49262. mainTextureRatio: number;
  49263. /**
  49264. * Enforces a fixed size texture to ensure effect stability across devices.
  49265. */
  49266. mainTextureFixedSize?: number;
  49267. /**
  49268. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49269. */
  49270. alphaBlendingMode: number;
  49271. /**
  49272. * The camera attached to the layer.
  49273. */
  49274. camera: Nullable<Camera>;
  49275. /**
  49276. * The rendering group to draw the layer in.
  49277. */
  49278. renderingGroupId: number;
  49279. }
  49280. /**
  49281. * The effect layer Helps adding post process effect blended with the main pass.
  49282. *
  49283. * This can be for instance use to generate glow or higlight effects on the scene.
  49284. *
  49285. * The effect layer class can not be used directly and is intented to inherited from to be
  49286. * customized per effects.
  49287. */
  49288. export abstract class EffectLayer {
  49289. private _vertexBuffers;
  49290. private _indexBuffer;
  49291. private _cachedDefines;
  49292. private _effectLayerMapGenerationEffect;
  49293. private _effectLayerOptions;
  49294. private _mergeEffect;
  49295. protected _scene: Scene;
  49296. protected _engine: Engine;
  49297. protected _maxSize: number;
  49298. protected _mainTextureDesiredSize: ISize;
  49299. protected _mainTexture: RenderTargetTexture;
  49300. protected _shouldRender: boolean;
  49301. protected _postProcesses: PostProcess[];
  49302. protected _textures: BaseTexture[];
  49303. protected _emissiveTextureAndColor: {
  49304. texture: Nullable<BaseTexture>;
  49305. color: Color4;
  49306. };
  49307. /**
  49308. * The name of the layer
  49309. */
  49310. name: string;
  49311. /**
  49312. * The clear color of the texture used to generate the glow map.
  49313. */
  49314. neutralColor: Color4;
  49315. /**
  49316. * Specifies wether the highlight layer is enabled or not.
  49317. */
  49318. isEnabled: boolean;
  49319. /**
  49320. * Gets the camera attached to the layer.
  49321. */
  49322. readonly camera: Nullable<Camera>;
  49323. /**
  49324. * Gets the rendering group id the layer should render in.
  49325. */
  49326. readonly renderingGroupId: number;
  49327. /**
  49328. * An event triggered when the effect layer has been disposed.
  49329. */
  49330. onDisposeObservable: Observable<EffectLayer>;
  49331. /**
  49332. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49333. */
  49334. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49335. /**
  49336. * An event triggered when the generated texture is being merged in the scene.
  49337. */
  49338. onBeforeComposeObservable: Observable<EffectLayer>;
  49339. /**
  49340. * An event triggered when the generated texture has been merged in the scene.
  49341. */
  49342. onAfterComposeObservable: Observable<EffectLayer>;
  49343. /**
  49344. * An event triggered when the efffect layer changes its size.
  49345. */
  49346. onSizeChangedObservable: Observable<EffectLayer>;
  49347. /** @hidden */
  49348. static _SceneComponentInitialization: (scene: Scene) => void;
  49349. /**
  49350. * Instantiates a new effect Layer and references it in the scene.
  49351. * @param name The name of the layer
  49352. * @param scene The scene to use the layer in
  49353. */
  49354. constructor(
  49355. /** The Friendly of the effect in the scene */
  49356. name: string, scene: Scene);
  49357. /**
  49358. * Get the effect name of the layer.
  49359. * @return The effect name
  49360. */
  49361. abstract getEffectName(): string;
  49362. /**
  49363. * Checks for the readiness of the element composing the layer.
  49364. * @param subMesh the mesh to check for
  49365. * @param useInstances specify wether or not to use instances to render the mesh
  49366. * @return true if ready otherwise, false
  49367. */
  49368. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49369. /**
  49370. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49371. * @returns true if the effect requires stencil during the main canvas render pass.
  49372. */
  49373. abstract needStencil(): boolean;
  49374. /**
  49375. * Create the merge effect. This is the shader use to blit the information back
  49376. * to the main canvas at the end of the scene rendering.
  49377. * @returns The effect containing the shader used to merge the effect on the main canvas
  49378. */
  49379. protected abstract _createMergeEffect(): Effect;
  49380. /**
  49381. * Creates the render target textures and post processes used in the effect layer.
  49382. */
  49383. protected abstract _createTextureAndPostProcesses(): void;
  49384. /**
  49385. * Implementation specific of rendering the generating effect on the main canvas.
  49386. * @param effect The effect used to render through
  49387. */
  49388. protected abstract _internalRender(effect: Effect): void;
  49389. /**
  49390. * Sets the required values for both the emissive texture and and the main color.
  49391. */
  49392. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49393. /**
  49394. * Free any resources and references associated to a mesh.
  49395. * Internal use
  49396. * @param mesh The mesh to free.
  49397. */
  49398. abstract _disposeMesh(mesh: Mesh): void;
  49399. /**
  49400. * Serializes this layer (Glow or Highlight for example)
  49401. * @returns a serialized layer object
  49402. */
  49403. abstract serialize?(): any;
  49404. /**
  49405. * Initializes the effect layer with the required options.
  49406. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49407. */
  49408. protected _init(options: Partial<IEffectLayerOptions>): void;
  49409. /**
  49410. * Generates the index buffer of the full screen quad blending to the main canvas.
  49411. */
  49412. private _generateIndexBuffer;
  49413. /**
  49414. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49415. */
  49416. private _generateVertexBuffer;
  49417. /**
  49418. * Sets the main texture desired size which is the closest power of two
  49419. * of the engine canvas size.
  49420. */
  49421. private _setMainTextureSize;
  49422. /**
  49423. * Creates the main texture for the effect layer.
  49424. */
  49425. protected _createMainTexture(): void;
  49426. /**
  49427. * Adds specific effects defines.
  49428. * @param defines The defines to add specifics to.
  49429. */
  49430. protected _addCustomEffectDefines(defines: string[]): void;
  49431. /**
  49432. * Checks for the readiness of the element composing the layer.
  49433. * @param subMesh the mesh to check for
  49434. * @param useInstances specify wether or not to use instances to render the mesh
  49435. * @param emissiveTexture the associated emissive texture used to generate the glow
  49436. * @return true if ready otherwise, false
  49437. */
  49438. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49439. /**
  49440. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49441. */
  49442. render(): void;
  49443. /**
  49444. * Determine if a given mesh will be used in the current effect.
  49445. * @param mesh mesh to test
  49446. * @returns true if the mesh will be used
  49447. */
  49448. hasMesh(mesh: AbstractMesh): boolean;
  49449. /**
  49450. * Returns true if the layer contains information to display, otherwise false.
  49451. * @returns true if the glow layer should be rendered
  49452. */
  49453. shouldRender(): boolean;
  49454. /**
  49455. * Returns true if the mesh should render, otherwise false.
  49456. * @param mesh The mesh to render
  49457. * @returns true if it should render otherwise false
  49458. */
  49459. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49460. /**
  49461. * Returns true if the mesh can be rendered, otherwise false.
  49462. * @param mesh The mesh to render
  49463. * @param material The material used on the mesh
  49464. * @returns true if it can be rendered otherwise false
  49465. */
  49466. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49467. /**
  49468. * Returns true if the mesh should render, otherwise false.
  49469. * @param mesh The mesh to render
  49470. * @returns true if it should render otherwise false
  49471. */
  49472. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49473. /**
  49474. * Renders the submesh passed in parameter to the generation map.
  49475. */
  49476. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49477. /**
  49478. * Rebuild the required buffers.
  49479. * @hidden Internal use only.
  49480. */
  49481. _rebuild(): void;
  49482. /**
  49483. * Dispose only the render target textures and post process.
  49484. */
  49485. private _disposeTextureAndPostProcesses;
  49486. /**
  49487. * Dispose the highlight layer and free resources.
  49488. */
  49489. dispose(): void;
  49490. /**
  49491. * Gets the class name of the effect layer
  49492. * @returns the string with the class name of the effect layer
  49493. */
  49494. getClassName(): string;
  49495. /**
  49496. * Creates an effect layer from parsed effect layer data
  49497. * @param parsedEffectLayer defines effect layer data
  49498. * @param scene defines the current scene
  49499. * @param rootUrl defines the root URL containing the effect layer information
  49500. * @returns a parsed effect Layer
  49501. */
  49502. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49503. }
  49504. }
  49505. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49506. import { Scene } from "babylonjs/scene";
  49507. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49508. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49509. import { AbstractScene } from "babylonjs/abstractScene";
  49510. module "babylonjs/abstractScene" {
  49511. interface AbstractScene {
  49512. /**
  49513. * The list of effect layers (highlights/glow) added to the scene
  49514. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49515. * @see http://doc.babylonjs.com/how_to/glow_layer
  49516. */
  49517. effectLayers: Array<EffectLayer>;
  49518. /**
  49519. * Removes the given effect layer from this scene.
  49520. * @param toRemove defines the effect layer to remove
  49521. * @returns the index of the removed effect layer
  49522. */
  49523. removeEffectLayer(toRemove: EffectLayer): number;
  49524. /**
  49525. * Adds the given effect layer to this scene
  49526. * @param newEffectLayer defines the effect layer to add
  49527. */
  49528. addEffectLayer(newEffectLayer: EffectLayer): void;
  49529. }
  49530. }
  49531. /**
  49532. * Defines the layer scene component responsible to manage any effect layers
  49533. * in a given scene.
  49534. */
  49535. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49536. /**
  49537. * The component name helpfull to identify the component in the list of scene components.
  49538. */
  49539. readonly name: string;
  49540. /**
  49541. * The scene the component belongs to.
  49542. */
  49543. scene: Scene;
  49544. private _engine;
  49545. private _renderEffects;
  49546. private _needStencil;
  49547. private _previousStencilState;
  49548. /**
  49549. * Creates a new instance of the component for the given scene
  49550. * @param scene Defines the scene to register the component in
  49551. */
  49552. constructor(scene: Scene);
  49553. /**
  49554. * Registers the component in a given scene
  49555. */
  49556. register(): void;
  49557. /**
  49558. * Rebuilds the elements related to this component in case of
  49559. * context lost for instance.
  49560. */
  49561. rebuild(): void;
  49562. /**
  49563. * Serializes the component data to the specified json object
  49564. * @param serializationObject The object to serialize to
  49565. */
  49566. serialize(serializationObject: any): void;
  49567. /**
  49568. * Adds all the elements from the container to the scene
  49569. * @param container the container holding the elements
  49570. */
  49571. addFromContainer(container: AbstractScene): void;
  49572. /**
  49573. * Removes all the elements in the container from the scene
  49574. * @param container contains the elements to remove
  49575. * @param dispose if the removed element should be disposed (default: false)
  49576. */
  49577. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49578. /**
  49579. * Disposes the component and the associated ressources.
  49580. */
  49581. dispose(): void;
  49582. private _isReadyForMesh;
  49583. private _renderMainTexture;
  49584. private _setStencil;
  49585. private _setStencilBack;
  49586. private _draw;
  49587. private _drawCamera;
  49588. private _drawRenderingGroup;
  49589. }
  49590. }
  49591. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49592. /** @hidden */
  49593. export var glowMapMergePixelShader: {
  49594. name: string;
  49595. shader: string;
  49596. };
  49597. }
  49598. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49599. /** @hidden */
  49600. export var glowMapMergeVertexShader: {
  49601. name: string;
  49602. shader: string;
  49603. };
  49604. }
  49605. declare module "babylonjs/Layers/glowLayer" {
  49606. import { Nullable } from "babylonjs/types";
  49607. import { Camera } from "babylonjs/Cameras/camera";
  49608. import { Scene } from "babylonjs/scene";
  49609. import { Color4 } from "babylonjs/Maths/math";
  49610. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49611. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49612. import { Mesh } from "babylonjs/Meshes/mesh";
  49613. import { Texture } from "babylonjs/Materials/Textures/texture";
  49614. import { Effect } from "babylonjs/Materials/effect";
  49615. import { Material } from "babylonjs/Materials/material";
  49616. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49617. import "babylonjs/Shaders/glowMapMerge.fragment";
  49618. import "babylonjs/Shaders/glowMapMerge.vertex";
  49619. import "babylonjs/Layers/effectLayerSceneComponent";
  49620. module "babylonjs/abstractScene" {
  49621. interface AbstractScene {
  49622. /**
  49623. * Return a the first highlight layer of the scene with a given name.
  49624. * @param name The name of the highlight layer to look for.
  49625. * @return The highlight layer if found otherwise null.
  49626. */
  49627. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49628. }
  49629. }
  49630. /**
  49631. * Glow layer options. This helps customizing the behaviour
  49632. * of the glow layer.
  49633. */
  49634. export interface IGlowLayerOptions {
  49635. /**
  49636. * Multiplication factor apply to the canvas size to compute the render target size
  49637. * used to generated the glowing objects (the smaller the faster).
  49638. */
  49639. mainTextureRatio: number;
  49640. /**
  49641. * Enforces a fixed size texture to ensure resize independant blur.
  49642. */
  49643. mainTextureFixedSize?: number;
  49644. /**
  49645. * How big is the kernel of the blur texture.
  49646. */
  49647. blurKernelSize: number;
  49648. /**
  49649. * The camera attached to the layer.
  49650. */
  49651. camera: Nullable<Camera>;
  49652. /**
  49653. * Enable MSAA by chosing the number of samples.
  49654. */
  49655. mainTextureSamples?: number;
  49656. /**
  49657. * The rendering group to draw the layer in.
  49658. */
  49659. renderingGroupId: number;
  49660. }
  49661. /**
  49662. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49663. *
  49664. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49665. * glowy meshes to your scene.
  49666. *
  49667. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49668. */
  49669. export class GlowLayer extends EffectLayer {
  49670. /**
  49671. * Effect Name of the layer.
  49672. */
  49673. static readonly EffectName: string;
  49674. /**
  49675. * The default blur kernel size used for the glow.
  49676. */
  49677. static DefaultBlurKernelSize: number;
  49678. /**
  49679. * The default texture size ratio used for the glow.
  49680. */
  49681. static DefaultTextureRatio: number;
  49682. /**
  49683. * Sets the kernel size of the blur.
  49684. */
  49685. /**
  49686. * Gets the kernel size of the blur.
  49687. */
  49688. blurKernelSize: number;
  49689. /**
  49690. * Sets the glow intensity.
  49691. */
  49692. /**
  49693. * Gets the glow intensity.
  49694. */
  49695. intensity: number;
  49696. private _options;
  49697. private _intensity;
  49698. private _horizontalBlurPostprocess1;
  49699. private _verticalBlurPostprocess1;
  49700. private _horizontalBlurPostprocess2;
  49701. private _verticalBlurPostprocess2;
  49702. private _blurTexture1;
  49703. private _blurTexture2;
  49704. private _postProcesses1;
  49705. private _postProcesses2;
  49706. private _includedOnlyMeshes;
  49707. private _excludedMeshes;
  49708. /**
  49709. * Callback used to let the user override the color selection on a per mesh basis
  49710. */
  49711. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49712. /**
  49713. * Callback used to let the user override the texture selection on a per mesh basis
  49714. */
  49715. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49716. /**
  49717. * Instantiates a new glow Layer and references it to the scene.
  49718. * @param name The name of the layer
  49719. * @param scene The scene to use the layer in
  49720. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49721. */
  49722. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49723. /**
  49724. * Get the effect name of the layer.
  49725. * @return The effect name
  49726. */
  49727. getEffectName(): string;
  49728. /**
  49729. * Create the merge effect. This is the shader use to blit the information back
  49730. * to the main canvas at the end of the scene rendering.
  49731. */
  49732. protected _createMergeEffect(): Effect;
  49733. /**
  49734. * Creates the render target textures and post processes used in the glow layer.
  49735. */
  49736. protected _createTextureAndPostProcesses(): void;
  49737. /**
  49738. * Checks for the readiness of the element composing the layer.
  49739. * @param subMesh the mesh to check for
  49740. * @param useInstances specify wether or not to use instances to render the mesh
  49741. * @param emissiveTexture the associated emissive texture used to generate the glow
  49742. * @return true if ready otherwise, false
  49743. */
  49744. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49745. /**
  49746. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49747. */
  49748. needStencil(): boolean;
  49749. /**
  49750. * Returns true if the mesh can be rendered, otherwise false.
  49751. * @param mesh The mesh to render
  49752. * @param material The material used on the mesh
  49753. * @returns true if it can be rendered otherwise false
  49754. */
  49755. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49756. /**
  49757. * Implementation specific of rendering the generating effect on the main canvas.
  49758. * @param effect The effect used to render through
  49759. */
  49760. protected _internalRender(effect: Effect): void;
  49761. /**
  49762. * Sets the required values for both the emissive texture and and the main color.
  49763. */
  49764. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49765. /**
  49766. * Returns true if the mesh should render, otherwise false.
  49767. * @param mesh The mesh to render
  49768. * @returns true if it should render otherwise false
  49769. */
  49770. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49771. /**
  49772. * Adds specific effects defines.
  49773. * @param defines The defines to add specifics to.
  49774. */
  49775. protected _addCustomEffectDefines(defines: string[]): void;
  49776. /**
  49777. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49778. * @param mesh The mesh to exclude from the glow layer
  49779. */
  49780. addExcludedMesh(mesh: Mesh): void;
  49781. /**
  49782. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49783. * @param mesh The mesh to remove
  49784. */
  49785. removeExcludedMesh(mesh: Mesh): void;
  49786. /**
  49787. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49788. * @param mesh The mesh to include in the glow layer
  49789. */
  49790. addIncludedOnlyMesh(mesh: Mesh): void;
  49791. /**
  49792. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49793. * @param mesh The mesh to remove
  49794. */
  49795. removeIncludedOnlyMesh(mesh: Mesh): void;
  49796. /**
  49797. * Determine if a given mesh will be used in the glow layer
  49798. * @param mesh The mesh to test
  49799. * @returns true if the mesh will be highlighted by the current glow layer
  49800. */
  49801. hasMesh(mesh: AbstractMesh): boolean;
  49802. /**
  49803. * Free any resources and references associated to a mesh.
  49804. * Internal use
  49805. * @param mesh The mesh to free.
  49806. * @hidden
  49807. */
  49808. _disposeMesh(mesh: Mesh): void;
  49809. /**
  49810. * Gets the class name of the effect layer
  49811. * @returns the string with the class name of the effect layer
  49812. */
  49813. getClassName(): string;
  49814. /**
  49815. * Serializes this glow layer
  49816. * @returns a serialized glow layer object
  49817. */
  49818. serialize(): any;
  49819. /**
  49820. * Creates a Glow Layer from parsed glow layer data
  49821. * @param parsedGlowLayer defines glow layer data
  49822. * @param scene defines the current scene
  49823. * @param rootUrl defines the root URL containing the glow layer information
  49824. * @returns a parsed Glow Layer
  49825. */
  49826. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49827. }
  49828. }
  49829. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49830. /** @hidden */
  49831. export var glowBlurPostProcessPixelShader: {
  49832. name: string;
  49833. shader: string;
  49834. };
  49835. }
  49836. declare module "babylonjs/Layers/highlightLayer" {
  49837. import { Observable } from "babylonjs/Misc/observable";
  49838. import { Nullable } from "babylonjs/types";
  49839. import { Camera } from "babylonjs/Cameras/camera";
  49840. import { Scene } from "babylonjs/scene";
  49841. import { Color3, Color4 } from "babylonjs/Maths/math";
  49842. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49844. import { Mesh } from "babylonjs/Meshes/mesh";
  49845. import { Effect } from "babylonjs/Materials/effect";
  49846. import { Material } from "babylonjs/Materials/material";
  49847. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49848. import "babylonjs/Shaders/glowMapMerge.fragment";
  49849. import "babylonjs/Shaders/glowMapMerge.vertex";
  49850. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49851. module "babylonjs/abstractScene" {
  49852. interface AbstractScene {
  49853. /**
  49854. * Return a the first highlight layer of the scene with a given name.
  49855. * @param name The name of the highlight layer to look for.
  49856. * @return The highlight layer if found otherwise null.
  49857. */
  49858. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49859. }
  49860. }
  49861. /**
  49862. * Highlight layer options. This helps customizing the behaviour
  49863. * of the highlight layer.
  49864. */
  49865. export interface IHighlightLayerOptions {
  49866. /**
  49867. * Multiplication factor apply to the canvas size to compute the render target size
  49868. * used to generated the glowing objects (the smaller the faster).
  49869. */
  49870. mainTextureRatio: number;
  49871. /**
  49872. * Enforces a fixed size texture to ensure resize independant blur.
  49873. */
  49874. mainTextureFixedSize?: number;
  49875. /**
  49876. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49877. * of the picture to blur (the smaller the faster).
  49878. */
  49879. blurTextureSizeRatio: number;
  49880. /**
  49881. * How big in texel of the blur texture is the vertical blur.
  49882. */
  49883. blurVerticalSize: number;
  49884. /**
  49885. * How big in texel of the blur texture is the horizontal blur.
  49886. */
  49887. blurHorizontalSize: number;
  49888. /**
  49889. * Alpha blending mode used to apply the blur. Default is combine.
  49890. */
  49891. alphaBlendingMode: number;
  49892. /**
  49893. * The camera attached to the layer.
  49894. */
  49895. camera: Nullable<Camera>;
  49896. /**
  49897. * Should we display highlight as a solid stroke?
  49898. */
  49899. isStroke?: boolean;
  49900. /**
  49901. * The rendering group to draw the layer in.
  49902. */
  49903. renderingGroupId: number;
  49904. }
  49905. /**
  49906. * The highlight layer Helps adding a glow effect around a mesh.
  49907. *
  49908. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49909. * glowy meshes to your scene.
  49910. *
  49911. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49912. */
  49913. export class HighlightLayer extends EffectLayer {
  49914. name: string;
  49915. /**
  49916. * Effect Name of the highlight layer.
  49917. */
  49918. static readonly EffectName: string;
  49919. /**
  49920. * The neutral color used during the preparation of the glow effect.
  49921. * This is black by default as the blend operation is a blend operation.
  49922. */
  49923. static NeutralColor: Color4;
  49924. /**
  49925. * Stencil value used for glowing meshes.
  49926. */
  49927. static GlowingMeshStencilReference: number;
  49928. /**
  49929. * Stencil value used for the other meshes in the scene.
  49930. */
  49931. static NormalMeshStencilReference: number;
  49932. /**
  49933. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49934. */
  49935. innerGlow: boolean;
  49936. /**
  49937. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49938. */
  49939. outerGlow: boolean;
  49940. /**
  49941. * Specifies the horizontal size of the blur.
  49942. */
  49943. /**
  49944. * Gets the horizontal size of the blur.
  49945. */
  49946. blurHorizontalSize: number;
  49947. /**
  49948. * Specifies the vertical size of the blur.
  49949. */
  49950. /**
  49951. * Gets the vertical size of the blur.
  49952. */
  49953. blurVerticalSize: number;
  49954. /**
  49955. * An event triggered when the highlight layer is being blurred.
  49956. */
  49957. onBeforeBlurObservable: Observable<HighlightLayer>;
  49958. /**
  49959. * An event triggered when the highlight layer has been blurred.
  49960. */
  49961. onAfterBlurObservable: Observable<HighlightLayer>;
  49962. private _instanceGlowingMeshStencilReference;
  49963. private _options;
  49964. private _downSamplePostprocess;
  49965. private _horizontalBlurPostprocess;
  49966. private _verticalBlurPostprocess;
  49967. private _blurTexture;
  49968. private _meshes;
  49969. private _excludedMeshes;
  49970. /**
  49971. * Instantiates a new highlight Layer and references it to the scene..
  49972. * @param name The name of the layer
  49973. * @param scene The scene to use the layer in
  49974. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49975. */
  49976. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49977. /**
  49978. * Get the effect name of the layer.
  49979. * @return The effect name
  49980. */
  49981. getEffectName(): string;
  49982. /**
  49983. * Create the merge effect. This is the shader use to blit the information back
  49984. * to the main canvas at the end of the scene rendering.
  49985. */
  49986. protected _createMergeEffect(): Effect;
  49987. /**
  49988. * Creates the render target textures and post processes used in the highlight layer.
  49989. */
  49990. protected _createTextureAndPostProcesses(): void;
  49991. /**
  49992. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49993. */
  49994. needStencil(): boolean;
  49995. /**
  49996. * Checks for the readiness of the element composing the layer.
  49997. * @param subMesh the mesh to check for
  49998. * @param useInstances specify wether or not to use instances to render the mesh
  49999. * @param emissiveTexture the associated emissive texture used to generate the glow
  50000. * @return true if ready otherwise, false
  50001. */
  50002. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50003. /**
  50004. * Implementation specific of rendering the generating effect on the main canvas.
  50005. * @param effect The effect used to render through
  50006. */
  50007. protected _internalRender(effect: Effect): void;
  50008. /**
  50009. * Returns true if the layer contains information to display, otherwise false.
  50010. */
  50011. shouldRender(): boolean;
  50012. /**
  50013. * Returns true if the mesh should render, otherwise false.
  50014. * @param mesh The mesh to render
  50015. * @returns true if it should render otherwise false
  50016. */
  50017. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50018. /**
  50019. * Sets the required values for both the emissive texture and and the main color.
  50020. */
  50021. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50022. /**
  50023. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50024. * @param mesh The mesh to exclude from the highlight layer
  50025. */
  50026. addExcludedMesh(mesh: Mesh): void;
  50027. /**
  50028. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50029. * @param mesh The mesh to highlight
  50030. */
  50031. removeExcludedMesh(mesh: Mesh): void;
  50032. /**
  50033. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50034. * @param mesh mesh to test
  50035. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50036. */
  50037. hasMesh(mesh: AbstractMesh): boolean;
  50038. /**
  50039. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50040. * @param mesh The mesh to highlight
  50041. * @param color The color of the highlight
  50042. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50043. */
  50044. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50045. /**
  50046. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50047. * @param mesh The mesh to highlight
  50048. */
  50049. removeMesh(mesh: Mesh): void;
  50050. /**
  50051. * Force the stencil to the normal expected value for none glowing parts
  50052. */
  50053. private _defaultStencilReference;
  50054. /**
  50055. * Free any resources and references associated to a mesh.
  50056. * Internal use
  50057. * @param mesh The mesh to free.
  50058. * @hidden
  50059. */
  50060. _disposeMesh(mesh: Mesh): void;
  50061. /**
  50062. * Dispose the highlight layer and free resources.
  50063. */
  50064. dispose(): void;
  50065. /**
  50066. * Gets the class name of the effect layer
  50067. * @returns the string with the class name of the effect layer
  50068. */
  50069. getClassName(): string;
  50070. /**
  50071. * Serializes this Highlight layer
  50072. * @returns a serialized Highlight layer object
  50073. */
  50074. serialize(): any;
  50075. /**
  50076. * Creates a Highlight layer from parsed Highlight layer data
  50077. * @param parsedHightlightLayer defines the Highlight layer data
  50078. * @param scene defines the current scene
  50079. * @param rootUrl defines the root URL containing the Highlight layer information
  50080. * @returns a parsed Highlight layer
  50081. */
  50082. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50083. }
  50084. }
  50085. declare module "babylonjs/Layers/layerSceneComponent" {
  50086. import { Scene } from "babylonjs/scene";
  50087. import { ISceneComponent } from "babylonjs/sceneComponent";
  50088. import { Layer } from "babylonjs/Layers/layer";
  50089. import { AbstractScene } from "babylonjs/abstractScene";
  50090. module "babylonjs/abstractScene" {
  50091. interface AbstractScene {
  50092. /**
  50093. * The list of layers (background and foreground) of the scene
  50094. */
  50095. layers: Array<Layer>;
  50096. }
  50097. }
  50098. /**
  50099. * Defines the layer scene component responsible to manage any layers
  50100. * in a given scene.
  50101. */
  50102. export class LayerSceneComponent implements ISceneComponent {
  50103. /**
  50104. * The component name helpfull to identify the component in the list of scene components.
  50105. */
  50106. readonly name: string;
  50107. /**
  50108. * The scene the component belongs to.
  50109. */
  50110. scene: Scene;
  50111. private _engine;
  50112. /**
  50113. * Creates a new instance of the component for the given scene
  50114. * @param scene Defines the scene to register the component in
  50115. */
  50116. constructor(scene: Scene);
  50117. /**
  50118. * Registers the component in a given scene
  50119. */
  50120. register(): void;
  50121. /**
  50122. * Rebuilds the elements related to this component in case of
  50123. * context lost for instance.
  50124. */
  50125. rebuild(): void;
  50126. /**
  50127. * Disposes the component and the associated ressources.
  50128. */
  50129. dispose(): void;
  50130. private _draw;
  50131. private _drawCameraPredicate;
  50132. private _drawCameraBackground;
  50133. private _drawCameraForeground;
  50134. private _drawRenderTargetPredicate;
  50135. private _drawRenderTargetBackground;
  50136. private _drawRenderTargetForeground;
  50137. /**
  50138. * Adds all the elements from the container to the scene
  50139. * @param container the container holding the elements
  50140. */
  50141. addFromContainer(container: AbstractScene): void;
  50142. /**
  50143. * Removes all the elements in the container from the scene
  50144. * @param container contains the elements to remove
  50145. * @param dispose if the removed element should be disposed (default: false)
  50146. */
  50147. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50148. }
  50149. }
  50150. declare module "babylonjs/Shaders/layer.fragment" {
  50151. /** @hidden */
  50152. export var layerPixelShader: {
  50153. name: string;
  50154. shader: string;
  50155. };
  50156. }
  50157. declare module "babylonjs/Shaders/layer.vertex" {
  50158. /** @hidden */
  50159. export var layerVertexShader: {
  50160. name: string;
  50161. shader: string;
  50162. };
  50163. }
  50164. declare module "babylonjs/Layers/layer" {
  50165. import { Observable } from "babylonjs/Misc/observable";
  50166. import { Nullable } from "babylonjs/types";
  50167. import { Scene } from "babylonjs/scene";
  50168. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50169. import { Texture } from "babylonjs/Materials/Textures/texture";
  50170. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50171. import "babylonjs/Shaders/layer.fragment";
  50172. import "babylonjs/Shaders/layer.vertex";
  50173. /**
  50174. * This represents a full screen 2d layer.
  50175. * This can be useful to display a picture in the background of your scene for instance.
  50176. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50177. */
  50178. export class Layer {
  50179. /**
  50180. * Define the name of the layer.
  50181. */
  50182. name: string;
  50183. /**
  50184. * Define the texture the layer should display.
  50185. */
  50186. texture: Nullable<Texture>;
  50187. /**
  50188. * Is the layer in background or foreground.
  50189. */
  50190. isBackground: boolean;
  50191. /**
  50192. * Define the color of the layer (instead of texture).
  50193. */
  50194. color: Color4;
  50195. /**
  50196. * Define the scale of the layer in order to zoom in out of the texture.
  50197. */
  50198. scale: Vector2;
  50199. /**
  50200. * Define an offset for the layer in order to shift the texture.
  50201. */
  50202. offset: Vector2;
  50203. /**
  50204. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50205. */
  50206. alphaBlendingMode: number;
  50207. /**
  50208. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50209. * Alpha test will not mix with the background color in case of transparency.
  50210. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50211. */
  50212. alphaTest: boolean;
  50213. /**
  50214. * Define a mask to restrict the layer to only some of the scene cameras.
  50215. */
  50216. layerMask: number;
  50217. /**
  50218. * Define the list of render target the layer is visible into.
  50219. */
  50220. renderTargetTextures: RenderTargetTexture[];
  50221. /**
  50222. * Define if the layer is only used in renderTarget or if it also
  50223. * renders in the main frame buffer of the canvas.
  50224. */
  50225. renderOnlyInRenderTargetTextures: boolean;
  50226. private _scene;
  50227. private _vertexBuffers;
  50228. private _indexBuffer;
  50229. private _effect;
  50230. private _alphaTestEffect;
  50231. /**
  50232. * An event triggered when the layer is disposed.
  50233. */
  50234. onDisposeObservable: Observable<Layer>;
  50235. private _onDisposeObserver;
  50236. /**
  50237. * Back compatibility with callback before the onDisposeObservable existed.
  50238. * The set callback will be triggered when the layer has been disposed.
  50239. */
  50240. onDispose: () => void;
  50241. /**
  50242. * An event triggered before rendering the scene
  50243. */
  50244. onBeforeRenderObservable: Observable<Layer>;
  50245. private _onBeforeRenderObserver;
  50246. /**
  50247. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50248. * The set callback will be triggered just before rendering the layer.
  50249. */
  50250. onBeforeRender: () => void;
  50251. /**
  50252. * An event triggered after rendering the scene
  50253. */
  50254. onAfterRenderObservable: Observable<Layer>;
  50255. private _onAfterRenderObserver;
  50256. /**
  50257. * Back compatibility with callback before the onAfterRenderObservable existed.
  50258. * The set callback will be triggered just after rendering the layer.
  50259. */
  50260. onAfterRender: () => void;
  50261. /**
  50262. * Instantiates a new layer.
  50263. * This represents a full screen 2d layer.
  50264. * This can be useful to display a picture in the background of your scene for instance.
  50265. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50266. * @param name Define the name of the layer in the scene
  50267. * @param imgUrl Define the url of the texture to display in the layer
  50268. * @param scene Define the scene the layer belongs to
  50269. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50270. * @param color Defines a color for the layer
  50271. */
  50272. constructor(
  50273. /**
  50274. * Define the name of the layer.
  50275. */
  50276. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50277. private _createIndexBuffer;
  50278. /** @hidden */
  50279. _rebuild(): void;
  50280. /**
  50281. * Renders the layer in the scene.
  50282. */
  50283. render(): void;
  50284. /**
  50285. * Disposes and releases the associated ressources.
  50286. */
  50287. dispose(): void;
  50288. }
  50289. }
  50290. declare module "babylonjs/Layers/index" {
  50291. export * from "babylonjs/Layers/effectLayer";
  50292. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50293. export * from "babylonjs/Layers/glowLayer";
  50294. export * from "babylonjs/Layers/highlightLayer";
  50295. export * from "babylonjs/Layers/layer";
  50296. export * from "babylonjs/Layers/layerSceneComponent";
  50297. }
  50298. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50299. /** @hidden */
  50300. export var lensFlarePixelShader: {
  50301. name: string;
  50302. shader: string;
  50303. };
  50304. }
  50305. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50306. /** @hidden */
  50307. export var lensFlareVertexShader: {
  50308. name: string;
  50309. shader: string;
  50310. };
  50311. }
  50312. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50313. import { Scene } from "babylonjs/scene";
  50314. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50316. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50317. import "babylonjs/Shaders/lensFlare.fragment";
  50318. import "babylonjs/Shaders/lensFlare.vertex";
  50319. /**
  50320. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50321. * It is usually composed of several `lensFlare`.
  50322. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50323. */
  50324. export class LensFlareSystem {
  50325. /**
  50326. * Define the name of the lens flare system
  50327. */
  50328. name: string;
  50329. /**
  50330. * List of lens flares used in this system.
  50331. */
  50332. lensFlares: LensFlare[];
  50333. /**
  50334. * Define a limit from the border the lens flare can be visible.
  50335. */
  50336. borderLimit: number;
  50337. /**
  50338. * Define a viewport border we do not want to see the lens flare in.
  50339. */
  50340. viewportBorder: number;
  50341. /**
  50342. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50343. */
  50344. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50345. /**
  50346. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50347. */
  50348. layerMask: number;
  50349. /**
  50350. * Define the id of the lens flare system in the scene.
  50351. * (equal to name by default)
  50352. */
  50353. id: string;
  50354. private _scene;
  50355. private _emitter;
  50356. private _vertexBuffers;
  50357. private _indexBuffer;
  50358. private _effect;
  50359. private _positionX;
  50360. private _positionY;
  50361. private _isEnabled;
  50362. /** @hidden */
  50363. static _SceneComponentInitialization: (scene: Scene) => void;
  50364. /**
  50365. * Instantiates a lens flare system.
  50366. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50367. * It is usually composed of several `lensFlare`.
  50368. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50369. * @param name Define the name of the lens flare system in the scene
  50370. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50371. * @param scene Define the scene the lens flare system belongs to
  50372. */
  50373. constructor(
  50374. /**
  50375. * Define the name of the lens flare system
  50376. */
  50377. name: string, emitter: any, scene: Scene);
  50378. /**
  50379. * Define if the lens flare system is enabled.
  50380. */
  50381. isEnabled: boolean;
  50382. /**
  50383. * Get the scene the effects belongs to.
  50384. * @returns the scene holding the lens flare system
  50385. */
  50386. getScene(): Scene;
  50387. /**
  50388. * Get the emitter of the lens flare system.
  50389. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50390. * @returns the emitter of the lens flare system
  50391. */
  50392. getEmitter(): any;
  50393. /**
  50394. * Set the emitter of the lens flare system.
  50395. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50396. * @param newEmitter Define the new emitter of the system
  50397. */
  50398. setEmitter(newEmitter: any): void;
  50399. /**
  50400. * Get the lens flare system emitter position.
  50401. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50402. * @returns the position
  50403. */
  50404. getEmitterPosition(): Vector3;
  50405. /**
  50406. * @hidden
  50407. */
  50408. computeEffectivePosition(globalViewport: Viewport): boolean;
  50409. /** @hidden */
  50410. _isVisible(): boolean;
  50411. /**
  50412. * @hidden
  50413. */
  50414. render(): boolean;
  50415. /**
  50416. * Dispose and release the lens flare with its associated resources.
  50417. */
  50418. dispose(): void;
  50419. /**
  50420. * Parse a lens flare system from a JSON repressentation
  50421. * @param parsedLensFlareSystem Define the JSON to parse
  50422. * @param scene Define the scene the parsed system should be instantiated in
  50423. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50424. * @returns the parsed system
  50425. */
  50426. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50427. /**
  50428. * Serialize the current Lens Flare System into a JSON representation.
  50429. * @returns the serialized JSON
  50430. */
  50431. serialize(): any;
  50432. }
  50433. }
  50434. declare module "babylonjs/LensFlares/lensFlare" {
  50435. import { Nullable } from "babylonjs/types";
  50436. import { Color3 } from "babylonjs/Maths/math";
  50437. import { Texture } from "babylonjs/Materials/Textures/texture";
  50438. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50439. /**
  50440. * This represents one of the lens effect in a `lensFlareSystem`.
  50441. * It controls one of the indiviual texture used in the effect.
  50442. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50443. */
  50444. export class LensFlare {
  50445. /**
  50446. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50447. */
  50448. size: number;
  50449. /**
  50450. * 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.
  50451. */
  50452. position: number;
  50453. /**
  50454. * Define the lens color.
  50455. */
  50456. color: Color3;
  50457. /**
  50458. * Define the lens texture.
  50459. */
  50460. texture: Nullable<Texture>;
  50461. /**
  50462. * Define the alpha mode to render this particular lens.
  50463. */
  50464. alphaMode: number;
  50465. private _system;
  50466. /**
  50467. * Creates a new Lens Flare.
  50468. * This represents one of the lens effect in a `lensFlareSystem`.
  50469. * It controls one of the indiviual texture used in the effect.
  50470. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50471. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50472. * @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.
  50473. * @param color Define the lens color
  50474. * @param imgUrl Define the lens texture url
  50475. * @param system Define the `lensFlareSystem` this flare is part of
  50476. * @returns The newly created Lens Flare
  50477. */
  50478. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50479. /**
  50480. * Instantiates a new Lens Flare.
  50481. * This represents one of the lens effect in a `lensFlareSystem`.
  50482. * It controls one of the indiviual texture used in the effect.
  50483. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50484. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50485. * @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.
  50486. * @param color Define the lens color
  50487. * @param imgUrl Define the lens texture url
  50488. * @param system Define the `lensFlareSystem` this flare is part of
  50489. */
  50490. constructor(
  50491. /**
  50492. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50493. */
  50494. size: number,
  50495. /**
  50496. * 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.
  50497. */
  50498. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50499. /**
  50500. * Dispose and release the lens flare with its associated resources.
  50501. */
  50502. dispose(): void;
  50503. }
  50504. }
  50505. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50506. import { Nullable } from "babylonjs/types";
  50507. import { Scene } from "babylonjs/scene";
  50508. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50509. import { AbstractScene } from "babylonjs/abstractScene";
  50510. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50511. module "babylonjs/abstractScene" {
  50512. interface AbstractScene {
  50513. /**
  50514. * The list of lens flare system added to the scene
  50515. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50516. */
  50517. lensFlareSystems: Array<LensFlareSystem>;
  50518. /**
  50519. * Removes the given lens flare system from this scene.
  50520. * @param toRemove The lens flare system to remove
  50521. * @returns The index of the removed lens flare system
  50522. */
  50523. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50524. /**
  50525. * Adds the given lens flare system to this scene
  50526. * @param newLensFlareSystem The lens flare system to add
  50527. */
  50528. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50529. /**
  50530. * Gets a lens flare system using its name
  50531. * @param name defines the name to look for
  50532. * @returns the lens flare system or null if not found
  50533. */
  50534. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50535. /**
  50536. * Gets a lens flare system using its id
  50537. * @param id defines the id to look for
  50538. * @returns the lens flare system or null if not found
  50539. */
  50540. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50541. }
  50542. }
  50543. /**
  50544. * Defines the lens flare scene component responsible to manage any lens flares
  50545. * in a given scene.
  50546. */
  50547. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50548. /**
  50549. * The component name helpfull to identify the component in the list of scene components.
  50550. */
  50551. readonly name: string;
  50552. /**
  50553. * The scene the component belongs to.
  50554. */
  50555. scene: Scene;
  50556. /**
  50557. * Creates a new instance of the component for the given scene
  50558. * @param scene Defines the scene to register the component in
  50559. */
  50560. constructor(scene: Scene);
  50561. /**
  50562. * Registers the component in a given scene
  50563. */
  50564. register(): void;
  50565. /**
  50566. * Rebuilds the elements related to this component in case of
  50567. * context lost for instance.
  50568. */
  50569. rebuild(): void;
  50570. /**
  50571. * Adds all the elements from the container to the scene
  50572. * @param container the container holding the elements
  50573. */
  50574. addFromContainer(container: AbstractScene): void;
  50575. /**
  50576. * Removes all the elements in the container from the scene
  50577. * @param container contains the elements to remove
  50578. * @param dispose if the removed element should be disposed (default: false)
  50579. */
  50580. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50581. /**
  50582. * Serializes the component data to the specified json object
  50583. * @param serializationObject The object to serialize to
  50584. */
  50585. serialize(serializationObject: any): void;
  50586. /**
  50587. * Disposes the component and the associated ressources.
  50588. */
  50589. dispose(): void;
  50590. private _draw;
  50591. }
  50592. }
  50593. declare module "babylonjs/LensFlares/index" {
  50594. export * from "babylonjs/LensFlares/lensFlare";
  50595. export * from "babylonjs/LensFlares/lensFlareSystem";
  50596. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50597. }
  50598. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50599. import { Scene } from "babylonjs/scene";
  50600. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50601. import { AbstractScene } from "babylonjs/abstractScene";
  50602. /**
  50603. * Defines the shadow generator component responsible to manage any shadow generators
  50604. * in a given scene.
  50605. */
  50606. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50607. /**
  50608. * The component name helpfull to identify the component in the list of scene components.
  50609. */
  50610. readonly name: string;
  50611. /**
  50612. * The scene the component belongs to.
  50613. */
  50614. scene: Scene;
  50615. /**
  50616. * Creates a new instance of the component for the given scene
  50617. * @param scene Defines the scene to register the component in
  50618. */
  50619. constructor(scene: Scene);
  50620. /**
  50621. * Registers the component in a given scene
  50622. */
  50623. register(): void;
  50624. /**
  50625. * Rebuilds the elements related to this component in case of
  50626. * context lost for instance.
  50627. */
  50628. rebuild(): void;
  50629. /**
  50630. * Serializes the component data to the specified json object
  50631. * @param serializationObject The object to serialize to
  50632. */
  50633. serialize(serializationObject: any): void;
  50634. /**
  50635. * Adds all the elements from the container to the scene
  50636. * @param container the container holding the elements
  50637. */
  50638. addFromContainer(container: AbstractScene): void;
  50639. /**
  50640. * Removes all the elements in the container from the scene
  50641. * @param container contains the elements to remove
  50642. * @param dispose if the removed element should be disposed (default: false)
  50643. */
  50644. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50645. /**
  50646. * Rebuilds the elements related to this component in case of
  50647. * context lost for instance.
  50648. */
  50649. dispose(): void;
  50650. private _gatherRenderTargets;
  50651. }
  50652. }
  50653. declare module "babylonjs/Lights/Shadows/index" {
  50654. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50655. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50656. }
  50657. declare module "babylonjs/Lights/pointLight" {
  50658. import { Scene } from "babylonjs/scene";
  50659. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50661. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50662. import { Effect } from "babylonjs/Materials/effect";
  50663. /**
  50664. * A point light is a light defined by an unique point in world space.
  50665. * The light is emitted in every direction from this point.
  50666. * A good example of a point light is a standard light bulb.
  50667. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50668. */
  50669. export class PointLight extends ShadowLight {
  50670. private _shadowAngle;
  50671. /**
  50672. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50673. * This specifies what angle the shadow will use to be created.
  50674. *
  50675. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50676. */
  50677. /**
  50678. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50679. * This specifies what angle the shadow will use to be created.
  50680. *
  50681. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50682. */
  50683. shadowAngle: number;
  50684. /**
  50685. * Gets the direction if it has been set.
  50686. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50687. */
  50688. /**
  50689. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50690. */
  50691. direction: Vector3;
  50692. /**
  50693. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50694. * A PointLight emits the light in every direction.
  50695. * It can cast shadows.
  50696. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50697. * ```javascript
  50698. * var pointLight = new PointLight("pl", camera.position, scene);
  50699. * ```
  50700. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50701. * @param name The light friendly name
  50702. * @param position The position of the point light in the scene
  50703. * @param scene The scene the lights belongs to
  50704. */
  50705. constructor(name: string, position: Vector3, scene: Scene);
  50706. /**
  50707. * Returns the string "PointLight"
  50708. * @returns the class name
  50709. */
  50710. getClassName(): string;
  50711. /**
  50712. * Returns the integer 0.
  50713. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50714. */
  50715. getTypeID(): number;
  50716. /**
  50717. * Specifies wether or not the shadowmap should be a cube texture.
  50718. * @returns true if the shadowmap needs to be a cube texture.
  50719. */
  50720. needCube(): boolean;
  50721. /**
  50722. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50723. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50724. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50725. */
  50726. getShadowDirection(faceIndex?: number): Vector3;
  50727. /**
  50728. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50729. * - fov = PI / 2
  50730. * - aspect ratio : 1.0
  50731. * - z-near and far equal to the active camera minZ and maxZ.
  50732. * Returns the PointLight.
  50733. */
  50734. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50735. protected _buildUniformLayout(): void;
  50736. /**
  50737. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50738. * @param effect The effect to update
  50739. * @param lightIndex The index of the light in the effect to update
  50740. * @returns The point light
  50741. */
  50742. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50743. /**
  50744. * Prepares the list of defines specific to the light type.
  50745. * @param defines the list of defines
  50746. * @param lightIndex defines the index of the light for the effect
  50747. */
  50748. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50749. }
  50750. }
  50751. declare module "babylonjs/Lights/index" {
  50752. export * from "babylonjs/Lights/light";
  50753. export * from "babylonjs/Lights/shadowLight";
  50754. export * from "babylonjs/Lights/Shadows/index";
  50755. export * from "babylonjs/Lights/directionalLight";
  50756. export * from "babylonjs/Lights/hemisphericLight";
  50757. export * from "babylonjs/Lights/pointLight";
  50758. export * from "babylonjs/Lights/spotLight";
  50759. }
  50760. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50761. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50762. /**
  50763. * Header information of HDR texture files.
  50764. */
  50765. export interface HDRInfo {
  50766. /**
  50767. * The height of the texture in pixels.
  50768. */
  50769. height: number;
  50770. /**
  50771. * The width of the texture in pixels.
  50772. */
  50773. width: number;
  50774. /**
  50775. * The index of the beginning of the data in the binary file.
  50776. */
  50777. dataPosition: number;
  50778. }
  50779. /**
  50780. * This groups tools to convert HDR texture to native colors array.
  50781. */
  50782. export class HDRTools {
  50783. private static Ldexp;
  50784. private static Rgbe2float;
  50785. private static readStringLine;
  50786. /**
  50787. * Reads header information from an RGBE texture stored in a native array.
  50788. * More information on this format are available here:
  50789. * https://en.wikipedia.org/wiki/RGBE_image_format
  50790. *
  50791. * @param uint8array The binary file stored in native array.
  50792. * @return The header information.
  50793. */
  50794. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50795. /**
  50796. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50797. * This RGBE texture needs to store the information as a panorama.
  50798. *
  50799. * More information on this format are available here:
  50800. * https://en.wikipedia.org/wiki/RGBE_image_format
  50801. *
  50802. * @param buffer The binary file stored in an array buffer.
  50803. * @param size The expected size of the extracted cubemap.
  50804. * @return The Cube Map information.
  50805. */
  50806. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50807. /**
  50808. * Returns the pixels data extracted from an RGBE texture.
  50809. * This pixels will be stored left to right up to down in the R G B order in one array.
  50810. *
  50811. * More information on this format are available here:
  50812. * https://en.wikipedia.org/wiki/RGBE_image_format
  50813. *
  50814. * @param uint8array The binary file stored in an array buffer.
  50815. * @param hdrInfo The header information of the file.
  50816. * @return The pixels data in RGB right to left up to down order.
  50817. */
  50818. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50819. private static RGBE_ReadPixels_RLE;
  50820. }
  50821. }
  50822. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50823. import { Nullable } from "babylonjs/types";
  50824. import { Scene } from "babylonjs/scene";
  50825. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50826. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50827. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50828. /**
  50829. * This represents a texture coming from an HDR input.
  50830. *
  50831. * The only supported format is currently panorama picture stored in RGBE format.
  50832. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50833. */
  50834. export class HDRCubeTexture extends BaseTexture {
  50835. private static _facesMapping;
  50836. private _generateHarmonics;
  50837. private _noMipmap;
  50838. private _textureMatrix;
  50839. private _size;
  50840. private _onLoad;
  50841. private _onError;
  50842. /**
  50843. * The texture URL.
  50844. */
  50845. url: string;
  50846. /**
  50847. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50848. */
  50849. coordinatesMode: number;
  50850. protected _isBlocking: boolean;
  50851. /**
  50852. * Sets wether or not the texture is blocking during loading.
  50853. */
  50854. /**
  50855. * Gets wether or not the texture is blocking during loading.
  50856. */
  50857. isBlocking: boolean;
  50858. protected _rotationY: number;
  50859. /**
  50860. * Sets texture matrix rotation angle around Y axis in radians.
  50861. */
  50862. /**
  50863. * Gets texture matrix rotation angle around Y axis radians.
  50864. */
  50865. rotationY: number;
  50866. /**
  50867. * Gets or sets the center of the bounding box associated with the cube texture
  50868. * It must define where the camera used to render the texture was set
  50869. */
  50870. boundingBoxPosition: Vector3;
  50871. private _boundingBoxSize;
  50872. /**
  50873. * Gets or sets the size of the bounding box associated with the cube texture
  50874. * When defined, the cubemap will switch to local mode
  50875. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50876. * @example https://www.babylonjs-playground.com/#RNASML
  50877. */
  50878. boundingBoxSize: Vector3;
  50879. /**
  50880. * Instantiates an HDRTexture from the following parameters.
  50881. *
  50882. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50883. * @param scene The scene the texture will be used in
  50884. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50885. * @param noMipmap Forces to not generate the mipmap if true
  50886. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50887. * @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)
  50888. * @param reserved Reserved flag for internal use.
  50889. */
  50890. 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>);
  50891. /**
  50892. * Get the current class name of the texture useful for serialization or dynamic coding.
  50893. * @returns "HDRCubeTexture"
  50894. */
  50895. getClassName(): string;
  50896. /**
  50897. * Occurs when the file is raw .hdr file.
  50898. */
  50899. private loadTexture;
  50900. clone(): HDRCubeTexture;
  50901. delayLoad(): void;
  50902. /**
  50903. * Get the texture reflection matrix used to rotate/transform the reflection.
  50904. * @returns the reflection matrix
  50905. */
  50906. getReflectionTextureMatrix(): Matrix;
  50907. /**
  50908. * Set the texture reflection matrix used to rotate/transform the reflection.
  50909. * @param value Define the reflection matrix to set
  50910. */
  50911. setReflectionTextureMatrix(value: Matrix): void;
  50912. /**
  50913. * Parses a JSON representation of an HDR Texture in order to create the texture
  50914. * @param parsedTexture Define the JSON representation
  50915. * @param scene Define the scene the texture should be created in
  50916. * @param rootUrl Define the root url in case we need to load relative dependencies
  50917. * @returns the newly created texture after parsing
  50918. */
  50919. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50920. serialize(): any;
  50921. }
  50922. }
  50923. declare module "babylonjs/Physics/physicsEngine" {
  50924. import { Nullable } from "babylonjs/types";
  50925. import { Vector3 } from "babylonjs/Maths/math";
  50926. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50927. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50928. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50929. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50930. /**
  50931. * Class used to control physics engine
  50932. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50933. */
  50934. export class PhysicsEngine implements IPhysicsEngine {
  50935. private _physicsPlugin;
  50936. /**
  50937. * Global value used to control the smallest number supported by the simulation
  50938. */
  50939. static Epsilon: number;
  50940. private _impostors;
  50941. private _joints;
  50942. /**
  50943. * Gets the gravity vector used by the simulation
  50944. */
  50945. gravity: Vector3;
  50946. /**
  50947. * Factory used to create the default physics plugin.
  50948. * @returns The default physics plugin
  50949. */
  50950. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50951. /**
  50952. * Creates a new Physics Engine
  50953. * @param gravity defines the gravity vector used by the simulation
  50954. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50955. */
  50956. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50957. /**
  50958. * Sets the gravity vector used by the simulation
  50959. * @param gravity defines the gravity vector to use
  50960. */
  50961. setGravity(gravity: Vector3): void;
  50962. /**
  50963. * Set the time step of the physics engine.
  50964. * Default is 1/60.
  50965. * To slow it down, enter 1/600 for example.
  50966. * To speed it up, 1/30
  50967. * @param newTimeStep defines the new timestep to apply to this world.
  50968. */
  50969. setTimeStep(newTimeStep?: number): void;
  50970. /**
  50971. * Get the time step of the physics engine.
  50972. * @returns the current time step
  50973. */
  50974. getTimeStep(): number;
  50975. /**
  50976. * Release all resources
  50977. */
  50978. dispose(): void;
  50979. /**
  50980. * Gets the name of the current physics plugin
  50981. * @returns the name of the plugin
  50982. */
  50983. getPhysicsPluginName(): string;
  50984. /**
  50985. * Adding a new impostor for the impostor tracking.
  50986. * This will be done by the impostor itself.
  50987. * @param impostor the impostor to add
  50988. */
  50989. addImpostor(impostor: PhysicsImpostor): void;
  50990. /**
  50991. * Remove an impostor from the engine.
  50992. * This impostor and its mesh will not longer be updated by the physics engine.
  50993. * @param impostor the impostor to remove
  50994. */
  50995. removeImpostor(impostor: PhysicsImpostor): void;
  50996. /**
  50997. * Add a joint to the physics engine
  50998. * @param mainImpostor defines the main impostor to which the joint is added.
  50999. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51000. * @param joint defines the joint that will connect both impostors.
  51001. */
  51002. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51003. /**
  51004. * Removes a joint from the simulation
  51005. * @param mainImpostor defines the impostor used with the joint
  51006. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51007. * @param joint defines the joint to remove
  51008. */
  51009. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51010. /**
  51011. * Called by the scene. No need to call it.
  51012. * @param delta defines the timespam between frames
  51013. */
  51014. _step(delta: number): void;
  51015. /**
  51016. * Gets the current plugin used to run the simulation
  51017. * @returns current plugin
  51018. */
  51019. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51020. /**
  51021. * Gets the list of physic impostors
  51022. * @returns an array of PhysicsImpostor
  51023. */
  51024. getImpostors(): Array<PhysicsImpostor>;
  51025. /**
  51026. * Gets the impostor for a physics enabled object
  51027. * @param object defines the object impersonated by the impostor
  51028. * @returns the PhysicsImpostor or null if not found
  51029. */
  51030. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51031. /**
  51032. * Gets the impostor for a physics body object
  51033. * @param body defines physics body used by the impostor
  51034. * @returns the PhysicsImpostor or null if not found
  51035. */
  51036. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51037. /**
  51038. * Does a raycast in the physics world
  51039. * @param from when should the ray start?
  51040. * @param to when should the ray end?
  51041. * @returns PhysicsRaycastResult
  51042. */
  51043. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51044. }
  51045. }
  51046. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51047. import { Nullable } from "babylonjs/types";
  51048. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51050. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51051. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51052. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51053. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51054. /** @hidden */
  51055. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51056. private _useDeltaForWorldStep;
  51057. world: any;
  51058. name: string;
  51059. private _physicsMaterials;
  51060. private _fixedTimeStep;
  51061. private _cannonRaycastResult;
  51062. private _raycastResult;
  51063. private _removeAfterStep;
  51064. BJSCANNON: any;
  51065. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51066. setGravity(gravity: Vector3): void;
  51067. setTimeStep(timeStep: number): void;
  51068. getTimeStep(): number;
  51069. executeStep(delta: number): void;
  51070. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51071. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51072. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51073. private _processChildMeshes;
  51074. removePhysicsBody(impostor: PhysicsImpostor): void;
  51075. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51076. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51077. private _addMaterial;
  51078. private _checkWithEpsilon;
  51079. private _createShape;
  51080. private _createHeightmap;
  51081. private _minus90X;
  51082. private _plus90X;
  51083. private _tmpPosition;
  51084. private _tmpDeltaPosition;
  51085. private _tmpUnityRotation;
  51086. private _updatePhysicsBodyTransformation;
  51087. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51088. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51089. isSupported(): boolean;
  51090. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51091. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51092. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51093. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51094. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51095. getBodyMass(impostor: PhysicsImpostor): number;
  51096. getBodyFriction(impostor: PhysicsImpostor): number;
  51097. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51098. getBodyRestitution(impostor: PhysicsImpostor): number;
  51099. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51100. sleepBody(impostor: PhysicsImpostor): void;
  51101. wakeUpBody(impostor: PhysicsImpostor): void;
  51102. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51103. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51104. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51105. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51106. getRadius(impostor: PhysicsImpostor): number;
  51107. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51108. dispose(): void;
  51109. private _extendNamespace;
  51110. /**
  51111. * Does a raycast in the physics world
  51112. * @param from when should the ray start?
  51113. * @param to when should the ray end?
  51114. * @returns PhysicsRaycastResult
  51115. */
  51116. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51117. }
  51118. }
  51119. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51120. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51121. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51122. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51124. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51125. import { Nullable } from "babylonjs/types";
  51126. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51127. /** @hidden */
  51128. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51129. world: any;
  51130. name: string;
  51131. BJSOIMO: any;
  51132. private _raycastResult;
  51133. constructor(iterations?: number, oimoInjection?: any);
  51134. setGravity(gravity: Vector3): void;
  51135. setTimeStep(timeStep: number): void;
  51136. getTimeStep(): number;
  51137. private _tmpImpostorsArray;
  51138. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51139. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51140. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51141. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51142. private _tmpPositionVector;
  51143. removePhysicsBody(impostor: PhysicsImpostor): void;
  51144. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51145. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51146. isSupported(): boolean;
  51147. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51148. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51149. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51150. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51151. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51152. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51153. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51154. getBodyMass(impostor: PhysicsImpostor): number;
  51155. getBodyFriction(impostor: PhysicsImpostor): number;
  51156. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51157. getBodyRestitution(impostor: PhysicsImpostor): number;
  51158. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51159. sleepBody(impostor: PhysicsImpostor): void;
  51160. wakeUpBody(impostor: PhysicsImpostor): void;
  51161. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51162. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51163. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51164. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51165. getRadius(impostor: PhysicsImpostor): number;
  51166. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51167. dispose(): void;
  51168. /**
  51169. * Does a raycast in the physics world
  51170. * @param from when should the ray start?
  51171. * @param to when should the ray end?
  51172. * @returns PhysicsRaycastResult
  51173. */
  51174. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51175. }
  51176. }
  51177. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51178. import { Nullable } from "babylonjs/types";
  51179. import { Scene } from "babylonjs/scene";
  51180. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51181. import { Mesh } from "babylonjs/Meshes/mesh";
  51182. /**
  51183. * Class containing static functions to help procedurally build meshes
  51184. */
  51185. export class RibbonBuilder {
  51186. /**
  51187. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51188. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51189. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51190. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51191. * * 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
  51192. * * 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
  51193. * * 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
  51194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51196. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51197. * * 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
  51198. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51199. * * 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
  51200. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51202. * @param name defines the name of the mesh
  51203. * @param options defines the options used to create the mesh
  51204. * @param scene defines the hosting scene
  51205. * @returns the ribbon mesh
  51206. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51207. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51208. */
  51209. static CreateRibbon(name: string, options: {
  51210. pathArray: Vector3[][];
  51211. closeArray?: boolean;
  51212. closePath?: boolean;
  51213. offset?: number;
  51214. updatable?: boolean;
  51215. sideOrientation?: number;
  51216. frontUVs?: Vector4;
  51217. backUVs?: Vector4;
  51218. instance?: Mesh;
  51219. invertUV?: boolean;
  51220. uvs?: Vector2[];
  51221. colors?: Color4[];
  51222. }, scene?: Nullable<Scene>): Mesh;
  51223. }
  51224. }
  51225. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51226. import { Nullable } from "babylonjs/types";
  51227. import { Scene } from "babylonjs/scene";
  51228. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51229. import { Mesh } from "babylonjs/Meshes/mesh";
  51230. /**
  51231. * Class containing static functions to help procedurally build meshes
  51232. */
  51233. export class ShapeBuilder {
  51234. /**
  51235. * 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.
  51236. * * 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.
  51237. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51238. * * 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.
  51239. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51240. * * 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
  51241. * * 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
  51242. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51245. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51247. * @param name defines the name of the mesh
  51248. * @param options defines the options used to create the mesh
  51249. * @param scene defines the hosting scene
  51250. * @returns the extruded shape mesh
  51251. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51253. */
  51254. static ExtrudeShape(name: string, options: {
  51255. shape: Vector3[];
  51256. path: Vector3[];
  51257. scale?: number;
  51258. rotation?: number;
  51259. cap?: number;
  51260. updatable?: boolean;
  51261. sideOrientation?: number;
  51262. frontUVs?: Vector4;
  51263. backUVs?: Vector4;
  51264. instance?: Mesh;
  51265. invertUV?: boolean;
  51266. }, scene?: Nullable<Scene>): Mesh;
  51267. /**
  51268. * Creates an custom extruded shape mesh.
  51269. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51270. * * 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.
  51271. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51272. * * 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
  51273. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51274. * * 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
  51275. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51276. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51277. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51278. * * 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
  51279. * * 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
  51280. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51283. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51285. * @param name defines the name of the mesh
  51286. * @param options defines the options used to create the mesh
  51287. * @param scene defines the hosting scene
  51288. * @returns the custom extruded shape mesh
  51289. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51290. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51291. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51292. */
  51293. static ExtrudeShapeCustom(name: string, options: {
  51294. shape: Vector3[];
  51295. path: Vector3[];
  51296. scaleFunction?: any;
  51297. rotationFunction?: any;
  51298. ribbonCloseArray?: boolean;
  51299. ribbonClosePath?: boolean;
  51300. cap?: number;
  51301. updatable?: boolean;
  51302. sideOrientation?: number;
  51303. frontUVs?: Vector4;
  51304. backUVs?: Vector4;
  51305. instance?: Mesh;
  51306. invertUV?: boolean;
  51307. }, scene?: Nullable<Scene>): Mesh;
  51308. private static _ExtrudeShapeGeneric;
  51309. }
  51310. }
  51311. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51312. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51313. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51314. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51315. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51316. import { Nullable } from "babylonjs/types";
  51317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51318. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51319. /**
  51320. * AmmoJS Physics plugin
  51321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51322. * @see https://github.com/kripken/ammo.js/
  51323. */
  51324. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51325. private _useDeltaForWorldStep;
  51326. /**
  51327. * Reference to the Ammo library
  51328. */
  51329. bjsAMMO: any;
  51330. /**
  51331. * Created ammoJS world which physics bodies are added to
  51332. */
  51333. world: any;
  51334. /**
  51335. * Name of the plugin
  51336. */
  51337. name: string;
  51338. private _timeStep;
  51339. private _fixedTimeStep;
  51340. private _maxSteps;
  51341. private _tmpQuaternion;
  51342. private _tmpAmmoTransform;
  51343. private _tmpAmmoQuaternion;
  51344. private _tmpAmmoConcreteContactResultCallback;
  51345. private _collisionConfiguration;
  51346. private _dispatcher;
  51347. private _overlappingPairCache;
  51348. private _solver;
  51349. private _softBodySolver;
  51350. private _tmpAmmoVectorA;
  51351. private _tmpAmmoVectorB;
  51352. private _tmpAmmoVectorC;
  51353. private _tmpAmmoVectorD;
  51354. private _tmpContactCallbackResult;
  51355. private _tmpAmmoVectorRCA;
  51356. private _tmpAmmoVectorRCB;
  51357. private _raycastResult;
  51358. private static readonly DISABLE_COLLISION_FLAG;
  51359. private static readonly KINEMATIC_FLAG;
  51360. private static readonly DISABLE_DEACTIVATION_FLAG;
  51361. /**
  51362. * Initializes the ammoJS plugin
  51363. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51364. * @param ammoInjection can be used to inject your own ammo reference
  51365. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51366. */
  51367. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51368. /**
  51369. * Sets the gravity of the physics world (m/(s^2))
  51370. * @param gravity Gravity to set
  51371. */
  51372. setGravity(gravity: Vector3): void;
  51373. /**
  51374. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51375. * @param timeStep timestep to use in seconds
  51376. */
  51377. setTimeStep(timeStep: number): void;
  51378. /**
  51379. * 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)
  51380. * @param fixedTimeStep fixedTimeStep to use in seconds
  51381. */
  51382. setFixedTimeStep(fixedTimeStep: number): void;
  51383. /**
  51384. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51385. * @param maxSteps the maximum number of steps by the physics engine per frame
  51386. */
  51387. setMaxSteps(maxSteps: number): void;
  51388. /**
  51389. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51390. * @returns the current timestep in seconds
  51391. */
  51392. getTimeStep(): number;
  51393. private _isImpostorInContact;
  51394. private _isImpostorPairInContact;
  51395. private _stepSimulation;
  51396. /**
  51397. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51398. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51399. * After the step the babylon meshes are set to the position of the physics imposters
  51400. * @param delta amount of time to step forward
  51401. * @param impostors array of imposters to update before/after the step
  51402. */
  51403. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51404. /**
  51405. * Update babylon mesh to match physics world object
  51406. * @param impostor imposter to match
  51407. */
  51408. private _afterSoftStep;
  51409. /**
  51410. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51411. * @param impostor imposter to match
  51412. */
  51413. private _ropeStep;
  51414. /**
  51415. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51416. * @param impostor imposter to match
  51417. */
  51418. private _softbodyOrClothStep;
  51419. private _tmpVector;
  51420. private _tmpMatrix;
  51421. /**
  51422. * Applies an impulse on the imposter
  51423. * @param impostor imposter to apply impulse to
  51424. * @param force amount of force to be applied to the imposter
  51425. * @param contactPoint the location to apply the impulse on the imposter
  51426. */
  51427. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51428. /**
  51429. * Applies a force on the imposter
  51430. * @param impostor imposter to apply force
  51431. * @param force amount of force to be applied to the imposter
  51432. * @param contactPoint the location to apply the force on the imposter
  51433. */
  51434. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51435. /**
  51436. * Creates a physics body using the plugin
  51437. * @param impostor the imposter to create the physics body on
  51438. */
  51439. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51440. /**
  51441. * Removes the physics body from the imposter and disposes of the body's memory
  51442. * @param impostor imposter to remove the physics body from
  51443. */
  51444. removePhysicsBody(impostor: PhysicsImpostor): void;
  51445. /**
  51446. * Generates a joint
  51447. * @param impostorJoint the imposter joint to create the joint with
  51448. */
  51449. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51450. /**
  51451. * Removes a joint
  51452. * @param impostorJoint the imposter joint to remove the joint from
  51453. */
  51454. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51455. private _addMeshVerts;
  51456. /**
  51457. * Initialise the soft body vertices to match its object's (mesh) vertices
  51458. * Softbody vertices (nodes) are in world space and to match this
  51459. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51460. * @param impostor to create the softbody for
  51461. */
  51462. private _softVertexData;
  51463. /**
  51464. * Create an impostor's soft body
  51465. * @param impostor to create the softbody for
  51466. */
  51467. private _createSoftbody;
  51468. /**
  51469. * Create cloth for an impostor
  51470. * @param impostor to create the softbody for
  51471. */
  51472. private _createCloth;
  51473. /**
  51474. * Create rope for an impostor
  51475. * @param impostor to create the softbody for
  51476. */
  51477. private _createRope;
  51478. private _addHullVerts;
  51479. private _createShape;
  51480. /**
  51481. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51482. * @param impostor imposter containing the physics body and babylon object
  51483. */
  51484. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51485. /**
  51486. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51487. * @param impostor imposter containing the physics body and babylon object
  51488. * @param newPosition new position
  51489. * @param newRotation new rotation
  51490. */
  51491. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51492. /**
  51493. * If this plugin is supported
  51494. * @returns true if its supported
  51495. */
  51496. isSupported(): boolean;
  51497. /**
  51498. * Sets the linear velocity of the physics body
  51499. * @param impostor imposter to set the velocity on
  51500. * @param velocity velocity to set
  51501. */
  51502. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51503. /**
  51504. * Sets the angular velocity of the physics body
  51505. * @param impostor imposter to set the velocity on
  51506. * @param velocity velocity to set
  51507. */
  51508. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51509. /**
  51510. * gets the linear velocity
  51511. * @param impostor imposter to get linear velocity from
  51512. * @returns linear velocity
  51513. */
  51514. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51515. /**
  51516. * gets the angular velocity
  51517. * @param impostor imposter to get angular velocity from
  51518. * @returns angular velocity
  51519. */
  51520. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51521. /**
  51522. * Sets the mass of physics body
  51523. * @param impostor imposter to set the mass on
  51524. * @param mass mass to set
  51525. */
  51526. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51527. /**
  51528. * Gets the mass of the physics body
  51529. * @param impostor imposter to get the mass from
  51530. * @returns mass
  51531. */
  51532. getBodyMass(impostor: PhysicsImpostor): number;
  51533. /**
  51534. * Gets friction of the impostor
  51535. * @param impostor impostor to get friction from
  51536. * @returns friction value
  51537. */
  51538. getBodyFriction(impostor: PhysicsImpostor): number;
  51539. /**
  51540. * Sets friction of the impostor
  51541. * @param impostor impostor to set friction on
  51542. * @param friction friction value
  51543. */
  51544. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51545. /**
  51546. * Gets restitution of the impostor
  51547. * @param impostor impostor to get restitution from
  51548. * @returns restitution value
  51549. */
  51550. getBodyRestitution(impostor: PhysicsImpostor): number;
  51551. /**
  51552. * Sets resitution of the impostor
  51553. * @param impostor impostor to set resitution on
  51554. * @param restitution resitution value
  51555. */
  51556. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51557. /**
  51558. * Gets pressure inside the impostor
  51559. * @param impostor impostor to get pressure from
  51560. * @returns pressure value
  51561. */
  51562. getBodyPressure(impostor: PhysicsImpostor): number;
  51563. /**
  51564. * Sets pressure inside a soft body impostor
  51565. * Cloth and rope must remain 0 pressure
  51566. * @param impostor impostor to set pressure on
  51567. * @param pressure pressure value
  51568. */
  51569. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51570. /**
  51571. * Gets stiffness of the impostor
  51572. * @param impostor impostor to get stiffness from
  51573. * @returns pressure value
  51574. */
  51575. getBodyStiffness(impostor: PhysicsImpostor): number;
  51576. /**
  51577. * Sets stiffness of the impostor
  51578. * @param impostor impostor to set stiffness on
  51579. * @param stiffness stiffness value from 0 to 1
  51580. */
  51581. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51582. /**
  51583. * Gets velocityIterations of the impostor
  51584. * @param impostor impostor to get velocity iterations from
  51585. * @returns velocityIterations value
  51586. */
  51587. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51588. /**
  51589. * Sets velocityIterations of the impostor
  51590. * @param impostor impostor to set velocity iterations on
  51591. * @param velocityIterations velocityIterations value
  51592. */
  51593. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51594. /**
  51595. * Gets positionIterations of the impostor
  51596. * @param impostor impostor to get position iterations from
  51597. * @returns positionIterations value
  51598. */
  51599. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51600. /**
  51601. * Sets positionIterations of the impostor
  51602. * @param impostor impostor to set position on
  51603. * @param positionIterations positionIterations value
  51604. */
  51605. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51606. /**
  51607. * Append an anchor to a cloth object
  51608. * @param impostor is the cloth impostor to add anchor to
  51609. * @param otherImpostor is the rigid impostor to anchor to
  51610. * @param width ratio across width from 0 to 1
  51611. * @param height ratio up height from 0 to 1
  51612. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51613. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51614. */
  51615. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51616. /**
  51617. * Append an hook to a rope object
  51618. * @param impostor is the rope impostor to add hook to
  51619. * @param otherImpostor is the rigid impostor to hook to
  51620. * @param length ratio along the rope from 0 to 1
  51621. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51622. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51623. */
  51624. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51625. /**
  51626. * Sleeps the physics body and stops it from being active
  51627. * @param impostor impostor to sleep
  51628. */
  51629. sleepBody(impostor: PhysicsImpostor): void;
  51630. /**
  51631. * Activates the physics body
  51632. * @param impostor impostor to activate
  51633. */
  51634. wakeUpBody(impostor: PhysicsImpostor): void;
  51635. /**
  51636. * Updates the distance parameters of the joint
  51637. * @param joint joint to update
  51638. * @param maxDistance maximum distance of the joint
  51639. * @param minDistance minimum distance of the joint
  51640. */
  51641. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51642. /**
  51643. * Sets a motor on the joint
  51644. * @param joint joint to set motor on
  51645. * @param speed speed of the motor
  51646. * @param maxForce maximum force of the motor
  51647. * @param motorIndex index of the motor
  51648. */
  51649. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51650. /**
  51651. * Sets the motors limit
  51652. * @param joint joint to set limit on
  51653. * @param upperLimit upper limit
  51654. * @param lowerLimit lower limit
  51655. */
  51656. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51657. /**
  51658. * Syncs the position and rotation of a mesh with the impostor
  51659. * @param mesh mesh to sync
  51660. * @param impostor impostor to update the mesh with
  51661. */
  51662. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51663. /**
  51664. * Gets the radius of the impostor
  51665. * @param impostor impostor to get radius from
  51666. * @returns the radius
  51667. */
  51668. getRadius(impostor: PhysicsImpostor): number;
  51669. /**
  51670. * Gets the box size of the impostor
  51671. * @param impostor impostor to get box size from
  51672. * @param result the resulting box size
  51673. */
  51674. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51675. /**
  51676. * Disposes of the impostor
  51677. */
  51678. dispose(): void;
  51679. /**
  51680. * Does a raycast in the physics world
  51681. * @param from when should the ray start?
  51682. * @param to when should the ray end?
  51683. * @returns PhysicsRaycastResult
  51684. */
  51685. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51686. }
  51687. }
  51688. declare module "babylonjs/Probes/reflectionProbe" {
  51689. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51690. import { Vector3 } from "babylonjs/Maths/math";
  51691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51692. import { Nullable } from "babylonjs/types";
  51693. import { Scene } from "babylonjs/scene";
  51694. module "babylonjs/abstractScene" {
  51695. interface AbstractScene {
  51696. /**
  51697. * The list of reflection probes added to the scene
  51698. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51699. */
  51700. reflectionProbes: Array<ReflectionProbe>;
  51701. /**
  51702. * Removes the given reflection probe from this scene.
  51703. * @param toRemove The reflection probe to remove
  51704. * @returns The index of the removed reflection probe
  51705. */
  51706. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51707. /**
  51708. * Adds the given reflection probe to this scene.
  51709. * @param newReflectionProbe The reflection probe to add
  51710. */
  51711. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51712. }
  51713. }
  51714. /**
  51715. * Class used to generate realtime reflection / refraction cube textures
  51716. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51717. */
  51718. export class ReflectionProbe {
  51719. /** defines the name of the probe */
  51720. name: string;
  51721. private _scene;
  51722. private _renderTargetTexture;
  51723. private _projectionMatrix;
  51724. private _viewMatrix;
  51725. private _target;
  51726. private _add;
  51727. private _attachedMesh;
  51728. private _invertYAxis;
  51729. /** Gets or sets probe position (center of the cube map) */
  51730. position: Vector3;
  51731. /**
  51732. * Creates a new reflection probe
  51733. * @param name defines the name of the probe
  51734. * @param size defines the texture resolution (for each face)
  51735. * @param scene defines the hosting scene
  51736. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51737. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51738. */
  51739. constructor(
  51740. /** defines the name of the probe */
  51741. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51742. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51743. samples: number;
  51744. /** Gets or sets the refresh rate to use (on every frame by default) */
  51745. refreshRate: number;
  51746. /**
  51747. * Gets the hosting scene
  51748. * @returns a Scene
  51749. */
  51750. getScene(): Scene;
  51751. /** Gets the internal CubeTexture used to render to */
  51752. readonly cubeTexture: RenderTargetTexture;
  51753. /** Gets the list of meshes to render */
  51754. readonly renderList: Nullable<AbstractMesh[]>;
  51755. /**
  51756. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51757. * @param mesh defines the mesh to attach to
  51758. */
  51759. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51760. /**
  51761. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51762. * @param renderingGroupId The rendering group id corresponding to its index
  51763. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51764. */
  51765. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51766. /**
  51767. * Clean all associated resources
  51768. */
  51769. dispose(): void;
  51770. /**
  51771. * Converts the reflection probe information to a readable string for debug purpose.
  51772. * @param fullDetails Supports for multiple levels of logging within scene loading
  51773. * @returns the human readable reflection probe info
  51774. */
  51775. toString(fullDetails?: boolean): string;
  51776. /**
  51777. * Get the class name of the relfection probe.
  51778. * @returns "ReflectionProbe"
  51779. */
  51780. getClassName(): string;
  51781. /**
  51782. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51783. * @returns The JSON representation of the texture
  51784. */
  51785. serialize(): any;
  51786. /**
  51787. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51788. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51789. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51790. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51791. * @returns The parsed reflection probe if successful
  51792. */
  51793. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51794. }
  51795. }
  51796. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51797. /** @hidden */
  51798. export var _BabylonLoaderRegistered: boolean;
  51799. }
  51800. declare module "babylonjs/Loading/Plugins/index" {
  51801. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51802. }
  51803. declare module "babylonjs/Loading/index" {
  51804. export * from "babylonjs/Loading/loadingScreen";
  51805. export * from "babylonjs/Loading/Plugins/index";
  51806. export * from "babylonjs/Loading/sceneLoader";
  51807. export * from "babylonjs/Loading/sceneLoaderFlags";
  51808. }
  51809. declare module "babylonjs/Materials/Background/index" {
  51810. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51811. }
  51812. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51813. import { Scene } from "babylonjs/scene";
  51814. import { Color3 } from "babylonjs/Maths/math";
  51815. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51816. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51817. /**
  51818. * The Physically based simple base material of BJS.
  51819. *
  51820. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51821. * It is used as the base class for both the specGloss and metalRough conventions.
  51822. */
  51823. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51824. /**
  51825. * Number of Simultaneous lights allowed on the material.
  51826. */
  51827. maxSimultaneousLights: number;
  51828. /**
  51829. * If sets to true, disables all the lights affecting the material.
  51830. */
  51831. disableLighting: boolean;
  51832. /**
  51833. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51834. */
  51835. environmentTexture: BaseTexture;
  51836. /**
  51837. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51838. */
  51839. invertNormalMapX: boolean;
  51840. /**
  51841. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51842. */
  51843. invertNormalMapY: boolean;
  51844. /**
  51845. * Normal map used in the model.
  51846. */
  51847. normalTexture: BaseTexture;
  51848. /**
  51849. * Emissivie color used to self-illuminate the model.
  51850. */
  51851. emissiveColor: Color3;
  51852. /**
  51853. * Emissivie texture used to self-illuminate the model.
  51854. */
  51855. emissiveTexture: BaseTexture;
  51856. /**
  51857. * Occlusion Channel Strenght.
  51858. */
  51859. occlusionStrength: number;
  51860. /**
  51861. * Occlusion Texture of the material (adding extra occlusion effects).
  51862. */
  51863. occlusionTexture: BaseTexture;
  51864. /**
  51865. * Defines the alpha limits in alpha test mode.
  51866. */
  51867. alphaCutOff: number;
  51868. /**
  51869. * Gets the current double sided mode.
  51870. */
  51871. /**
  51872. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51873. */
  51874. doubleSided: boolean;
  51875. /**
  51876. * Stores the pre-calculated light information of a mesh in a texture.
  51877. */
  51878. lightmapTexture: BaseTexture;
  51879. /**
  51880. * If true, the light map contains occlusion information instead of lighting info.
  51881. */
  51882. useLightmapAsShadowmap: boolean;
  51883. /**
  51884. * Instantiates a new PBRMaterial instance.
  51885. *
  51886. * @param name The material name
  51887. * @param scene The scene the material will be use in.
  51888. */
  51889. constructor(name: string, scene: Scene);
  51890. getClassName(): string;
  51891. }
  51892. }
  51893. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51894. import { Scene } from "babylonjs/scene";
  51895. import { Color3 } from "babylonjs/Maths/math";
  51896. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51897. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51898. /**
  51899. * The PBR material of BJS following the metal roughness convention.
  51900. *
  51901. * This fits to the PBR convention in the GLTF definition:
  51902. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51903. */
  51904. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51905. /**
  51906. * The base color has two different interpretations depending on the value of metalness.
  51907. * When the material is a metal, the base color is the specific measured reflectance value
  51908. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51909. * of the material.
  51910. */
  51911. baseColor: Color3;
  51912. /**
  51913. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51914. * well as opacity information in the alpha channel.
  51915. */
  51916. baseTexture: BaseTexture;
  51917. /**
  51918. * Specifies the metallic scalar value of the material.
  51919. * Can also be used to scale the metalness values of the metallic texture.
  51920. */
  51921. metallic: number;
  51922. /**
  51923. * Specifies the roughness scalar value of the material.
  51924. * Can also be used to scale the roughness values of the metallic texture.
  51925. */
  51926. roughness: number;
  51927. /**
  51928. * Texture containing both the metallic value in the B channel and the
  51929. * roughness value in the G channel to keep better precision.
  51930. */
  51931. metallicRoughnessTexture: BaseTexture;
  51932. /**
  51933. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51934. *
  51935. * @param name The material name
  51936. * @param scene The scene the material will be use in.
  51937. */
  51938. constructor(name: string, scene: Scene);
  51939. /**
  51940. * Return the currrent class name of the material.
  51941. */
  51942. getClassName(): string;
  51943. /**
  51944. * Makes a duplicate of the current material.
  51945. * @param name - name to use for the new material.
  51946. */
  51947. clone(name: string): PBRMetallicRoughnessMaterial;
  51948. /**
  51949. * Serialize the material to a parsable JSON object.
  51950. */
  51951. serialize(): any;
  51952. /**
  51953. * Parses a JSON object correponding to the serialize function.
  51954. */
  51955. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51956. }
  51957. }
  51958. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51959. import { Scene } from "babylonjs/scene";
  51960. import { Color3 } from "babylonjs/Maths/math";
  51961. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51962. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51963. /**
  51964. * The PBR material of BJS following the specular glossiness convention.
  51965. *
  51966. * This fits to the PBR convention in the GLTF definition:
  51967. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51968. */
  51969. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51970. /**
  51971. * Specifies the diffuse color of the material.
  51972. */
  51973. diffuseColor: Color3;
  51974. /**
  51975. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51976. * channel.
  51977. */
  51978. diffuseTexture: BaseTexture;
  51979. /**
  51980. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51981. */
  51982. specularColor: Color3;
  51983. /**
  51984. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51985. */
  51986. glossiness: number;
  51987. /**
  51988. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51989. */
  51990. specularGlossinessTexture: BaseTexture;
  51991. /**
  51992. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51993. *
  51994. * @param name The material name
  51995. * @param scene The scene the material will be use in.
  51996. */
  51997. constructor(name: string, scene: Scene);
  51998. /**
  51999. * Return the currrent class name of the material.
  52000. */
  52001. getClassName(): string;
  52002. /**
  52003. * Makes a duplicate of the current material.
  52004. * @param name - name to use for the new material.
  52005. */
  52006. clone(name: string): PBRSpecularGlossinessMaterial;
  52007. /**
  52008. * Serialize the material to a parsable JSON object.
  52009. */
  52010. serialize(): any;
  52011. /**
  52012. * Parses a JSON object correponding to the serialize function.
  52013. */
  52014. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52015. }
  52016. }
  52017. declare module "babylonjs/Materials/PBR/index" {
  52018. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52019. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52020. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52021. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52022. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52023. }
  52024. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52025. import { Nullable } from "babylonjs/types";
  52026. import { Scene } from "babylonjs/scene";
  52027. import { Matrix } from "babylonjs/Maths/math";
  52028. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52029. /**
  52030. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52031. * It can help converting any input color in a desired output one. This can then be used to create effects
  52032. * from sepia, black and white to sixties or futuristic rendering...
  52033. *
  52034. * The only supported format is currently 3dl.
  52035. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52036. */
  52037. export class ColorGradingTexture extends BaseTexture {
  52038. /**
  52039. * The current texture matrix. (will always be identity in color grading texture)
  52040. */
  52041. private _textureMatrix;
  52042. /**
  52043. * The texture URL.
  52044. */
  52045. url: string;
  52046. /**
  52047. * Empty line regex stored for GC.
  52048. */
  52049. private static _noneEmptyLineRegex;
  52050. private _engine;
  52051. /**
  52052. * Instantiates a ColorGradingTexture from the following parameters.
  52053. *
  52054. * @param url The location of the color gradind data (currently only supporting 3dl)
  52055. * @param scene The scene the texture will be used in
  52056. */
  52057. constructor(url: string, scene: Scene);
  52058. /**
  52059. * Returns the texture matrix used in most of the material.
  52060. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52061. */
  52062. getTextureMatrix(): Matrix;
  52063. /**
  52064. * Occurs when the file being loaded is a .3dl LUT file.
  52065. */
  52066. private load3dlTexture;
  52067. /**
  52068. * Starts the loading process of the texture.
  52069. */
  52070. private loadTexture;
  52071. /**
  52072. * Clones the color gradind texture.
  52073. */
  52074. clone(): ColorGradingTexture;
  52075. /**
  52076. * Called during delayed load for textures.
  52077. */
  52078. delayLoad(): void;
  52079. /**
  52080. * Parses a color grading texture serialized by Babylon.
  52081. * @param parsedTexture The texture information being parsedTexture
  52082. * @param scene The scene to load the texture in
  52083. * @param rootUrl The root url of the data assets to load
  52084. * @return A color gradind texture
  52085. */
  52086. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52087. /**
  52088. * Serializes the LUT texture to json format.
  52089. */
  52090. serialize(): any;
  52091. }
  52092. }
  52093. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52094. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52095. import { Scene } from "babylonjs/scene";
  52096. import { Nullable } from "babylonjs/types";
  52097. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52098. /**
  52099. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52100. */
  52101. export class EquiRectangularCubeTexture extends BaseTexture {
  52102. /** The six faces of the cube. */
  52103. private static _FacesMapping;
  52104. private _noMipmap;
  52105. private _onLoad;
  52106. private _onError;
  52107. /** The size of the cubemap. */
  52108. private _size;
  52109. /** The buffer of the image. */
  52110. private _buffer;
  52111. /** The width of the input image. */
  52112. private _width;
  52113. /** The height of the input image. */
  52114. private _height;
  52115. /** The URL to the image. */
  52116. url: string;
  52117. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52118. coordinatesMode: number;
  52119. /**
  52120. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52121. * @param url The location of the image
  52122. * @param scene The scene the texture will be used in
  52123. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52124. * @param noMipmap Forces to not generate the mipmap if true
  52125. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52126. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52127. * @param onLoad — defines a callback called when texture is loaded
  52128. * @param onError — defines a callback called if there is an error
  52129. */
  52130. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52131. /**
  52132. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52133. */
  52134. private loadImage;
  52135. /**
  52136. * Convert the image buffer into a cubemap and create a CubeTexture.
  52137. */
  52138. private loadTexture;
  52139. /**
  52140. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52141. * @param buffer The ArrayBuffer that should be converted.
  52142. * @returns The buffer as Float32Array.
  52143. */
  52144. private getFloat32ArrayFromArrayBuffer;
  52145. /**
  52146. * Get the current class name of the texture useful for serialization or dynamic coding.
  52147. * @returns "EquiRectangularCubeTexture"
  52148. */
  52149. getClassName(): string;
  52150. /**
  52151. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52152. * @returns A clone of the current EquiRectangularCubeTexture.
  52153. */
  52154. clone(): EquiRectangularCubeTexture;
  52155. }
  52156. }
  52157. declare module "babylonjs/Misc/tga" {
  52158. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52159. /**
  52160. * Based on jsTGALoader - Javascript loader for TGA file
  52161. * By Vincent Thibault
  52162. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52163. */
  52164. export class TGATools {
  52165. private static _TYPE_INDEXED;
  52166. private static _TYPE_RGB;
  52167. private static _TYPE_GREY;
  52168. private static _TYPE_RLE_INDEXED;
  52169. private static _TYPE_RLE_RGB;
  52170. private static _TYPE_RLE_GREY;
  52171. private static _ORIGIN_MASK;
  52172. private static _ORIGIN_SHIFT;
  52173. private static _ORIGIN_BL;
  52174. private static _ORIGIN_BR;
  52175. private static _ORIGIN_UL;
  52176. private static _ORIGIN_UR;
  52177. /**
  52178. * Gets the header of a TGA file
  52179. * @param data defines the TGA data
  52180. * @returns the header
  52181. */
  52182. static GetTGAHeader(data: Uint8Array): any;
  52183. /**
  52184. * Uploads TGA content to a Babylon Texture
  52185. * @hidden
  52186. */
  52187. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52188. /** @hidden */
  52189. 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;
  52190. /** @hidden */
  52191. 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;
  52192. /** @hidden */
  52193. 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;
  52194. /** @hidden */
  52195. 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;
  52196. /** @hidden */
  52197. 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;
  52198. /** @hidden */
  52199. 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;
  52200. }
  52201. }
  52202. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52203. import { Nullable } from "babylonjs/types";
  52204. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52205. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52206. /**
  52207. * Implementation of the TGA Texture Loader.
  52208. * @hidden
  52209. */
  52210. export class _TGATextureLoader implements IInternalTextureLoader {
  52211. /**
  52212. * Defines wether the loader supports cascade loading the different faces.
  52213. */
  52214. readonly supportCascades: boolean;
  52215. /**
  52216. * This returns if the loader support the current file information.
  52217. * @param extension defines the file extension of the file being loaded
  52218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52219. * @param fallback defines the fallback internal texture if any
  52220. * @param isBase64 defines whether the texture is encoded as a base64
  52221. * @param isBuffer defines whether the texture data are stored as a buffer
  52222. * @returns true if the loader can load the specified file
  52223. */
  52224. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52225. /**
  52226. * Transform the url before loading if required.
  52227. * @param rootUrl the url of the texture
  52228. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52229. * @returns the transformed texture
  52230. */
  52231. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52232. /**
  52233. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52234. * @param rootUrl the url of the texture
  52235. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52236. * @returns the fallback texture
  52237. */
  52238. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52239. /**
  52240. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52241. * @param data contains the texture data
  52242. * @param texture defines the BabylonJS internal texture
  52243. * @param createPolynomials will be true if polynomials have been requested
  52244. * @param onLoad defines the callback to trigger once the texture is ready
  52245. * @param onError defines the callback to trigger in case of error
  52246. */
  52247. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52248. /**
  52249. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52250. * @param data contains the texture data
  52251. * @param texture defines the BabylonJS internal texture
  52252. * @param callback defines the method to call once ready to upload
  52253. */
  52254. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52255. }
  52256. }
  52257. declare module "babylonjs/Misc/basis" {
  52258. /**
  52259. * Info about the .basis files
  52260. */
  52261. class BasisFileInfo {
  52262. /**
  52263. * If the file has alpha
  52264. */
  52265. hasAlpha: boolean;
  52266. /**
  52267. * Info about each image of the basis file
  52268. */
  52269. images: Array<{
  52270. levels: Array<{
  52271. width: number;
  52272. height: number;
  52273. transcodedPixels: ArrayBufferView;
  52274. }>;
  52275. }>;
  52276. }
  52277. /**
  52278. * Configuration options for the Basis transcoder
  52279. */
  52280. export class BasisTranscodeConfiguration {
  52281. /**
  52282. * Supported compression formats used to determine the supported output format of the transcoder
  52283. */
  52284. supportedCompressionFormats?: {
  52285. /**
  52286. * etc1 compression format
  52287. */
  52288. etc1?: boolean;
  52289. /**
  52290. * s3tc compression format
  52291. */
  52292. s3tc?: boolean;
  52293. /**
  52294. * pvrtc compression format
  52295. */
  52296. pvrtc?: boolean;
  52297. /**
  52298. * etc2 compression format
  52299. */
  52300. etc2?: boolean;
  52301. };
  52302. /**
  52303. * If mipmap levels should be loaded for transcoded images (Default: true)
  52304. */
  52305. loadMipmapLevels?: boolean;
  52306. /**
  52307. * Index of a single image to load (Default: all images)
  52308. */
  52309. loadSingleImage?: number;
  52310. }
  52311. /**
  52312. * Used to load .Basis files
  52313. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52314. */
  52315. export class BasisTools {
  52316. private static _IgnoreSupportedFormats;
  52317. /**
  52318. * URL to use when loading the basis transcoder
  52319. */
  52320. static JSModuleURL: string;
  52321. /**
  52322. * URL to use when loading the wasm module for the transcoder
  52323. */
  52324. static WasmModuleURL: string;
  52325. /**
  52326. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52327. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52328. * @returns internal format corresponding to the Basis format
  52329. */
  52330. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52331. private static _WorkerPromise;
  52332. private static _Worker;
  52333. private static _CreateWorkerAsync;
  52334. /**
  52335. * Transcodes a loaded image file to compressed pixel data
  52336. * @param imageData image data to transcode
  52337. * @param config configuration options for the transcoding
  52338. * @returns a promise resulting in the transcoded image
  52339. */
  52340. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<{
  52341. fileInfo: BasisFileInfo;
  52342. format: number;
  52343. }>;
  52344. }
  52345. }
  52346. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  52347. import { Nullable } from "babylonjs/types";
  52348. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52349. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52350. /**
  52351. * Loader for .basis file format
  52352. */
  52353. export class _BasisTextureLoader implements IInternalTextureLoader {
  52354. /**
  52355. * Defines whether the loader supports cascade loading the different faces.
  52356. */
  52357. readonly supportCascades: boolean;
  52358. /**
  52359. * This returns if the loader support the current file information.
  52360. * @param extension defines the file extension of the file being loaded
  52361. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52362. * @param fallback defines the fallback internal texture if any
  52363. * @param isBase64 defines whether the texture is encoded as a base64
  52364. * @param isBuffer defines whether the texture data are stored as a buffer
  52365. * @returns true if the loader can load the specified file
  52366. */
  52367. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52368. /**
  52369. * Transform the url before loading if required.
  52370. * @param rootUrl the url of the texture
  52371. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52372. * @returns the transformed texture
  52373. */
  52374. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52375. /**
  52376. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52377. * @param rootUrl the url of the texture
  52378. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52379. * @returns the fallback texture
  52380. */
  52381. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52382. /**
  52383. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52384. * @param data contains the texture data
  52385. * @param texture defines the BabylonJS internal texture
  52386. * @param createPolynomials will be true if polynomials have been requested
  52387. * @param onLoad defines the callback to trigger once the texture is ready
  52388. * @param onError defines the callback to trigger in case of error
  52389. */
  52390. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52391. /**
  52392. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52393. * @param data contains the texture data
  52394. * @param texture defines the BabylonJS internal texture
  52395. * @param callback defines the method to call once ready to upload
  52396. */
  52397. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52398. }
  52399. }
  52400. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52401. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52402. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52403. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52404. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52405. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  52406. }
  52407. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52408. import { Scene } from "babylonjs/scene";
  52409. import { Texture } from "babylonjs/Materials/Textures/texture";
  52410. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52411. /**
  52412. * 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.
  52413. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52414. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52415. */
  52416. export class CustomProceduralTexture extends ProceduralTexture {
  52417. private _animate;
  52418. private _time;
  52419. private _config;
  52420. private _texturePath;
  52421. /**
  52422. * Instantiates a new Custom Procedural Texture.
  52423. * 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.
  52424. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52425. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52426. * @param name Define the name of the texture
  52427. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52428. * @param size Define the size of the texture to create
  52429. * @param scene Define the scene the texture belongs to
  52430. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52431. * @param generateMipMaps Define if the texture should creates mip maps or not
  52432. */
  52433. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52434. private _loadJson;
  52435. /**
  52436. * Is the texture ready to be used ? (rendered at least once)
  52437. * @returns true if ready, otherwise, false.
  52438. */
  52439. isReady(): boolean;
  52440. /**
  52441. * Render the texture to its associated render target.
  52442. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52443. */
  52444. render(useCameraPostProcess?: boolean): void;
  52445. /**
  52446. * Update the list of dependant textures samplers in the shader.
  52447. */
  52448. updateTextures(): void;
  52449. /**
  52450. * Update the uniform values of the procedural texture in the shader.
  52451. */
  52452. updateShaderUniforms(): void;
  52453. /**
  52454. * Define if the texture animates or not.
  52455. */
  52456. animate: boolean;
  52457. }
  52458. }
  52459. declare module "babylonjs/Shaders/noise.fragment" {
  52460. /** @hidden */
  52461. export var noisePixelShader: {
  52462. name: string;
  52463. shader: string;
  52464. };
  52465. }
  52466. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52467. import { Nullable } from "babylonjs/types";
  52468. import { Scene } from "babylonjs/scene";
  52469. import { Texture } from "babylonjs/Materials/Textures/texture";
  52470. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52471. import "babylonjs/Shaders/noise.fragment";
  52472. /**
  52473. * Class used to generate noise procedural textures
  52474. */
  52475. export class NoiseProceduralTexture extends ProceduralTexture {
  52476. private _time;
  52477. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52478. brightness: number;
  52479. /** Defines the number of octaves to process */
  52480. octaves: number;
  52481. /** Defines the level of persistence (0.8 by default) */
  52482. persistence: number;
  52483. /** Gets or sets animation speed factor (default is 1) */
  52484. animationSpeedFactor: number;
  52485. /**
  52486. * Creates a new NoiseProceduralTexture
  52487. * @param name defines the name fo the texture
  52488. * @param size defines the size of the texture (default is 256)
  52489. * @param scene defines the hosting scene
  52490. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52491. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52492. */
  52493. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52494. private _updateShaderUniforms;
  52495. protected _getDefines(): string;
  52496. /** Generate the current state of the procedural texture */
  52497. render(useCameraPostProcess?: boolean): void;
  52498. /**
  52499. * Serializes this noise procedural texture
  52500. * @returns a serialized noise procedural texture object
  52501. */
  52502. serialize(): any;
  52503. /**
  52504. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52505. * @param parsedTexture defines parsed texture data
  52506. * @param scene defines the current scene
  52507. * @param rootUrl defines the root URL containing noise procedural texture information
  52508. * @returns a parsed NoiseProceduralTexture
  52509. */
  52510. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52511. }
  52512. }
  52513. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52514. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52515. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52516. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52517. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52518. }
  52519. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52520. import { Nullable } from "babylonjs/types";
  52521. import { Scene } from "babylonjs/scene";
  52522. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52523. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52524. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52525. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52526. /**
  52527. * Raw cube texture where the raw buffers are passed in
  52528. */
  52529. export class RawCubeTexture extends CubeTexture {
  52530. /**
  52531. * Creates a cube texture where the raw buffers are passed in.
  52532. * @param scene defines the scene the texture is attached to
  52533. * @param data defines the array of data to use to create each face
  52534. * @param size defines the size of the textures
  52535. * @param format defines the format of the data
  52536. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52537. * @param generateMipMaps defines if the engine should generate the mip levels
  52538. * @param invertY defines if data must be stored with Y axis inverted
  52539. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52540. * @param compression defines the compression used (null by default)
  52541. */
  52542. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52543. /**
  52544. * Updates the raw cube texture.
  52545. * @param data defines the data to store
  52546. * @param format defines the data format
  52547. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52548. * @param invertY defines if data must be stored with Y axis inverted
  52549. * @param compression defines the compression used (null by default)
  52550. * @param level defines which level of the texture to update
  52551. */
  52552. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52553. /**
  52554. * Updates a raw cube texture with RGBD encoded data.
  52555. * @param data defines the array of data [mipmap][face] to use to create each face
  52556. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52557. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52558. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52559. * @returns a promsie that resolves when the operation is complete
  52560. */
  52561. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52562. /**
  52563. * Clones the raw cube texture.
  52564. * @return a new cube texture
  52565. */
  52566. clone(): CubeTexture;
  52567. /** @hidden */
  52568. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52569. }
  52570. }
  52571. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52572. import { Scene } from "babylonjs/scene";
  52573. import { Texture } from "babylonjs/Materials/Textures/texture";
  52574. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52575. /**
  52576. * Class used to store 3D textures containing user data
  52577. */
  52578. export class RawTexture3D extends Texture {
  52579. /** Gets or sets the texture format to use */
  52580. format: number;
  52581. private _engine;
  52582. /**
  52583. * Create a new RawTexture3D
  52584. * @param data defines the data of the texture
  52585. * @param width defines the width of the texture
  52586. * @param height defines the height of the texture
  52587. * @param depth defines the depth of the texture
  52588. * @param format defines the texture format to use
  52589. * @param scene defines the hosting scene
  52590. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52591. * @param invertY defines if texture must be stored with Y axis inverted
  52592. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52593. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52594. */
  52595. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52596. /** Gets or sets the texture format to use */
  52597. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52598. /**
  52599. * Update the texture with new data
  52600. * @param data defines the data to store in the texture
  52601. */
  52602. update(data: ArrayBufferView): void;
  52603. }
  52604. }
  52605. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52606. import { Scene } from "babylonjs/scene";
  52607. import { Plane } from "babylonjs/Maths/math";
  52608. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52609. /**
  52610. * Creates a refraction texture used by refraction channel of the standard material.
  52611. * It is like a mirror but to see through a material.
  52612. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52613. */
  52614. export class RefractionTexture extends RenderTargetTexture {
  52615. /**
  52616. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52617. * 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.
  52618. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52619. */
  52620. refractionPlane: Plane;
  52621. /**
  52622. * Define how deep under the surface we should see.
  52623. */
  52624. depth: number;
  52625. /**
  52626. * Creates a refraction texture used by refraction channel of the standard material.
  52627. * It is like a mirror but to see through a material.
  52628. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52629. * @param name Define the texture name
  52630. * @param size Define the size of the underlying texture
  52631. * @param scene Define the scene the refraction belongs to
  52632. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52633. */
  52634. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52635. /**
  52636. * Clone the refraction texture.
  52637. * @returns the cloned texture
  52638. */
  52639. clone(): RefractionTexture;
  52640. /**
  52641. * Serialize the texture to a JSON representation you could use in Parse later on
  52642. * @returns the serialized JSON representation
  52643. */
  52644. serialize(): any;
  52645. }
  52646. }
  52647. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52648. import { Nullable } from "babylonjs/types";
  52649. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52650. import { Matrix } from "babylonjs/Maths/math";
  52651. import { Engine } from "babylonjs/Engines/engine";
  52652. import { Scene } from "babylonjs/scene";
  52653. /**
  52654. * Defines the options related to the creation of an HtmlElementTexture
  52655. */
  52656. export interface IHtmlElementTextureOptions {
  52657. /**
  52658. * Defines wether mip maps should be created or not.
  52659. */
  52660. generateMipMaps?: boolean;
  52661. /**
  52662. * Defines the sampling mode of the texture.
  52663. */
  52664. samplingMode?: number;
  52665. /**
  52666. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52667. */
  52668. engine: Nullable<Engine>;
  52669. /**
  52670. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52671. */
  52672. scene: Nullable<Scene>;
  52673. }
  52674. /**
  52675. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52676. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52677. * is automatically managed.
  52678. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52679. * in your application.
  52680. *
  52681. * As the update is not automatic, you need to call them manually.
  52682. */
  52683. export class HtmlElementTexture extends BaseTexture {
  52684. /**
  52685. * The texture URL.
  52686. */
  52687. element: HTMLVideoElement | HTMLCanvasElement;
  52688. private static readonly DefaultOptions;
  52689. private _textureMatrix;
  52690. private _engine;
  52691. private _isVideo;
  52692. private _generateMipMaps;
  52693. private _samplingMode;
  52694. /**
  52695. * Instantiates a HtmlElementTexture from the following parameters.
  52696. *
  52697. * @param name Defines the name of the texture
  52698. * @param element Defines the video or canvas the texture is filled with
  52699. * @param options Defines the other none mandatory texture creation options
  52700. */
  52701. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52702. private _createInternalTexture;
  52703. /**
  52704. * Returns the texture matrix used in most of the material.
  52705. */
  52706. getTextureMatrix(): Matrix;
  52707. /**
  52708. * Updates the content of the texture.
  52709. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52710. */
  52711. update(invertY?: Nullable<boolean>): void;
  52712. }
  52713. }
  52714. declare module "babylonjs/Materials/Textures/index" {
  52715. export * from "babylonjs/Materials/Textures/baseTexture";
  52716. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  52717. export * from "babylonjs/Materials/Textures/cubeTexture";
  52718. export * from "babylonjs/Materials/Textures/dynamicTexture";
  52719. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  52720. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  52721. export * from "babylonjs/Materials/Textures/internalTexture";
  52722. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  52723. export * from "babylonjs/Materials/Textures/Loaders/index";
  52724. export * from "babylonjs/Materials/Textures/mirrorTexture";
  52725. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  52726. export * from "babylonjs/Materials/Textures/Procedurals/index";
  52727. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  52728. export * from "babylonjs/Materials/Textures/rawTexture";
  52729. export * from "babylonjs/Materials/Textures/rawTexture3D";
  52730. export * from "babylonjs/Materials/Textures/refractionTexture";
  52731. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  52732. export * from "babylonjs/Materials/Textures/texture";
  52733. export * from "babylonjs/Materials/Textures/videoTexture";
  52734. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  52735. }
  52736. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  52737. /**
  52738. * Enum used to define the target of a block
  52739. */
  52740. export enum NodeMaterialBlockTargets {
  52741. /** Vertex shader */
  52742. Vertex = 1,
  52743. /** Fragment shader */
  52744. Fragment = 2,
  52745. /** Vertex and Fragment */
  52746. VertexAndFragment = 3
  52747. }
  52748. }
  52749. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  52750. /**
  52751. * Defines the kind of connection point for node based material
  52752. */
  52753. export enum NodeMaterialBlockConnectionPointTypes {
  52754. /** Float */
  52755. Float = 1,
  52756. /** Int */
  52757. Int = 2,
  52758. /** Vector2 */
  52759. Vector2 = 4,
  52760. /** Vector3 */
  52761. Vector3 = 8,
  52762. /** Vector4 */
  52763. Vector4 = 16,
  52764. /** Color3 */
  52765. Color3 = 32,
  52766. /** Color4 */
  52767. Color4 = 64,
  52768. /** Matrix */
  52769. Matrix = 128,
  52770. /** Texture */
  52771. Texture = 256,
  52772. /** Texture3D */
  52773. Texture3D = 512,
  52774. /** Vector3 or Color3 */
  52775. Vector3OrColor3 = 40,
  52776. /** Vector3 or Vector4 */
  52777. Vector3OrVector4 = 24,
  52778. /** Vector4 or Color4 */
  52779. Vector4OrColor4 = 80,
  52780. /** Color3 or Color4 */
  52781. Color3OrColor4 = 96,
  52782. /** Vector3 or Color3 */
  52783. Vector3OrColor3OrVector4OrColor4 = 120,
  52784. /** Detect type based on connection */
  52785. AutoDetect = 1024,
  52786. /** Output type that will be defined by input type */
  52787. BasedOnInput = 2048
  52788. }
  52789. }
  52790. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  52791. /**
  52792. * Enum used to define well known values e.g. values automatically provided by the system
  52793. */
  52794. export enum NodeMaterialWellKnownValues {
  52795. /** World */
  52796. World = 1,
  52797. /** View */
  52798. View = 2,
  52799. /** Projection */
  52800. Projection = 3,
  52801. /** ViewProjection */
  52802. ViewProjection = 4,
  52803. /** WorldView */
  52804. WorldView = 5,
  52805. /** WorldViewProjection */
  52806. WorldViewProjection = 6,
  52807. /** Will be filled by the block itself */
  52808. Automatic = 7
  52809. }
  52810. }
  52811. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  52812. /**
  52813. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52814. */
  52815. export enum NodeMaterialBlockConnectionPointMode {
  52816. /** Value is an uniform */
  52817. Uniform = 0,
  52818. /** Value is a mesh attribute */
  52819. Attribute = 1,
  52820. /** Value is a varying between vertex and fragment shaders */
  52821. Varying = 2,
  52822. /** Mode is undefined */
  52823. Undefined = 3
  52824. }
  52825. }
  52826. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  52827. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52828. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52829. /**
  52830. * Class used to store shared data between 2 NodeMaterialBuildState
  52831. */
  52832. export class NodeMaterialBuildStateSharedData {
  52833. /**
  52834. * Gets the list of emitted varyings
  52835. */
  52836. varyings: string[];
  52837. /**
  52838. * Gets the varying declaration string
  52839. */
  52840. varyingDeclaration: string;
  52841. /**
  52842. * Uniform connection points
  52843. */
  52844. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  52845. /**
  52846. * Bindable blocks (Blocks that need to set data to the effect)
  52847. */
  52848. bindableBlocks: NodeMaterialBlock[];
  52849. /**
  52850. * List of blocks that can provide a compilation fallback
  52851. */
  52852. blocksWithFallbacks: NodeMaterialBlock[];
  52853. /**
  52854. * List of blocks that can provide a define update
  52855. */
  52856. blocksWithDefines: NodeMaterialBlock[];
  52857. /**
  52858. * List of blocks that can provide a repeatable content
  52859. */
  52860. repeatableContentBlocks: NodeMaterialBlock[];
  52861. /**
  52862. * List of blocks that can block the isReady function for the material
  52863. */
  52864. blockingBlocks: NodeMaterialBlock[];
  52865. /**
  52866. * Build Id used to avoid multiple recompilations
  52867. */
  52868. buildId: number;
  52869. /** List of emitted variables */
  52870. variableNames: {
  52871. [key: string]: number;
  52872. };
  52873. /** List of emitted defines */
  52874. defineNames: {
  52875. [key: string]: number;
  52876. };
  52877. /** Should emit comments? */
  52878. emitComments: boolean;
  52879. /** Emit build activity */
  52880. verbose: boolean;
  52881. /**
  52882. * Gets the compilation hints emitted at compilation time
  52883. */
  52884. hints: {
  52885. needWorldViewMatrix: boolean;
  52886. needWorldViewProjectionMatrix: boolean;
  52887. needAlphaBlending: boolean;
  52888. needAlphaTesting: boolean;
  52889. };
  52890. /**
  52891. * List of compilation checks
  52892. */
  52893. checks: {
  52894. emitVertex: boolean;
  52895. emitFragment: boolean;
  52896. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52897. };
  52898. /** Creates a new shared data */
  52899. constructor();
  52900. /**
  52901. * Emits console errors and exceptions if there is a failing check
  52902. */
  52903. emitErrors(): void;
  52904. }
  52905. }
  52906. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  52907. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52908. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  52909. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  52910. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  52911. /**
  52912. * Class used to store node based material build state
  52913. */
  52914. export class NodeMaterialBuildState {
  52915. /**
  52916. * Gets the list of emitted attributes
  52917. */
  52918. attributes: string[];
  52919. /**
  52920. * Gets the list of emitted uniforms
  52921. */
  52922. uniforms: string[];
  52923. /**
  52924. * Gets the list of emitted samplers
  52925. */
  52926. samplers: string[];
  52927. /**
  52928. * Gets the list of emitted functions
  52929. */
  52930. functions: {
  52931. [key: string]: string;
  52932. };
  52933. /**
  52934. * Gets the target of the compilation state
  52935. */
  52936. target: NodeMaterialBlockTargets;
  52937. /**
  52938. * Shared data between multiple NodeMaterialBuildState instances
  52939. */
  52940. sharedData: NodeMaterialBuildStateSharedData;
  52941. /** @hidden */
  52942. _vertexState: NodeMaterialBuildState;
  52943. private _attributeDeclaration;
  52944. private _uniformDeclaration;
  52945. private _samplerDeclaration;
  52946. private _varyingTransfer;
  52947. private _repeatableContentAnchorIndex;
  52948. /** @hidden */
  52949. _builtCompilationString: string;
  52950. /**
  52951. * Gets the emitted compilation strings
  52952. */
  52953. compilationString: string;
  52954. /**
  52955. * Finalize the compilation strings
  52956. * @param state defines the current compilation state
  52957. */
  52958. finalize(state: NodeMaterialBuildState): void;
  52959. /** @hidden */
  52960. readonly _repeatableContentAnchor: string;
  52961. /** @hidden */
  52962. _getFreeVariableName(prefix: string): string;
  52963. /** @hidden */
  52964. _getFreeDefineName(prefix: string): string;
  52965. /** @hidden */
  52966. _excludeVariableName(name: string): void;
  52967. /** @hidden */
  52968. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52969. /** @hidden */
  52970. _emitFunction(name: string, code: string, comments: string): void;
  52971. /** @hidden */
  52972. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52973. replaceStrings?: {
  52974. search: RegExp;
  52975. replace: string;
  52976. }[];
  52977. }): string;
  52978. /** @hidden */
  52979. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52980. repeatKey?: string;
  52981. removeAttributes?: boolean;
  52982. removeUniforms?: boolean;
  52983. removeVaryings?: boolean;
  52984. removeIfDef?: boolean;
  52985. replaceStrings?: {
  52986. search: RegExp;
  52987. replace: string;
  52988. }[];
  52989. }): void;
  52990. /** @hidden */
  52991. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  52992. private _emitDefine;
  52993. /** @hidden */
  52994. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  52995. }
  52996. }
  52997. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  52998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52999. /**
  53000. * Root class for all node material optimizers
  53001. */
  53002. export class NodeMaterialOptimizer {
  53003. /**
  53004. * Function used to optimize a NodeMaterial graph
  53005. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53006. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53007. */
  53008. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53009. }
  53010. }
  53011. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  53012. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53013. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53015. /**
  53016. * Block used to transform a vector4 with a matrix
  53017. */
  53018. export class Vector4TransformBlock extends NodeMaterialBlock {
  53019. /**
  53020. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53021. */
  53022. complementW: number;
  53023. /**
  53024. * Creates a new Vector4TransformBlock
  53025. * @param name defines the block name
  53026. */
  53027. constructor(name: string);
  53028. /**
  53029. * Gets the current class name
  53030. * @returns the class name
  53031. */
  53032. getClassName(): string;
  53033. /**
  53034. * Gets the vector input
  53035. */
  53036. readonly vector: NodeMaterialConnectionPoint;
  53037. /**
  53038. * Gets the matrix transform input
  53039. */
  53040. readonly transform: NodeMaterialConnectionPoint;
  53041. protected _buildBlock(state: NodeMaterialBuildState): this;
  53042. }
  53043. }
  53044. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53045. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53046. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53047. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53048. /**
  53049. * Block used to output the vertex position
  53050. */
  53051. export class VertexOutputBlock extends NodeMaterialBlock {
  53052. /**
  53053. * Creates a new VertexOutputBlock
  53054. * @param name defines the block name
  53055. */
  53056. constructor(name: string);
  53057. /**
  53058. * Gets the current class name
  53059. * @returns the class name
  53060. */
  53061. getClassName(): string;
  53062. /**
  53063. * Gets the vector input component
  53064. */
  53065. readonly vector: NodeMaterialConnectionPoint;
  53066. protected _buildBlock(state: NodeMaterialBuildState): this;
  53067. }
  53068. }
  53069. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53070. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53071. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53072. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53073. /**
  53074. * Block used to output the final color
  53075. */
  53076. export class FragmentOutputBlock extends NodeMaterialBlock {
  53077. /**
  53078. * Gets or sets a boolean indicating if this block will output an alpha value
  53079. */
  53080. alphaBlendingEnabled: boolean;
  53081. /**
  53082. * Create a new FragmentOutputBlock
  53083. * @param name defines the block name
  53084. */
  53085. constructor(name: string);
  53086. /**
  53087. * Gets the current class name
  53088. * @returns the class name
  53089. */
  53090. getClassName(): string;
  53091. /**
  53092. * Gets the color input component
  53093. */
  53094. readonly color: NodeMaterialConnectionPoint;
  53095. protected _buildBlock(state: NodeMaterialBuildState): this;
  53096. }
  53097. }
  53098. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53100. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53101. import { Scene } from "babylonjs/scene";
  53102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53103. import { Matrix } from "babylonjs/Maths/math";
  53104. import { Mesh } from "babylonjs/Meshes/mesh";
  53105. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53106. import { Observable } from "babylonjs/Misc/observable";
  53107. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53108. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53109. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53110. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53111. import { Nullable } from "babylonjs/types";
  53112. /**
  53113. * Interface used to configure the node material editor
  53114. */
  53115. export interface INodeMaterialEditorOptions {
  53116. /** Define the URl to load node editor script */
  53117. editorURL?: string;
  53118. }
  53119. /** @hidden */
  53120. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53121. /** BONES */
  53122. NUM_BONE_INFLUENCERS: number;
  53123. BonesPerMesh: number;
  53124. BONETEXTURE: boolean;
  53125. /** MORPH TARGETS */
  53126. MORPHTARGETS: boolean;
  53127. MORPHTARGETS_NORMAL: boolean;
  53128. MORPHTARGETS_TANGENT: boolean;
  53129. NUM_MORPH_INFLUENCERS: number;
  53130. /** IMAGE PROCESSING */
  53131. IMAGEPROCESSING: boolean;
  53132. VIGNETTE: boolean;
  53133. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53134. VIGNETTEBLENDMODEOPAQUE: boolean;
  53135. TONEMAPPING: boolean;
  53136. TONEMAPPING_ACES: boolean;
  53137. CONTRAST: boolean;
  53138. EXPOSURE: boolean;
  53139. COLORCURVES: boolean;
  53140. COLORGRADING: boolean;
  53141. COLORGRADING3D: boolean;
  53142. SAMPLER3DGREENDEPTH: boolean;
  53143. SAMPLER3DBGRMAP: boolean;
  53144. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53145. constructor();
  53146. setValue(name: string, value: boolean): void;
  53147. }
  53148. /**
  53149. * Class used to configure NodeMaterial
  53150. */
  53151. export interface INodeMaterialOptions {
  53152. /**
  53153. * Defines if blocks should emit comments
  53154. */
  53155. emitComments: boolean;
  53156. }
  53157. /**
  53158. * Class used to create a node based material built by assembling shader blocks
  53159. */
  53160. export class NodeMaterial extends PushMaterial {
  53161. private _options;
  53162. private _vertexCompilationState;
  53163. private _fragmentCompilationState;
  53164. private _sharedData;
  53165. private _buildId;
  53166. private _buildWasSuccessful;
  53167. private _cachedWorldViewMatrix;
  53168. private _cachedWorldViewProjectionMatrix;
  53169. private _textureConnectionPoints;
  53170. private _optimizers;
  53171. /** Define the URl to load node editor script */
  53172. static EditorURL: string;
  53173. private BJSNODEMATERIALEDITOR;
  53174. /** Get the inspector from bundle or global */
  53175. private _getGlobalNodeMaterialEditor;
  53176. /**
  53177. * Defines the maximum number of lights that can be used in the material
  53178. */
  53179. maxSimultaneousLights: number;
  53180. /**
  53181. * Observable raised when the material is built
  53182. */
  53183. onBuildObservable: Observable<NodeMaterial>;
  53184. /**
  53185. * Gets or sets the root nodes of the material vertex shader
  53186. */
  53187. _vertexOutputNodes: NodeMaterialBlock[];
  53188. /**
  53189. * Gets or sets the root nodes of the material fragment (pixel) shader
  53190. */
  53191. _fragmentOutputNodes: NodeMaterialBlock[];
  53192. /** Gets or sets options to control the node material overall behavior */
  53193. options: INodeMaterialOptions;
  53194. /**
  53195. * Default configuration related to image processing available in the standard Material.
  53196. */
  53197. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53198. /**
  53199. * Gets the image processing configuration used either in this material.
  53200. */
  53201. /**
  53202. * Sets the Default image processing configuration used either in the this material.
  53203. *
  53204. * If sets to null, the scene one is in use.
  53205. */
  53206. imageProcessingConfiguration: ImageProcessingConfiguration;
  53207. /**
  53208. * Create a new node based material
  53209. * @param name defines the material name
  53210. * @param scene defines the hosting scene
  53211. * @param options defines creation option
  53212. */
  53213. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53214. /**
  53215. * Gets the current class name of the material e.g. "NodeMaterial"
  53216. * @returns the class name
  53217. */
  53218. getClassName(): string;
  53219. /**
  53220. * Keep track of the image processing observer to allow dispose and replace.
  53221. */
  53222. private _imageProcessingObserver;
  53223. /**
  53224. * Attaches a new image processing configuration to the Standard Material.
  53225. * @param configuration
  53226. */
  53227. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53228. /**
  53229. * Adds a new optimizer to the list of optimizers
  53230. * @param optimizer defines the optimizers to add
  53231. * @returns the current material
  53232. */
  53233. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53234. /**
  53235. * Remove an optimizer from the list of optimizers
  53236. * @param optimizer defines the optimizers to remove
  53237. * @returns the current material
  53238. */
  53239. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53240. /**
  53241. * Add a new block to the list of output nodes
  53242. * @param node defines the node to add
  53243. * @returns the current material
  53244. */
  53245. addOutputNode(node: NodeMaterialBlock): this;
  53246. /**
  53247. * Remove a block from the list of root nodes
  53248. * @param node defines the node to remove
  53249. * @returns the current material
  53250. */
  53251. removeOutputNode(node: NodeMaterialBlock): this;
  53252. private _addVertexOutputNode;
  53253. private _removeVertexOutputNode;
  53254. private _addFragmentOutputNode;
  53255. private _removeFragmentOutputNode;
  53256. /**
  53257. * Specifies if the material will require alpha blending
  53258. * @returns a boolean specifying if alpha blending is needed
  53259. */
  53260. needAlphaBlending(): boolean;
  53261. /**
  53262. * Specifies if this material should be rendered in alpha test mode
  53263. * @returns a boolean specifying if an alpha test is needed.
  53264. */
  53265. needAlphaTesting(): boolean;
  53266. private _initializeBlock;
  53267. private _resetDualBlocks;
  53268. /**
  53269. * Build the material and generates the inner effect
  53270. * @param verbose defines if the build should log activity
  53271. */
  53272. build(verbose?: boolean): void;
  53273. /**
  53274. * Runs an otpimization phase to try to improve the shader code
  53275. */
  53276. optimize(): void;
  53277. private _prepareDefinesForAttributes;
  53278. /**
  53279. * Get if the submesh is ready to be used and all its information available.
  53280. * Child classes can use it to update shaders
  53281. * @param mesh defines the mesh to check
  53282. * @param subMesh defines which submesh to check
  53283. * @param useInstances specifies that instances should be used
  53284. * @returns a boolean indicating that the submesh is ready or not
  53285. */
  53286. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53287. /**
  53288. * Binds the world matrix to the material
  53289. * @param world defines the world transformation matrix
  53290. */
  53291. bindOnlyWorldMatrix(world: Matrix): void;
  53292. /**
  53293. * Binds the submesh to this material by preparing the effect and shader to draw
  53294. * @param world defines the world transformation matrix
  53295. * @param mesh defines the mesh containing the submesh
  53296. * @param subMesh defines the submesh to bind the material to
  53297. */
  53298. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53299. /**
  53300. * Gets the active textures from the material
  53301. * @returns an array of textures
  53302. */
  53303. getActiveTextures(): BaseTexture[];
  53304. /**
  53305. * Specifies if the material uses a texture
  53306. * @param texture defines the texture to check against the material
  53307. * @returns a boolean specifying if the material uses the texture
  53308. */
  53309. hasTexture(texture: BaseTexture): boolean;
  53310. /**
  53311. * Disposes the material
  53312. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53313. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53314. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53315. */
  53316. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53317. /** Creates the node editor window. */
  53318. private _createNodeEditor;
  53319. /**
  53320. * Launch the node material editor
  53321. * @param config Define the configuration of the editor
  53322. * @return a promise fulfilled when the node editor is visible
  53323. */
  53324. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53325. /**
  53326. * Clear the current material
  53327. */
  53328. clear(): void;
  53329. /**
  53330. * Clear the current material and set it to a default state
  53331. */
  53332. setToDefault(): void;
  53333. }
  53334. }
  53335. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53336. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53337. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53338. import { Nullable } from "babylonjs/types";
  53339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53340. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53341. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53343. import { Mesh } from "babylonjs/Meshes/mesh";
  53344. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53345. /**
  53346. * Defines a block that can be used inside a node based material
  53347. */
  53348. export class NodeMaterialBlock {
  53349. private _buildId;
  53350. private _target;
  53351. private _isFinalMerger;
  53352. /** @hidden */
  53353. _inputs: NodeMaterialConnectionPoint[];
  53354. /** @hidden */
  53355. _outputs: NodeMaterialConnectionPoint[];
  53356. /**
  53357. * Gets or sets the name of the block
  53358. */
  53359. name: string;
  53360. /**
  53361. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53362. */
  53363. readonly isFinalMerger: boolean;
  53364. /**
  53365. * Gets or sets the build Id
  53366. */
  53367. buildId: number;
  53368. /**
  53369. * Gets or sets the target of the block
  53370. */
  53371. target: NodeMaterialBlockTargets;
  53372. /**
  53373. * Gets the list of input points
  53374. */
  53375. readonly inputs: NodeMaterialConnectionPoint[];
  53376. /** Gets the list of output points */
  53377. readonly outputs: NodeMaterialConnectionPoint[];
  53378. /**
  53379. * Find an input by its name
  53380. * @param name defines the name of the input to look for
  53381. * @returns the input or null if not found
  53382. */
  53383. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53384. /**
  53385. * Find an output by its name
  53386. * @param name defines the name of the outputto look for
  53387. * @returns the output or null if not found
  53388. */
  53389. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53390. /**
  53391. * Creates a new NodeMaterialBlock
  53392. * @param name defines the block name
  53393. * @param target defines the target of that block (Vertex by default)
  53394. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53395. */
  53396. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  53397. /**
  53398. * Initialize the block and prepare the context for build
  53399. * @param state defines the state that will be used for the build
  53400. */
  53401. initialize(state: NodeMaterialBuildState): void;
  53402. /**
  53403. * Bind data to effect. Will only be called for blocks with isBindable === true
  53404. * @param effect defines the effect to bind data to
  53405. * @param nodeMaterial defines the hosting NodeMaterial
  53406. * @param mesh defines the mesh that will be rendered
  53407. */
  53408. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53409. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53410. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53411. protected _writeFloat(value: number): string;
  53412. /**
  53413. * Gets the current class name e.g. "NodeMaterialBlock"
  53414. * @returns the class name
  53415. */
  53416. getClassName(): string;
  53417. /**
  53418. * Register a new input. Must be called inside a block constructor
  53419. * @param name defines the connection point name
  53420. * @param type defines the connection point type
  53421. * @param isOptional defines a boolean indicating that this input can be omitted
  53422. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53423. * @returns the current block
  53424. */
  53425. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53426. /**
  53427. * Register a new output. Must be called inside a block constructor
  53428. * @param name defines the connection point name
  53429. * @param type defines the connection point type
  53430. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53431. * @returns the current block
  53432. */
  53433. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53434. /**
  53435. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53436. * @param forOutput defines an optional connection point to check compatibility with
  53437. * @returns the first available input or null
  53438. */
  53439. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53440. /**
  53441. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53442. * @param forBlock defines an optional block to check compatibility with
  53443. * @returns the first available input or null
  53444. */
  53445. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53446. /**
  53447. * Connect current block with another block
  53448. * @param other defines the block to connect with
  53449. * @param options define the various options to help pick the right connections
  53450. * @returns the current block
  53451. */
  53452. connectTo(other: NodeMaterialBlock, options?: {
  53453. input?: string;
  53454. output?: string;
  53455. outputSwizzle?: string;
  53456. }): this | undefined;
  53457. protected _buildBlock(state: NodeMaterialBuildState): void;
  53458. /**
  53459. * Add potential fallbacks if shader compilation fails
  53460. * @param mesh defines the mesh to be rendered
  53461. * @param fallbacks defines the current prioritized list of fallbacks
  53462. */
  53463. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53464. /**
  53465. * Update defines for shader compilation
  53466. * @param mesh defines the mesh to be rendered
  53467. * @param nodeMaterial defines the node material requesting the update
  53468. * @param defines defines the material defines to update
  53469. * @param useInstances specifies that instances should be used
  53470. */
  53471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53472. /**
  53473. * Lets the block try to connect some inputs automatically
  53474. */
  53475. autoConfigure(): void;
  53476. /**
  53477. * Function called when a block is declared as repeatable content generator
  53478. * @param vertexShaderState defines the current compilation state for the vertex shader
  53479. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53480. * @param mesh defines the mesh to be rendered
  53481. * @param defines defines the material defines to update
  53482. */
  53483. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53484. /**
  53485. * Checks if the block is ready
  53486. * @param mesh defines the mesh to be rendered
  53487. * @param nodeMaterial defines the node material requesting the update
  53488. * @param defines defines the material defines to update
  53489. * @param useInstances specifies that instances should be used
  53490. * @returns true if the block is ready
  53491. */
  53492. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53493. /**
  53494. * Compile the current node and generate the shader code
  53495. * @param state defines the current compilation state (uniforms, samplers, current string)
  53496. * @returns the current block
  53497. */
  53498. build(state: NodeMaterialBuildState): this | undefined;
  53499. }
  53500. }
  53501. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  53502. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53503. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53504. import { Nullable } from "babylonjs/types";
  53505. import { Effect } from "babylonjs/Materials/effect";
  53506. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53507. import { Scene } from "babylonjs/scene";
  53508. import { Matrix } from "babylonjs/Maths/math";
  53509. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53510. /**
  53511. * Defines a connection point for a block
  53512. */
  53513. export class NodeMaterialConnectionPoint {
  53514. /** @hidden */
  53515. _ownerBlock: NodeMaterialBlock;
  53516. /** @hidden */
  53517. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53518. private _associatedVariableName;
  53519. private _endpoints;
  53520. private _storedValue;
  53521. private _valueCallback;
  53522. private _mode;
  53523. /** @hidden */
  53524. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53525. /** @hidden */
  53526. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53527. /** @hidden */
  53528. _needToEmitVarying: boolean;
  53529. private _type;
  53530. /**
  53531. * Gets or sets the connection point type (default is float)
  53532. */
  53533. type: NodeMaterialBlockConnectionPointTypes;
  53534. /**
  53535. * Gets or sets the connection point name
  53536. */
  53537. name: string;
  53538. /**
  53539. * Gets or sets the swizzle to apply to this connection point when reading or writing
  53540. */
  53541. swizzle: string;
  53542. /**
  53543. * Gets or sets a boolean indicating that this connection point can be omitted
  53544. */
  53545. isOptional: boolean;
  53546. /**
  53547. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53548. */
  53549. define: string;
  53550. /** Gets or sets the target of that connection point */
  53551. target: NodeMaterialBlockTargets;
  53552. /**
  53553. * Gets or sets the value of that point.
  53554. * Please note that this value will be ignored if valueCallback is defined
  53555. */
  53556. value: any;
  53557. /**
  53558. * Gets or sets a callback used to get the value of that point.
  53559. * Please note that setting this value will force the connection point to ignore the value property
  53560. */
  53561. valueCallback: () => any;
  53562. /**
  53563. * Gets or sets the associated variable name in the shader
  53564. */
  53565. associatedVariableName: string;
  53566. /**
  53567. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53568. * In this case the connection point name must be the name of the uniform to use.
  53569. * Can only be set on inputs
  53570. */
  53571. isUniform: boolean;
  53572. /**
  53573. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53574. * In this case the connection point name must be the name of the attribute to use
  53575. * Can only be set on inputs
  53576. */
  53577. isAttribute: boolean;
  53578. /**
  53579. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53580. * Can only be set on exit points
  53581. */
  53582. isVarying: boolean;
  53583. /** Get the other side of the connection (if any) */
  53584. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53585. /** Get the block that owns this connection point */
  53586. readonly ownerBlock: NodeMaterialBlock;
  53587. /** Get the block connected on the other side of this connection (if any) */
  53588. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53589. /** Get the block connected on the endpoints of this connection (if any) */
  53590. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53591. /**
  53592. * Creates a new connection point
  53593. * @param name defines the connection point name
  53594. * @param ownerBlock defines the block hosting this connection point
  53595. */
  53596. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53597. /**
  53598. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53599. * @returns the class name
  53600. */
  53601. getClassName(): string;
  53602. /**
  53603. * Set the source of this connection point to a vertex attribute
  53604. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53605. * @returns the current connection point
  53606. */
  53607. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  53608. /**
  53609. * Set the source of this connection point to a well known value
  53610. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53611. * @returns the current connection point
  53612. */
  53613. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  53614. /**
  53615. * Gets a boolean indicating that the current connection point is a well known value
  53616. */
  53617. readonly isWellKnownValue: boolean;
  53618. /**
  53619. * Gets or sets the current well known value or null if not defined as well know value
  53620. */
  53621. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53622. private _getTypeLength;
  53623. /**
  53624. * Connect this point to another connection point
  53625. * @param connectionPoint defines the other connection point
  53626. * @returns the current connection point
  53627. */
  53628. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53629. /**
  53630. * Disconnect this point from one of his endpoint
  53631. * @param endpoint defines the other connection point
  53632. * @returns the current connection point
  53633. */
  53634. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53635. /**
  53636. * When connection point is an uniform, this function will send its value to the effect
  53637. * @param effect defines the effect to transmit value to
  53638. * @param world defines the world matrix
  53639. * @param worldView defines the worldxview matrix
  53640. * @param worldViewProjection defines the worldxviewxprojection matrix
  53641. */
  53642. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53643. /**
  53644. * When connection point is an uniform, this function will send its value to the effect
  53645. * @param effect defines the effect to transmit value to
  53646. * @param scene defines the hosting scene
  53647. */
  53648. transmit(effect: Effect, scene: Scene): void;
  53649. }
  53650. }
  53651. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53652. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53653. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53655. import { Mesh } from "babylonjs/Meshes/mesh";
  53656. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53657. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53658. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53659. /**
  53660. * Block used to add support for vertex skinning (bones)
  53661. */
  53662. export class BonesBlock extends NodeMaterialBlock {
  53663. /**
  53664. * Creates a new BonesBlock
  53665. * @param name defines the block name
  53666. */
  53667. constructor(name: string);
  53668. /**
  53669. * Initialize the block and prepare the context for build
  53670. * @param state defines the state that will be used for the build
  53671. */
  53672. initialize(state: NodeMaterialBuildState): void;
  53673. /**
  53674. * Gets the current class name
  53675. * @returns the class name
  53676. */
  53677. getClassName(): string;
  53678. /**
  53679. * Gets the matrix indices input component
  53680. */
  53681. readonly matricesIndices: NodeMaterialConnectionPoint;
  53682. /**
  53683. * Gets the matrix weights input component
  53684. */
  53685. readonly matricesWeights: NodeMaterialConnectionPoint;
  53686. /**
  53687. * Gets the extra matrix indices input component
  53688. */
  53689. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53690. /**
  53691. * Gets the extra matrix weights input component
  53692. */
  53693. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53694. /**
  53695. * Gets the world input component
  53696. */
  53697. readonly world: NodeMaterialConnectionPoint;
  53698. autoConfigure(): void;
  53699. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53700. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53701. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53702. protected _buildBlock(state: NodeMaterialBuildState): this;
  53703. }
  53704. }
  53705. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  53706. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53708. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53710. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53711. /**
  53712. * Block used to add support for instances
  53713. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53714. */
  53715. export class InstancesBlock extends NodeMaterialBlock {
  53716. /**
  53717. * Creates a new InstancesBlock
  53718. * @param name defines the block name
  53719. */
  53720. constructor(name: string);
  53721. /**
  53722. * Gets the current class name
  53723. * @returns the class name
  53724. */
  53725. getClassName(): string;
  53726. /**
  53727. * Gets the first world row input component
  53728. */
  53729. readonly world0: NodeMaterialConnectionPoint;
  53730. /**
  53731. * Gets the second world row input component
  53732. */
  53733. readonly world1: NodeMaterialConnectionPoint;
  53734. /**
  53735. * Gets the third world row input component
  53736. */
  53737. readonly world2: NodeMaterialConnectionPoint;
  53738. /**
  53739. * Gets the forth world row input component
  53740. */
  53741. readonly world3: NodeMaterialConnectionPoint;
  53742. /**
  53743. * Gets the world input component
  53744. */
  53745. readonly world: NodeMaterialConnectionPoint;
  53746. /**
  53747. * Gets the output component
  53748. */
  53749. readonly output: NodeMaterialConnectionPoint;
  53750. autoConfigure(): void;
  53751. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53752. protected _buildBlock(state: NodeMaterialBuildState): this;
  53753. }
  53754. }
  53755. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  53756. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53757. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53758. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53760. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53761. import { Effect } from "babylonjs/Materials/effect";
  53762. import { Mesh } from "babylonjs/Meshes/mesh";
  53763. /**
  53764. * Block used to add morph targets support to vertex shader
  53765. */
  53766. export class MorphTargetsBlock extends NodeMaterialBlock {
  53767. private _repeatableContentAnchor;
  53768. private _repeatebleContentGenerated;
  53769. /**
  53770. * Create a new MorphTargetsBlock
  53771. * @param name defines the block name
  53772. */
  53773. constructor(name: string);
  53774. /**
  53775. * Gets the current class name
  53776. * @returns the class name
  53777. */
  53778. getClassName(): string;
  53779. /**
  53780. * Gets the position input component
  53781. */
  53782. readonly position: NodeMaterialConnectionPoint;
  53783. /**
  53784. * Gets the normal input component
  53785. */
  53786. readonly normal: NodeMaterialConnectionPoint;
  53787. /**
  53788. * Gets the tangent input component
  53789. */
  53790. readonly tangent: NodeMaterialConnectionPoint;
  53791. /**
  53792. * Gets the position output component
  53793. */
  53794. readonly positionOutput: NodeMaterialConnectionPoint;
  53795. /**
  53796. * Gets the normal output component
  53797. */
  53798. readonly normalOutput: NodeMaterialConnectionPoint;
  53799. /**
  53800. * Gets the tangent output component
  53801. */
  53802. readonly tangentOutput: NodeMaterialConnectionPoint;
  53803. initialize(state: NodeMaterialBuildState): void;
  53804. autoConfigure(): void;
  53805. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53806. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53807. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53808. protected _buildBlock(state: NodeMaterialBuildState): this;
  53809. }
  53810. }
  53811. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  53812. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  53813. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  53814. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  53815. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  53816. }
  53817. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  53818. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53819. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53820. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53821. /**
  53822. * Block used to add an alpha test in the fragment shader
  53823. */
  53824. export class AlphaTestBlock extends NodeMaterialBlock {
  53825. /**
  53826. * Gets or sets the alpha value where alpha testing happens
  53827. */
  53828. alphaCutOff: number;
  53829. /**
  53830. * Create a new AlphaTestBlock
  53831. * @param name defines the block name
  53832. */
  53833. constructor(name: string);
  53834. /**
  53835. * Gets the current class name
  53836. * @returns the class name
  53837. */
  53838. getClassName(): string;
  53839. /**
  53840. * Gets the color input component
  53841. */
  53842. readonly color: NodeMaterialConnectionPoint;
  53843. protected _buildBlock(state: NodeMaterialBuildState): this;
  53844. }
  53845. }
  53846. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  53847. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53848. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53849. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53850. /**
  53851. * Block used to create a Color4 out of 4 inputs (one for each component)
  53852. */
  53853. export class RGBAMergerBlock extends NodeMaterialBlock {
  53854. /**
  53855. * Create a new RGBAMergerBlock
  53856. * @param name defines the block name
  53857. */
  53858. constructor(name: string);
  53859. /**
  53860. * Gets the current class name
  53861. * @returns the class name
  53862. */
  53863. getClassName(): string;
  53864. /**
  53865. * Gets the R input component
  53866. */
  53867. readonly r: NodeMaterialConnectionPoint;
  53868. /**
  53869. * Gets the G input component
  53870. */
  53871. readonly g: NodeMaterialConnectionPoint;
  53872. /**
  53873. * Gets the B input component
  53874. */
  53875. readonly b: NodeMaterialConnectionPoint;
  53876. /**
  53877. * Gets the RGB input component
  53878. */
  53879. readonly rgb: NodeMaterialConnectionPoint;
  53880. /**
  53881. * Gets the R input component
  53882. */
  53883. readonly a: NodeMaterialConnectionPoint;
  53884. protected _buildBlock(state: NodeMaterialBuildState): this;
  53885. }
  53886. }
  53887. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  53888. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53889. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53890. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53891. /**
  53892. * Block used to create a Color3 out of 3 inputs (one for each component)
  53893. */
  53894. export class RGBMergerBlock extends NodeMaterialBlock {
  53895. /**
  53896. * Create a new RGBMergerBlock
  53897. * @param name defines the block name
  53898. */
  53899. constructor(name: string);
  53900. /**
  53901. * Gets the current class name
  53902. * @returns the class name
  53903. */
  53904. getClassName(): string;
  53905. /**
  53906. * Gets the R component input
  53907. */
  53908. readonly r: NodeMaterialConnectionPoint;
  53909. /**
  53910. * Gets the G component input
  53911. */
  53912. readonly g: NodeMaterialConnectionPoint;
  53913. /**
  53914. * Gets the B component input
  53915. */
  53916. readonly b: NodeMaterialConnectionPoint;
  53917. protected _buildBlock(state: NodeMaterialBuildState): this;
  53918. }
  53919. }
  53920. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  53921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53924. /**
  53925. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  53926. */
  53927. export class RGBASplitterBlock extends NodeMaterialBlock {
  53928. /**
  53929. * Create a new RGBASplitterBlock
  53930. * @param name defines the block name
  53931. */
  53932. constructor(name: string);
  53933. /**
  53934. * Gets the current class name
  53935. * @returns the class name
  53936. */
  53937. getClassName(): string;
  53938. /**
  53939. * Gets the input component
  53940. */
  53941. readonly input: NodeMaterialConnectionPoint;
  53942. protected _buildBlock(state: NodeMaterialBuildState): this;
  53943. }
  53944. }
  53945. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  53946. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53947. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53948. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53949. /**
  53950. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  53951. */
  53952. export class RGBSplitterBlock extends NodeMaterialBlock {
  53953. /**
  53954. * Create a new RGBSplitterBlock
  53955. * @param name defines the block name
  53956. */
  53957. constructor(name: string);
  53958. /**
  53959. * Gets the current class name
  53960. * @returns the class name
  53961. */
  53962. getClassName(): string;
  53963. /**
  53964. * Gets the input component
  53965. */
  53966. readonly input: NodeMaterialConnectionPoint;
  53967. protected _buildBlock(state: NodeMaterialBuildState): this;
  53968. }
  53969. }
  53970. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  53971. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53972. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53973. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53975. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53976. /**
  53977. * Block used to read a texture from a sampler
  53978. */
  53979. export class TextureBlock extends NodeMaterialBlock {
  53980. private _defineName;
  53981. /**
  53982. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  53983. */
  53984. autoConnectTextureMatrix: boolean;
  53985. /**
  53986. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  53987. */
  53988. autoSelectUV: boolean;
  53989. /**
  53990. * Create a new TextureBlock
  53991. * @param name defines the block name
  53992. */
  53993. constructor(name: string);
  53994. /**
  53995. * Gets the current class name
  53996. * @returns the class name
  53997. */
  53998. getClassName(): string;
  53999. /**
  54000. * Gets the uv input component
  54001. */
  54002. readonly uv: NodeMaterialConnectionPoint;
  54003. /**
  54004. * Gets the texture information input component
  54005. */
  54006. readonly textureInfo: NodeMaterialConnectionPoint;
  54007. /**
  54008. * Gets the transformed uv input component
  54009. */
  54010. readonly transformedUV: NodeMaterialConnectionPoint;
  54011. /**
  54012. * Gets the texture input component
  54013. */
  54014. readonly texture: NodeMaterialConnectionPoint;
  54015. /**
  54016. * Gets the texture transform input component
  54017. */
  54018. readonly textureTransform: NodeMaterialConnectionPoint;
  54019. autoConfigure(): void;
  54020. initialize(state: NodeMaterialBuildState): void;
  54021. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54022. isReady(): boolean;
  54023. private _injectVertexCode;
  54024. protected _buildBlock(state: NodeMaterialBuildState): this;
  54025. }
  54026. }
  54027. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  54028. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54029. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54030. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54032. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54033. import { Effect } from "babylonjs/Materials/effect";
  54034. import { Mesh } from "babylonjs/Meshes/mesh";
  54035. /**
  54036. * Block used to add image processing support to fragment shader
  54037. */
  54038. export class ImageProcessingBlock extends NodeMaterialBlock {
  54039. /**
  54040. * Create a new ImageProcessingBlock
  54041. * @param name defines the block name
  54042. */
  54043. constructor(name: string);
  54044. /**
  54045. * Gets the current class name
  54046. * @returns the class name
  54047. */
  54048. getClassName(): string;
  54049. /**
  54050. * Gets the color input component
  54051. */
  54052. readonly color: NodeMaterialConnectionPoint;
  54053. /**
  54054. * Initialize the block and prepare the context for build
  54055. * @param state defines the state that will be used for the build
  54056. */
  54057. initialize(state: NodeMaterialBuildState): void;
  54058. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54060. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54061. protected _buildBlock(state: NodeMaterialBuildState): this;
  54062. }
  54063. }
  54064. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  54065. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  54066. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  54067. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  54068. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  54069. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  54070. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  54071. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  54072. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  54073. }
  54074. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  54075. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54076. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54077. import { Mesh } from "babylonjs/Meshes/mesh";
  54078. import { Effect } from "babylonjs/Materials/effect";
  54079. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54081. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54082. /**
  54083. * Block used to add support for scene fog
  54084. */
  54085. export class FogBlock extends NodeMaterialBlock {
  54086. /**
  54087. * Create a new FogBlock
  54088. * @param name defines the block name
  54089. */
  54090. constructor(name: string);
  54091. /**
  54092. * Gets the current class name
  54093. * @returns the class name
  54094. */
  54095. getClassName(): string;
  54096. /**
  54097. * Gets the world position input component
  54098. */
  54099. readonly worldPosition: NodeMaterialConnectionPoint;
  54100. /**
  54101. * Gets the view input component
  54102. */
  54103. readonly view: NodeMaterialConnectionPoint;
  54104. /**
  54105. * Gets the color input component
  54106. */
  54107. readonly color: NodeMaterialConnectionPoint;
  54108. /**
  54109. * Gets the fog color input component
  54110. */
  54111. readonly fogColor: NodeMaterialConnectionPoint;
  54112. /**
  54113. * Gets the for parameter input component
  54114. */
  54115. readonly fogParameters: NodeMaterialConnectionPoint;
  54116. autoConfigure(): void;
  54117. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54118. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54119. protected _buildBlock(state: NodeMaterialBuildState): this;
  54120. }
  54121. }
  54122. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  54123. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  54124. }
  54125. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  54126. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54127. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54128. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54129. /**
  54130. * Block used to multiply 2 vector4
  54131. */
  54132. export class MultiplyBlock extends NodeMaterialBlock {
  54133. /**
  54134. * Creates a new MultiplyBlock
  54135. * @param name defines the block name
  54136. */
  54137. constructor(name: string);
  54138. /**
  54139. * Gets the current class name
  54140. * @returns the class name
  54141. */
  54142. getClassName(): string;
  54143. /**
  54144. * Gets the left operand input component
  54145. */
  54146. readonly left: NodeMaterialConnectionPoint;
  54147. /**
  54148. * Gets the right operand input component
  54149. */
  54150. readonly right: NodeMaterialConnectionPoint;
  54151. protected _buildBlock(state: NodeMaterialBuildState): this;
  54152. }
  54153. }
  54154. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  54155. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54156. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54157. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54158. /**
  54159. * Block used to add 2 vector4
  54160. */
  54161. export class AddBlock extends NodeMaterialBlock {
  54162. /**
  54163. * Creates a new AddBlock
  54164. * @param name defines the block name
  54165. */
  54166. constructor(name: string);
  54167. /**
  54168. * Gets the current class name
  54169. * @returns the class name
  54170. */
  54171. getClassName(): string;
  54172. /**
  54173. * Gets the left operand input component
  54174. */
  54175. readonly left: NodeMaterialConnectionPoint;
  54176. /**
  54177. * Gets the right operand input component
  54178. */
  54179. readonly right: NodeMaterialConnectionPoint;
  54180. protected _buildBlock(state: NodeMaterialBuildState): this;
  54181. }
  54182. }
  54183. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  54184. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54185. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54187. /**
  54188. * Block used to clamp a float
  54189. */
  54190. export class ClampBlock extends NodeMaterialBlock {
  54191. /** Gets or sets the minimum range */
  54192. minimum: number;
  54193. /** Gets or sets the maximum range */
  54194. maximum: number;
  54195. /**
  54196. * Creates a new ClampBlock
  54197. * @param name defines the block name
  54198. */
  54199. constructor(name: string);
  54200. /**
  54201. * Gets the current class name
  54202. * @returns the class name
  54203. */
  54204. getClassName(): string;
  54205. /**
  54206. * Gets the value input component
  54207. */
  54208. readonly value: NodeMaterialConnectionPoint;
  54209. protected _buildBlock(state: NodeMaterialBuildState): this;
  54210. }
  54211. }
  54212. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  54213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54214. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54215. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54216. /**
  54217. * Block used to scale a value
  54218. */
  54219. export class ScaleBlock extends NodeMaterialBlock {
  54220. /**
  54221. * Creates a new ScaleBlock
  54222. * @param name defines the block name
  54223. */
  54224. constructor(name: string);
  54225. /**
  54226. * Gets the current class name
  54227. * @returns the class name
  54228. */
  54229. getClassName(): string;
  54230. /**
  54231. * Gets the value operand input component
  54232. */
  54233. readonly value: NodeMaterialConnectionPoint;
  54234. /**
  54235. * Gets the scale operand input component
  54236. */
  54237. readonly scale: NodeMaterialConnectionPoint;
  54238. protected _buildBlock(state: NodeMaterialBuildState): this;
  54239. }
  54240. }
  54241. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  54242. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54243. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54244. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54245. /**
  54246. * Block used to transform a vector2 with a matrix
  54247. */
  54248. export class Vector2TransformBlock extends NodeMaterialBlock {
  54249. /**
  54250. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54251. */
  54252. complementZ: number;
  54253. /**
  54254. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54255. */
  54256. complementW: number;
  54257. /**
  54258. * Creates a new Vector2TransformBlock
  54259. * @param name defines the block name
  54260. */
  54261. constructor(name: string);
  54262. /**
  54263. * Gets the vector input
  54264. */
  54265. readonly vector: NodeMaterialConnectionPoint;
  54266. /**
  54267. * Gets the matrix transform input
  54268. */
  54269. readonly transform: NodeMaterialConnectionPoint;
  54270. /**
  54271. * Gets the current class name
  54272. * @returns the class name
  54273. */
  54274. getClassName(): string;
  54275. protected _buildBlock(state: NodeMaterialBuildState): this;
  54276. }
  54277. }
  54278. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54280. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54281. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54282. /**
  54283. * Block used to transform a vector3 with a matrix
  54284. */
  54285. export class Vector3TransformBlock extends NodeMaterialBlock {
  54286. /**
  54287. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54288. */
  54289. complement: number;
  54290. /**
  54291. * Creates a new Vector3TransformBlock
  54292. * @param name defines the block name
  54293. */
  54294. constructor(name: string);
  54295. /**
  54296. * Gets the vector input
  54297. */
  54298. readonly vector: NodeMaterialConnectionPoint;
  54299. /**
  54300. * Gets the matrix transform input
  54301. */
  54302. readonly transform: NodeMaterialConnectionPoint;
  54303. /**
  54304. * Gets the current class name
  54305. * @returns the class name
  54306. */
  54307. getClassName(): string;
  54308. protected _buildBlock(state: NodeMaterialBuildState): this;
  54309. }
  54310. }
  54311. declare module "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock" {
  54312. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54313. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54314. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54315. /**
  54316. * Block used to multiply two matrices
  54317. */
  54318. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  54319. /**
  54320. * Creates a new MatrixMultiplicationBlock
  54321. * @param name defines the block name
  54322. */
  54323. constructor(name: string);
  54324. /**
  54325. * Gets the left operand
  54326. */
  54327. readonly left: NodeMaterialConnectionPoint;
  54328. /**
  54329. * Gets the right operand
  54330. */
  54331. readonly right: NodeMaterialConnectionPoint;
  54332. /**
  54333. * Gets the current class name
  54334. * @returns the class name
  54335. */
  54336. getClassName(): string;
  54337. protected _buildBlock(state: NodeMaterialBuildState): this;
  54338. }
  54339. }
  54340. declare module "babylonjs/Materials/Node/Blocks/index" {
  54341. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  54342. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  54343. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  54344. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  54345. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  54346. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  54347. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  54348. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  54349. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54350. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54351. export * from "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock";
  54352. }
  54353. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54354. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54355. }
  54356. declare module "babylonjs/Materials/Node/index" {
  54357. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54358. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54359. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54360. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54361. export * from "babylonjs/Materials/Node/nodeMaterial";
  54362. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54363. export * from "babylonjs/Materials/Node/Blocks/index";
  54364. export * from "babylonjs/Materials/Node/Optimizers/index";
  54365. }
  54366. declare module "babylonjs/Materials/index" {
  54367. export * from "babylonjs/Materials/Background/index";
  54368. export * from "babylonjs/Materials/colorCurves";
  54369. export * from "babylonjs/Materials/effect";
  54370. export * from "babylonjs/Materials/fresnelParameters";
  54371. export * from "babylonjs/Materials/imageProcessingConfiguration";
  54372. export * from "babylonjs/Materials/material";
  54373. export * from "babylonjs/Materials/materialDefines";
  54374. export * from "babylonjs/Materials/materialHelper";
  54375. export * from "babylonjs/Materials/multiMaterial";
  54376. export * from "babylonjs/Materials/PBR/index";
  54377. export * from "babylonjs/Materials/pushMaterial";
  54378. export * from "babylonjs/Materials/shaderMaterial";
  54379. export * from "babylonjs/Materials/standardMaterial";
  54380. export * from "babylonjs/Materials/Textures/index";
  54381. export * from "babylonjs/Materials/uniformBuffer";
  54382. export * from "babylonjs/Materials/materialFlags";
  54383. export * from "babylonjs/Materials/Node/index";
  54384. }
  54385. declare module "babylonjs/Maths/index" {
  54386. export * from "babylonjs/Maths/math.scalar";
  54387. export * from "babylonjs/Maths/math";
  54388. export * from "babylonjs/Maths/sphericalPolynomial";
  54389. }
  54390. declare module "babylonjs/Misc/workerPool" {
  54391. import { IDisposable } from "babylonjs/scene";
  54392. /**
  54393. * Helper class to push actions to a pool of workers.
  54394. */
  54395. export class WorkerPool implements IDisposable {
  54396. private _workerInfos;
  54397. private _pendingActions;
  54398. /**
  54399. * Constructor
  54400. * @param workers Array of workers to use for actions
  54401. */
  54402. constructor(workers: Array<Worker>);
  54403. /**
  54404. * Terminates all workers and clears any pending actions.
  54405. */
  54406. dispose(): void;
  54407. /**
  54408. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54409. * pended until a worker has completed its action.
  54410. * @param action The action to perform. Call onComplete when the action is complete.
  54411. */
  54412. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54413. private _execute;
  54414. }
  54415. }
  54416. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  54417. import { IDisposable } from "babylonjs/scene";
  54418. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54419. /**
  54420. * Configuration for Draco compression
  54421. */
  54422. export interface IDracoCompressionConfiguration {
  54423. /**
  54424. * Configuration for the decoder.
  54425. */
  54426. decoder: {
  54427. /**
  54428. * The url to the WebAssembly module.
  54429. */
  54430. wasmUrl?: string;
  54431. /**
  54432. * The url to the WebAssembly binary.
  54433. */
  54434. wasmBinaryUrl?: string;
  54435. /**
  54436. * The url to the fallback JavaScript module.
  54437. */
  54438. fallbackUrl?: string;
  54439. };
  54440. }
  54441. /**
  54442. * Draco compression (https://google.github.io/draco/)
  54443. *
  54444. * This class wraps the Draco module.
  54445. *
  54446. * **Encoder**
  54447. *
  54448. * The encoder is not currently implemented.
  54449. *
  54450. * **Decoder**
  54451. *
  54452. * 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.
  54453. *
  54454. * To update the configuration, use the following code:
  54455. * ```javascript
  54456. * DracoCompression.Configuration = {
  54457. * decoder: {
  54458. * wasmUrl: "<url to the WebAssembly library>",
  54459. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54460. * fallbackUrl: "<url to the fallback JavaScript library>",
  54461. * }
  54462. * };
  54463. * ```
  54464. *
  54465. * 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.
  54466. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54467. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54468. *
  54469. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54470. * ```javascript
  54471. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54472. * ```
  54473. *
  54474. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54475. */
  54476. export class DracoCompression implements IDisposable {
  54477. private _workerPoolPromise?;
  54478. private _decoderModulePromise?;
  54479. /**
  54480. * The configuration. Defaults to the following urls:
  54481. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54482. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54483. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54484. */
  54485. static Configuration: IDracoCompressionConfiguration;
  54486. /**
  54487. * Returns true if the decoder configuration is available.
  54488. */
  54489. static readonly DecoderAvailable: boolean;
  54490. /**
  54491. * Default number of workers to create when creating the draco compression object.
  54492. */
  54493. static DefaultNumWorkers: number;
  54494. private static GetDefaultNumWorkers;
  54495. private static _Default;
  54496. /**
  54497. * Default instance for the draco compression object.
  54498. */
  54499. static readonly Default: DracoCompression;
  54500. /**
  54501. * Constructor
  54502. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54503. */
  54504. constructor(numWorkers?: number);
  54505. /**
  54506. * Stop all async operations and release resources.
  54507. */
  54508. dispose(): void;
  54509. /**
  54510. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54511. * @returns a promise that resolves when ready
  54512. */
  54513. whenReadyAsync(): Promise<void>;
  54514. /**
  54515. * Decode Draco compressed mesh data to vertex data.
  54516. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54517. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54518. * @returns A promise that resolves with the decoded vertex data
  54519. */
  54520. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54521. [kind: string]: number;
  54522. }): Promise<VertexData>;
  54523. }
  54524. }
  54525. declare module "babylonjs/Meshes/Compression/index" {
  54526. export * from "babylonjs/Meshes/Compression/dracoCompression";
  54527. }
  54528. declare module "babylonjs/Meshes/csg" {
  54529. import { Nullable } from "babylonjs/types";
  54530. import { Scene } from "babylonjs/scene";
  54531. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  54532. import { Mesh } from "babylonjs/Meshes/mesh";
  54533. import { Material } from "babylonjs/Materials/material";
  54534. /**
  54535. * Class for building Constructive Solid Geometry
  54536. */
  54537. export class CSG {
  54538. private polygons;
  54539. /**
  54540. * The world matrix
  54541. */
  54542. matrix: Matrix;
  54543. /**
  54544. * Stores the position
  54545. */
  54546. position: Vector3;
  54547. /**
  54548. * Stores the rotation
  54549. */
  54550. rotation: Vector3;
  54551. /**
  54552. * Stores the rotation quaternion
  54553. */
  54554. rotationQuaternion: Nullable<Quaternion>;
  54555. /**
  54556. * Stores the scaling vector
  54557. */
  54558. scaling: Vector3;
  54559. /**
  54560. * Convert the Mesh to CSG
  54561. * @param mesh The Mesh to convert to CSG
  54562. * @returns A new CSG from the Mesh
  54563. */
  54564. static FromMesh(mesh: Mesh): CSG;
  54565. /**
  54566. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54567. * @param polygons Polygons used to construct a CSG solid
  54568. */
  54569. private static FromPolygons;
  54570. /**
  54571. * Clones, or makes a deep copy, of the CSG
  54572. * @returns A new CSG
  54573. */
  54574. clone(): CSG;
  54575. /**
  54576. * Unions this CSG with another CSG
  54577. * @param csg The CSG to union against this CSG
  54578. * @returns The unioned CSG
  54579. */
  54580. union(csg: CSG): CSG;
  54581. /**
  54582. * Unions this CSG with another CSG in place
  54583. * @param csg The CSG to union against this CSG
  54584. */
  54585. unionInPlace(csg: CSG): void;
  54586. /**
  54587. * Subtracts this CSG with another CSG
  54588. * @param csg The CSG to subtract against this CSG
  54589. * @returns A new CSG
  54590. */
  54591. subtract(csg: CSG): CSG;
  54592. /**
  54593. * Subtracts this CSG with another CSG in place
  54594. * @param csg The CSG to subtact against this CSG
  54595. */
  54596. subtractInPlace(csg: CSG): void;
  54597. /**
  54598. * Intersect this CSG with another CSG
  54599. * @param csg The CSG to intersect against this CSG
  54600. * @returns A new CSG
  54601. */
  54602. intersect(csg: CSG): CSG;
  54603. /**
  54604. * Intersects this CSG with another CSG in place
  54605. * @param csg The CSG to intersect against this CSG
  54606. */
  54607. intersectInPlace(csg: CSG): void;
  54608. /**
  54609. * Return a new CSG solid with solid and empty space switched. This solid is
  54610. * not modified.
  54611. * @returns A new CSG solid with solid and empty space switched
  54612. */
  54613. inverse(): CSG;
  54614. /**
  54615. * Inverses the CSG in place
  54616. */
  54617. inverseInPlace(): void;
  54618. /**
  54619. * This is used to keep meshes transformations so they can be restored
  54620. * when we build back a Babylon Mesh
  54621. * NB : All CSG operations are performed in world coordinates
  54622. * @param csg The CSG to copy the transform attributes from
  54623. * @returns This CSG
  54624. */
  54625. copyTransformAttributes(csg: CSG): CSG;
  54626. /**
  54627. * Build Raw mesh from CSG
  54628. * Coordinates here are in world space
  54629. * @param name The name of the mesh geometry
  54630. * @param scene The Scene
  54631. * @param keepSubMeshes Specifies if the submeshes should be kept
  54632. * @returns A new Mesh
  54633. */
  54634. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  54635. /**
  54636. * Build Mesh from CSG taking material and transforms into account
  54637. * @param name The name of the Mesh
  54638. * @param material The material of the Mesh
  54639. * @param scene The Scene
  54640. * @param keepSubMeshes Specifies if submeshes should be kept
  54641. * @returns The new Mesh
  54642. */
  54643. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  54644. }
  54645. }
  54646. declare module "babylonjs/Meshes/trailMesh" {
  54647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54648. import { Mesh } from "babylonjs/Meshes/mesh";
  54649. import { Scene } from "babylonjs/scene";
  54650. /**
  54651. * Class used to create a trail following a mesh
  54652. */
  54653. export class TrailMesh extends Mesh {
  54654. private _generator;
  54655. private _autoStart;
  54656. private _running;
  54657. private _diameter;
  54658. private _length;
  54659. private _sectionPolygonPointsCount;
  54660. private _sectionVectors;
  54661. private _sectionNormalVectors;
  54662. private _beforeRenderObserver;
  54663. /**
  54664. * @constructor
  54665. * @param name The value used by scene.getMeshByName() to do a lookup.
  54666. * @param generator The mesh to generate a trail.
  54667. * @param scene The scene to add this mesh to.
  54668. * @param diameter Diameter of trailing mesh. Default is 1.
  54669. * @param length Length of trailing mesh. Default is 60.
  54670. * @param autoStart Automatically start trailing mesh. Default true.
  54671. */
  54672. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54673. /**
  54674. * "TrailMesh"
  54675. * @returns "TrailMesh"
  54676. */
  54677. getClassName(): string;
  54678. private _createMesh;
  54679. /**
  54680. * Start trailing mesh.
  54681. */
  54682. start(): void;
  54683. /**
  54684. * Stop trailing mesh.
  54685. */
  54686. stop(): void;
  54687. /**
  54688. * Update trailing mesh geometry.
  54689. */
  54690. update(): void;
  54691. /**
  54692. * Returns a new TrailMesh object.
  54693. * @param name is a string, the name given to the new mesh
  54694. * @param newGenerator use new generator object for cloned trail mesh
  54695. * @returns a new mesh
  54696. */
  54697. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54698. /**
  54699. * Serializes this trail mesh
  54700. * @param serializationObject object to write serialization to
  54701. */
  54702. serialize(serializationObject: any): void;
  54703. /**
  54704. * Parses a serialized trail mesh
  54705. * @param parsedMesh the serialized mesh
  54706. * @param scene the scene to create the trail mesh in
  54707. * @returns the created trail mesh
  54708. */
  54709. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54710. }
  54711. }
  54712. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  54713. import { Nullable } from "babylonjs/types";
  54714. import { Scene } from "babylonjs/scene";
  54715. import { Vector4, Color4 } from "babylonjs/Maths/math";
  54716. import { Mesh } from "babylonjs/Meshes/mesh";
  54717. /**
  54718. * Class containing static functions to help procedurally build meshes
  54719. */
  54720. export class TiledBoxBuilder {
  54721. /**
  54722. * Creates a box mesh
  54723. * 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)
  54724. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54728. * @param name defines the name of the mesh
  54729. * @param options defines the options used to create the mesh
  54730. * @param scene defines the hosting scene
  54731. * @returns the box mesh
  54732. */
  54733. static CreateTiledBox(name: string, options: {
  54734. pattern?: number;
  54735. width?: number;
  54736. height?: number;
  54737. depth?: number;
  54738. tileSize?: number;
  54739. tileWidth?: number;
  54740. tileHeight?: number;
  54741. alignHorizontal?: number;
  54742. alignVertical?: number;
  54743. faceUV?: Vector4[];
  54744. faceColors?: Color4[];
  54745. sideOrientation?: number;
  54746. updatable?: boolean;
  54747. }, scene?: Nullable<Scene>): Mesh;
  54748. }
  54749. }
  54750. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  54751. import { Vector4 } from "babylonjs/Maths/math";
  54752. import { Mesh } from "babylonjs/Meshes/mesh";
  54753. /**
  54754. * Class containing static functions to help procedurally build meshes
  54755. */
  54756. export class TorusKnotBuilder {
  54757. /**
  54758. * Creates a torus knot mesh
  54759. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54760. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54761. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54762. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54764. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54766. * @param name defines the name of the mesh
  54767. * @param options defines the options used to create the mesh
  54768. * @param scene defines the hosting scene
  54769. * @returns the torus knot mesh
  54770. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54771. */
  54772. static CreateTorusKnot(name: string, options: {
  54773. radius?: number;
  54774. tube?: number;
  54775. radialSegments?: number;
  54776. tubularSegments?: number;
  54777. p?: number;
  54778. q?: number;
  54779. updatable?: boolean;
  54780. sideOrientation?: number;
  54781. frontUVs?: Vector4;
  54782. backUVs?: Vector4;
  54783. }, scene: any): Mesh;
  54784. }
  54785. }
  54786. declare module "babylonjs/Meshes/polygonMesh" {
  54787. import { Scene } from "babylonjs/scene";
  54788. import { Vector2, Path2 } from "babylonjs/Maths/math";
  54789. import { Mesh } from "babylonjs/Meshes/mesh";
  54790. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54791. /**
  54792. * Polygon
  54793. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54794. */
  54795. export class Polygon {
  54796. /**
  54797. * Creates a rectangle
  54798. * @param xmin bottom X coord
  54799. * @param ymin bottom Y coord
  54800. * @param xmax top X coord
  54801. * @param ymax top Y coord
  54802. * @returns points that make the resulting rectation
  54803. */
  54804. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54805. /**
  54806. * Creates a circle
  54807. * @param radius radius of circle
  54808. * @param cx scale in x
  54809. * @param cy scale in y
  54810. * @param numberOfSides number of sides that make up the circle
  54811. * @returns points that make the resulting circle
  54812. */
  54813. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54814. /**
  54815. * Creates a polygon from input string
  54816. * @param input Input polygon data
  54817. * @returns the parsed points
  54818. */
  54819. static Parse(input: string): Vector2[];
  54820. /**
  54821. * Starts building a polygon from x and y coordinates
  54822. * @param x x coordinate
  54823. * @param y y coordinate
  54824. * @returns the started path2
  54825. */
  54826. static StartingAt(x: number, y: number): Path2;
  54827. }
  54828. /**
  54829. * Builds a polygon
  54830. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54831. */
  54832. export class PolygonMeshBuilder {
  54833. private _points;
  54834. private _outlinepoints;
  54835. private _holes;
  54836. private _name;
  54837. private _scene;
  54838. private _epoints;
  54839. private _eholes;
  54840. private _addToepoint;
  54841. /**
  54842. * Babylon reference to the earcut plugin.
  54843. */
  54844. bjsEarcut: any;
  54845. /**
  54846. * Creates a PolygonMeshBuilder
  54847. * @param name name of the builder
  54848. * @param contours Path of the polygon
  54849. * @param scene scene to add to when creating the mesh
  54850. * @param earcutInjection can be used to inject your own earcut reference
  54851. */
  54852. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54853. /**
  54854. * Adds a whole within the polygon
  54855. * @param hole Array of points defining the hole
  54856. * @returns this
  54857. */
  54858. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54859. /**
  54860. * Creates the polygon
  54861. * @param updatable If the mesh should be updatable
  54862. * @param depth The depth of the mesh created
  54863. * @returns the created mesh
  54864. */
  54865. build(updatable?: boolean, depth?: number): Mesh;
  54866. /**
  54867. * Creates the polygon
  54868. * @param depth The depth of the mesh created
  54869. * @returns the created VertexData
  54870. */
  54871. buildVertexData(depth?: number): VertexData;
  54872. /**
  54873. * Adds a side to the polygon
  54874. * @param positions points that make the polygon
  54875. * @param normals normals of the polygon
  54876. * @param uvs uvs of the polygon
  54877. * @param indices indices of the polygon
  54878. * @param bounds bounds of the polygon
  54879. * @param points points of the polygon
  54880. * @param depth depth of the polygon
  54881. * @param flip flip of the polygon
  54882. */
  54883. private addSide;
  54884. }
  54885. }
  54886. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  54887. import { Scene } from "babylonjs/scene";
  54888. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  54889. import { Mesh } from "babylonjs/Meshes/mesh";
  54890. import { Nullable } from "babylonjs/types";
  54891. /**
  54892. * Class containing static functions to help procedurally build meshes
  54893. */
  54894. export class PolygonBuilder {
  54895. /**
  54896. * Creates a polygon mesh
  54897. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54898. * * 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
  54899. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  54902. * * Remember you can only change the shape positions, not their number when updating a polygon
  54903. * @param name defines the name of the mesh
  54904. * @param options defines the options used to create the mesh
  54905. * @param scene defines the hosting scene
  54906. * @param earcutInjection can be used to inject your own earcut reference
  54907. * @returns the polygon mesh
  54908. */
  54909. static CreatePolygon(name: string, options: {
  54910. shape: Vector3[];
  54911. holes?: Vector3[][];
  54912. depth?: number;
  54913. faceUV?: Vector4[];
  54914. faceColors?: Color4[];
  54915. updatable?: boolean;
  54916. sideOrientation?: number;
  54917. frontUVs?: Vector4;
  54918. backUVs?: Vector4;
  54919. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54920. /**
  54921. * Creates an extruded polygon mesh, with depth in the Y direction.
  54922. * * 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)
  54923. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54924. * @param name defines the name of the mesh
  54925. * @param options defines the options used to create the mesh
  54926. * @param scene defines the hosting scene
  54927. * @param earcutInjection can be used to inject your own earcut reference
  54928. * @returns the polygon mesh
  54929. */
  54930. static ExtrudePolygon(name: string, options: {
  54931. shape: Vector3[];
  54932. holes?: Vector3[][];
  54933. depth?: number;
  54934. faceUV?: Vector4[];
  54935. faceColors?: Color4[];
  54936. updatable?: boolean;
  54937. sideOrientation?: number;
  54938. frontUVs?: Vector4;
  54939. backUVs?: Vector4;
  54940. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54941. }
  54942. }
  54943. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  54944. import { Scene } from "babylonjs/scene";
  54945. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  54946. import { Mesh } from "babylonjs/Meshes/mesh";
  54947. import { Nullable } from "babylonjs/types";
  54948. /**
  54949. * Class containing static functions to help procedurally build meshes
  54950. */
  54951. export class LatheBuilder {
  54952. /**
  54953. * Creates lathe mesh.
  54954. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54955. * * 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
  54956. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54957. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54958. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54959. * * 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
  54960. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54961. * * 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
  54962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54964. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54966. * @param name defines the name of the mesh
  54967. * @param options defines the options used to create the mesh
  54968. * @param scene defines the hosting scene
  54969. * @returns the lathe mesh
  54970. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54971. */
  54972. static CreateLathe(name: string, options: {
  54973. shape: Vector3[];
  54974. radius?: number;
  54975. tessellation?: number;
  54976. clip?: number;
  54977. arc?: number;
  54978. closed?: boolean;
  54979. updatable?: boolean;
  54980. sideOrientation?: number;
  54981. frontUVs?: Vector4;
  54982. backUVs?: Vector4;
  54983. cap?: number;
  54984. invertUV?: boolean;
  54985. }, scene?: Nullable<Scene>): Mesh;
  54986. }
  54987. }
  54988. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  54989. import { Nullable } from "babylonjs/types";
  54990. import { Scene } from "babylonjs/scene";
  54991. import { Vector4 } from "babylonjs/Maths/math";
  54992. import { Mesh } from "babylonjs/Meshes/mesh";
  54993. /**
  54994. * Class containing static functions to help procedurally build meshes
  54995. */
  54996. export class TiledPlaneBuilder {
  54997. /**
  54998. * Creates a tiled plane mesh
  54999. * * The parameter `pattern` will, depending on value, do nothing or
  55000. * * * flip (reflect about central vertical) alternate tiles across and up
  55001. * * * flip every tile on alternate rows
  55002. * * * rotate (180 degs) alternate tiles across and up
  55003. * * * rotate every tile on alternate rows
  55004. * * * flip and rotate alternate tiles across and up
  55005. * * * flip and rotate every tile on alternate rows
  55006. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55007. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55008. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55009. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55010. * * 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)
  55011. * * 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)
  55012. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55013. * @param name defines the name of the mesh
  55014. * @param options defines the options used to create the mesh
  55015. * @param scene defines the hosting scene
  55016. * @returns the box mesh
  55017. */
  55018. static CreateTiledPlane(name: string, options: {
  55019. pattern?: number;
  55020. tileSize?: number;
  55021. tileWidth?: number;
  55022. tileHeight?: number;
  55023. size?: number;
  55024. width?: number;
  55025. height?: number;
  55026. alignHorizontal?: number;
  55027. alignVertical?: number;
  55028. sideOrientation?: number;
  55029. frontUVs?: Vector4;
  55030. backUVs?: Vector4;
  55031. updatable?: boolean;
  55032. }, scene?: Nullable<Scene>): Mesh;
  55033. }
  55034. }
  55035. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  55036. import { Nullable } from "babylonjs/types";
  55037. import { Scene } from "babylonjs/scene";
  55038. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55039. import { Mesh } from "babylonjs/Meshes/mesh";
  55040. /**
  55041. * Class containing static functions to help procedurally build meshes
  55042. */
  55043. export class TubeBuilder {
  55044. /**
  55045. * Creates a tube mesh.
  55046. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55047. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55048. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55049. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55050. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55051. * * 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)
  55052. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55053. * * 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
  55054. * * 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
  55055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55056. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55057. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55059. * @param name defines the name of the mesh
  55060. * @param options defines the options used to create the mesh
  55061. * @param scene defines the hosting scene
  55062. * @returns the tube mesh
  55063. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55064. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55065. */
  55066. static CreateTube(name: string, options: {
  55067. path: Vector3[];
  55068. radius?: number;
  55069. tessellation?: number;
  55070. radiusFunction?: {
  55071. (i: number, distance: number): number;
  55072. };
  55073. cap?: number;
  55074. arc?: number;
  55075. updatable?: boolean;
  55076. sideOrientation?: number;
  55077. frontUVs?: Vector4;
  55078. backUVs?: Vector4;
  55079. instance?: Mesh;
  55080. invertUV?: boolean;
  55081. }, scene?: Nullable<Scene>): Mesh;
  55082. }
  55083. }
  55084. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  55085. import { Scene } from "babylonjs/scene";
  55086. import { Vector4 } from "babylonjs/Maths/math";
  55087. import { Mesh } from "babylonjs/Meshes/mesh";
  55088. import { Nullable } from "babylonjs/types";
  55089. /**
  55090. * Class containing static functions to help procedurally build meshes
  55091. */
  55092. export class IcoSphereBuilder {
  55093. /**
  55094. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55095. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55096. * * 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`)
  55097. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55098. * * 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
  55099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55102. * @param name defines the name of the mesh
  55103. * @param options defines the options used to create the mesh
  55104. * @param scene defines the hosting scene
  55105. * @returns the icosahedron mesh
  55106. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55107. */
  55108. static CreateIcoSphere(name: string, options: {
  55109. radius?: number;
  55110. radiusX?: number;
  55111. radiusY?: number;
  55112. radiusZ?: number;
  55113. flat?: boolean;
  55114. subdivisions?: number;
  55115. sideOrientation?: number;
  55116. frontUVs?: Vector4;
  55117. backUVs?: Vector4;
  55118. updatable?: boolean;
  55119. }, scene?: Nullable<Scene>): Mesh;
  55120. }
  55121. }
  55122. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  55123. import { Vector3 } from "babylonjs/Maths/math";
  55124. import { Mesh } from "babylonjs/Meshes/mesh";
  55125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55126. /**
  55127. * Class containing static functions to help procedurally build meshes
  55128. */
  55129. export class DecalBuilder {
  55130. /**
  55131. * Creates a decal mesh.
  55132. * 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
  55133. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55134. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55135. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55136. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55137. * @param name defines the name of the mesh
  55138. * @param sourceMesh defines the mesh where the decal must be applied
  55139. * @param options defines the options used to create the mesh
  55140. * @param scene defines the hosting scene
  55141. * @returns the decal mesh
  55142. * @see https://doc.babylonjs.com/how_to/decals
  55143. */
  55144. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55145. position?: Vector3;
  55146. normal?: Vector3;
  55147. size?: Vector3;
  55148. angle?: number;
  55149. }): Mesh;
  55150. }
  55151. }
  55152. declare module "babylonjs/Meshes/meshBuilder" {
  55153. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  55154. import { Nullable } from "babylonjs/types";
  55155. import { Scene } from "babylonjs/scene";
  55156. import { Mesh } from "babylonjs/Meshes/mesh";
  55157. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  55158. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55160. /**
  55161. * Class containing static functions to help procedurally build meshes
  55162. */
  55163. export class MeshBuilder {
  55164. /**
  55165. * Creates a box mesh
  55166. * * The parameter `size` sets the size (float) of each box side (default 1)
  55167. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55168. * * 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)
  55169. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55173. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55174. * @param name defines the name of the mesh
  55175. * @param options defines the options used to create the mesh
  55176. * @param scene defines the hosting scene
  55177. * @returns the box mesh
  55178. */
  55179. static CreateBox(name: string, options: {
  55180. size?: number;
  55181. width?: number;
  55182. height?: number;
  55183. depth?: number;
  55184. faceUV?: Vector4[];
  55185. faceColors?: Color4[];
  55186. sideOrientation?: number;
  55187. frontUVs?: Vector4;
  55188. backUVs?: Vector4;
  55189. updatable?: boolean;
  55190. }, scene?: Nullable<Scene>): Mesh;
  55191. /**
  55192. * Creates a tiled box mesh
  55193. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55195. * @param name defines the name of the mesh
  55196. * @param options defines the options used to create the mesh
  55197. * @param scene defines the hosting scene
  55198. * @returns the tiled box mesh
  55199. */
  55200. static CreateTiledBox(name: string, options: {
  55201. pattern?: number;
  55202. size?: number;
  55203. width?: number;
  55204. height?: number;
  55205. depth: number;
  55206. tileSize?: number;
  55207. tileWidth?: number;
  55208. tileHeight?: number;
  55209. faceUV?: Vector4[];
  55210. faceColors?: Color4[];
  55211. alignHorizontal?: number;
  55212. alignVertical?: number;
  55213. sideOrientation?: number;
  55214. updatable?: boolean;
  55215. }, scene?: Nullable<Scene>): Mesh;
  55216. /**
  55217. * Creates a sphere mesh
  55218. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55219. * * 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`)
  55220. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55221. * * 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
  55222. * * 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)
  55223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55226. * @param name defines the name of the mesh
  55227. * @param options defines the options used to create the mesh
  55228. * @param scene defines the hosting scene
  55229. * @returns the sphere mesh
  55230. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55231. */
  55232. static CreateSphere(name: string, options: {
  55233. segments?: number;
  55234. diameter?: number;
  55235. diameterX?: number;
  55236. diameterY?: number;
  55237. diameterZ?: number;
  55238. arc?: number;
  55239. slice?: number;
  55240. sideOrientation?: number;
  55241. frontUVs?: Vector4;
  55242. backUVs?: Vector4;
  55243. updatable?: boolean;
  55244. }, scene?: Nullable<Scene>): Mesh;
  55245. /**
  55246. * Creates a plane polygonal mesh. By default, this is a disc
  55247. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55248. * * 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
  55249. * * 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
  55250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55253. * @param name defines the name of the mesh
  55254. * @param options defines the options used to create the mesh
  55255. * @param scene defines the hosting scene
  55256. * @returns the plane polygonal mesh
  55257. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55258. */
  55259. static CreateDisc(name: string, options: {
  55260. radius?: number;
  55261. tessellation?: number;
  55262. arc?: number;
  55263. updatable?: boolean;
  55264. sideOrientation?: number;
  55265. frontUVs?: Vector4;
  55266. backUVs?: Vector4;
  55267. }, scene?: Nullable<Scene>): Mesh;
  55268. /**
  55269. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55270. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55271. * * 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`)
  55272. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55273. * * 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
  55274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55275. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55277. * @param name defines the name of the mesh
  55278. * @param options defines the options used to create the mesh
  55279. * @param scene defines the hosting scene
  55280. * @returns the icosahedron mesh
  55281. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55282. */
  55283. static CreateIcoSphere(name: string, options: {
  55284. radius?: number;
  55285. radiusX?: number;
  55286. radiusY?: number;
  55287. radiusZ?: number;
  55288. flat?: boolean;
  55289. subdivisions?: number;
  55290. sideOrientation?: number;
  55291. frontUVs?: Vector4;
  55292. backUVs?: Vector4;
  55293. updatable?: boolean;
  55294. }, scene?: Nullable<Scene>): Mesh;
  55295. /**
  55296. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55297. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55298. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55299. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55300. * * 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
  55301. * * 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
  55302. * * 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
  55303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55304. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55305. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55306. * * 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
  55307. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55308. * * 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
  55309. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55311. * @param name defines the name of the mesh
  55312. * @param options defines the options used to create the mesh
  55313. * @param scene defines the hosting scene
  55314. * @returns the ribbon mesh
  55315. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55316. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55317. */
  55318. static CreateRibbon(name: string, options: {
  55319. pathArray: Vector3[][];
  55320. closeArray?: boolean;
  55321. closePath?: boolean;
  55322. offset?: number;
  55323. updatable?: boolean;
  55324. sideOrientation?: number;
  55325. frontUVs?: Vector4;
  55326. backUVs?: Vector4;
  55327. instance?: Mesh;
  55328. invertUV?: boolean;
  55329. uvs?: Vector2[];
  55330. colors?: Color4[];
  55331. }, scene?: Nullable<Scene>): Mesh;
  55332. /**
  55333. * Creates a cylinder or a cone mesh
  55334. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55335. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55336. * * 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.
  55337. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55338. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55339. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55340. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55341. * * 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).
  55342. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55343. * * 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).
  55344. * * 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
  55345. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55346. * * 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
  55347. * * 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.
  55348. * * If `enclose` is false, a ring surface is one element.
  55349. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55350. * * 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
  55351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55354. * @param name defines the name of the mesh
  55355. * @param options defines the options used to create the mesh
  55356. * @param scene defines the hosting scene
  55357. * @returns the cylinder mesh
  55358. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55359. */
  55360. static CreateCylinder(name: string, options: {
  55361. height?: number;
  55362. diameterTop?: number;
  55363. diameterBottom?: number;
  55364. diameter?: number;
  55365. tessellation?: number;
  55366. subdivisions?: number;
  55367. arc?: number;
  55368. faceColors?: Color4[];
  55369. faceUV?: Vector4[];
  55370. updatable?: boolean;
  55371. hasRings?: boolean;
  55372. enclose?: boolean;
  55373. cap?: number;
  55374. sideOrientation?: number;
  55375. frontUVs?: Vector4;
  55376. backUVs?: Vector4;
  55377. }, scene?: Nullable<Scene>): Mesh;
  55378. /**
  55379. * Creates a torus mesh
  55380. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55381. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55382. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55386. * @param name defines the name of the mesh
  55387. * @param options defines the options used to create the mesh
  55388. * @param scene defines the hosting scene
  55389. * @returns the torus mesh
  55390. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55391. */
  55392. static CreateTorus(name: string, options: {
  55393. diameter?: number;
  55394. thickness?: number;
  55395. tessellation?: number;
  55396. updatable?: boolean;
  55397. sideOrientation?: number;
  55398. frontUVs?: Vector4;
  55399. backUVs?: Vector4;
  55400. }, scene?: Nullable<Scene>): Mesh;
  55401. /**
  55402. * Creates a torus knot mesh
  55403. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55404. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55405. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55406. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55410. * @param name defines the name of the mesh
  55411. * @param options defines the options used to create the mesh
  55412. * @param scene defines the hosting scene
  55413. * @returns the torus knot mesh
  55414. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55415. */
  55416. static CreateTorusKnot(name: string, options: {
  55417. radius?: number;
  55418. tube?: number;
  55419. radialSegments?: number;
  55420. tubularSegments?: number;
  55421. p?: number;
  55422. q?: number;
  55423. updatable?: boolean;
  55424. sideOrientation?: number;
  55425. frontUVs?: Vector4;
  55426. backUVs?: Vector4;
  55427. }, scene?: Nullable<Scene>): Mesh;
  55428. /**
  55429. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55430. * * 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
  55431. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55432. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55433. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55434. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55435. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55436. * * 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
  55437. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55439. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55440. * @param name defines the name of the new line system
  55441. * @param options defines the options used to create the line system
  55442. * @param scene defines the hosting scene
  55443. * @returns a new line system mesh
  55444. */
  55445. static CreateLineSystem(name: string, options: {
  55446. lines: Vector3[][];
  55447. updatable?: boolean;
  55448. instance?: Nullable<LinesMesh>;
  55449. colors?: Nullable<Color4[][]>;
  55450. useVertexAlpha?: boolean;
  55451. }, scene: Nullable<Scene>): LinesMesh;
  55452. /**
  55453. * Creates a line mesh
  55454. * 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
  55455. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55456. * * The parameter `points` is an array successive Vector3
  55457. * * 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
  55458. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55459. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55460. * * When updating an instance, remember that only point positions can change, not the number of points
  55461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55462. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55463. * @param name defines the name of the new line system
  55464. * @param options defines the options used to create the line system
  55465. * @param scene defines the hosting scene
  55466. * @returns a new line mesh
  55467. */
  55468. static CreateLines(name: string, options: {
  55469. points: Vector3[];
  55470. updatable?: boolean;
  55471. instance?: Nullable<LinesMesh>;
  55472. colors?: Color4[];
  55473. useVertexAlpha?: boolean;
  55474. }, scene?: Nullable<Scene>): LinesMesh;
  55475. /**
  55476. * Creates a dashed line mesh
  55477. * * 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
  55478. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55479. * * The parameter `points` is an array successive Vector3
  55480. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55481. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55482. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55483. * * 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
  55484. * * When updating an instance, remember that only point positions can change, not the number of points
  55485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55486. * @param name defines the name of the mesh
  55487. * @param options defines the options used to create the mesh
  55488. * @param scene defines the hosting scene
  55489. * @returns the dashed line mesh
  55490. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55491. */
  55492. static CreateDashedLines(name: string, options: {
  55493. points: Vector3[];
  55494. dashSize?: number;
  55495. gapSize?: number;
  55496. dashNb?: number;
  55497. updatable?: boolean;
  55498. instance?: LinesMesh;
  55499. }, scene?: Nullable<Scene>): LinesMesh;
  55500. /**
  55501. * 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.
  55502. * * 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.
  55503. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55504. * * 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.
  55505. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55506. * * 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
  55507. * * 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
  55508. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55511. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55513. * @param name defines the name of the mesh
  55514. * @param options defines the options used to create the mesh
  55515. * @param scene defines the hosting scene
  55516. * @returns the extruded shape mesh
  55517. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55519. */
  55520. static ExtrudeShape(name: string, options: {
  55521. shape: Vector3[];
  55522. path: Vector3[];
  55523. scale?: number;
  55524. rotation?: number;
  55525. cap?: number;
  55526. updatable?: boolean;
  55527. sideOrientation?: number;
  55528. frontUVs?: Vector4;
  55529. backUVs?: Vector4;
  55530. instance?: Mesh;
  55531. invertUV?: boolean;
  55532. }, scene?: Nullable<Scene>): Mesh;
  55533. /**
  55534. * Creates an custom extruded shape mesh.
  55535. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55536. * * 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.
  55537. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55538. * * 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
  55539. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55540. * * 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
  55541. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55542. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55543. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55544. * * 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
  55545. * * 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
  55546. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55549. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55551. * @param name defines the name of the mesh
  55552. * @param options defines the options used to create the mesh
  55553. * @param scene defines the hosting scene
  55554. * @returns the custom extruded shape mesh
  55555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55556. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55557. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55558. */
  55559. static ExtrudeShapeCustom(name: string, options: {
  55560. shape: Vector3[];
  55561. path: Vector3[];
  55562. scaleFunction?: any;
  55563. rotationFunction?: any;
  55564. ribbonCloseArray?: boolean;
  55565. ribbonClosePath?: boolean;
  55566. cap?: number;
  55567. updatable?: boolean;
  55568. sideOrientation?: number;
  55569. frontUVs?: Vector4;
  55570. backUVs?: Vector4;
  55571. instance?: Mesh;
  55572. invertUV?: boolean;
  55573. }, scene?: Nullable<Scene>): Mesh;
  55574. /**
  55575. * Creates lathe mesh.
  55576. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55577. * * 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
  55578. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55579. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55580. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55581. * * 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
  55582. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55583. * * 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
  55584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55586. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55588. * @param name defines the name of the mesh
  55589. * @param options defines the options used to create the mesh
  55590. * @param scene defines the hosting scene
  55591. * @returns the lathe mesh
  55592. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55593. */
  55594. static CreateLathe(name: string, options: {
  55595. shape: Vector3[];
  55596. radius?: number;
  55597. tessellation?: number;
  55598. clip?: number;
  55599. arc?: number;
  55600. closed?: boolean;
  55601. updatable?: boolean;
  55602. sideOrientation?: number;
  55603. frontUVs?: Vector4;
  55604. backUVs?: Vector4;
  55605. cap?: number;
  55606. invertUV?: boolean;
  55607. }, scene?: Nullable<Scene>): Mesh;
  55608. /**
  55609. * Creates a tiled plane mesh
  55610. * * You can set a limited pattern arrangement with the tiles
  55611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55614. * @param name defines the name of the mesh
  55615. * @param options defines the options used to create the mesh
  55616. * @param scene defines the hosting scene
  55617. * @returns the plane mesh
  55618. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55619. */
  55620. static CreateTiledPlane(name: string, options: {
  55621. pattern?: number;
  55622. tileSize?: number;
  55623. tileWidth?: number;
  55624. tileHeight?: number;
  55625. size?: number;
  55626. width?: number;
  55627. height?: number;
  55628. alignHorizontal?: number;
  55629. alignVertical?: number;
  55630. sideOrientation?: number;
  55631. frontUVs?: Vector4;
  55632. backUVs?: Vector4;
  55633. updatable?: boolean;
  55634. }, scene?: Nullable<Scene>): Mesh;
  55635. /**
  55636. * Creates a plane mesh
  55637. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55638. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55639. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55643. * @param name defines the name of the mesh
  55644. * @param options defines the options used to create the mesh
  55645. * @param scene defines the hosting scene
  55646. * @returns the plane mesh
  55647. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55648. */
  55649. static CreatePlane(name: string, options: {
  55650. size?: number;
  55651. width?: number;
  55652. height?: number;
  55653. sideOrientation?: number;
  55654. frontUVs?: Vector4;
  55655. backUVs?: Vector4;
  55656. updatable?: boolean;
  55657. sourcePlane?: Plane;
  55658. }, scene?: Nullable<Scene>): Mesh;
  55659. /**
  55660. * Creates a ground mesh
  55661. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55662. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55664. * @param name defines the name of the mesh
  55665. * @param options defines the options used to create the mesh
  55666. * @param scene defines the hosting scene
  55667. * @returns the ground mesh
  55668. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55669. */
  55670. static CreateGround(name: string, options: {
  55671. width?: number;
  55672. height?: number;
  55673. subdivisions?: number;
  55674. subdivisionsX?: number;
  55675. subdivisionsY?: number;
  55676. updatable?: boolean;
  55677. }, scene?: Nullable<Scene>): Mesh;
  55678. /**
  55679. * Creates a tiled ground mesh
  55680. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55681. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55682. * * 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
  55683. * * 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
  55684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55685. * @param name defines the name of the mesh
  55686. * @param options defines the options used to create the mesh
  55687. * @param scene defines the hosting scene
  55688. * @returns the tiled ground mesh
  55689. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55690. */
  55691. static CreateTiledGround(name: string, options: {
  55692. xmin: number;
  55693. zmin: number;
  55694. xmax: number;
  55695. zmax: number;
  55696. subdivisions?: {
  55697. w: number;
  55698. h: number;
  55699. };
  55700. precision?: {
  55701. w: number;
  55702. h: number;
  55703. };
  55704. updatable?: boolean;
  55705. }, scene?: Nullable<Scene>): Mesh;
  55706. /**
  55707. * Creates a ground mesh from a height map
  55708. * * The parameter `url` sets the URL of the height map image resource.
  55709. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55710. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55711. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55712. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55713. * * 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.
  55714. * * 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).
  55715. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55717. * @param name defines the name of the mesh
  55718. * @param url defines the url to the height map
  55719. * @param options defines the options used to create the mesh
  55720. * @param scene defines the hosting scene
  55721. * @returns the ground mesh
  55722. * @see https://doc.babylonjs.com/babylon101/height_map
  55723. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55724. */
  55725. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55726. width?: number;
  55727. height?: number;
  55728. subdivisions?: number;
  55729. minHeight?: number;
  55730. maxHeight?: number;
  55731. colorFilter?: Color3;
  55732. alphaFilter?: number;
  55733. updatable?: boolean;
  55734. onReady?: (mesh: GroundMesh) => void;
  55735. }, scene?: Nullable<Scene>): GroundMesh;
  55736. /**
  55737. * Creates a polygon mesh
  55738. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55739. * * 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
  55740. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55742. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55743. * * Remember you can only change the shape positions, not their number when updating a polygon
  55744. * @param name defines the name of the mesh
  55745. * @param options defines the options used to create the mesh
  55746. * @param scene defines the hosting scene
  55747. * @param earcutInjection can be used to inject your own earcut reference
  55748. * @returns the polygon mesh
  55749. */
  55750. static CreatePolygon(name: string, options: {
  55751. shape: Vector3[];
  55752. holes?: Vector3[][];
  55753. depth?: number;
  55754. faceUV?: Vector4[];
  55755. faceColors?: Color4[];
  55756. updatable?: boolean;
  55757. sideOrientation?: number;
  55758. frontUVs?: Vector4;
  55759. backUVs?: Vector4;
  55760. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55761. /**
  55762. * Creates an extruded polygon mesh, with depth in the Y direction.
  55763. * * 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)
  55764. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55765. * @param name defines the name of the mesh
  55766. * @param options defines the options used to create the mesh
  55767. * @param scene defines the hosting scene
  55768. * @param earcutInjection can be used to inject your own earcut reference
  55769. * @returns the polygon mesh
  55770. */
  55771. static ExtrudePolygon(name: string, options: {
  55772. shape: Vector3[];
  55773. holes?: Vector3[][];
  55774. depth?: number;
  55775. faceUV?: Vector4[];
  55776. faceColors?: Color4[];
  55777. updatable?: boolean;
  55778. sideOrientation?: number;
  55779. frontUVs?: Vector4;
  55780. backUVs?: Vector4;
  55781. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55782. /**
  55783. * Creates a tube mesh.
  55784. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55785. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55786. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55787. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55788. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55789. * * 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)
  55790. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55791. * * 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
  55792. * * 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
  55793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55794. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55795. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55797. * @param name defines the name of the mesh
  55798. * @param options defines the options used to create the mesh
  55799. * @param scene defines the hosting scene
  55800. * @returns the tube mesh
  55801. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55802. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55803. */
  55804. static CreateTube(name: string, options: {
  55805. path: Vector3[];
  55806. radius?: number;
  55807. tessellation?: number;
  55808. radiusFunction?: {
  55809. (i: number, distance: number): number;
  55810. };
  55811. cap?: number;
  55812. arc?: number;
  55813. updatable?: boolean;
  55814. sideOrientation?: number;
  55815. frontUVs?: Vector4;
  55816. backUVs?: Vector4;
  55817. instance?: Mesh;
  55818. invertUV?: boolean;
  55819. }, scene?: Nullable<Scene>): Mesh;
  55820. /**
  55821. * Creates a polyhedron mesh
  55822. * * 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
  55823. * * The parameter `size` (positive float, default 1) sets the polygon size
  55824. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55825. * * 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`
  55826. * * 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
  55827. * * 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)`)
  55828. * * 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
  55829. * * 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
  55830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55831. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55833. * @param name defines the name of the mesh
  55834. * @param options defines the options used to create the mesh
  55835. * @param scene defines the hosting scene
  55836. * @returns the polyhedron mesh
  55837. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55838. */
  55839. static CreatePolyhedron(name: string, options: {
  55840. type?: number;
  55841. size?: number;
  55842. sizeX?: number;
  55843. sizeY?: number;
  55844. sizeZ?: number;
  55845. custom?: any;
  55846. faceUV?: Vector4[];
  55847. faceColors?: Color4[];
  55848. flat?: boolean;
  55849. updatable?: boolean;
  55850. sideOrientation?: number;
  55851. frontUVs?: Vector4;
  55852. backUVs?: Vector4;
  55853. }, scene?: Nullable<Scene>): Mesh;
  55854. /**
  55855. * Creates a decal mesh.
  55856. * 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
  55857. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55858. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55859. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55860. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55861. * @param name defines the name of the mesh
  55862. * @param sourceMesh defines the mesh where the decal must be applied
  55863. * @param options defines the options used to create the mesh
  55864. * @param scene defines the hosting scene
  55865. * @returns the decal mesh
  55866. * @see https://doc.babylonjs.com/how_to/decals
  55867. */
  55868. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55869. position?: Vector3;
  55870. normal?: Vector3;
  55871. size?: Vector3;
  55872. angle?: number;
  55873. }): Mesh;
  55874. }
  55875. }
  55876. declare module "babylonjs/Meshes/meshSimplification" {
  55877. import { Mesh } from "babylonjs/Meshes/mesh";
  55878. /**
  55879. * A simplifier interface for future simplification implementations
  55880. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55881. */
  55882. export interface ISimplifier {
  55883. /**
  55884. * Simplification of a given mesh according to the given settings.
  55885. * Since this requires computation, it is assumed that the function runs async.
  55886. * @param settings The settings of the simplification, including quality and distance
  55887. * @param successCallback A callback that will be called after the mesh was simplified.
  55888. * @param errorCallback in case of an error, this callback will be called. optional.
  55889. */
  55890. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55891. }
  55892. /**
  55893. * Expected simplification settings.
  55894. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55895. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55896. */
  55897. export interface ISimplificationSettings {
  55898. /**
  55899. * Gets or sets the expected quality
  55900. */
  55901. quality: number;
  55902. /**
  55903. * Gets or sets the distance when this optimized version should be used
  55904. */
  55905. distance: number;
  55906. /**
  55907. * Gets an already optimized mesh
  55908. */
  55909. optimizeMesh?: boolean;
  55910. }
  55911. /**
  55912. * Class used to specify simplification options
  55913. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55914. */
  55915. export class SimplificationSettings implements ISimplificationSettings {
  55916. /** expected quality */
  55917. quality: number;
  55918. /** distance when this optimized version should be used */
  55919. distance: number;
  55920. /** already optimized mesh */
  55921. optimizeMesh?: boolean | undefined;
  55922. /**
  55923. * Creates a SimplificationSettings
  55924. * @param quality expected quality
  55925. * @param distance distance when this optimized version should be used
  55926. * @param optimizeMesh already optimized mesh
  55927. */
  55928. constructor(
  55929. /** expected quality */
  55930. quality: number,
  55931. /** distance when this optimized version should be used */
  55932. distance: number,
  55933. /** already optimized mesh */
  55934. optimizeMesh?: boolean | undefined);
  55935. }
  55936. /**
  55937. * Interface used to define a simplification task
  55938. */
  55939. export interface ISimplificationTask {
  55940. /**
  55941. * Array of settings
  55942. */
  55943. settings: Array<ISimplificationSettings>;
  55944. /**
  55945. * Simplification type
  55946. */
  55947. simplificationType: SimplificationType;
  55948. /**
  55949. * Mesh to simplify
  55950. */
  55951. mesh: Mesh;
  55952. /**
  55953. * Callback called on success
  55954. */
  55955. successCallback?: () => void;
  55956. /**
  55957. * Defines if parallel processing can be used
  55958. */
  55959. parallelProcessing: boolean;
  55960. }
  55961. /**
  55962. * Queue used to order the simplification tasks
  55963. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55964. */
  55965. export class SimplificationQueue {
  55966. private _simplificationArray;
  55967. /**
  55968. * Gets a boolean indicating that the process is still running
  55969. */
  55970. running: boolean;
  55971. /**
  55972. * Creates a new queue
  55973. */
  55974. constructor();
  55975. /**
  55976. * Adds a new simplification task
  55977. * @param task defines a task to add
  55978. */
  55979. addTask(task: ISimplificationTask): void;
  55980. /**
  55981. * Execute next task
  55982. */
  55983. executeNext(): void;
  55984. /**
  55985. * Execute a simplification task
  55986. * @param task defines the task to run
  55987. */
  55988. runSimplification(task: ISimplificationTask): void;
  55989. private getSimplifier;
  55990. }
  55991. /**
  55992. * The implemented types of simplification
  55993. * At the moment only Quadratic Error Decimation is implemented
  55994. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55995. */
  55996. export enum SimplificationType {
  55997. /** Quadratic error decimation */
  55998. QUADRATIC = 0
  55999. }
  56000. }
  56001. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  56002. import { Scene } from "babylonjs/scene";
  56003. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  56004. import { ISceneComponent } from "babylonjs/sceneComponent";
  56005. module "babylonjs/scene" {
  56006. interface Scene {
  56007. /** @hidden (Backing field) */
  56008. _simplificationQueue: SimplificationQueue;
  56009. /**
  56010. * Gets or sets the simplification queue attached to the scene
  56011. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56012. */
  56013. simplificationQueue: SimplificationQueue;
  56014. }
  56015. }
  56016. module "babylonjs/Meshes/mesh" {
  56017. interface Mesh {
  56018. /**
  56019. * Simplify the mesh according to the given array of settings.
  56020. * Function will return immediately and will simplify async
  56021. * @param settings a collection of simplification settings
  56022. * @param parallelProcessing should all levels calculate parallel or one after the other
  56023. * @param simplificationType the type of simplification to run
  56024. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56025. * @returns the current mesh
  56026. */
  56027. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56028. }
  56029. }
  56030. /**
  56031. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56032. * created in a scene
  56033. */
  56034. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56035. /**
  56036. * The component name helpfull to identify the component in the list of scene components.
  56037. */
  56038. readonly name: string;
  56039. /**
  56040. * The scene the component belongs to.
  56041. */
  56042. scene: Scene;
  56043. /**
  56044. * Creates a new instance of the component for the given scene
  56045. * @param scene Defines the scene to register the component in
  56046. */
  56047. constructor(scene: Scene);
  56048. /**
  56049. * Registers the component in a given scene
  56050. */
  56051. register(): void;
  56052. /**
  56053. * Rebuilds the elements related to this component in case of
  56054. * context lost for instance.
  56055. */
  56056. rebuild(): void;
  56057. /**
  56058. * Disposes the component and the associated ressources
  56059. */
  56060. dispose(): void;
  56061. private _beforeCameraUpdate;
  56062. }
  56063. }
  56064. declare module "babylonjs/Meshes/Builders/index" {
  56065. export * from "babylonjs/Meshes/Builders/boxBuilder";
  56066. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  56067. export * from "babylonjs/Meshes/Builders/discBuilder";
  56068. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  56069. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  56070. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  56071. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  56072. export * from "babylonjs/Meshes/Builders/torusBuilder";
  56073. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  56074. export * from "babylonjs/Meshes/Builders/linesBuilder";
  56075. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  56076. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  56077. export * from "babylonjs/Meshes/Builders/latheBuilder";
  56078. export * from "babylonjs/Meshes/Builders/planeBuilder";
  56079. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  56080. export * from "babylonjs/Meshes/Builders/groundBuilder";
  56081. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  56082. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  56083. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  56084. export * from "babylonjs/Meshes/Builders/decalBuilder";
  56085. }
  56086. declare module "babylonjs/Meshes/index" {
  56087. export * from "babylonjs/Meshes/abstractMesh";
  56088. export * from "babylonjs/Meshes/buffer";
  56089. export * from "babylonjs/Meshes/Compression/index";
  56090. export * from "babylonjs/Meshes/csg";
  56091. export * from "babylonjs/Meshes/geometry";
  56092. export * from "babylonjs/Meshes/groundMesh";
  56093. export * from "babylonjs/Meshes/trailMesh";
  56094. export * from "babylonjs/Meshes/instancedMesh";
  56095. export * from "babylonjs/Meshes/linesMesh";
  56096. export * from "babylonjs/Meshes/mesh";
  56097. export * from "babylonjs/Meshes/mesh.vertexData";
  56098. export * from "babylonjs/Meshes/meshBuilder";
  56099. export * from "babylonjs/Meshes/meshSimplification";
  56100. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  56101. export * from "babylonjs/Meshes/polygonMesh";
  56102. export * from "babylonjs/Meshes/subMesh";
  56103. export * from "babylonjs/Meshes/meshLODLevel";
  56104. export * from "babylonjs/Meshes/transformNode";
  56105. export * from "babylonjs/Meshes/Builders/index";
  56106. export * from "babylonjs/Meshes/dataBuffer";
  56107. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  56108. }
  56109. declare module "babylonjs/Morph/index" {
  56110. export * from "babylonjs/Morph/morphTarget";
  56111. export * from "babylonjs/Morph/morphTargetManager";
  56112. }
  56113. declare module "babylonjs/Offline/database" {
  56114. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  56115. /**
  56116. * Class used to enable access to IndexedDB
  56117. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56118. */
  56119. export class Database implements IOfflineProvider {
  56120. private _callbackManifestChecked;
  56121. private _currentSceneUrl;
  56122. private _db;
  56123. private _enableSceneOffline;
  56124. private _enableTexturesOffline;
  56125. private _manifestVersionFound;
  56126. private _mustUpdateRessources;
  56127. private _hasReachedQuota;
  56128. private _isSupported;
  56129. private _idbFactory;
  56130. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56131. private static IsUASupportingBlobStorage;
  56132. /**
  56133. * Gets a boolean indicating if Database storate is enabled (off by default)
  56134. */
  56135. static IDBStorageEnabled: boolean;
  56136. /**
  56137. * Gets a boolean indicating if scene must be saved in the database
  56138. */
  56139. readonly enableSceneOffline: boolean;
  56140. /**
  56141. * Gets a boolean indicating if textures must be saved in the database
  56142. */
  56143. readonly enableTexturesOffline: boolean;
  56144. /**
  56145. * Creates a new Database
  56146. * @param urlToScene defines the url to load the scene
  56147. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56148. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56149. */
  56150. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56151. private static _ParseURL;
  56152. private static _ReturnFullUrlLocation;
  56153. private _checkManifestFile;
  56154. /**
  56155. * Open the database and make it available
  56156. * @param successCallback defines the callback to call on success
  56157. * @param errorCallback defines the callback to call on error
  56158. */
  56159. open(successCallback: () => void, errorCallback: () => void): void;
  56160. /**
  56161. * Loads an image from the database
  56162. * @param url defines the url to load from
  56163. * @param image defines the target DOM image
  56164. */
  56165. loadImage(url: string, image: HTMLImageElement): void;
  56166. private _loadImageFromDBAsync;
  56167. private _saveImageIntoDBAsync;
  56168. private _checkVersionFromDB;
  56169. private _loadVersionFromDBAsync;
  56170. private _saveVersionIntoDBAsync;
  56171. /**
  56172. * Loads a file from database
  56173. * @param url defines the URL to load from
  56174. * @param sceneLoaded defines a callback to call on success
  56175. * @param progressCallBack defines a callback to call when progress changed
  56176. * @param errorCallback defines a callback to call on error
  56177. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56178. */
  56179. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56180. private _loadFileAsync;
  56181. private _saveFileAsync;
  56182. /**
  56183. * Validates if xhr data is correct
  56184. * @param xhr defines the request to validate
  56185. * @param dataType defines the expected data type
  56186. * @returns true if data is correct
  56187. */
  56188. private static _ValidateXHRData;
  56189. }
  56190. }
  56191. declare module "babylonjs/Offline/index" {
  56192. export * from "babylonjs/Offline/database";
  56193. export * from "babylonjs/Offline/IOfflineProvider";
  56194. }
  56195. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  56196. /** @hidden */
  56197. export var gpuUpdateParticlesPixelShader: {
  56198. name: string;
  56199. shader: string;
  56200. };
  56201. }
  56202. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  56203. /** @hidden */
  56204. export var gpuUpdateParticlesVertexShader: {
  56205. name: string;
  56206. shader: string;
  56207. };
  56208. }
  56209. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  56210. /** @hidden */
  56211. export var clipPlaneFragmentDeclaration2: {
  56212. name: string;
  56213. shader: string;
  56214. };
  56215. }
  56216. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  56217. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  56218. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56219. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56220. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56221. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56222. /** @hidden */
  56223. export var gpuRenderParticlesPixelShader: {
  56224. name: string;
  56225. shader: string;
  56226. };
  56227. }
  56228. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  56229. /** @hidden */
  56230. export var clipPlaneVertexDeclaration2: {
  56231. name: string;
  56232. shader: string;
  56233. };
  56234. }
  56235. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  56236. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  56237. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56238. /** @hidden */
  56239. export var gpuRenderParticlesVertexShader: {
  56240. name: string;
  56241. shader: string;
  56242. };
  56243. }
  56244. declare module "babylonjs/Particles/gpuParticleSystem" {
  56245. import { Nullable } from "babylonjs/types";
  56246. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  56247. import { Observable } from "babylonjs/Misc/observable";
  56248. import { Color4, Color3 } from "babylonjs/Maths/math";
  56249. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56250. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  56251. import { Scene, IDisposable } from "babylonjs/scene";
  56252. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  56253. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  56254. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  56255. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  56256. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  56257. /**
  56258. * This represents a GPU particle system in Babylon
  56259. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56260. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56261. */
  56262. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56263. /**
  56264. * The layer mask we are rendering the particles through.
  56265. */
  56266. layerMask: number;
  56267. private _capacity;
  56268. private _activeCount;
  56269. private _currentActiveCount;
  56270. private _accumulatedCount;
  56271. private _renderEffect;
  56272. private _updateEffect;
  56273. private _buffer0;
  56274. private _buffer1;
  56275. private _spriteBuffer;
  56276. private _updateVAO;
  56277. private _renderVAO;
  56278. private _targetIndex;
  56279. private _sourceBuffer;
  56280. private _targetBuffer;
  56281. private _engine;
  56282. private _currentRenderId;
  56283. private _started;
  56284. private _stopped;
  56285. private _timeDelta;
  56286. private _randomTexture;
  56287. private _randomTexture2;
  56288. private _attributesStrideSize;
  56289. private _updateEffectOptions;
  56290. private _randomTextureSize;
  56291. private _actualFrame;
  56292. private readonly _rawTextureWidth;
  56293. /**
  56294. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56295. */
  56296. static readonly IsSupported: boolean;
  56297. /**
  56298. * An event triggered when the system is disposed.
  56299. */
  56300. onDisposeObservable: Observable<GPUParticleSystem>;
  56301. /**
  56302. * Gets the maximum number of particles active at the same time.
  56303. * @returns The max number of active particles.
  56304. */
  56305. getCapacity(): number;
  56306. /**
  56307. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56308. * to override the particles.
  56309. */
  56310. forceDepthWrite: boolean;
  56311. /**
  56312. * Gets or set the number of active particles
  56313. */
  56314. activeParticleCount: number;
  56315. private _preWarmDone;
  56316. /**
  56317. * Is this system ready to be used/rendered
  56318. * @return true if the system is ready
  56319. */
  56320. isReady(): boolean;
  56321. /**
  56322. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56323. * @returns True if it has been started, otherwise false.
  56324. */
  56325. isStarted(): boolean;
  56326. /**
  56327. * Starts the particle system and begins to emit
  56328. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56329. */
  56330. start(delay?: number): void;
  56331. /**
  56332. * Stops the particle system.
  56333. */
  56334. stop(): void;
  56335. /**
  56336. * Remove all active particles
  56337. */
  56338. reset(): void;
  56339. /**
  56340. * Returns the string "GPUParticleSystem"
  56341. * @returns a string containing the class name
  56342. */
  56343. getClassName(): string;
  56344. private _colorGradientsTexture;
  56345. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56346. /**
  56347. * Adds a new color gradient
  56348. * @param gradient defines the gradient to use (between 0 and 1)
  56349. * @param color1 defines the color to affect to the specified gradient
  56350. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56351. * @returns the current particle system
  56352. */
  56353. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56354. /**
  56355. * Remove a specific color gradient
  56356. * @param gradient defines the gradient to remove
  56357. * @returns the current particle system
  56358. */
  56359. removeColorGradient(gradient: number): GPUParticleSystem;
  56360. private _angularSpeedGradientsTexture;
  56361. private _sizeGradientsTexture;
  56362. private _velocityGradientsTexture;
  56363. private _limitVelocityGradientsTexture;
  56364. private _dragGradientsTexture;
  56365. private _addFactorGradient;
  56366. /**
  56367. * Adds a new size gradient
  56368. * @param gradient defines the gradient to use (between 0 and 1)
  56369. * @param factor defines the size factor to affect to the specified gradient
  56370. * @returns the current particle system
  56371. */
  56372. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56373. /**
  56374. * Remove a specific size gradient
  56375. * @param gradient defines the gradient to remove
  56376. * @returns the current particle system
  56377. */
  56378. removeSizeGradient(gradient: number): GPUParticleSystem;
  56379. /**
  56380. * Adds a new angular speed gradient
  56381. * @param gradient defines the gradient to use (between 0 and 1)
  56382. * @param factor defines the angular speed to affect to the specified gradient
  56383. * @returns the current particle system
  56384. */
  56385. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56386. /**
  56387. * Remove a specific angular speed gradient
  56388. * @param gradient defines the gradient to remove
  56389. * @returns the current particle system
  56390. */
  56391. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56392. /**
  56393. * Adds a new velocity gradient
  56394. * @param gradient defines the gradient to use (between 0 and 1)
  56395. * @param factor defines the velocity to affect to the specified gradient
  56396. * @returns the current particle system
  56397. */
  56398. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56399. /**
  56400. * Remove a specific velocity gradient
  56401. * @param gradient defines the gradient to remove
  56402. * @returns the current particle system
  56403. */
  56404. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56405. /**
  56406. * Adds a new limit velocity gradient
  56407. * @param gradient defines the gradient to use (between 0 and 1)
  56408. * @param factor defines the limit velocity value to affect to the specified gradient
  56409. * @returns the current particle system
  56410. */
  56411. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56412. /**
  56413. * Remove a specific limit velocity gradient
  56414. * @param gradient defines the gradient to remove
  56415. * @returns the current particle system
  56416. */
  56417. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56418. /**
  56419. * Adds a new drag gradient
  56420. * @param gradient defines the gradient to use (between 0 and 1)
  56421. * @param factor defines the drag value to affect to the specified gradient
  56422. * @returns the current particle system
  56423. */
  56424. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56425. /**
  56426. * Remove a specific drag gradient
  56427. * @param gradient defines the gradient to remove
  56428. * @returns the current particle system
  56429. */
  56430. removeDragGradient(gradient: number): GPUParticleSystem;
  56431. /**
  56432. * Not supported by GPUParticleSystem
  56433. * @param gradient defines the gradient to use (between 0 and 1)
  56434. * @param factor defines the emit rate value to affect to the specified gradient
  56435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56436. * @returns the current particle system
  56437. */
  56438. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56439. /**
  56440. * Not supported by GPUParticleSystem
  56441. * @param gradient defines the gradient to remove
  56442. * @returns the current particle system
  56443. */
  56444. removeEmitRateGradient(gradient: number): IParticleSystem;
  56445. /**
  56446. * Not supported by GPUParticleSystem
  56447. * @param gradient defines the gradient to use (between 0 and 1)
  56448. * @param factor defines the start size value to affect to the specified gradient
  56449. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56450. * @returns the current particle system
  56451. */
  56452. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56453. /**
  56454. * Not supported by GPUParticleSystem
  56455. * @param gradient defines the gradient to remove
  56456. * @returns the current particle system
  56457. */
  56458. removeStartSizeGradient(gradient: number): IParticleSystem;
  56459. /**
  56460. * Not supported by GPUParticleSystem
  56461. * @param gradient defines the gradient to use (between 0 and 1)
  56462. * @param min defines the color remap minimal range
  56463. * @param max defines the color remap maximal range
  56464. * @returns the current particle system
  56465. */
  56466. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56467. /**
  56468. * Not supported by GPUParticleSystem
  56469. * @param gradient defines the gradient to remove
  56470. * @returns the current particle system
  56471. */
  56472. removeColorRemapGradient(): IParticleSystem;
  56473. /**
  56474. * Not supported by GPUParticleSystem
  56475. * @param gradient defines the gradient to use (between 0 and 1)
  56476. * @param min defines the alpha remap minimal range
  56477. * @param max defines the alpha remap maximal range
  56478. * @returns the current particle system
  56479. */
  56480. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56481. /**
  56482. * Not supported by GPUParticleSystem
  56483. * @param gradient defines the gradient to remove
  56484. * @returns the current particle system
  56485. */
  56486. removeAlphaRemapGradient(): IParticleSystem;
  56487. /**
  56488. * Not supported by GPUParticleSystem
  56489. * @param gradient defines the gradient to use (between 0 and 1)
  56490. * @param color defines the color to affect to the specified gradient
  56491. * @returns the current particle system
  56492. */
  56493. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56494. /**
  56495. * Not supported by GPUParticleSystem
  56496. * @param gradient defines the gradient to remove
  56497. * @returns the current particle system
  56498. */
  56499. removeRampGradient(): IParticleSystem;
  56500. /**
  56501. * Not supported by GPUParticleSystem
  56502. * @returns the list of ramp gradients
  56503. */
  56504. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56505. /**
  56506. * Not supported by GPUParticleSystem
  56507. * Gets or sets a boolean indicating that ramp gradients must be used
  56508. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56509. */
  56510. useRampGradients: boolean;
  56511. /**
  56512. * Not supported by GPUParticleSystem
  56513. * @param gradient defines the gradient to use (between 0 and 1)
  56514. * @param factor defines the life time factor to affect to the specified gradient
  56515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56516. * @returns the current particle system
  56517. */
  56518. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56519. /**
  56520. * Not supported by GPUParticleSystem
  56521. * @param gradient defines the gradient to remove
  56522. * @returns the current particle system
  56523. */
  56524. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56525. /**
  56526. * Instantiates a GPU particle system.
  56527. * 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.
  56528. * @param name The name of the particle system
  56529. * @param options The options used to create the system
  56530. * @param scene The scene the particle system belongs to
  56531. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56532. */
  56533. constructor(name: string, options: Partial<{
  56534. capacity: number;
  56535. randomTextureSize: number;
  56536. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56537. protected _reset(): void;
  56538. private _createUpdateVAO;
  56539. private _createRenderVAO;
  56540. private _initialize;
  56541. /** @hidden */
  56542. _recreateUpdateEffect(): void;
  56543. /** @hidden */
  56544. _recreateRenderEffect(): void;
  56545. /**
  56546. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56547. * @param preWarm defines if we are in the pre-warmimg phase
  56548. */
  56549. animate(preWarm?: boolean): void;
  56550. private _createFactorGradientTexture;
  56551. private _createSizeGradientTexture;
  56552. private _createAngularSpeedGradientTexture;
  56553. private _createVelocityGradientTexture;
  56554. private _createLimitVelocityGradientTexture;
  56555. private _createDragGradientTexture;
  56556. private _createColorGradientTexture;
  56557. /**
  56558. * Renders the particle system in its current state
  56559. * @param preWarm defines if the system should only update the particles but not render them
  56560. * @returns the current number of particles
  56561. */
  56562. render(preWarm?: boolean): number;
  56563. /**
  56564. * Rebuilds the particle system
  56565. */
  56566. rebuild(): void;
  56567. private _releaseBuffers;
  56568. private _releaseVAOs;
  56569. /**
  56570. * Disposes the particle system and free the associated resources
  56571. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56572. */
  56573. dispose(disposeTexture?: boolean): void;
  56574. /**
  56575. * Clones the particle system.
  56576. * @param name The name of the cloned object
  56577. * @param newEmitter The new emitter to use
  56578. * @returns the cloned particle system
  56579. */
  56580. clone(name: string, newEmitter: any): GPUParticleSystem;
  56581. /**
  56582. * Serializes the particle system to a JSON object.
  56583. * @returns the JSON object
  56584. */
  56585. serialize(): any;
  56586. /**
  56587. * Parses a JSON object to create a GPU particle system.
  56588. * @param parsedParticleSystem The JSON object to parse
  56589. * @param scene The scene to create the particle system in
  56590. * @param rootUrl The root url to use to load external dependencies like texture
  56591. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56592. * @returns the parsed GPU particle system
  56593. */
  56594. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56595. }
  56596. }
  56597. declare module "babylonjs/Particles/particleSystemSet" {
  56598. import { Nullable } from "babylonjs/types";
  56599. import { Color3 } from "babylonjs/Maths/math";
  56600. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56602. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56603. import { Scene, IDisposable } from "babylonjs/scene";
  56604. /**
  56605. * Represents a set of particle systems working together to create a specific effect
  56606. */
  56607. export class ParticleSystemSet implements IDisposable {
  56608. private _emitterCreationOptions;
  56609. private _emitterNode;
  56610. /**
  56611. * Gets the particle system list
  56612. */
  56613. systems: IParticleSystem[];
  56614. /**
  56615. * Gets the emitter node used with this set
  56616. */
  56617. readonly emitterNode: Nullable<TransformNode>;
  56618. /**
  56619. * Creates a new emitter mesh as a sphere
  56620. * @param options defines the options used to create the sphere
  56621. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56622. * @param scene defines the hosting scene
  56623. */
  56624. setEmitterAsSphere(options: {
  56625. diameter: number;
  56626. segments: number;
  56627. color: Color3;
  56628. }, renderingGroupId: number, scene: Scene): void;
  56629. /**
  56630. * Starts all particle systems of the set
  56631. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56632. */
  56633. start(emitter?: AbstractMesh): void;
  56634. /**
  56635. * Release all associated resources
  56636. */
  56637. dispose(): void;
  56638. /**
  56639. * Serialize the set into a JSON compatible object
  56640. * @returns a JSON compatible representation of the set
  56641. */
  56642. serialize(): any;
  56643. /**
  56644. * Parse a new ParticleSystemSet from a serialized source
  56645. * @param data defines a JSON compatible representation of the set
  56646. * @param scene defines the hosting scene
  56647. * @param gpu defines if we want GPU particles or CPU particles
  56648. * @returns a new ParticleSystemSet
  56649. */
  56650. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56651. }
  56652. }
  56653. declare module "babylonjs/Particles/particleHelper" {
  56654. import { Nullable } from "babylonjs/types";
  56655. import { Scene } from "babylonjs/scene";
  56656. import { Vector3 } from "babylonjs/Maths/math";
  56657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56658. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56659. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  56660. /**
  56661. * This class is made for on one-liner static method to help creating particle system set.
  56662. */
  56663. export class ParticleHelper {
  56664. /**
  56665. * Gets or sets base Assets URL
  56666. */
  56667. static BaseAssetsUrl: string;
  56668. /**
  56669. * Create a default particle system that you can tweak
  56670. * @param emitter defines the emitter to use
  56671. * @param capacity defines the system capacity (default is 500 particles)
  56672. * @param scene defines the hosting scene
  56673. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56674. * @returns the new Particle system
  56675. */
  56676. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56677. /**
  56678. * This is the main static method (one-liner) of this helper to create different particle systems
  56679. * @param type This string represents the type to the particle system to create
  56680. * @param scene The scene where the particle system should live
  56681. * @param gpu If the system will use gpu
  56682. * @returns the ParticleSystemSet created
  56683. */
  56684. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56685. /**
  56686. * Static function used to export a particle system to a ParticleSystemSet variable.
  56687. * Please note that the emitter shape is not exported
  56688. * @param systems defines the particle systems to export
  56689. * @returns the created particle system set
  56690. */
  56691. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56692. }
  56693. }
  56694. declare module "babylonjs/Particles/particleSystemComponent" {
  56695. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56696. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  56697. import "babylonjs/Shaders/particles.vertex";
  56698. module "babylonjs/Engines/engine" {
  56699. interface Engine {
  56700. /**
  56701. * Create an effect to use with particle systems.
  56702. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56703. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56704. * @param uniformsNames defines a list of attribute names
  56705. * @param samplers defines an array of string used to represent textures
  56706. * @param defines defines the string containing the defines to use to compile the shaders
  56707. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56708. * @param onCompiled defines a function to call when the effect creation is successful
  56709. * @param onError defines a function to call when the effect creation has failed
  56710. * @returns the new Effect
  56711. */
  56712. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56713. }
  56714. }
  56715. module "babylonjs/Meshes/mesh" {
  56716. interface Mesh {
  56717. /**
  56718. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56719. * @returns an array of IParticleSystem
  56720. */
  56721. getEmittedParticleSystems(): IParticleSystem[];
  56722. /**
  56723. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56724. * @returns an array of IParticleSystem
  56725. */
  56726. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56727. }
  56728. }
  56729. /**
  56730. * @hidden
  56731. */
  56732. export var _IDoNeedToBeInTheBuild: number;
  56733. }
  56734. declare module "babylonjs/Particles/index" {
  56735. export * from "babylonjs/Particles/baseParticleSystem";
  56736. export * from "babylonjs/Particles/EmitterTypes/index";
  56737. export * from "babylonjs/Particles/gpuParticleSystem";
  56738. export * from "babylonjs/Particles/IParticleSystem";
  56739. export * from "babylonjs/Particles/particle";
  56740. export * from "babylonjs/Particles/particleHelper";
  56741. export * from "babylonjs/Particles/particleSystem";
  56742. export * from "babylonjs/Particles/particleSystemComponent";
  56743. export * from "babylonjs/Particles/particleSystemSet";
  56744. export * from "babylonjs/Particles/solidParticle";
  56745. export * from "babylonjs/Particles/solidParticleSystem";
  56746. export * from "babylonjs/Particles/subEmitter";
  56747. }
  56748. declare module "babylonjs/Physics/physicsEngineComponent" {
  56749. import { Nullable } from "babylonjs/types";
  56750. import { Observable, Observer } from "babylonjs/Misc/observable";
  56751. import { Vector3 } from "babylonjs/Maths/math";
  56752. import { Mesh } from "babylonjs/Meshes/mesh";
  56753. import { ISceneComponent } from "babylonjs/sceneComponent";
  56754. import { Scene } from "babylonjs/scene";
  56755. import { Node } from "babylonjs/node";
  56756. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56757. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56758. module "babylonjs/scene" {
  56759. interface Scene {
  56760. /** @hidden (Backing field) */
  56761. _physicsEngine: Nullable<IPhysicsEngine>;
  56762. /**
  56763. * Gets the current physics engine
  56764. * @returns a IPhysicsEngine or null if none attached
  56765. */
  56766. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56767. /**
  56768. * Enables physics to the current scene
  56769. * @param gravity defines the scene's gravity for the physics engine
  56770. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56771. * @return a boolean indicating if the physics engine was initialized
  56772. */
  56773. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56774. /**
  56775. * Disables and disposes the physics engine associated with the scene
  56776. */
  56777. disablePhysicsEngine(): void;
  56778. /**
  56779. * Gets a boolean indicating if there is an active physics engine
  56780. * @returns a boolean indicating if there is an active physics engine
  56781. */
  56782. isPhysicsEnabled(): boolean;
  56783. /**
  56784. * Deletes a physics compound impostor
  56785. * @param compound defines the compound to delete
  56786. */
  56787. deleteCompoundImpostor(compound: any): void;
  56788. /**
  56789. * An event triggered when physic simulation is about to be run
  56790. */
  56791. onBeforePhysicsObservable: Observable<Scene>;
  56792. /**
  56793. * An event triggered when physic simulation has been done
  56794. */
  56795. onAfterPhysicsObservable: Observable<Scene>;
  56796. }
  56797. }
  56798. module "babylonjs/Meshes/abstractMesh" {
  56799. interface AbstractMesh {
  56800. /** @hidden */
  56801. _physicsImpostor: Nullable<PhysicsImpostor>;
  56802. /**
  56803. * Gets or sets impostor used for physic simulation
  56804. * @see http://doc.babylonjs.com/features/physics_engine
  56805. */
  56806. physicsImpostor: Nullable<PhysicsImpostor>;
  56807. /**
  56808. * Gets the current physics impostor
  56809. * @see http://doc.babylonjs.com/features/physics_engine
  56810. * @returns a physics impostor or null
  56811. */
  56812. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56813. /** Apply a physic impulse to the mesh
  56814. * @param force defines the force to apply
  56815. * @param contactPoint defines where to apply the force
  56816. * @returns the current mesh
  56817. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56818. */
  56819. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56820. /**
  56821. * Creates a physic joint between two meshes
  56822. * @param otherMesh defines the other mesh to use
  56823. * @param pivot1 defines the pivot to use on this mesh
  56824. * @param pivot2 defines the pivot to use on the other mesh
  56825. * @param options defines additional options (can be plugin dependent)
  56826. * @returns the current mesh
  56827. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56828. */
  56829. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56830. /** @hidden */
  56831. _disposePhysicsObserver: Nullable<Observer<Node>>;
  56832. }
  56833. }
  56834. /**
  56835. * Defines the physics engine scene component responsible to manage a physics engine
  56836. */
  56837. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56838. /**
  56839. * The component name helpful to identify the component in the list of scene components.
  56840. */
  56841. readonly name: string;
  56842. /**
  56843. * The scene the component belongs to.
  56844. */
  56845. scene: Scene;
  56846. /**
  56847. * Creates a new instance of the component for the given scene
  56848. * @param scene Defines the scene to register the component in
  56849. */
  56850. constructor(scene: Scene);
  56851. /**
  56852. * Registers the component in a given scene
  56853. */
  56854. register(): void;
  56855. /**
  56856. * Rebuilds the elements related to this component in case of
  56857. * context lost for instance.
  56858. */
  56859. rebuild(): void;
  56860. /**
  56861. * Disposes the component and the associated ressources
  56862. */
  56863. dispose(): void;
  56864. }
  56865. }
  56866. declare module "babylonjs/Physics/physicsHelper" {
  56867. import { Nullable } from "babylonjs/types";
  56868. import { Vector3 } from "babylonjs/Maths/math";
  56869. import { Mesh } from "babylonjs/Meshes/mesh";
  56870. import { Scene } from "babylonjs/scene";
  56871. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56872. /**
  56873. * A helper for physics simulations
  56874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56875. */
  56876. export class PhysicsHelper {
  56877. private _scene;
  56878. private _physicsEngine;
  56879. /**
  56880. * Initializes the Physics helper
  56881. * @param scene Babylon.js scene
  56882. */
  56883. constructor(scene: Scene);
  56884. /**
  56885. * Applies a radial explosion impulse
  56886. * @param origin the origin of the explosion
  56887. * @param radiusOrEventOptions the radius or the options of radial explosion
  56888. * @param strength the explosion strength
  56889. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56890. * @returns A physics radial explosion event, or null
  56891. */
  56892. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56893. /**
  56894. * Applies a radial explosion force
  56895. * @param origin the origin of the explosion
  56896. * @param radiusOrEventOptions the radius or the options of radial explosion
  56897. * @param strength the explosion strength
  56898. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56899. * @returns A physics radial explosion event, or null
  56900. */
  56901. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56902. /**
  56903. * Creates a gravitational field
  56904. * @param origin the origin of the explosion
  56905. * @param radiusOrEventOptions the radius or the options of radial explosion
  56906. * @param strength the explosion strength
  56907. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56908. * @returns A physics gravitational field event, or null
  56909. */
  56910. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56911. /**
  56912. * Creates a physics updraft event
  56913. * @param origin the origin of the updraft
  56914. * @param radiusOrEventOptions the radius or the options of the updraft
  56915. * @param strength the strength of the updraft
  56916. * @param height the height of the updraft
  56917. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56918. * @returns A physics updraft event, or null
  56919. */
  56920. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56921. /**
  56922. * Creates a physics vortex event
  56923. * @param origin the of the vortex
  56924. * @param radiusOrEventOptions the radius or the options of the vortex
  56925. * @param strength the strength of the vortex
  56926. * @param height the height of the vortex
  56927. * @returns a Physics vortex event, or null
  56928. * A physics vortex event or null
  56929. */
  56930. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56931. }
  56932. /**
  56933. * Represents a physics radial explosion event
  56934. */
  56935. class PhysicsRadialExplosionEvent {
  56936. private _scene;
  56937. private _options;
  56938. private _sphere;
  56939. private _dataFetched;
  56940. /**
  56941. * Initializes a radial explosioin event
  56942. * @param _scene BabylonJS scene
  56943. * @param _options The options for the vortex event
  56944. */
  56945. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56946. /**
  56947. * Returns the data related to the radial explosion event (sphere).
  56948. * @returns The radial explosion event data
  56949. */
  56950. getData(): PhysicsRadialExplosionEventData;
  56951. /**
  56952. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56953. * @param impostor A physics imposter
  56954. * @param origin the origin of the explosion
  56955. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56956. */
  56957. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56958. /**
  56959. * Triggers affecterd impostors callbacks
  56960. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56961. */
  56962. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56963. /**
  56964. * Disposes the sphere.
  56965. * @param force Specifies if the sphere should be disposed by force
  56966. */
  56967. dispose(force?: boolean): void;
  56968. /*** Helpers ***/
  56969. private _prepareSphere;
  56970. private _intersectsWithSphere;
  56971. }
  56972. /**
  56973. * Represents a gravitational field event
  56974. */
  56975. class PhysicsGravitationalFieldEvent {
  56976. private _physicsHelper;
  56977. private _scene;
  56978. private _origin;
  56979. private _options;
  56980. private _tickCallback;
  56981. private _sphere;
  56982. private _dataFetched;
  56983. /**
  56984. * Initializes the physics gravitational field event
  56985. * @param _physicsHelper A physics helper
  56986. * @param _scene BabylonJS scene
  56987. * @param _origin The origin position of the gravitational field event
  56988. * @param _options The options for the vortex event
  56989. */
  56990. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56991. /**
  56992. * Returns the data related to the gravitational field event (sphere).
  56993. * @returns A gravitational field event
  56994. */
  56995. getData(): PhysicsGravitationalFieldEventData;
  56996. /**
  56997. * Enables the gravitational field.
  56998. */
  56999. enable(): void;
  57000. /**
  57001. * Disables the gravitational field.
  57002. */
  57003. disable(): void;
  57004. /**
  57005. * Disposes the sphere.
  57006. * @param force The force to dispose from the gravitational field event
  57007. */
  57008. dispose(force?: boolean): void;
  57009. private _tick;
  57010. }
  57011. /**
  57012. * Represents a physics updraft event
  57013. */
  57014. class PhysicsUpdraftEvent {
  57015. private _scene;
  57016. private _origin;
  57017. private _options;
  57018. private _physicsEngine;
  57019. private _originTop;
  57020. private _originDirection;
  57021. private _tickCallback;
  57022. private _cylinder;
  57023. private _cylinderPosition;
  57024. private _dataFetched;
  57025. /**
  57026. * Initializes the physics updraft event
  57027. * @param _scene BabylonJS scene
  57028. * @param _origin The origin position of the updraft
  57029. * @param _options The options for the updraft event
  57030. */
  57031. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57032. /**
  57033. * Returns the data related to the updraft event (cylinder).
  57034. * @returns A physics updraft event
  57035. */
  57036. getData(): PhysicsUpdraftEventData;
  57037. /**
  57038. * Enables the updraft.
  57039. */
  57040. enable(): void;
  57041. /**
  57042. * Disables the updraft.
  57043. */
  57044. disable(): void;
  57045. /**
  57046. * Disposes the cylinder.
  57047. * @param force Specifies if the updraft should be disposed by force
  57048. */
  57049. dispose(force?: boolean): void;
  57050. private getImpostorHitData;
  57051. private _tick;
  57052. /*** Helpers ***/
  57053. private _prepareCylinder;
  57054. private _intersectsWithCylinder;
  57055. }
  57056. /**
  57057. * Represents a physics vortex event
  57058. */
  57059. class PhysicsVortexEvent {
  57060. private _scene;
  57061. private _origin;
  57062. private _options;
  57063. private _physicsEngine;
  57064. private _originTop;
  57065. private _tickCallback;
  57066. private _cylinder;
  57067. private _cylinderPosition;
  57068. private _dataFetched;
  57069. /**
  57070. * Initializes the physics vortex event
  57071. * @param _scene The BabylonJS scene
  57072. * @param _origin The origin position of the vortex
  57073. * @param _options The options for the vortex event
  57074. */
  57075. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57076. /**
  57077. * Returns the data related to the vortex event (cylinder).
  57078. * @returns The physics vortex event data
  57079. */
  57080. getData(): PhysicsVortexEventData;
  57081. /**
  57082. * Enables the vortex.
  57083. */
  57084. enable(): void;
  57085. /**
  57086. * Disables the cortex.
  57087. */
  57088. disable(): void;
  57089. /**
  57090. * Disposes the sphere.
  57091. * @param force
  57092. */
  57093. dispose(force?: boolean): void;
  57094. private getImpostorHitData;
  57095. private _tick;
  57096. /*** Helpers ***/
  57097. private _prepareCylinder;
  57098. private _intersectsWithCylinder;
  57099. }
  57100. /**
  57101. * Options fot the radial explosion event
  57102. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57103. */
  57104. export class PhysicsRadialExplosionEventOptions {
  57105. /**
  57106. * The radius of the sphere for the radial explosion.
  57107. */
  57108. radius: number;
  57109. /**
  57110. * The strenth of the explosion.
  57111. */
  57112. strength: number;
  57113. /**
  57114. * The strenght of the force in correspondence to the distance of the affected object
  57115. */
  57116. falloff: PhysicsRadialImpulseFalloff;
  57117. /**
  57118. * Sphere options for the radial explosion.
  57119. */
  57120. sphere: {
  57121. segments: number;
  57122. diameter: number;
  57123. };
  57124. /**
  57125. * Sphere options for the radial explosion.
  57126. */
  57127. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57128. }
  57129. /**
  57130. * Options fot the updraft event
  57131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57132. */
  57133. export class PhysicsUpdraftEventOptions {
  57134. /**
  57135. * The radius of the cylinder for the vortex
  57136. */
  57137. radius: number;
  57138. /**
  57139. * The strenth of the updraft.
  57140. */
  57141. strength: number;
  57142. /**
  57143. * The height of the cylinder for the updraft.
  57144. */
  57145. height: number;
  57146. /**
  57147. * The mode for the the updraft.
  57148. */
  57149. updraftMode: PhysicsUpdraftMode;
  57150. }
  57151. /**
  57152. * Options fot the vortex event
  57153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57154. */
  57155. export class PhysicsVortexEventOptions {
  57156. /**
  57157. * The radius of the cylinder for the vortex
  57158. */
  57159. radius: number;
  57160. /**
  57161. * The strenth of the vortex.
  57162. */
  57163. strength: number;
  57164. /**
  57165. * The height of the cylinder for the vortex.
  57166. */
  57167. height: number;
  57168. /**
  57169. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57170. */
  57171. centripetalForceThreshold: number;
  57172. /**
  57173. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57174. */
  57175. centripetalForceMultiplier: number;
  57176. /**
  57177. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57178. */
  57179. centrifugalForceMultiplier: number;
  57180. /**
  57181. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57182. */
  57183. updraftForceMultiplier: number;
  57184. }
  57185. /**
  57186. * The strenght of the force in correspondence to the distance of the affected object
  57187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57188. */
  57189. export enum PhysicsRadialImpulseFalloff {
  57190. /** Defines that impulse is constant in strength across it's whole radius */
  57191. Constant = 0,
  57192. /** Defines that impulse gets weaker if it's further from the origin */
  57193. Linear = 1
  57194. }
  57195. /**
  57196. * The strength of the force in correspondence to the distance of the affected object
  57197. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57198. */
  57199. export enum PhysicsUpdraftMode {
  57200. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57201. Center = 0,
  57202. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57203. Perpendicular = 1
  57204. }
  57205. /**
  57206. * Interface for a physics hit data
  57207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57208. */
  57209. export interface PhysicsHitData {
  57210. /**
  57211. * The force applied at the contact point
  57212. */
  57213. force: Vector3;
  57214. /**
  57215. * The contact point
  57216. */
  57217. contactPoint: Vector3;
  57218. /**
  57219. * The distance from the origin to the contact point
  57220. */
  57221. distanceFromOrigin: number;
  57222. }
  57223. /**
  57224. * Interface for radial explosion event data
  57225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57226. */
  57227. export interface PhysicsRadialExplosionEventData {
  57228. /**
  57229. * A sphere used for the radial explosion event
  57230. */
  57231. sphere: Mesh;
  57232. }
  57233. /**
  57234. * Interface for gravitational field event data
  57235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57236. */
  57237. export interface PhysicsGravitationalFieldEventData {
  57238. /**
  57239. * A sphere mesh used for the gravitational field event
  57240. */
  57241. sphere: Mesh;
  57242. }
  57243. /**
  57244. * Interface for updraft event data
  57245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57246. */
  57247. export interface PhysicsUpdraftEventData {
  57248. /**
  57249. * A cylinder used for the updraft event
  57250. */
  57251. cylinder: Mesh;
  57252. }
  57253. /**
  57254. * Interface for vortex event data
  57255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57256. */
  57257. export interface PhysicsVortexEventData {
  57258. /**
  57259. * A cylinder used for the vortex event
  57260. */
  57261. cylinder: Mesh;
  57262. }
  57263. /**
  57264. * Interface for an affected physics impostor
  57265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57266. */
  57267. export interface PhysicsAffectedImpostorWithData {
  57268. /**
  57269. * The impostor affected by the effect
  57270. */
  57271. impostor: PhysicsImpostor;
  57272. /**
  57273. * The data about the hit/horce from the explosion
  57274. */
  57275. hitData: PhysicsHitData;
  57276. }
  57277. }
  57278. declare module "babylonjs/Physics/Plugins/index" {
  57279. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57280. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57281. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57282. }
  57283. declare module "babylonjs/Physics/index" {
  57284. export * from "babylonjs/Physics/IPhysicsEngine";
  57285. export * from "babylonjs/Physics/physicsEngine";
  57286. export * from "babylonjs/Physics/physicsEngineComponent";
  57287. export * from "babylonjs/Physics/physicsHelper";
  57288. export * from "babylonjs/Physics/physicsImpostor";
  57289. export * from "babylonjs/Physics/physicsJoint";
  57290. export * from "babylonjs/Physics/Plugins/index";
  57291. }
  57292. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57293. /** @hidden */
  57294. export var blackAndWhitePixelShader: {
  57295. name: string;
  57296. shader: string;
  57297. };
  57298. }
  57299. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57300. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57301. import { Camera } from "babylonjs/Cameras/camera";
  57302. import { Engine } from "babylonjs/Engines/engine";
  57303. import "babylonjs/Shaders/blackAndWhite.fragment";
  57304. /**
  57305. * Post process used to render in black and white
  57306. */
  57307. export class BlackAndWhitePostProcess extends PostProcess {
  57308. /**
  57309. * Linear about to convert he result to black and white (default: 1)
  57310. */
  57311. degree: number;
  57312. /**
  57313. * Creates a black and white post process
  57314. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57315. * @param name The name of the effect.
  57316. * @param options The required width/height ratio to downsize to before computing the render pass.
  57317. * @param camera The camera to apply the render pass to.
  57318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57319. * @param engine The engine which the post process will be applied. (default: current engine)
  57320. * @param reusable If the post process can be reused on the same frame. (default: false)
  57321. */
  57322. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57323. }
  57324. }
  57325. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  57326. import { Nullable } from "babylonjs/types";
  57327. import { Camera } from "babylonjs/Cameras/camera";
  57328. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57329. import { Engine } from "babylonjs/Engines/engine";
  57330. /**
  57331. * This represents a set of one or more post processes in Babylon.
  57332. * A post process can be used to apply a shader to a texture after it is rendered.
  57333. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57334. */
  57335. export class PostProcessRenderEffect {
  57336. private _postProcesses;
  57337. private _getPostProcesses;
  57338. private _singleInstance;
  57339. private _cameras;
  57340. private _indicesForCamera;
  57341. /**
  57342. * Name of the effect
  57343. * @hidden
  57344. */
  57345. _name: string;
  57346. /**
  57347. * Instantiates a post process render effect.
  57348. * A post process can be used to apply a shader to a texture after it is rendered.
  57349. * @param engine The engine the effect is tied to
  57350. * @param name The name of the effect
  57351. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57352. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57353. */
  57354. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57355. /**
  57356. * Checks if all the post processes in the effect are supported.
  57357. */
  57358. readonly isSupported: boolean;
  57359. /**
  57360. * Updates the current state of the effect
  57361. * @hidden
  57362. */
  57363. _update(): void;
  57364. /**
  57365. * Attaches the effect on cameras
  57366. * @param cameras The camera to attach to.
  57367. * @hidden
  57368. */
  57369. _attachCameras(cameras: Camera): void;
  57370. /**
  57371. * Attaches the effect on cameras
  57372. * @param cameras The camera to attach to.
  57373. * @hidden
  57374. */
  57375. _attachCameras(cameras: Camera[]): void;
  57376. /**
  57377. * Detaches the effect on cameras
  57378. * @param cameras The camera to detatch from.
  57379. * @hidden
  57380. */
  57381. _detachCameras(cameras: Camera): void;
  57382. /**
  57383. * Detatches the effect on cameras
  57384. * @param cameras The camera to detatch from.
  57385. * @hidden
  57386. */
  57387. _detachCameras(cameras: Camera[]): void;
  57388. /**
  57389. * Enables the effect on given cameras
  57390. * @param cameras The camera to enable.
  57391. * @hidden
  57392. */
  57393. _enable(cameras: Camera): void;
  57394. /**
  57395. * Enables the effect on given cameras
  57396. * @param cameras The camera to enable.
  57397. * @hidden
  57398. */
  57399. _enable(cameras: Nullable<Camera[]>): void;
  57400. /**
  57401. * Disables the effect on the given cameras
  57402. * @param cameras The camera to disable.
  57403. * @hidden
  57404. */
  57405. _disable(cameras: Camera): void;
  57406. /**
  57407. * Disables the effect on the given cameras
  57408. * @param cameras The camera to disable.
  57409. * @hidden
  57410. */
  57411. _disable(cameras: Nullable<Camera[]>): void;
  57412. /**
  57413. * Gets a list of the post processes contained in the effect.
  57414. * @param camera The camera to get the post processes on.
  57415. * @returns The list of the post processes in the effect.
  57416. */
  57417. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57418. }
  57419. }
  57420. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  57421. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57422. /** @hidden */
  57423. export var extractHighlightsPixelShader: {
  57424. name: string;
  57425. shader: string;
  57426. };
  57427. }
  57428. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  57429. import { Nullable } from "babylonjs/types";
  57430. import { Camera } from "babylonjs/Cameras/camera";
  57431. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57432. import { Engine } from "babylonjs/Engines/engine";
  57433. import "babylonjs/Shaders/extractHighlights.fragment";
  57434. /**
  57435. * 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.
  57436. */
  57437. export class ExtractHighlightsPostProcess extends PostProcess {
  57438. /**
  57439. * The luminance threshold, pixels below this value will be set to black.
  57440. */
  57441. threshold: number;
  57442. /** @hidden */
  57443. _exposure: number;
  57444. /**
  57445. * Post process which has the input texture to be used when performing highlight extraction
  57446. * @hidden
  57447. */
  57448. _inputPostProcess: Nullable<PostProcess>;
  57449. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57450. }
  57451. }
  57452. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  57453. /** @hidden */
  57454. export var bloomMergePixelShader: {
  57455. name: string;
  57456. shader: string;
  57457. };
  57458. }
  57459. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  57460. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57461. import { Nullable } from "babylonjs/types";
  57462. import { Engine } from "babylonjs/Engines/engine";
  57463. import { Camera } from "babylonjs/Cameras/camera";
  57464. import "babylonjs/Shaders/bloomMerge.fragment";
  57465. /**
  57466. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57467. */
  57468. export class BloomMergePostProcess extends PostProcess {
  57469. /** Weight of the bloom to be added to the original input. */
  57470. weight: number;
  57471. /**
  57472. * Creates a new instance of @see BloomMergePostProcess
  57473. * @param name The name of the effect.
  57474. * @param originalFromInput Post process which's input will be used for the merge.
  57475. * @param blurred Blurred highlights post process which's output will be used.
  57476. * @param weight Weight of the bloom to be added to the original input.
  57477. * @param options The required width/height ratio to downsize to before computing the render pass.
  57478. * @param camera The camera to apply the render pass to.
  57479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57480. * @param engine The engine which the post process will be applied. (default: current engine)
  57481. * @param reusable If the post process can be reused on the same frame. (default: false)
  57482. * @param textureType Type of textures used when performing the post process. (default: 0)
  57483. * @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)
  57484. */
  57485. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57486. /** Weight of the bloom to be added to the original input. */
  57487. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57488. }
  57489. }
  57490. declare module "babylonjs/PostProcesses/bloomEffect" {
  57491. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57492. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57493. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57494. import { Camera } from "babylonjs/Cameras/camera";
  57495. import { Scene } from "babylonjs/scene";
  57496. /**
  57497. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57498. */
  57499. export class BloomEffect extends PostProcessRenderEffect {
  57500. private bloomScale;
  57501. /**
  57502. * @hidden Internal
  57503. */
  57504. _effects: Array<PostProcess>;
  57505. /**
  57506. * @hidden Internal
  57507. */
  57508. _downscale: ExtractHighlightsPostProcess;
  57509. private _blurX;
  57510. private _blurY;
  57511. private _merge;
  57512. /**
  57513. * The luminance threshold to find bright areas of the image to bloom.
  57514. */
  57515. threshold: number;
  57516. /**
  57517. * The strength of the bloom.
  57518. */
  57519. weight: number;
  57520. /**
  57521. * Specifies the size of the bloom blur kernel, relative to the final output size
  57522. */
  57523. kernel: number;
  57524. /**
  57525. * Creates a new instance of @see BloomEffect
  57526. * @param scene The scene the effect belongs to.
  57527. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57528. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57529. * @param bloomWeight The the strength of bloom.
  57530. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57531. * @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)
  57532. */
  57533. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57534. /**
  57535. * Disposes each of the internal effects for a given camera.
  57536. * @param camera The camera to dispose the effect on.
  57537. */
  57538. disposeEffects(camera: Camera): void;
  57539. /**
  57540. * @hidden Internal
  57541. */
  57542. _updateEffects(): void;
  57543. /**
  57544. * Internal
  57545. * @returns if all the contained post processes are ready.
  57546. * @hidden
  57547. */
  57548. _isReady(): boolean;
  57549. }
  57550. }
  57551. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  57552. /** @hidden */
  57553. export var chromaticAberrationPixelShader: {
  57554. name: string;
  57555. shader: string;
  57556. };
  57557. }
  57558. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  57559. import { Vector2 } from "babylonjs/Maths/math";
  57560. import { Nullable } from "babylonjs/types";
  57561. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57562. import { Camera } from "babylonjs/Cameras/camera";
  57563. import { Engine } from "babylonjs/Engines/engine";
  57564. import "babylonjs/Shaders/chromaticAberration.fragment";
  57565. /**
  57566. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57567. */
  57568. export class ChromaticAberrationPostProcess extends PostProcess {
  57569. /**
  57570. * The amount of seperation of rgb channels (default: 30)
  57571. */
  57572. aberrationAmount: number;
  57573. /**
  57574. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57575. */
  57576. radialIntensity: number;
  57577. /**
  57578. * 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))
  57579. */
  57580. direction: Vector2;
  57581. /**
  57582. * 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))
  57583. */
  57584. centerPosition: Vector2;
  57585. /**
  57586. * Creates a new instance ChromaticAberrationPostProcess
  57587. * @param name The name of the effect.
  57588. * @param screenWidth The width of the screen to apply the effect on.
  57589. * @param screenHeight The height of the screen to apply the effect on.
  57590. * @param options The required width/height ratio to downsize to before computing the render pass.
  57591. * @param camera The camera to apply the render pass to.
  57592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57593. * @param engine The engine which the post process will be applied. (default: current engine)
  57594. * @param reusable If the post process can be reused on the same frame. (default: false)
  57595. * @param textureType Type of textures used when performing the post process. (default: 0)
  57596. * @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)
  57597. */
  57598. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57599. }
  57600. }
  57601. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  57602. /** @hidden */
  57603. export var circleOfConfusionPixelShader: {
  57604. name: string;
  57605. shader: string;
  57606. };
  57607. }
  57608. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  57609. import { Nullable } from "babylonjs/types";
  57610. import { Engine } from "babylonjs/Engines/engine";
  57611. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57612. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57613. import { Camera } from "babylonjs/Cameras/camera";
  57614. import "babylonjs/Shaders/circleOfConfusion.fragment";
  57615. /**
  57616. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57617. */
  57618. export class CircleOfConfusionPostProcess extends PostProcess {
  57619. /**
  57620. * 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.
  57621. */
  57622. lensSize: number;
  57623. /**
  57624. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57625. */
  57626. fStop: number;
  57627. /**
  57628. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57629. */
  57630. focusDistance: number;
  57631. /**
  57632. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57633. */
  57634. focalLength: number;
  57635. private _depthTexture;
  57636. /**
  57637. * Creates a new instance CircleOfConfusionPostProcess
  57638. * @param name The name of the effect.
  57639. * @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.
  57640. * @param options The required width/height ratio to downsize to before computing the render pass.
  57641. * @param camera The camera to apply the render pass to.
  57642. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57643. * @param engine The engine which the post process will be applied. (default: current engine)
  57644. * @param reusable If the post process can be reused on the same frame. (default: false)
  57645. * @param textureType Type of textures used when performing the post process. (default: 0)
  57646. * @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)
  57647. */
  57648. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57649. /**
  57650. * 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.
  57651. */
  57652. depthTexture: RenderTargetTexture;
  57653. }
  57654. }
  57655. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  57656. /** @hidden */
  57657. export var colorCorrectionPixelShader: {
  57658. name: string;
  57659. shader: string;
  57660. };
  57661. }
  57662. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  57663. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57664. import { Engine } from "babylonjs/Engines/engine";
  57665. import { Camera } from "babylonjs/Cameras/camera";
  57666. import "babylonjs/Shaders/colorCorrection.fragment";
  57667. /**
  57668. *
  57669. * This post-process allows the modification of rendered colors by using
  57670. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57671. *
  57672. * The object needs to be provided an url to a texture containing the color
  57673. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57674. * Use an image editing software to tweak the LUT to match your needs.
  57675. *
  57676. * For an example of a color LUT, see here:
  57677. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57678. * For explanations on color grading, see here:
  57679. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57680. *
  57681. */
  57682. export class ColorCorrectionPostProcess extends PostProcess {
  57683. private _colorTableTexture;
  57684. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57685. }
  57686. }
  57687. declare module "babylonjs/Shaders/convolution.fragment" {
  57688. /** @hidden */
  57689. export var convolutionPixelShader: {
  57690. name: string;
  57691. shader: string;
  57692. };
  57693. }
  57694. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  57695. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57696. import { Nullable } from "babylonjs/types";
  57697. import { Camera } from "babylonjs/Cameras/camera";
  57698. import { Engine } from "babylonjs/Engines/engine";
  57699. import "babylonjs/Shaders/convolution.fragment";
  57700. /**
  57701. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57702. * input texture to perform effects such as edge detection or sharpening
  57703. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57704. */
  57705. export class ConvolutionPostProcess extends PostProcess {
  57706. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57707. kernel: number[];
  57708. /**
  57709. * Creates a new instance ConvolutionPostProcess
  57710. * @param name The name of the effect.
  57711. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57712. * @param options The required width/height ratio to downsize to before computing the render pass.
  57713. * @param camera The camera to apply the render pass to.
  57714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57715. * @param engine The engine which the post process will be applied. (default: current engine)
  57716. * @param reusable If the post process can be reused on the same frame. (default: false)
  57717. * @param textureType Type of textures used when performing the post process. (default: 0)
  57718. */
  57719. constructor(name: string,
  57720. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57721. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57722. /**
  57723. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57724. */
  57725. static EdgeDetect0Kernel: number[];
  57726. /**
  57727. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57728. */
  57729. static EdgeDetect1Kernel: number[];
  57730. /**
  57731. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57732. */
  57733. static EdgeDetect2Kernel: number[];
  57734. /**
  57735. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57736. */
  57737. static SharpenKernel: number[];
  57738. /**
  57739. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57740. */
  57741. static EmbossKernel: number[];
  57742. /**
  57743. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57744. */
  57745. static GaussianKernel: number[];
  57746. }
  57747. }
  57748. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  57749. import { Nullable } from "babylonjs/types";
  57750. import { Vector2 } from "babylonjs/Maths/math";
  57751. import { Camera } from "babylonjs/Cameras/camera";
  57752. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57753. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  57754. import { Engine } from "babylonjs/Engines/engine";
  57755. import { Scene } from "babylonjs/scene";
  57756. /**
  57757. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57758. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57759. * based on samples that have a large difference in distance than the center pixel.
  57760. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57761. */
  57762. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57763. direction: Vector2;
  57764. /**
  57765. * Creates a new instance CircleOfConfusionPostProcess
  57766. * @param name The name of the effect.
  57767. * @param scene The scene the effect belongs to.
  57768. * @param direction The direction the blur should be applied.
  57769. * @param kernel The size of the kernel used to blur.
  57770. * @param options The required width/height ratio to downsize to before computing the render pass.
  57771. * @param camera The camera to apply the render pass to.
  57772. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57773. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57775. * @param engine The engine which the post process will be applied. (default: current engine)
  57776. * @param reusable If the post process can be reused on the same frame. (default: false)
  57777. * @param textureType Type of textures used when performing the post process. (default: 0)
  57778. * @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)
  57779. */
  57780. 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);
  57781. }
  57782. }
  57783. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  57784. /** @hidden */
  57785. export var depthOfFieldMergePixelShader: {
  57786. name: string;
  57787. shader: string;
  57788. };
  57789. }
  57790. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  57791. import { Nullable } from "babylonjs/types";
  57792. import { Camera } from "babylonjs/Cameras/camera";
  57793. import { Effect } from "babylonjs/Materials/effect";
  57794. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57795. import { Engine } from "babylonjs/Engines/engine";
  57796. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  57797. /**
  57798. * Options to be set when merging outputs from the default pipeline.
  57799. */
  57800. export class DepthOfFieldMergePostProcessOptions {
  57801. /**
  57802. * The original image to merge on top of
  57803. */
  57804. originalFromInput: PostProcess;
  57805. /**
  57806. * Parameters to perform the merge of the depth of field effect
  57807. */
  57808. depthOfField?: {
  57809. circleOfConfusion: PostProcess;
  57810. blurSteps: Array<PostProcess>;
  57811. };
  57812. /**
  57813. * Parameters to perform the merge of bloom effect
  57814. */
  57815. bloom?: {
  57816. blurred: PostProcess;
  57817. weight: number;
  57818. };
  57819. }
  57820. /**
  57821. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57822. */
  57823. export class DepthOfFieldMergePostProcess extends PostProcess {
  57824. private blurSteps;
  57825. /**
  57826. * Creates a new instance of DepthOfFieldMergePostProcess
  57827. * @param name The name of the effect.
  57828. * @param originalFromInput Post process which's input will be used for the merge.
  57829. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57830. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57831. * @param options The required width/height ratio to downsize to before computing the render pass.
  57832. * @param camera The camera to apply the render pass to.
  57833. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57834. * @param engine The engine which the post process will be applied. (default: current engine)
  57835. * @param reusable If the post process can be reused on the same frame. (default: false)
  57836. * @param textureType Type of textures used when performing the post process. (default: 0)
  57837. * @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)
  57838. */
  57839. 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);
  57840. /**
  57841. * Updates the effect with the current post process compile time values and recompiles the shader.
  57842. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57843. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57844. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57845. * @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
  57846. * @param onCompiled Called when the shader has been compiled.
  57847. * @param onError Called if there is an error when compiling a shader.
  57848. */
  57849. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57850. }
  57851. }
  57852. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  57853. import { Nullable } from "babylonjs/types";
  57854. import { Camera } from "babylonjs/Cameras/camera";
  57855. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57856. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57857. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57858. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57859. import { Scene } from "babylonjs/scene";
  57860. /**
  57861. * Specifies the level of max blur that should be applied when using the depth of field effect
  57862. */
  57863. export enum DepthOfFieldEffectBlurLevel {
  57864. /**
  57865. * Subtle blur
  57866. */
  57867. Low = 0,
  57868. /**
  57869. * Medium blur
  57870. */
  57871. Medium = 1,
  57872. /**
  57873. * Large blur
  57874. */
  57875. High = 2
  57876. }
  57877. /**
  57878. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57879. */
  57880. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57881. private _circleOfConfusion;
  57882. /**
  57883. * @hidden Internal, blurs from high to low
  57884. */
  57885. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57886. private _depthOfFieldBlurY;
  57887. private _dofMerge;
  57888. /**
  57889. * @hidden Internal post processes in depth of field effect
  57890. */
  57891. _effects: Array<PostProcess>;
  57892. /**
  57893. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57894. */
  57895. focalLength: number;
  57896. /**
  57897. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57898. */
  57899. fStop: number;
  57900. /**
  57901. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57902. */
  57903. focusDistance: number;
  57904. /**
  57905. * 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.
  57906. */
  57907. lensSize: number;
  57908. /**
  57909. * Creates a new instance DepthOfFieldEffect
  57910. * @param scene The scene the effect belongs to.
  57911. * @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.
  57912. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57913. * @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)
  57914. */
  57915. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57916. /**
  57917. * Get the current class name of the current effet
  57918. * @returns "DepthOfFieldEffect"
  57919. */
  57920. getClassName(): string;
  57921. /**
  57922. * 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.
  57923. */
  57924. depthTexture: RenderTargetTexture;
  57925. /**
  57926. * Disposes each of the internal effects for a given camera.
  57927. * @param camera The camera to dispose the effect on.
  57928. */
  57929. disposeEffects(camera: Camera): void;
  57930. /**
  57931. * @hidden Internal
  57932. */
  57933. _updateEffects(): void;
  57934. /**
  57935. * Internal
  57936. * @returns if all the contained post processes are ready.
  57937. * @hidden
  57938. */
  57939. _isReady(): boolean;
  57940. }
  57941. }
  57942. declare module "babylonjs/Shaders/displayPass.fragment" {
  57943. /** @hidden */
  57944. export var displayPassPixelShader: {
  57945. name: string;
  57946. shader: string;
  57947. };
  57948. }
  57949. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  57950. import { Nullable } from "babylonjs/types";
  57951. import { Camera } from "babylonjs/Cameras/camera";
  57952. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57953. import { Engine } from "babylonjs/Engines/engine";
  57954. import "babylonjs/Shaders/displayPass.fragment";
  57955. /**
  57956. * DisplayPassPostProcess which produces an output the same as it's input
  57957. */
  57958. export class DisplayPassPostProcess extends PostProcess {
  57959. /**
  57960. * Creates the DisplayPassPostProcess
  57961. * @param name The name of the effect.
  57962. * @param options The required width/height ratio to downsize to before computing the render pass.
  57963. * @param camera The camera to apply the render pass to.
  57964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57965. * @param engine The engine which the post process will be applied. (default: current engine)
  57966. * @param reusable If the post process can be reused on the same frame. (default: false)
  57967. */
  57968. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57969. }
  57970. }
  57971. declare module "babylonjs/Shaders/filter.fragment" {
  57972. /** @hidden */
  57973. export var filterPixelShader: {
  57974. name: string;
  57975. shader: string;
  57976. };
  57977. }
  57978. declare module "babylonjs/PostProcesses/filterPostProcess" {
  57979. import { Nullable } from "babylonjs/types";
  57980. import { Matrix } from "babylonjs/Maths/math";
  57981. import { Camera } from "babylonjs/Cameras/camera";
  57982. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57983. import { Engine } from "babylonjs/Engines/engine";
  57984. import "babylonjs/Shaders/filter.fragment";
  57985. /**
  57986. * Applies a kernel filter to the image
  57987. */
  57988. export class FilterPostProcess extends PostProcess {
  57989. /** The matrix to be applied to the image */
  57990. kernelMatrix: Matrix;
  57991. /**
  57992. *
  57993. * @param name The name of the effect.
  57994. * @param kernelMatrix The matrix to be applied to the image
  57995. * @param options The required width/height ratio to downsize to before computing the render pass.
  57996. * @param camera The camera to apply the render pass to.
  57997. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57998. * @param engine The engine which the post process will be applied. (default: current engine)
  57999. * @param reusable If the post process can be reused on the same frame. (default: false)
  58000. */
  58001. constructor(name: string,
  58002. /** The matrix to be applied to the image */
  58003. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58004. }
  58005. }
  58006. declare module "babylonjs/Shaders/fxaa.fragment" {
  58007. /** @hidden */
  58008. export var fxaaPixelShader: {
  58009. name: string;
  58010. shader: string;
  58011. };
  58012. }
  58013. declare module "babylonjs/Shaders/fxaa.vertex" {
  58014. /** @hidden */
  58015. export var fxaaVertexShader: {
  58016. name: string;
  58017. shader: string;
  58018. };
  58019. }
  58020. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  58021. import { Nullable } from "babylonjs/types";
  58022. import { Camera } from "babylonjs/Cameras/camera";
  58023. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58024. import { Engine } from "babylonjs/Engines/engine";
  58025. import "babylonjs/Shaders/fxaa.fragment";
  58026. import "babylonjs/Shaders/fxaa.vertex";
  58027. /**
  58028. * Fxaa post process
  58029. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58030. */
  58031. export class FxaaPostProcess extends PostProcess {
  58032. /** @hidden */
  58033. texelWidth: number;
  58034. /** @hidden */
  58035. texelHeight: number;
  58036. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58037. private _getDefines;
  58038. }
  58039. }
  58040. declare module "babylonjs/Shaders/grain.fragment" {
  58041. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58042. /** @hidden */
  58043. export var grainPixelShader: {
  58044. name: string;
  58045. shader: string;
  58046. };
  58047. }
  58048. declare module "babylonjs/PostProcesses/grainPostProcess" {
  58049. import { Nullable } from "babylonjs/types";
  58050. import { Camera } from "babylonjs/Cameras/camera";
  58051. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58052. import { Engine } from "babylonjs/Engines/engine";
  58053. import "babylonjs/Shaders/grain.fragment";
  58054. /**
  58055. * The GrainPostProcess adds noise to the image at mid luminance levels
  58056. */
  58057. export class GrainPostProcess extends PostProcess {
  58058. /**
  58059. * The intensity of the grain added (default: 30)
  58060. */
  58061. intensity: number;
  58062. /**
  58063. * If the grain should be randomized on every frame
  58064. */
  58065. animated: boolean;
  58066. /**
  58067. * Creates a new instance of @see GrainPostProcess
  58068. * @param name The name of the effect.
  58069. * @param options The required width/height ratio to downsize to before computing the render pass.
  58070. * @param camera The camera to apply the render pass to.
  58071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58072. * @param engine The engine which the post process will be applied. (default: current engine)
  58073. * @param reusable If the post process can be reused on the same frame. (default: false)
  58074. * @param textureType Type of textures used when performing the post process. (default: 0)
  58075. * @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)
  58076. */
  58077. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58078. }
  58079. }
  58080. declare module "babylonjs/Shaders/highlights.fragment" {
  58081. /** @hidden */
  58082. export var highlightsPixelShader: {
  58083. name: string;
  58084. shader: string;
  58085. };
  58086. }
  58087. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  58088. import { Nullable } from "babylonjs/types";
  58089. import { Camera } from "babylonjs/Cameras/camera";
  58090. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58091. import { Engine } from "babylonjs/Engines/engine";
  58092. import "babylonjs/Shaders/highlights.fragment";
  58093. /**
  58094. * Extracts highlights from the image
  58095. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58096. */
  58097. export class HighlightsPostProcess extends PostProcess {
  58098. /**
  58099. * Extracts highlights from the image
  58100. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58101. * @param name The name of the effect.
  58102. * @param options The required width/height ratio to downsize to before computing the render pass.
  58103. * @param camera The camera to apply the render pass to.
  58104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58105. * @param engine The engine which the post process will be applied. (default: current engine)
  58106. * @param reusable If the post process can be reused on the same frame. (default: false)
  58107. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58108. */
  58109. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58110. }
  58111. }
  58112. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  58113. /** @hidden */
  58114. export var mrtFragmentDeclaration: {
  58115. name: string;
  58116. shader: string;
  58117. };
  58118. }
  58119. declare module "babylonjs/Shaders/geometry.fragment" {
  58120. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  58121. /** @hidden */
  58122. export var geometryPixelShader: {
  58123. name: string;
  58124. shader: string;
  58125. };
  58126. }
  58127. declare module "babylonjs/Shaders/geometry.vertex" {
  58128. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58129. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58130. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58131. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58132. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58133. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58134. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58135. /** @hidden */
  58136. export var geometryVertexShader: {
  58137. name: string;
  58138. shader: string;
  58139. };
  58140. }
  58141. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  58142. import { Matrix } from "babylonjs/Maths/math";
  58143. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58144. import { Mesh } from "babylonjs/Meshes/mesh";
  58145. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  58146. import { Effect } from "babylonjs/Materials/effect";
  58147. import { Scene } from "babylonjs/scene";
  58148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58149. import "babylonjs/Shaders/geometry.fragment";
  58150. import "babylonjs/Shaders/geometry.vertex";
  58151. /** @hidden */
  58152. interface ISavedTransformationMatrix {
  58153. world: Matrix;
  58154. viewProjection: Matrix;
  58155. }
  58156. /**
  58157. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58158. */
  58159. export class GeometryBufferRenderer {
  58160. /**
  58161. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58162. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58163. */
  58164. static readonly POSITION_TEXTURE_TYPE: number;
  58165. /**
  58166. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58167. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58168. */
  58169. static readonly VELOCITY_TEXTURE_TYPE: number;
  58170. /**
  58171. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58172. * in order to compute objects velocities when enableVelocity is set to "true"
  58173. * @hidden
  58174. */
  58175. _previousTransformationMatrices: {
  58176. [index: number]: ISavedTransformationMatrix;
  58177. };
  58178. /**
  58179. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58180. * in order to compute objects velocities when enableVelocity is set to "true"
  58181. * @hidden
  58182. */
  58183. _previousBonesTransformationMatrices: {
  58184. [index: number]: Float32Array;
  58185. };
  58186. /**
  58187. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58188. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58189. */
  58190. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58191. private _scene;
  58192. private _multiRenderTarget;
  58193. private _ratio;
  58194. private _enablePosition;
  58195. private _enableVelocity;
  58196. private _positionIndex;
  58197. private _velocityIndex;
  58198. protected _effect: Effect;
  58199. protected _cachedDefines: string;
  58200. /**
  58201. * Set the render list (meshes to be rendered) used in the G buffer.
  58202. */
  58203. renderList: Mesh[];
  58204. /**
  58205. * Gets wether or not G buffer are supported by the running hardware.
  58206. * This requires draw buffer supports
  58207. */
  58208. readonly isSupported: boolean;
  58209. /**
  58210. * Returns the index of the given texture type in the G-Buffer textures array
  58211. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58212. * @returns the index of the given texture type in the G-Buffer textures array
  58213. */
  58214. getTextureIndex(textureType: number): number;
  58215. /**
  58216. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58217. */
  58218. /**
  58219. * Sets whether or not objects positions are enabled for the G buffer.
  58220. */
  58221. enablePosition: boolean;
  58222. /**
  58223. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58224. */
  58225. /**
  58226. * Sets wether or not objects velocities are enabled for the G buffer.
  58227. */
  58228. enableVelocity: boolean;
  58229. /**
  58230. * Gets the scene associated with the buffer.
  58231. */
  58232. readonly scene: Scene;
  58233. /**
  58234. * Gets the ratio used by the buffer during its creation.
  58235. * How big is the buffer related to the main canvas.
  58236. */
  58237. readonly ratio: number;
  58238. /** @hidden */
  58239. static _SceneComponentInitialization: (scene: Scene) => void;
  58240. /**
  58241. * Creates a new G Buffer for the scene
  58242. * @param scene The scene the buffer belongs to
  58243. * @param ratio How big is the buffer related to the main canvas.
  58244. */
  58245. constructor(scene: Scene, ratio?: number);
  58246. /**
  58247. * Checks wether everything is ready to render a submesh to the G buffer.
  58248. * @param subMesh the submesh to check readiness for
  58249. * @param useInstances is the mesh drawn using instance or not
  58250. * @returns true if ready otherwise false
  58251. */
  58252. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58253. /**
  58254. * Gets the current underlying G Buffer.
  58255. * @returns the buffer
  58256. */
  58257. getGBuffer(): MultiRenderTarget;
  58258. /**
  58259. * Gets the number of samples used to render the buffer (anti aliasing).
  58260. */
  58261. /**
  58262. * Sets the number of samples used to render the buffer (anti aliasing).
  58263. */
  58264. samples: number;
  58265. /**
  58266. * Disposes the renderer and frees up associated resources.
  58267. */
  58268. dispose(): void;
  58269. protected _createRenderTargets(): void;
  58270. private _copyBonesTransformationMatrices;
  58271. }
  58272. }
  58273. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  58274. import { Nullable } from "babylonjs/types";
  58275. import { Scene } from "babylonjs/scene";
  58276. import { ISceneComponent } from "babylonjs/sceneComponent";
  58277. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58278. module "babylonjs/scene" {
  58279. interface Scene {
  58280. /** @hidden (Backing field) */
  58281. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58282. /**
  58283. * Gets or Sets the current geometry buffer associated to the scene.
  58284. */
  58285. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58286. /**
  58287. * Enables a GeometryBufferRender and associates it with the scene
  58288. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58289. * @returns the GeometryBufferRenderer
  58290. */
  58291. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58292. /**
  58293. * Disables the GeometryBufferRender associated with the scene
  58294. */
  58295. disableGeometryBufferRenderer(): void;
  58296. }
  58297. }
  58298. /**
  58299. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58300. * in several rendering techniques.
  58301. */
  58302. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58303. /**
  58304. * The component name helpful to identify the component in the list of scene components.
  58305. */
  58306. readonly name: string;
  58307. /**
  58308. * The scene the component belongs to.
  58309. */
  58310. scene: Scene;
  58311. /**
  58312. * Creates a new instance of the component for the given scene
  58313. * @param scene Defines the scene to register the component in
  58314. */
  58315. constructor(scene: Scene);
  58316. /**
  58317. * Registers the component in a given scene
  58318. */
  58319. register(): void;
  58320. /**
  58321. * Rebuilds the elements related to this component in case of
  58322. * context lost for instance.
  58323. */
  58324. rebuild(): void;
  58325. /**
  58326. * Disposes the component and the associated ressources
  58327. */
  58328. dispose(): void;
  58329. private _gatherRenderTargets;
  58330. }
  58331. }
  58332. declare module "babylonjs/Shaders/motionBlur.fragment" {
  58333. /** @hidden */
  58334. export var motionBlurPixelShader: {
  58335. name: string;
  58336. shader: string;
  58337. };
  58338. }
  58339. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  58340. import { Nullable } from "babylonjs/types";
  58341. import { Camera } from "babylonjs/Cameras/camera";
  58342. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58343. import { Scene } from "babylonjs/scene";
  58344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58345. import "babylonjs/Animations/animatable";
  58346. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  58347. import "babylonjs/Shaders/motionBlur.fragment";
  58348. import { Engine } from "babylonjs/Engines/engine";
  58349. /**
  58350. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58351. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58352. * As an example, all you have to do is to create the post-process:
  58353. * var mb = new BABYLON.MotionBlurPostProcess(
  58354. * 'mb', // The name of the effect.
  58355. * scene, // The scene containing the objects to blur according to their velocity.
  58356. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58357. * camera // The camera to apply the render pass to.
  58358. * );
  58359. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58360. */
  58361. export class MotionBlurPostProcess extends PostProcess {
  58362. /**
  58363. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58364. */
  58365. motionStrength: number;
  58366. /**
  58367. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58368. */
  58369. /**
  58370. * Sets the number of iterations to be used for motion blur quality
  58371. */
  58372. motionBlurSamples: number;
  58373. private _motionBlurSamples;
  58374. private _geometryBufferRenderer;
  58375. /**
  58376. * Creates a new instance MotionBlurPostProcess
  58377. * @param name The name of the effect.
  58378. * @param scene The scene containing the objects to blur according to their velocity.
  58379. * @param options The required width/height ratio to downsize to before computing the render pass.
  58380. * @param camera The camera to apply the render pass to.
  58381. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58382. * @param engine The engine which the post process will be applied. (default: current engine)
  58383. * @param reusable If the post process can be reused on the same frame. (default: false)
  58384. * @param textureType Type of textures used when performing the post process. (default: 0)
  58385. * @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)
  58386. */
  58387. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58388. /**
  58389. * Excludes the given skinned mesh from computing bones velocities.
  58390. * 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.
  58391. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58392. */
  58393. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58394. /**
  58395. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58396. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58397. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58398. */
  58399. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58400. /**
  58401. * Disposes the post process.
  58402. * @param camera The camera to dispose the post process on.
  58403. */
  58404. dispose(camera?: Camera): void;
  58405. }
  58406. }
  58407. declare module "babylonjs/Shaders/refraction.fragment" {
  58408. /** @hidden */
  58409. export var refractionPixelShader: {
  58410. name: string;
  58411. shader: string;
  58412. };
  58413. }
  58414. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  58415. import { Color3 } from "babylonjs/Maths/math";
  58416. import { Camera } from "babylonjs/Cameras/camera";
  58417. import { Texture } from "babylonjs/Materials/Textures/texture";
  58418. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58419. import { Engine } from "babylonjs/Engines/engine";
  58420. import "babylonjs/Shaders/refraction.fragment";
  58421. /**
  58422. * Post process which applies a refractin texture
  58423. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58424. */
  58425. export class RefractionPostProcess extends PostProcess {
  58426. /** the base color of the refraction (used to taint the rendering) */
  58427. color: Color3;
  58428. /** simulated refraction depth */
  58429. depth: number;
  58430. /** the coefficient of the base color (0 to remove base color tainting) */
  58431. colorLevel: number;
  58432. private _refTexture;
  58433. private _ownRefractionTexture;
  58434. /**
  58435. * Gets or sets the refraction texture
  58436. * Please note that you are responsible for disposing the texture if you set it manually
  58437. */
  58438. refractionTexture: Texture;
  58439. /**
  58440. * Initializes the RefractionPostProcess
  58441. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58442. * @param name The name of the effect.
  58443. * @param refractionTextureUrl Url of the refraction texture to use
  58444. * @param color the base color of the refraction (used to taint the rendering)
  58445. * @param depth simulated refraction depth
  58446. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58447. * @param camera The camera to apply the render pass to.
  58448. * @param options The required width/height ratio to downsize to before computing the render pass.
  58449. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58450. * @param engine The engine which the post process will be applied. (default: current engine)
  58451. * @param reusable If the post process can be reused on the same frame. (default: false)
  58452. */
  58453. constructor(name: string, refractionTextureUrl: string,
  58454. /** the base color of the refraction (used to taint the rendering) */
  58455. color: Color3,
  58456. /** simulated refraction depth */
  58457. depth: number,
  58458. /** the coefficient of the base color (0 to remove base color tainting) */
  58459. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58460. /**
  58461. * Disposes of the post process
  58462. * @param camera Camera to dispose post process on
  58463. */
  58464. dispose(camera: Camera): void;
  58465. }
  58466. }
  58467. declare module "babylonjs/Shaders/sharpen.fragment" {
  58468. /** @hidden */
  58469. export var sharpenPixelShader: {
  58470. name: string;
  58471. shader: string;
  58472. };
  58473. }
  58474. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  58475. import { Nullable } from "babylonjs/types";
  58476. import { Camera } from "babylonjs/Cameras/camera";
  58477. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58478. import "babylonjs/Shaders/sharpen.fragment";
  58479. import { Engine } from "babylonjs/Engines/engine";
  58480. /**
  58481. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58482. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58483. */
  58484. export class SharpenPostProcess extends PostProcess {
  58485. /**
  58486. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58487. */
  58488. colorAmount: number;
  58489. /**
  58490. * How much sharpness should be applied (default: 0.3)
  58491. */
  58492. edgeAmount: number;
  58493. /**
  58494. * Creates a new instance ConvolutionPostProcess
  58495. * @param name The name of the effect.
  58496. * @param options The required width/height ratio to downsize to before computing the render pass.
  58497. * @param camera The camera to apply the render pass to.
  58498. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58499. * @param engine The engine which the post process will be applied. (default: current engine)
  58500. * @param reusable If the post process can be reused on the same frame. (default: false)
  58501. * @param textureType Type of textures used when performing the post process. (default: 0)
  58502. * @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)
  58503. */
  58504. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58505. }
  58506. }
  58507. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  58508. import { Nullable } from "babylonjs/types";
  58509. import { Camera } from "babylonjs/Cameras/camera";
  58510. import { Engine } from "babylonjs/Engines/engine";
  58511. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58512. import { IInspectable } from "babylonjs/Misc/iInspectable";
  58513. /**
  58514. * PostProcessRenderPipeline
  58515. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58516. */
  58517. export class PostProcessRenderPipeline {
  58518. private engine;
  58519. private _renderEffects;
  58520. private _renderEffectsForIsolatedPass;
  58521. /**
  58522. * List of inspectable custom properties (used by the Inspector)
  58523. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58524. */
  58525. inspectableCustomProperties: IInspectable[];
  58526. /**
  58527. * @hidden
  58528. */
  58529. protected _cameras: Camera[];
  58530. /** @hidden */
  58531. _name: string;
  58532. /**
  58533. * Gets pipeline name
  58534. */
  58535. readonly name: string;
  58536. /**
  58537. * Initializes a PostProcessRenderPipeline
  58538. * @param engine engine to add the pipeline to
  58539. * @param name name of the pipeline
  58540. */
  58541. constructor(engine: Engine, name: string);
  58542. /**
  58543. * Gets the class name
  58544. * @returns "PostProcessRenderPipeline"
  58545. */
  58546. getClassName(): string;
  58547. /**
  58548. * If all the render effects in the pipeline are supported
  58549. */
  58550. readonly isSupported: boolean;
  58551. /**
  58552. * Adds an effect to the pipeline
  58553. * @param renderEffect the effect to add
  58554. */
  58555. addEffect(renderEffect: PostProcessRenderEffect): void;
  58556. /** @hidden */
  58557. _rebuild(): void;
  58558. /** @hidden */
  58559. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58560. /** @hidden */
  58561. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58562. /** @hidden */
  58563. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58564. /** @hidden */
  58565. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58566. /** @hidden */
  58567. _attachCameras(cameras: Camera, unique: boolean): void;
  58568. /** @hidden */
  58569. _attachCameras(cameras: Camera[], unique: boolean): void;
  58570. /** @hidden */
  58571. _detachCameras(cameras: Camera): void;
  58572. /** @hidden */
  58573. _detachCameras(cameras: Nullable<Camera[]>): void;
  58574. /** @hidden */
  58575. _update(): void;
  58576. /** @hidden */
  58577. _reset(): void;
  58578. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58579. /**
  58580. * Disposes of the pipeline
  58581. */
  58582. dispose(): void;
  58583. }
  58584. }
  58585. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  58586. import { Camera } from "babylonjs/Cameras/camera";
  58587. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58588. /**
  58589. * PostProcessRenderPipelineManager class
  58590. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58591. */
  58592. export class PostProcessRenderPipelineManager {
  58593. private _renderPipelines;
  58594. /**
  58595. * Initializes a PostProcessRenderPipelineManager
  58596. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58597. */
  58598. constructor();
  58599. /**
  58600. * Gets the list of supported render pipelines
  58601. */
  58602. readonly supportedPipelines: PostProcessRenderPipeline[];
  58603. /**
  58604. * Adds a pipeline to the manager
  58605. * @param renderPipeline The pipeline to add
  58606. */
  58607. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58608. /**
  58609. * Attaches a camera to the pipeline
  58610. * @param renderPipelineName The name of the pipeline to attach to
  58611. * @param cameras the camera to attach
  58612. * @param unique if the camera can be attached multiple times to the pipeline
  58613. */
  58614. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58615. /**
  58616. * Detaches a camera from the pipeline
  58617. * @param renderPipelineName The name of the pipeline to detach from
  58618. * @param cameras the camera to detach
  58619. */
  58620. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58621. /**
  58622. * Enables an effect by name on a pipeline
  58623. * @param renderPipelineName the name of the pipeline to enable the effect in
  58624. * @param renderEffectName the name of the effect to enable
  58625. * @param cameras the cameras that the effect should be enabled on
  58626. */
  58627. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58628. /**
  58629. * Disables an effect by name on a pipeline
  58630. * @param renderPipelineName the name of the pipeline to disable the effect in
  58631. * @param renderEffectName the name of the effect to disable
  58632. * @param cameras the cameras that the effect should be disabled on
  58633. */
  58634. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58635. /**
  58636. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58637. */
  58638. update(): void;
  58639. /** @hidden */
  58640. _rebuild(): void;
  58641. /**
  58642. * Disposes of the manager and pipelines
  58643. */
  58644. dispose(): void;
  58645. }
  58646. }
  58647. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  58648. import { ISceneComponent } from "babylonjs/sceneComponent";
  58649. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  58650. import { Scene } from "babylonjs/scene";
  58651. module "babylonjs/scene" {
  58652. interface Scene {
  58653. /** @hidden (Backing field) */
  58654. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58655. /**
  58656. * Gets the postprocess render pipeline manager
  58657. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58658. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58659. */
  58660. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58661. }
  58662. }
  58663. /**
  58664. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58665. */
  58666. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58667. /**
  58668. * The component name helpfull to identify the component in the list of scene components.
  58669. */
  58670. readonly name: string;
  58671. /**
  58672. * The scene the component belongs to.
  58673. */
  58674. scene: Scene;
  58675. /**
  58676. * Creates a new instance of the component for the given scene
  58677. * @param scene Defines the scene to register the component in
  58678. */
  58679. constructor(scene: Scene);
  58680. /**
  58681. * Registers the component in a given scene
  58682. */
  58683. register(): void;
  58684. /**
  58685. * Rebuilds the elements related to this component in case of
  58686. * context lost for instance.
  58687. */
  58688. rebuild(): void;
  58689. /**
  58690. * Disposes the component and the associated ressources
  58691. */
  58692. dispose(): void;
  58693. private _gatherRenderTargets;
  58694. }
  58695. }
  58696. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  58697. import { Nullable } from "babylonjs/types";
  58698. import { IAnimatable } from "babylonjs/Misc/tools";
  58699. import { Camera } from "babylonjs/Cameras/camera";
  58700. import { IDisposable } from "babylonjs/scene";
  58701. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  58702. import { Scene } from "babylonjs/scene";
  58703. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  58704. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  58705. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  58706. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  58707. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  58708. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58709. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  58710. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  58711. import { Animation } from "babylonjs/Animations/animation";
  58712. /**
  58713. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58714. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58715. */
  58716. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58717. private _scene;
  58718. private _camerasToBeAttached;
  58719. /**
  58720. * ID of the sharpen post process,
  58721. */
  58722. private readonly SharpenPostProcessId;
  58723. /**
  58724. * @ignore
  58725. * ID of the image processing post process;
  58726. */
  58727. readonly ImageProcessingPostProcessId: string;
  58728. /**
  58729. * @ignore
  58730. * ID of the Fast Approximate Anti-Aliasing post process;
  58731. */
  58732. readonly FxaaPostProcessId: string;
  58733. /**
  58734. * ID of the chromatic aberration post process,
  58735. */
  58736. private readonly ChromaticAberrationPostProcessId;
  58737. /**
  58738. * ID of the grain post process
  58739. */
  58740. private readonly GrainPostProcessId;
  58741. /**
  58742. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58743. */
  58744. sharpen: SharpenPostProcess;
  58745. private _sharpenEffect;
  58746. private bloom;
  58747. /**
  58748. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58749. */
  58750. depthOfField: DepthOfFieldEffect;
  58751. /**
  58752. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58753. */
  58754. fxaa: FxaaPostProcess;
  58755. /**
  58756. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58757. */
  58758. imageProcessing: ImageProcessingPostProcess;
  58759. /**
  58760. * Chromatic aberration post process which will shift rgb colors in the image
  58761. */
  58762. chromaticAberration: ChromaticAberrationPostProcess;
  58763. private _chromaticAberrationEffect;
  58764. /**
  58765. * Grain post process which add noise to the image
  58766. */
  58767. grain: GrainPostProcess;
  58768. private _grainEffect;
  58769. /**
  58770. * Glow post process which adds a glow to emissive areas of the image
  58771. */
  58772. private _glowLayer;
  58773. /**
  58774. * Animations which can be used to tweak settings over a period of time
  58775. */
  58776. animations: Animation[];
  58777. private _imageProcessingConfigurationObserver;
  58778. private _sharpenEnabled;
  58779. private _bloomEnabled;
  58780. private _depthOfFieldEnabled;
  58781. private _depthOfFieldBlurLevel;
  58782. private _fxaaEnabled;
  58783. private _imageProcessingEnabled;
  58784. private _defaultPipelineTextureType;
  58785. private _bloomScale;
  58786. private _chromaticAberrationEnabled;
  58787. private _grainEnabled;
  58788. private _buildAllowed;
  58789. /**
  58790. * Gets active scene
  58791. */
  58792. readonly scene: Scene;
  58793. /**
  58794. * Enable or disable the sharpen process from the pipeline
  58795. */
  58796. sharpenEnabled: boolean;
  58797. private _resizeObserver;
  58798. private _hardwareScaleLevel;
  58799. private _bloomKernel;
  58800. /**
  58801. * Specifies the size of the bloom blur kernel, relative to the final output size
  58802. */
  58803. bloomKernel: number;
  58804. /**
  58805. * Specifies the weight of the bloom in the final rendering
  58806. */
  58807. private _bloomWeight;
  58808. /**
  58809. * Specifies the luma threshold for the area that will be blurred by the bloom
  58810. */
  58811. private _bloomThreshold;
  58812. private _hdr;
  58813. /**
  58814. * The strength of the bloom.
  58815. */
  58816. bloomWeight: number;
  58817. /**
  58818. * The strength of the bloom.
  58819. */
  58820. bloomThreshold: number;
  58821. /**
  58822. * The scale of the bloom, lower value will provide better performance.
  58823. */
  58824. bloomScale: number;
  58825. /**
  58826. * Enable or disable the bloom from the pipeline
  58827. */
  58828. bloomEnabled: boolean;
  58829. private _rebuildBloom;
  58830. /**
  58831. * If the depth of field is enabled.
  58832. */
  58833. depthOfFieldEnabled: boolean;
  58834. /**
  58835. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58836. */
  58837. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58838. /**
  58839. * If the anti aliasing is enabled.
  58840. */
  58841. fxaaEnabled: boolean;
  58842. private _samples;
  58843. /**
  58844. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58845. */
  58846. samples: number;
  58847. /**
  58848. * If image processing is enabled.
  58849. */
  58850. imageProcessingEnabled: boolean;
  58851. /**
  58852. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58853. */
  58854. glowLayerEnabled: boolean;
  58855. /**
  58856. * Gets the glow layer (or null if not defined)
  58857. */
  58858. readonly glowLayer: Nullable<GlowLayer>;
  58859. /**
  58860. * Enable or disable the chromaticAberration process from the pipeline
  58861. */
  58862. chromaticAberrationEnabled: boolean;
  58863. /**
  58864. * Enable or disable the grain process from the pipeline
  58865. */
  58866. grainEnabled: boolean;
  58867. /**
  58868. * @constructor
  58869. * @param name - The rendering pipeline name (default: "")
  58870. * @param hdr - If high dynamic range textures should be used (default: true)
  58871. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58872. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58873. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58874. */
  58875. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58876. /**
  58877. * Get the class name
  58878. * @returns "DefaultRenderingPipeline"
  58879. */
  58880. getClassName(): string;
  58881. /**
  58882. * Force the compilation of the entire pipeline.
  58883. */
  58884. prepare(): void;
  58885. private _hasCleared;
  58886. private _prevPostProcess;
  58887. private _prevPrevPostProcess;
  58888. private _setAutoClearAndTextureSharing;
  58889. private _depthOfFieldSceneObserver;
  58890. private _buildPipeline;
  58891. private _disposePostProcesses;
  58892. /**
  58893. * Adds a camera to the pipeline
  58894. * @param camera the camera to be added
  58895. */
  58896. addCamera(camera: Camera): void;
  58897. /**
  58898. * Removes a camera from the pipeline
  58899. * @param camera the camera to remove
  58900. */
  58901. removeCamera(camera: Camera): void;
  58902. /**
  58903. * Dispose of the pipeline and stop all post processes
  58904. */
  58905. dispose(): void;
  58906. /**
  58907. * Serialize the rendering pipeline (Used when exporting)
  58908. * @returns the serialized object
  58909. */
  58910. serialize(): any;
  58911. /**
  58912. * Parse the serialized pipeline
  58913. * @param source Source pipeline.
  58914. * @param scene The scene to load the pipeline to.
  58915. * @param rootUrl The URL of the serialized pipeline.
  58916. * @returns An instantiated pipeline from the serialized object.
  58917. */
  58918. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58919. }
  58920. }
  58921. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  58922. /** @hidden */
  58923. export var lensHighlightsPixelShader: {
  58924. name: string;
  58925. shader: string;
  58926. };
  58927. }
  58928. declare module "babylonjs/Shaders/depthOfField.fragment" {
  58929. /** @hidden */
  58930. export var depthOfFieldPixelShader: {
  58931. name: string;
  58932. shader: string;
  58933. };
  58934. }
  58935. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  58936. import { Camera } from "babylonjs/Cameras/camera";
  58937. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58938. import { Scene } from "babylonjs/scene";
  58939. import "babylonjs/Shaders/chromaticAberration.fragment";
  58940. import "babylonjs/Shaders/lensHighlights.fragment";
  58941. import "babylonjs/Shaders/depthOfField.fragment";
  58942. /**
  58943. * BABYLON.JS Chromatic Aberration GLSL Shader
  58944. * Author: Olivier Guyot
  58945. * Separates very slightly R, G and B colors on the edges of the screen
  58946. * Inspired by Francois Tarlier & Martins Upitis
  58947. */
  58948. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58949. /**
  58950. * @ignore
  58951. * The chromatic aberration PostProcess id in the pipeline
  58952. */
  58953. LensChromaticAberrationEffect: string;
  58954. /**
  58955. * @ignore
  58956. * The highlights enhancing PostProcess id in the pipeline
  58957. */
  58958. HighlightsEnhancingEffect: string;
  58959. /**
  58960. * @ignore
  58961. * The depth-of-field PostProcess id in the pipeline
  58962. */
  58963. LensDepthOfFieldEffect: string;
  58964. private _scene;
  58965. private _depthTexture;
  58966. private _grainTexture;
  58967. private _chromaticAberrationPostProcess;
  58968. private _highlightsPostProcess;
  58969. private _depthOfFieldPostProcess;
  58970. private _edgeBlur;
  58971. private _grainAmount;
  58972. private _chromaticAberration;
  58973. private _distortion;
  58974. private _highlightsGain;
  58975. private _highlightsThreshold;
  58976. private _dofDistance;
  58977. private _dofAperture;
  58978. private _dofDarken;
  58979. private _dofPentagon;
  58980. private _blurNoise;
  58981. /**
  58982. * @constructor
  58983. *
  58984. * Effect parameters are as follow:
  58985. * {
  58986. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58987. * edge_blur: number; // from 0 to x (1 for realism)
  58988. * distortion: number; // from 0 to x (1 for realism)
  58989. * grain_amount: number; // from 0 to 1
  58990. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58991. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58992. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58993. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58994. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58995. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58996. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58997. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58998. * }
  58999. * Note: if an effect parameter is unset, effect is disabled
  59000. *
  59001. * @param name The rendering pipeline name
  59002. * @param parameters - An object containing all parameters (see above)
  59003. * @param scene The scene linked to this pipeline
  59004. * @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)
  59005. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59006. */
  59007. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59008. /**
  59009. * Get the class name
  59010. * @returns "LensRenderingPipeline"
  59011. */
  59012. getClassName(): string;
  59013. /**
  59014. * Gets associated scene
  59015. */
  59016. readonly scene: Scene;
  59017. /**
  59018. * Gets or sets the edge blur
  59019. */
  59020. edgeBlur: number;
  59021. /**
  59022. * Gets or sets the grain amount
  59023. */
  59024. grainAmount: number;
  59025. /**
  59026. * Gets or sets the chromatic aberration amount
  59027. */
  59028. chromaticAberration: number;
  59029. /**
  59030. * Gets or sets the depth of field aperture
  59031. */
  59032. dofAperture: number;
  59033. /**
  59034. * Gets or sets the edge distortion
  59035. */
  59036. edgeDistortion: number;
  59037. /**
  59038. * Gets or sets the depth of field distortion
  59039. */
  59040. dofDistortion: number;
  59041. /**
  59042. * Gets or sets the darken out of focus amount
  59043. */
  59044. darkenOutOfFocus: number;
  59045. /**
  59046. * Gets or sets a boolean indicating if blur noise is enabled
  59047. */
  59048. blurNoise: boolean;
  59049. /**
  59050. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59051. */
  59052. pentagonBokeh: boolean;
  59053. /**
  59054. * Gets or sets the highlight grain amount
  59055. */
  59056. highlightsGain: number;
  59057. /**
  59058. * Gets or sets the highlight threshold
  59059. */
  59060. highlightsThreshold: number;
  59061. /**
  59062. * Sets the amount of blur at the edges
  59063. * @param amount blur amount
  59064. */
  59065. setEdgeBlur(amount: number): void;
  59066. /**
  59067. * Sets edge blur to 0
  59068. */
  59069. disableEdgeBlur(): void;
  59070. /**
  59071. * Sets the amout of grain
  59072. * @param amount Amount of grain
  59073. */
  59074. setGrainAmount(amount: number): void;
  59075. /**
  59076. * Set grain amount to 0
  59077. */
  59078. disableGrain(): void;
  59079. /**
  59080. * Sets the chromatic aberration amount
  59081. * @param amount amount of chromatic aberration
  59082. */
  59083. setChromaticAberration(amount: number): void;
  59084. /**
  59085. * Sets chromatic aberration amount to 0
  59086. */
  59087. disableChromaticAberration(): void;
  59088. /**
  59089. * Sets the EdgeDistortion amount
  59090. * @param amount amount of EdgeDistortion
  59091. */
  59092. setEdgeDistortion(amount: number): void;
  59093. /**
  59094. * Sets edge distortion to 0
  59095. */
  59096. disableEdgeDistortion(): void;
  59097. /**
  59098. * Sets the FocusDistance amount
  59099. * @param amount amount of FocusDistance
  59100. */
  59101. setFocusDistance(amount: number): void;
  59102. /**
  59103. * Disables depth of field
  59104. */
  59105. disableDepthOfField(): void;
  59106. /**
  59107. * Sets the Aperture amount
  59108. * @param amount amount of Aperture
  59109. */
  59110. setAperture(amount: number): void;
  59111. /**
  59112. * Sets the DarkenOutOfFocus amount
  59113. * @param amount amount of DarkenOutOfFocus
  59114. */
  59115. setDarkenOutOfFocus(amount: number): void;
  59116. private _pentagonBokehIsEnabled;
  59117. /**
  59118. * Creates a pentagon bokeh effect
  59119. */
  59120. enablePentagonBokeh(): void;
  59121. /**
  59122. * Disables the pentagon bokeh effect
  59123. */
  59124. disablePentagonBokeh(): void;
  59125. /**
  59126. * Enables noise blur
  59127. */
  59128. enableNoiseBlur(): void;
  59129. /**
  59130. * Disables noise blur
  59131. */
  59132. disableNoiseBlur(): void;
  59133. /**
  59134. * Sets the HighlightsGain amount
  59135. * @param amount amount of HighlightsGain
  59136. */
  59137. setHighlightsGain(amount: number): void;
  59138. /**
  59139. * Sets the HighlightsThreshold amount
  59140. * @param amount amount of HighlightsThreshold
  59141. */
  59142. setHighlightsThreshold(amount: number): void;
  59143. /**
  59144. * Disables highlights
  59145. */
  59146. disableHighlights(): void;
  59147. /**
  59148. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59149. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59150. */
  59151. dispose(disableDepthRender?: boolean): void;
  59152. private _createChromaticAberrationPostProcess;
  59153. private _createHighlightsPostProcess;
  59154. private _createDepthOfFieldPostProcess;
  59155. private _createGrainTexture;
  59156. }
  59157. }
  59158. declare module "babylonjs/Shaders/ssao2.fragment" {
  59159. /** @hidden */
  59160. export var ssao2PixelShader: {
  59161. name: string;
  59162. shader: string;
  59163. };
  59164. }
  59165. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  59166. /** @hidden */
  59167. export var ssaoCombinePixelShader: {
  59168. name: string;
  59169. shader: string;
  59170. };
  59171. }
  59172. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  59173. import { Camera } from "babylonjs/Cameras/camera";
  59174. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59175. import { Scene } from "babylonjs/scene";
  59176. import "babylonjs/Shaders/ssao2.fragment";
  59177. import "babylonjs/Shaders/ssaoCombine.fragment";
  59178. /**
  59179. * Render pipeline to produce ssao effect
  59180. */
  59181. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59182. /**
  59183. * @ignore
  59184. * The PassPostProcess id in the pipeline that contains the original scene color
  59185. */
  59186. SSAOOriginalSceneColorEffect: string;
  59187. /**
  59188. * @ignore
  59189. * The SSAO PostProcess id in the pipeline
  59190. */
  59191. SSAORenderEffect: string;
  59192. /**
  59193. * @ignore
  59194. * The horizontal blur PostProcess id in the pipeline
  59195. */
  59196. SSAOBlurHRenderEffect: string;
  59197. /**
  59198. * @ignore
  59199. * The vertical blur PostProcess id in the pipeline
  59200. */
  59201. SSAOBlurVRenderEffect: string;
  59202. /**
  59203. * @ignore
  59204. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59205. */
  59206. SSAOCombineRenderEffect: string;
  59207. /**
  59208. * The output strength of the SSAO post-process. Default value is 1.0.
  59209. */
  59210. totalStrength: number;
  59211. /**
  59212. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59213. */
  59214. maxZ: number;
  59215. /**
  59216. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59217. */
  59218. minZAspect: number;
  59219. private _samples;
  59220. /**
  59221. * Number of samples used for the SSAO calculations. Default value is 8
  59222. */
  59223. samples: number;
  59224. private _textureSamples;
  59225. /**
  59226. * Number of samples to use for antialiasing
  59227. */
  59228. textureSamples: number;
  59229. /**
  59230. * Ratio object used for SSAO ratio and blur ratio
  59231. */
  59232. private _ratio;
  59233. /**
  59234. * Dynamically generated sphere sampler.
  59235. */
  59236. private _sampleSphere;
  59237. /**
  59238. * Blur filter offsets
  59239. */
  59240. private _samplerOffsets;
  59241. private _expensiveBlur;
  59242. /**
  59243. * If bilateral blur should be used
  59244. */
  59245. expensiveBlur: boolean;
  59246. /**
  59247. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59248. */
  59249. radius: number;
  59250. /**
  59251. * The base color of the SSAO post-process
  59252. * The final result is "base + ssao" between [0, 1]
  59253. */
  59254. base: number;
  59255. /**
  59256. * Support test.
  59257. */
  59258. static readonly IsSupported: boolean;
  59259. private _scene;
  59260. private _depthTexture;
  59261. private _normalTexture;
  59262. private _randomTexture;
  59263. private _originalColorPostProcess;
  59264. private _ssaoPostProcess;
  59265. private _blurHPostProcess;
  59266. private _blurVPostProcess;
  59267. private _ssaoCombinePostProcess;
  59268. private _firstUpdate;
  59269. /**
  59270. * Gets active scene
  59271. */
  59272. readonly scene: Scene;
  59273. /**
  59274. * @constructor
  59275. * @param name The rendering pipeline name
  59276. * @param scene The scene linked to this pipeline
  59277. * @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 }
  59278. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59279. */
  59280. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59281. /**
  59282. * Get the class name
  59283. * @returns "SSAO2RenderingPipeline"
  59284. */
  59285. getClassName(): string;
  59286. /**
  59287. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59288. */
  59289. dispose(disableGeometryBufferRenderer?: boolean): void;
  59290. private _createBlurPostProcess;
  59291. /** @hidden */
  59292. _rebuild(): void;
  59293. private _bits;
  59294. private _radicalInverse_VdC;
  59295. private _hammersley;
  59296. private _hemisphereSample_uniform;
  59297. private _generateHemisphere;
  59298. private _createSSAOPostProcess;
  59299. private _createSSAOCombinePostProcess;
  59300. private _createRandomTexture;
  59301. /**
  59302. * Serialize the rendering pipeline (Used when exporting)
  59303. * @returns the serialized object
  59304. */
  59305. serialize(): any;
  59306. /**
  59307. * Parse the serialized pipeline
  59308. * @param source Source pipeline.
  59309. * @param scene The scene to load the pipeline to.
  59310. * @param rootUrl The URL of the serialized pipeline.
  59311. * @returns An instantiated pipeline from the serialized object.
  59312. */
  59313. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59314. }
  59315. }
  59316. declare module "babylonjs/Shaders/ssao.fragment" {
  59317. /** @hidden */
  59318. export var ssaoPixelShader: {
  59319. name: string;
  59320. shader: string;
  59321. };
  59322. }
  59323. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  59324. import { Camera } from "babylonjs/Cameras/camera";
  59325. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59326. import { Scene } from "babylonjs/scene";
  59327. import "babylonjs/Shaders/ssao.fragment";
  59328. import "babylonjs/Shaders/ssaoCombine.fragment";
  59329. /**
  59330. * Render pipeline to produce ssao effect
  59331. */
  59332. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59333. /**
  59334. * @ignore
  59335. * The PassPostProcess id in the pipeline that contains the original scene color
  59336. */
  59337. SSAOOriginalSceneColorEffect: string;
  59338. /**
  59339. * @ignore
  59340. * The SSAO PostProcess id in the pipeline
  59341. */
  59342. SSAORenderEffect: string;
  59343. /**
  59344. * @ignore
  59345. * The horizontal blur PostProcess id in the pipeline
  59346. */
  59347. SSAOBlurHRenderEffect: string;
  59348. /**
  59349. * @ignore
  59350. * The vertical blur PostProcess id in the pipeline
  59351. */
  59352. SSAOBlurVRenderEffect: string;
  59353. /**
  59354. * @ignore
  59355. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59356. */
  59357. SSAOCombineRenderEffect: string;
  59358. /**
  59359. * The output strength of the SSAO post-process. Default value is 1.0.
  59360. */
  59361. totalStrength: number;
  59362. /**
  59363. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59364. */
  59365. radius: number;
  59366. /**
  59367. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59368. * Must not be equal to fallOff and superior to fallOff.
  59369. * Default value is 0.0075
  59370. */
  59371. area: number;
  59372. /**
  59373. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59374. * Must not be equal to area and inferior to area.
  59375. * Default value is 0.000001
  59376. */
  59377. fallOff: number;
  59378. /**
  59379. * The base color of the SSAO post-process
  59380. * The final result is "base + ssao" between [0, 1]
  59381. */
  59382. base: number;
  59383. private _scene;
  59384. private _depthTexture;
  59385. private _randomTexture;
  59386. private _originalColorPostProcess;
  59387. private _ssaoPostProcess;
  59388. private _blurHPostProcess;
  59389. private _blurVPostProcess;
  59390. private _ssaoCombinePostProcess;
  59391. private _firstUpdate;
  59392. /**
  59393. * Gets active scene
  59394. */
  59395. readonly scene: Scene;
  59396. /**
  59397. * @constructor
  59398. * @param name - The rendering pipeline name
  59399. * @param scene - The scene linked to this pipeline
  59400. * @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 }
  59401. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59402. */
  59403. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59404. /**
  59405. * Get the class name
  59406. * @returns "SSAORenderingPipeline"
  59407. */
  59408. getClassName(): string;
  59409. /**
  59410. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59411. */
  59412. dispose(disableDepthRender?: boolean): void;
  59413. private _createBlurPostProcess;
  59414. /** @hidden */
  59415. _rebuild(): void;
  59416. private _createSSAOPostProcess;
  59417. private _createSSAOCombinePostProcess;
  59418. private _createRandomTexture;
  59419. }
  59420. }
  59421. declare module "babylonjs/Shaders/standard.fragment" {
  59422. /** @hidden */
  59423. export var standardPixelShader: {
  59424. name: string;
  59425. shader: string;
  59426. };
  59427. }
  59428. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  59429. import { Nullable } from "babylonjs/types";
  59430. import { IAnimatable } from "babylonjs/Misc/tools";
  59431. import { Camera } from "babylonjs/Cameras/camera";
  59432. import { Texture } from "babylonjs/Materials/Textures/texture";
  59433. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59434. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59435. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59436. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59437. import { IDisposable } from "babylonjs/scene";
  59438. import { SpotLight } from "babylonjs/Lights/spotLight";
  59439. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  59440. import { Scene } from "babylonjs/scene";
  59441. import { Animation } from "babylonjs/Animations/animation";
  59442. import "babylonjs/Shaders/standard.fragment";
  59443. /**
  59444. * Standard rendering pipeline
  59445. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59446. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59447. */
  59448. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59449. /**
  59450. * Public members
  59451. */
  59452. /**
  59453. * Post-process which contains the original scene color before the pipeline applies all the effects
  59454. */
  59455. originalPostProcess: Nullable<PostProcess>;
  59456. /**
  59457. * Post-process used to down scale an image x4
  59458. */
  59459. downSampleX4PostProcess: Nullable<PostProcess>;
  59460. /**
  59461. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59462. */
  59463. brightPassPostProcess: Nullable<PostProcess>;
  59464. /**
  59465. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59466. */
  59467. blurHPostProcesses: PostProcess[];
  59468. /**
  59469. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59470. */
  59471. blurVPostProcesses: PostProcess[];
  59472. /**
  59473. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59474. */
  59475. textureAdderPostProcess: Nullable<PostProcess>;
  59476. /**
  59477. * Post-process used to create volumetric lighting effect
  59478. */
  59479. volumetricLightPostProcess: Nullable<PostProcess>;
  59480. /**
  59481. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59482. */
  59483. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59484. /**
  59485. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59486. */
  59487. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59488. /**
  59489. * Post-process used to merge the volumetric light effect and the real scene color
  59490. */
  59491. volumetricLightMergePostProces: Nullable<PostProcess>;
  59492. /**
  59493. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59494. */
  59495. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59496. /**
  59497. * Base post-process used to calculate the average luminance of the final image for HDR
  59498. */
  59499. luminancePostProcess: Nullable<PostProcess>;
  59500. /**
  59501. * Post-processes used to create down sample post-processes in order to get
  59502. * the average luminance of the final image for HDR
  59503. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59504. */
  59505. luminanceDownSamplePostProcesses: PostProcess[];
  59506. /**
  59507. * Post-process used to create a HDR effect (light adaptation)
  59508. */
  59509. hdrPostProcess: Nullable<PostProcess>;
  59510. /**
  59511. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59512. */
  59513. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59514. /**
  59515. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59516. */
  59517. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59518. /**
  59519. * Post-process used to merge the final HDR post-process and the real scene color
  59520. */
  59521. hdrFinalPostProcess: Nullable<PostProcess>;
  59522. /**
  59523. * Post-process used to create a lens flare effect
  59524. */
  59525. lensFlarePostProcess: Nullable<PostProcess>;
  59526. /**
  59527. * Post-process that merges the result of the lens flare post-process and the real scene color
  59528. */
  59529. lensFlareComposePostProcess: Nullable<PostProcess>;
  59530. /**
  59531. * Post-process used to create a motion blur effect
  59532. */
  59533. motionBlurPostProcess: Nullable<PostProcess>;
  59534. /**
  59535. * Post-process used to create a depth of field effect
  59536. */
  59537. depthOfFieldPostProcess: Nullable<PostProcess>;
  59538. /**
  59539. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59540. */
  59541. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59542. /**
  59543. * Represents the brightness threshold in order to configure the illuminated surfaces
  59544. */
  59545. brightThreshold: number;
  59546. /**
  59547. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59548. */
  59549. blurWidth: number;
  59550. /**
  59551. * Sets if the blur for highlighted surfaces must be only horizontal
  59552. */
  59553. horizontalBlur: boolean;
  59554. /**
  59555. * Gets the overall exposure used by the pipeline
  59556. */
  59557. /**
  59558. * Sets the overall exposure used by the pipeline
  59559. */
  59560. exposure: number;
  59561. /**
  59562. * Texture used typically to simulate "dirty" on camera lens
  59563. */
  59564. lensTexture: Nullable<Texture>;
  59565. /**
  59566. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59567. */
  59568. volumetricLightCoefficient: number;
  59569. /**
  59570. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59571. */
  59572. volumetricLightPower: number;
  59573. /**
  59574. * Used the set the blur intensity to smooth the volumetric lights
  59575. */
  59576. volumetricLightBlurScale: number;
  59577. /**
  59578. * Light (spot or directional) used to generate the volumetric lights rays
  59579. * The source light must have a shadow generate so the pipeline can get its
  59580. * depth map
  59581. */
  59582. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59583. /**
  59584. * For eye adaptation, represents the minimum luminance the eye can see
  59585. */
  59586. hdrMinimumLuminance: number;
  59587. /**
  59588. * For eye adaptation, represents the decrease luminance speed
  59589. */
  59590. hdrDecreaseRate: number;
  59591. /**
  59592. * For eye adaptation, represents the increase luminance speed
  59593. */
  59594. hdrIncreaseRate: number;
  59595. /**
  59596. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59597. */
  59598. /**
  59599. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59600. */
  59601. hdrAutoExposure: boolean;
  59602. /**
  59603. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59604. */
  59605. lensColorTexture: Nullable<Texture>;
  59606. /**
  59607. * The overall strengh for the lens flare effect
  59608. */
  59609. lensFlareStrength: number;
  59610. /**
  59611. * Dispersion coefficient for lens flare ghosts
  59612. */
  59613. lensFlareGhostDispersal: number;
  59614. /**
  59615. * Main lens flare halo width
  59616. */
  59617. lensFlareHaloWidth: number;
  59618. /**
  59619. * Based on the lens distortion effect, defines how much the lens flare result
  59620. * is distorted
  59621. */
  59622. lensFlareDistortionStrength: number;
  59623. /**
  59624. * Lens star texture must be used to simulate rays on the flares and is available
  59625. * in the documentation
  59626. */
  59627. lensStarTexture: Nullable<Texture>;
  59628. /**
  59629. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59630. * flare effect by taking account of the dirt texture
  59631. */
  59632. lensFlareDirtTexture: Nullable<Texture>;
  59633. /**
  59634. * Represents the focal length for the depth of field effect
  59635. */
  59636. depthOfFieldDistance: number;
  59637. /**
  59638. * Represents the blur intensity for the blurred part of the depth of field effect
  59639. */
  59640. depthOfFieldBlurWidth: number;
  59641. /**
  59642. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59643. */
  59644. /**
  59645. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59646. */
  59647. motionStrength: number;
  59648. /**
  59649. * Gets wether or not the motion blur post-process is object based or screen based.
  59650. */
  59651. /**
  59652. * Sets wether or not the motion blur post-process should be object based or screen based
  59653. */
  59654. objectBasedMotionBlur: boolean;
  59655. /**
  59656. * List of animations for the pipeline (IAnimatable implementation)
  59657. */
  59658. animations: Animation[];
  59659. /**
  59660. * Private members
  59661. */
  59662. private _scene;
  59663. private _currentDepthOfFieldSource;
  59664. private _basePostProcess;
  59665. private _fixedExposure;
  59666. private _currentExposure;
  59667. private _hdrAutoExposure;
  59668. private _hdrCurrentLuminance;
  59669. private _motionStrength;
  59670. private _isObjectBasedMotionBlur;
  59671. private _floatTextureType;
  59672. private _ratio;
  59673. private _bloomEnabled;
  59674. private _depthOfFieldEnabled;
  59675. private _vlsEnabled;
  59676. private _lensFlareEnabled;
  59677. private _hdrEnabled;
  59678. private _motionBlurEnabled;
  59679. private _fxaaEnabled;
  59680. private _motionBlurSamples;
  59681. private _volumetricLightStepsCount;
  59682. private _samples;
  59683. /**
  59684. * @ignore
  59685. * Specifies if the bloom pipeline is enabled
  59686. */
  59687. BloomEnabled: boolean;
  59688. /**
  59689. * @ignore
  59690. * Specifies if the depth of field pipeline is enabed
  59691. */
  59692. DepthOfFieldEnabled: boolean;
  59693. /**
  59694. * @ignore
  59695. * Specifies if the lens flare pipeline is enabed
  59696. */
  59697. LensFlareEnabled: boolean;
  59698. /**
  59699. * @ignore
  59700. * Specifies if the HDR pipeline is enabled
  59701. */
  59702. HDREnabled: boolean;
  59703. /**
  59704. * @ignore
  59705. * Specifies if the volumetric lights scattering effect is enabled
  59706. */
  59707. VLSEnabled: boolean;
  59708. /**
  59709. * @ignore
  59710. * Specifies if the motion blur effect is enabled
  59711. */
  59712. MotionBlurEnabled: boolean;
  59713. /**
  59714. * Specifies if anti-aliasing is enabled
  59715. */
  59716. fxaaEnabled: boolean;
  59717. /**
  59718. * Specifies the number of steps used to calculate the volumetric lights
  59719. * Typically in interval [50, 200]
  59720. */
  59721. volumetricLightStepsCount: number;
  59722. /**
  59723. * Specifies the number of samples used for the motion blur effect
  59724. * Typically in interval [16, 64]
  59725. */
  59726. motionBlurSamples: number;
  59727. /**
  59728. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59729. */
  59730. samples: number;
  59731. /**
  59732. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59733. * @constructor
  59734. * @param name The rendering pipeline name
  59735. * @param scene The scene linked to this pipeline
  59736. * @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)
  59737. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59738. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59739. */
  59740. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59741. private _buildPipeline;
  59742. private _createDownSampleX4PostProcess;
  59743. private _createBrightPassPostProcess;
  59744. private _createBlurPostProcesses;
  59745. private _createTextureAdderPostProcess;
  59746. private _createVolumetricLightPostProcess;
  59747. private _createLuminancePostProcesses;
  59748. private _createHdrPostProcess;
  59749. private _createLensFlarePostProcess;
  59750. private _createDepthOfFieldPostProcess;
  59751. private _createMotionBlurPostProcess;
  59752. private _getDepthTexture;
  59753. private _disposePostProcesses;
  59754. /**
  59755. * Dispose of the pipeline and stop all post processes
  59756. */
  59757. dispose(): void;
  59758. /**
  59759. * Serialize the rendering pipeline (Used when exporting)
  59760. * @returns the serialized object
  59761. */
  59762. serialize(): any;
  59763. /**
  59764. * Parse the serialized pipeline
  59765. * @param source Source pipeline.
  59766. * @param scene The scene to load the pipeline to.
  59767. * @param rootUrl The URL of the serialized pipeline.
  59768. * @returns An instantiated pipeline from the serialized object.
  59769. */
  59770. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59771. /**
  59772. * Luminance steps
  59773. */
  59774. static LuminanceSteps: number;
  59775. }
  59776. }
  59777. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  59778. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  59779. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  59780. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  59781. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  59782. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  59783. }
  59784. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  59785. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  59786. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59787. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59788. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59789. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59790. }
  59791. declare module "babylonjs/Shaders/tonemap.fragment" {
  59792. /** @hidden */
  59793. export var tonemapPixelShader: {
  59794. name: string;
  59795. shader: string;
  59796. };
  59797. }
  59798. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  59799. import { Camera } from "babylonjs/Cameras/camera";
  59800. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59801. import "babylonjs/Shaders/tonemap.fragment";
  59802. import { Engine } from "babylonjs/Engines/engine";
  59803. /** Defines operator used for tonemapping */
  59804. export enum TonemappingOperator {
  59805. /** Hable */
  59806. Hable = 0,
  59807. /** Reinhard */
  59808. Reinhard = 1,
  59809. /** HejiDawson */
  59810. HejiDawson = 2,
  59811. /** Photographic */
  59812. Photographic = 3
  59813. }
  59814. /**
  59815. * Defines a post process to apply tone mapping
  59816. */
  59817. export class TonemapPostProcess extends PostProcess {
  59818. private _operator;
  59819. /** Defines the required exposure adjustement */
  59820. exposureAdjustment: number;
  59821. /**
  59822. * Creates a new TonemapPostProcess
  59823. * @param name defines the name of the postprocess
  59824. * @param _operator defines the operator to use
  59825. * @param exposureAdjustment defines the required exposure adjustement
  59826. * @param camera defines the camera to use (can be null)
  59827. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59828. * @param engine defines the hosting engine (can be ignore if camera is set)
  59829. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59830. */
  59831. constructor(name: string, _operator: TonemappingOperator,
  59832. /** Defines the required exposure adjustement */
  59833. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59834. }
  59835. }
  59836. declare module "babylonjs/Shaders/depth.vertex" {
  59837. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59838. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59839. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59840. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59841. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59842. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59843. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59844. /** @hidden */
  59845. export var depthVertexShader: {
  59846. name: string;
  59847. shader: string;
  59848. };
  59849. }
  59850. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  59851. /** @hidden */
  59852. export var volumetricLightScatteringPixelShader: {
  59853. name: string;
  59854. shader: string;
  59855. };
  59856. }
  59857. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  59858. /** @hidden */
  59859. export var volumetricLightScatteringPassPixelShader: {
  59860. name: string;
  59861. shader: string;
  59862. };
  59863. }
  59864. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  59865. import { Vector3 } from "babylonjs/Maths/math";
  59866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59867. import { Mesh } from "babylonjs/Meshes/mesh";
  59868. import { Camera } from "babylonjs/Cameras/camera";
  59869. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59870. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59871. import { Scene } from "babylonjs/scene";
  59872. import "babylonjs/Meshes/Builders/planeBuilder";
  59873. import "babylonjs/Shaders/depth.vertex";
  59874. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  59875. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  59876. import { Engine } from "babylonjs/Engines/engine";
  59877. /**
  59878. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59879. */
  59880. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59881. private _volumetricLightScatteringPass;
  59882. private _volumetricLightScatteringRTT;
  59883. private _viewPort;
  59884. private _screenCoordinates;
  59885. private _cachedDefines;
  59886. /**
  59887. * If not undefined, the mesh position is computed from the attached node position
  59888. */
  59889. attachedNode: {
  59890. position: Vector3;
  59891. };
  59892. /**
  59893. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59894. */
  59895. customMeshPosition: Vector3;
  59896. /**
  59897. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59898. */
  59899. useCustomMeshPosition: boolean;
  59900. /**
  59901. * If the post-process should inverse the light scattering direction
  59902. */
  59903. invert: boolean;
  59904. /**
  59905. * The internal mesh used by the post-process
  59906. */
  59907. mesh: Mesh;
  59908. /**
  59909. * @hidden
  59910. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59911. */
  59912. useDiffuseColor: boolean;
  59913. /**
  59914. * Array containing the excluded meshes not rendered in the internal pass
  59915. */
  59916. excludedMeshes: AbstractMesh[];
  59917. /**
  59918. * Controls the overall intensity of the post-process
  59919. */
  59920. exposure: number;
  59921. /**
  59922. * Dissipates each sample's contribution in range [0, 1]
  59923. */
  59924. decay: number;
  59925. /**
  59926. * Controls the overall intensity of each sample
  59927. */
  59928. weight: number;
  59929. /**
  59930. * Controls the density of each sample
  59931. */
  59932. density: number;
  59933. /**
  59934. * @constructor
  59935. * @param name The post-process name
  59936. * @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)
  59937. * @param camera The camera that the post-process will be attached to
  59938. * @param mesh The mesh used to create the light scattering
  59939. * @param samples The post-process quality, default 100
  59940. * @param samplingModeThe post-process filtering mode
  59941. * @param engine The babylon engine
  59942. * @param reusable If the post-process is reusable
  59943. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59944. */
  59945. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59946. /**
  59947. * Returns the string "VolumetricLightScatteringPostProcess"
  59948. * @returns "VolumetricLightScatteringPostProcess"
  59949. */
  59950. getClassName(): string;
  59951. private _isReady;
  59952. /**
  59953. * Sets the new light position for light scattering effect
  59954. * @param position The new custom light position
  59955. */
  59956. setCustomMeshPosition(position: Vector3): void;
  59957. /**
  59958. * Returns the light position for light scattering effect
  59959. * @return Vector3 The custom light position
  59960. */
  59961. getCustomMeshPosition(): Vector3;
  59962. /**
  59963. * Disposes the internal assets and detaches the post-process from the camera
  59964. */
  59965. dispose(camera: Camera): void;
  59966. /**
  59967. * Returns the render target texture used by the post-process
  59968. * @return the render target texture used by the post-process
  59969. */
  59970. getPass(): RenderTargetTexture;
  59971. private _meshExcluded;
  59972. private _createPass;
  59973. private _updateMeshScreenCoordinates;
  59974. /**
  59975. * Creates a default mesh for the Volumeric Light Scattering post-process
  59976. * @param name The mesh name
  59977. * @param scene The scene where to create the mesh
  59978. * @return the default mesh
  59979. */
  59980. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59981. }
  59982. }
  59983. declare module "babylonjs/PostProcesses/index" {
  59984. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  59985. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  59986. export * from "babylonjs/PostProcesses/bloomEffect";
  59987. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  59988. export * from "babylonjs/PostProcesses/blurPostProcess";
  59989. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59990. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  59991. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  59992. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  59993. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59994. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  59995. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  59996. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  59997. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59998. export * from "babylonjs/PostProcesses/filterPostProcess";
  59999. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  60000. export * from "babylonjs/PostProcesses/grainPostProcess";
  60001. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  60002. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60003. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  60004. export * from "babylonjs/PostProcesses/passPostProcess";
  60005. export * from "babylonjs/PostProcesses/postProcess";
  60006. export * from "babylonjs/PostProcesses/postProcessManager";
  60007. export * from "babylonjs/PostProcesses/refractionPostProcess";
  60008. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  60009. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  60010. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  60011. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  60012. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  60013. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  60014. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  60015. }
  60016. declare module "babylonjs/Probes/index" {
  60017. export * from "babylonjs/Probes/reflectionProbe";
  60018. }
  60019. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  60020. import { Scene } from "babylonjs/scene";
  60021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60022. import { Color3 } from "babylonjs/Maths/math";
  60023. import { SmartArray } from "babylonjs/Misc/smartArray";
  60024. import { ISceneComponent } from "babylonjs/sceneComponent";
  60025. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  60026. import "babylonjs/Meshes/Builders/boxBuilder";
  60027. import "babylonjs/Shaders/color.fragment";
  60028. import "babylonjs/Shaders/color.vertex";
  60029. module "babylonjs/scene" {
  60030. interface Scene {
  60031. /** @hidden (Backing field) */
  60032. _boundingBoxRenderer: BoundingBoxRenderer;
  60033. /** @hidden (Backing field) */
  60034. _forceShowBoundingBoxes: boolean;
  60035. /**
  60036. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60037. */
  60038. forceShowBoundingBoxes: boolean;
  60039. /**
  60040. * Gets the bounding box renderer associated with the scene
  60041. * @returns a BoundingBoxRenderer
  60042. */
  60043. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60044. }
  60045. }
  60046. module "babylonjs/Meshes/abstractMesh" {
  60047. interface AbstractMesh {
  60048. /** @hidden (Backing field) */
  60049. _showBoundingBox: boolean;
  60050. /**
  60051. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60052. */
  60053. showBoundingBox: boolean;
  60054. }
  60055. }
  60056. /**
  60057. * Component responsible of rendering the bounding box of the meshes in a scene.
  60058. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60059. */
  60060. export class BoundingBoxRenderer implements ISceneComponent {
  60061. /**
  60062. * The component name helpfull to identify the component in the list of scene components.
  60063. */
  60064. readonly name: string;
  60065. /**
  60066. * The scene the component belongs to.
  60067. */
  60068. scene: Scene;
  60069. /**
  60070. * Color of the bounding box lines placed in front of an object
  60071. */
  60072. frontColor: Color3;
  60073. /**
  60074. * Color of the bounding box lines placed behind an object
  60075. */
  60076. backColor: Color3;
  60077. /**
  60078. * Defines if the renderer should show the back lines or not
  60079. */
  60080. showBackLines: boolean;
  60081. /**
  60082. * @hidden
  60083. */
  60084. renderList: SmartArray<BoundingBox>;
  60085. private _colorShader;
  60086. private _vertexBuffers;
  60087. private _indexBuffer;
  60088. private _fillIndexBuffer;
  60089. private _fillIndexData;
  60090. /**
  60091. * Instantiates a new bounding box renderer in a scene.
  60092. * @param scene the scene the renderer renders in
  60093. */
  60094. constructor(scene: Scene);
  60095. /**
  60096. * Registers the component in a given scene
  60097. */
  60098. register(): void;
  60099. private _evaluateSubMesh;
  60100. private _activeMesh;
  60101. private _prepareRessources;
  60102. private _createIndexBuffer;
  60103. /**
  60104. * Rebuilds the elements related to this component in case of
  60105. * context lost for instance.
  60106. */
  60107. rebuild(): void;
  60108. /**
  60109. * @hidden
  60110. */
  60111. reset(): void;
  60112. /**
  60113. * Render the bounding boxes of a specific rendering group
  60114. * @param renderingGroupId defines the rendering group to render
  60115. */
  60116. render(renderingGroupId: number): void;
  60117. /**
  60118. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60119. * @param mesh Define the mesh to render the occlusion bounding box for
  60120. */
  60121. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60122. /**
  60123. * Dispose and release the resources attached to this renderer.
  60124. */
  60125. dispose(): void;
  60126. }
  60127. }
  60128. declare module "babylonjs/Shaders/depth.fragment" {
  60129. /** @hidden */
  60130. export var depthPixelShader: {
  60131. name: string;
  60132. shader: string;
  60133. };
  60134. }
  60135. declare module "babylonjs/Rendering/depthRenderer" {
  60136. import { Nullable } from "babylonjs/types";
  60137. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60138. import { Scene } from "babylonjs/scene";
  60139. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60140. import { Camera } from "babylonjs/Cameras/camera";
  60141. import "babylonjs/Shaders/depth.fragment";
  60142. import "babylonjs/Shaders/depth.vertex";
  60143. /**
  60144. * This represents a depth renderer in Babylon.
  60145. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60146. */
  60147. export class DepthRenderer {
  60148. private _scene;
  60149. private _depthMap;
  60150. private _effect;
  60151. private _cachedDefines;
  60152. private _camera;
  60153. /**
  60154. * Specifiess that the depth renderer will only be used within
  60155. * the camera it is created for.
  60156. * This can help forcing its rendering during the camera processing.
  60157. */
  60158. useOnlyInActiveCamera: boolean;
  60159. /** @hidden */
  60160. static _SceneComponentInitialization: (scene: Scene) => void;
  60161. /**
  60162. * Instantiates a depth renderer
  60163. * @param scene The scene the renderer belongs to
  60164. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60165. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60166. */
  60167. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  60168. /**
  60169. * Creates the depth rendering effect and checks if the effect is ready.
  60170. * @param subMesh The submesh to be used to render the depth map of
  60171. * @param useInstances If multiple world instances should be used
  60172. * @returns if the depth renderer is ready to render the depth map
  60173. */
  60174. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60175. /**
  60176. * Gets the texture which the depth map will be written to.
  60177. * @returns The depth map texture
  60178. */
  60179. getDepthMap(): RenderTargetTexture;
  60180. /**
  60181. * Disposes of the depth renderer.
  60182. */
  60183. dispose(): void;
  60184. }
  60185. }
  60186. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  60187. import { Nullable } from "babylonjs/types";
  60188. import { Scene } from "babylonjs/scene";
  60189. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60190. import { Camera } from "babylonjs/Cameras/camera";
  60191. import { ISceneComponent } from "babylonjs/sceneComponent";
  60192. module "babylonjs/scene" {
  60193. interface Scene {
  60194. /** @hidden (Backing field) */
  60195. _depthRenderer: {
  60196. [id: string]: DepthRenderer;
  60197. };
  60198. /**
  60199. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60200. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60201. * @returns the created depth renderer
  60202. */
  60203. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  60204. /**
  60205. * Disables a depth renderer for a given camera
  60206. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60207. */
  60208. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60209. }
  60210. }
  60211. /**
  60212. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60213. * in several rendering techniques.
  60214. */
  60215. export class DepthRendererSceneComponent implements ISceneComponent {
  60216. /**
  60217. * The component name helpfull to identify the component in the list of scene components.
  60218. */
  60219. readonly name: string;
  60220. /**
  60221. * The scene the component belongs to.
  60222. */
  60223. scene: Scene;
  60224. /**
  60225. * Creates a new instance of the component for the given scene
  60226. * @param scene Defines the scene to register the component in
  60227. */
  60228. constructor(scene: Scene);
  60229. /**
  60230. * Registers the component in a given scene
  60231. */
  60232. register(): void;
  60233. /**
  60234. * Rebuilds the elements related to this component in case of
  60235. * context lost for instance.
  60236. */
  60237. rebuild(): void;
  60238. /**
  60239. * Disposes the component and the associated ressources
  60240. */
  60241. dispose(): void;
  60242. private _gatherRenderTargets;
  60243. private _gatherActiveCameraRenderTargets;
  60244. }
  60245. }
  60246. declare module "babylonjs/Shaders/outline.fragment" {
  60247. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60248. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  60249. /** @hidden */
  60250. export var outlinePixelShader: {
  60251. name: string;
  60252. shader: string;
  60253. };
  60254. }
  60255. declare module "babylonjs/Shaders/outline.vertex" {
  60256. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60257. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60258. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60259. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60260. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60261. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60262. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60263. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60264. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  60265. /** @hidden */
  60266. export var outlineVertexShader: {
  60267. name: string;
  60268. shader: string;
  60269. };
  60270. }
  60271. declare module "babylonjs/Rendering/outlineRenderer" {
  60272. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60273. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  60274. import { Scene } from "babylonjs/scene";
  60275. import { ISceneComponent } from "babylonjs/sceneComponent";
  60276. import "babylonjs/Shaders/outline.fragment";
  60277. import "babylonjs/Shaders/outline.vertex";
  60278. module "babylonjs/scene" {
  60279. interface Scene {
  60280. /** @hidden */
  60281. _outlineRenderer: OutlineRenderer;
  60282. /**
  60283. * Gets the outline renderer associated with the scene
  60284. * @returns a OutlineRenderer
  60285. */
  60286. getOutlineRenderer(): OutlineRenderer;
  60287. }
  60288. }
  60289. module "babylonjs/Meshes/abstractMesh" {
  60290. interface AbstractMesh {
  60291. /** @hidden (Backing field) */
  60292. _renderOutline: boolean;
  60293. /**
  60294. * Gets or sets a boolean indicating if the outline must be rendered as well
  60295. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60296. */
  60297. renderOutline: boolean;
  60298. /** @hidden (Backing field) */
  60299. _renderOverlay: boolean;
  60300. /**
  60301. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60302. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60303. */
  60304. renderOverlay: boolean;
  60305. }
  60306. }
  60307. /**
  60308. * This class is responsible to draw bothe outline/overlay of meshes.
  60309. * It should not be used directly but through the available method on mesh.
  60310. */
  60311. export class OutlineRenderer implements ISceneComponent {
  60312. /**
  60313. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60314. */
  60315. private static _StencilReference;
  60316. /**
  60317. * The name of the component. Each component must have a unique name.
  60318. */
  60319. name: string;
  60320. /**
  60321. * The scene the component belongs to.
  60322. */
  60323. scene: Scene;
  60324. /**
  60325. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60326. */
  60327. zOffset: number;
  60328. private _engine;
  60329. private _effect;
  60330. private _cachedDefines;
  60331. private _savedDepthWrite;
  60332. /**
  60333. * Instantiates a new outline renderer. (There could be only one per scene).
  60334. * @param scene Defines the scene it belongs to
  60335. */
  60336. constructor(scene: Scene);
  60337. /**
  60338. * Register the component to one instance of a scene.
  60339. */
  60340. register(): void;
  60341. /**
  60342. * Rebuilds the elements related to this component in case of
  60343. * context lost for instance.
  60344. */
  60345. rebuild(): void;
  60346. /**
  60347. * Disposes the component and the associated ressources.
  60348. */
  60349. dispose(): void;
  60350. /**
  60351. * Renders the outline in the canvas.
  60352. * @param subMesh Defines the sumesh to render
  60353. * @param batch Defines the batch of meshes in case of instances
  60354. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60355. */
  60356. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60357. /**
  60358. * Returns whether or not the outline renderer is ready for a given submesh.
  60359. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60360. * @param subMesh Defines the submesh to check readyness for
  60361. * @param useInstances Defines wheter wee are trying to render instances or not
  60362. * @returns true if ready otherwise false
  60363. */
  60364. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60365. private _beforeRenderingMesh;
  60366. private _afterRenderingMesh;
  60367. }
  60368. }
  60369. declare module "babylonjs/Rendering/index" {
  60370. export * from "babylonjs/Rendering/boundingBoxRenderer";
  60371. export * from "babylonjs/Rendering/depthRenderer";
  60372. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  60373. export * from "babylonjs/Rendering/edgesRenderer";
  60374. export * from "babylonjs/Rendering/geometryBufferRenderer";
  60375. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60376. export * from "babylonjs/Rendering/outlineRenderer";
  60377. export * from "babylonjs/Rendering/renderingGroup";
  60378. export * from "babylonjs/Rendering/renderingManager";
  60379. export * from "babylonjs/Rendering/utilityLayerRenderer";
  60380. }
  60381. declare module "babylonjs/Sprites/index" {
  60382. export * from "babylonjs/Sprites/sprite";
  60383. export * from "babylonjs/Sprites/spriteManager";
  60384. export * from "babylonjs/Sprites/spriteSceneComponent";
  60385. }
  60386. declare module "babylonjs/Misc/assetsManager" {
  60387. import { Scene } from "babylonjs/scene";
  60388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60389. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60390. import { Skeleton } from "babylonjs/Bones/skeleton";
  60391. import { Observable } from "babylonjs/Misc/observable";
  60392. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60393. import { Texture } from "babylonjs/Materials/Textures/texture";
  60394. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  60395. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  60396. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60397. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  60398. /**
  60399. * Defines the list of states available for a task inside a AssetsManager
  60400. */
  60401. export enum AssetTaskState {
  60402. /**
  60403. * Initialization
  60404. */
  60405. INIT = 0,
  60406. /**
  60407. * Running
  60408. */
  60409. RUNNING = 1,
  60410. /**
  60411. * Done
  60412. */
  60413. DONE = 2,
  60414. /**
  60415. * Error
  60416. */
  60417. ERROR = 3
  60418. }
  60419. /**
  60420. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60421. */
  60422. export abstract class AbstractAssetTask {
  60423. /**
  60424. * Task name
  60425. */ name: string;
  60426. /**
  60427. * Callback called when the task is successful
  60428. */
  60429. onSuccess: (task: any) => void;
  60430. /**
  60431. * Callback called when the task is not successful
  60432. */
  60433. onError: (task: any, message?: string, exception?: any) => void;
  60434. /**
  60435. * Creates a new AssetsManager
  60436. * @param name defines the name of the task
  60437. */
  60438. constructor(
  60439. /**
  60440. * Task name
  60441. */ name: string);
  60442. private _isCompleted;
  60443. private _taskState;
  60444. private _errorObject;
  60445. /**
  60446. * Get if the task is completed
  60447. */
  60448. readonly isCompleted: boolean;
  60449. /**
  60450. * Gets the current state of the task
  60451. */
  60452. readonly taskState: AssetTaskState;
  60453. /**
  60454. * Gets the current error object (if task is in error)
  60455. */
  60456. readonly errorObject: {
  60457. message?: string;
  60458. exception?: any;
  60459. };
  60460. /**
  60461. * Internal only
  60462. * @hidden
  60463. */
  60464. _setErrorObject(message?: string, exception?: any): void;
  60465. /**
  60466. * Execute the current task
  60467. * @param scene defines the scene where you want your assets to be loaded
  60468. * @param onSuccess is a callback called when the task is successfully executed
  60469. * @param onError is a callback called if an error occurs
  60470. */
  60471. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60472. /**
  60473. * Execute the current task
  60474. * @param scene defines the scene where you want your assets to be loaded
  60475. * @param onSuccess is a callback called when the task is successfully executed
  60476. * @param onError is a callback called if an error occurs
  60477. */
  60478. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60479. /**
  60480. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60481. * This can be used with failed tasks that have the reason for failure fixed.
  60482. */
  60483. reset(): void;
  60484. private onErrorCallback;
  60485. private onDoneCallback;
  60486. }
  60487. /**
  60488. * Define the interface used by progress events raised during assets loading
  60489. */
  60490. export interface IAssetsProgressEvent {
  60491. /**
  60492. * Defines the number of remaining tasks to process
  60493. */
  60494. remainingCount: number;
  60495. /**
  60496. * Defines the total number of tasks
  60497. */
  60498. totalCount: number;
  60499. /**
  60500. * Defines the task that was just processed
  60501. */
  60502. task: AbstractAssetTask;
  60503. }
  60504. /**
  60505. * Class used to share progress information about assets loading
  60506. */
  60507. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60508. /**
  60509. * Defines the number of remaining tasks to process
  60510. */
  60511. remainingCount: number;
  60512. /**
  60513. * Defines the total number of tasks
  60514. */
  60515. totalCount: number;
  60516. /**
  60517. * Defines the task that was just processed
  60518. */
  60519. task: AbstractAssetTask;
  60520. /**
  60521. * Creates a AssetsProgressEvent
  60522. * @param remainingCount defines the number of remaining tasks to process
  60523. * @param totalCount defines the total number of tasks
  60524. * @param task defines the task that was just processed
  60525. */
  60526. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60527. }
  60528. /**
  60529. * Define a task used by AssetsManager to load meshes
  60530. */
  60531. export class MeshAssetTask extends AbstractAssetTask {
  60532. /**
  60533. * Defines the name of the task
  60534. */
  60535. name: string;
  60536. /**
  60537. * Defines the list of mesh's names you want to load
  60538. */
  60539. meshesNames: any;
  60540. /**
  60541. * Defines the root url to use as a base to load your meshes and associated resources
  60542. */
  60543. rootUrl: string;
  60544. /**
  60545. * Defines the filename of the scene to load from
  60546. */
  60547. sceneFilename: string;
  60548. /**
  60549. * Gets the list of loaded meshes
  60550. */
  60551. loadedMeshes: Array<AbstractMesh>;
  60552. /**
  60553. * Gets the list of loaded particle systems
  60554. */
  60555. loadedParticleSystems: Array<IParticleSystem>;
  60556. /**
  60557. * Gets the list of loaded skeletons
  60558. */
  60559. loadedSkeletons: Array<Skeleton>;
  60560. /**
  60561. * Gets the list of loaded animation groups
  60562. */
  60563. loadedAnimationGroups: Array<AnimationGroup>;
  60564. /**
  60565. * Callback called when the task is successful
  60566. */
  60567. onSuccess: (task: MeshAssetTask) => void;
  60568. /**
  60569. * Callback called when the task is successful
  60570. */
  60571. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60572. /**
  60573. * Creates a new MeshAssetTask
  60574. * @param name defines the name of the task
  60575. * @param meshesNames defines the list of mesh's names you want to load
  60576. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60577. * @param sceneFilename defines the filename of the scene to load from
  60578. */
  60579. constructor(
  60580. /**
  60581. * Defines the name of the task
  60582. */
  60583. name: string,
  60584. /**
  60585. * Defines the list of mesh's names you want to load
  60586. */
  60587. meshesNames: any,
  60588. /**
  60589. * Defines the root url to use as a base to load your meshes and associated resources
  60590. */
  60591. rootUrl: string,
  60592. /**
  60593. * Defines the filename of the scene to load from
  60594. */
  60595. sceneFilename: string);
  60596. /**
  60597. * Execute the current task
  60598. * @param scene defines the scene where you want your assets to be loaded
  60599. * @param onSuccess is a callback called when the task is successfully executed
  60600. * @param onError is a callback called if an error occurs
  60601. */
  60602. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60603. }
  60604. /**
  60605. * Define a task used by AssetsManager to load text content
  60606. */
  60607. export class TextFileAssetTask extends AbstractAssetTask {
  60608. /**
  60609. * Defines the name of the task
  60610. */
  60611. name: string;
  60612. /**
  60613. * Defines the location of the file to load
  60614. */
  60615. url: string;
  60616. /**
  60617. * Gets the loaded text string
  60618. */
  60619. text: string;
  60620. /**
  60621. * Callback called when the task is successful
  60622. */
  60623. onSuccess: (task: TextFileAssetTask) => void;
  60624. /**
  60625. * Callback called when the task is successful
  60626. */
  60627. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60628. /**
  60629. * Creates a new TextFileAssetTask object
  60630. * @param name defines the name of the task
  60631. * @param url defines the location of the file to load
  60632. */
  60633. constructor(
  60634. /**
  60635. * Defines the name of the task
  60636. */
  60637. name: string,
  60638. /**
  60639. * Defines the location of the file to load
  60640. */
  60641. url: string);
  60642. /**
  60643. * Execute the current task
  60644. * @param scene defines the scene where you want your assets to be loaded
  60645. * @param onSuccess is a callback called when the task is successfully executed
  60646. * @param onError is a callback called if an error occurs
  60647. */
  60648. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60649. }
  60650. /**
  60651. * Define a task used by AssetsManager to load binary data
  60652. */
  60653. export class BinaryFileAssetTask extends AbstractAssetTask {
  60654. /**
  60655. * Defines the name of the task
  60656. */
  60657. name: string;
  60658. /**
  60659. * Defines the location of the file to load
  60660. */
  60661. url: string;
  60662. /**
  60663. * Gets the lodaded data (as an array buffer)
  60664. */
  60665. data: ArrayBuffer;
  60666. /**
  60667. * Callback called when the task is successful
  60668. */
  60669. onSuccess: (task: BinaryFileAssetTask) => void;
  60670. /**
  60671. * Callback called when the task is successful
  60672. */
  60673. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60674. /**
  60675. * Creates a new BinaryFileAssetTask object
  60676. * @param name defines the name of the new task
  60677. * @param url defines the location of the file to load
  60678. */
  60679. constructor(
  60680. /**
  60681. * Defines the name of the task
  60682. */
  60683. name: string,
  60684. /**
  60685. * Defines the location of the file to load
  60686. */
  60687. url: string);
  60688. /**
  60689. * Execute the current task
  60690. * @param scene defines the scene where you want your assets to be loaded
  60691. * @param onSuccess is a callback called when the task is successfully executed
  60692. * @param onError is a callback called if an error occurs
  60693. */
  60694. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60695. }
  60696. /**
  60697. * Define a task used by AssetsManager to load images
  60698. */
  60699. export class ImageAssetTask extends AbstractAssetTask {
  60700. /**
  60701. * Defines the name of the task
  60702. */
  60703. name: string;
  60704. /**
  60705. * Defines the location of the image to load
  60706. */
  60707. url: string;
  60708. /**
  60709. * Gets the loaded images
  60710. */
  60711. image: HTMLImageElement;
  60712. /**
  60713. * Callback called when the task is successful
  60714. */
  60715. onSuccess: (task: ImageAssetTask) => void;
  60716. /**
  60717. * Callback called when the task is successful
  60718. */
  60719. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60720. /**
  60721. * Creates a new ImageAssetTask
  60722. * @param name defines the name of the task
  60723. * @param url defines the location of the image to load
  60724. */
  60725. constructor(
  60726. /**
  60727. * Defines the name of the task
  60728. */
  60729. name: string,
  60730. /**
  60731. * Defines the location of the image to load
  60732. */
  60733. url: string);
  60734. /**
  60735. * Execute the current task
  60736. * @param scene defines the scene where you want your assets to be loaded
  60737. * @param onSuccess is a callback called when the task is successfully executed
  60738. * @param onError is a callback called if an error occurs
  60739. */
  60740. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60741. }
  60742. /**
  60743. * Defines the interface used by texture loading tasks
  60744. */
  60745. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60746. /**
  60747. * Gets the loaded texture
  60748. */
  60749. texture: TEX;
  60750. }
  60751. /**
  60752. * Define a task used by AssetsManager to load 2D textures
  60753. */
  60754. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60755. /**
  60756. * Defines the name of the task
  60757. */
  60758. name: string;
  60759. /**
  60760. * Defines the location of the file to load
  60761. */
  60762. url: string;
  60763. /**
  60764. * Defines if mipmap should not be generated (default is false)
  60765. */
  60766. noMipmap?: boolean | undefined;
  60767. /**
  60768. * Defines if texture must be inverted on Y axis (default is false)
  60769. */
  60770. invertY?: boolean | undefined;
  60771. /**
  60772. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60773. */
  60774. samplingMode: number;
  60775. /**
  60776. * Gets the loaded texture
  60777. */
  60778. texture: Texture;
  60779. /**
  60780. * Callback called when the task is successful
  60781. */
  60782. onSuccess: (task: TextureAssetTask) => void;
  60783. /**
  60784. * Callback called when the task is successful
  60785. */
  60786. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60787. /**
  60788. * Creates a new TextureAssetTask object
  60789. * @param name defines the name of the task
  60790. * @param url defines the location of the file to load
  60791. * @param noMipmap defines if mipmap should not be generated (default is false)
  60792. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60793. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60794. */
  60795. constructor(
  60796. /**
  60797. * Defines the name of the task
  60798. */
  60799. name: string,
  60800. /**
  60801. * Defines the location of the file to load
  60802. */
  60803. url: string,
  60804. /**
  60805. * Defines if mipmap should not be generated (default is false)
  60806. */
  60807. noMipmap?: boolean | undefined,
  60808. /**
  60809. * Defines if texture must be inverted on Y axis (default is false)
  60810. */
  60811. invertY?: boolean | undefined,
  60812. /**
  60813. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60814. */
  60815. samplingMode?: number);
  60816. /**
  60817. * Execute the current task
  60818. * @param scene defines the scene where you want your assets to be loaded
  60819. * @param onSuccess is a callback called when the task is successfully executed
  60820. * @param onError is a callback called if an error occurs
  60821. */
  60822. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60823. }
  60824. /**
  60825. * Define a task used by AssetsManager to load cube textures
  60826. */
  60827. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60828. /**
  60829. * Defines the name of the task
  60830. */
  60831. name: string;
  60832. /**
  60833. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60834. */
  60835. url: string;
  60836. /**
  60837. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60838. */
  60839. extensions?: string[] | undefined;
  60840. /**
  60841. * Defines if mipmaps should not be generated (default is false)
  60842. */
  60843. noMipmap?: boolean | undefined;
  60844. /**
  60845. * Defines the explicit list of files (undefined by default)
  60846. */
  60847. files?: string[] | undefined;
  60848. /**
  60849. * Gets the loaded texture
  60850. */
  60851. texture: CubeTexture;
  60852. /**
  60853. * Callback called when the task is successful
  60854. */
  60855. onSuccess: (task: CubeTextureAssetTask) => void;
  60856. /**
  60857. * Callback called when the task is successful
  60858. */
  60859. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60860. /**
  60861. * Creates a new CubeTextureAssetTask
  60862. * @param name defines the name of the task
  60863. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60864. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60865. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60866. * @param files defines the explicit list of files (undefined by default)
  60867. */
  60868. constructor(
  60869. /**
  60870. * Defines the name of the task
  60871. */
  60872. name: string,
  60873. /**
  60874. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60875. */
  60876. url: string,
  60877. /**
  60878. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60879. */
  60880. extensions?: string[] | undefined,
  60881. /**
  60882. * Defines if mipmaps should not be generated (default is false)
  60883. */
  60884. noMipmap?: boolean | undefined,
  60885. /**
  60886. * Defines the explicit list of files (undefined by default)
  60887. */
  60888. files?: string[] | undefined);
  60889. /**
  60890. * Execute the current task
  60891. * @param scene defines the scene where you want your assets to be loaded
  60892. * @param onSuccess is a callback called when the task is successfully executed
  60893. * @param onError is a callback called if an error occurs
  60894. */
  60895. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60896. }
  60897. /**
  60898. * Define a task used by AssetsManager to load HDR cube textures
  60899. */
  60900. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60901. /**
  60902. * Defines the name of the task
  60903. */
  60904. name: string;
  60905. /**
  60906. * Defines the location of the file to load
  60907. */
  60908. url: string;
  60909. /**
  60910. * Defines the desired size (the more it increases the longer the generation will be)
  60911. */
  60912. size: number;
  60913. /**
  60914. * Defines if mipmaps should not be generated (default is false)
  60915. */
  60916. noMipmap: boolean;
  60917. /**
  60918. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60919. */
  60920. generateHarmonics: boolean;
  60921. /**
  60922. * 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)
  60923. */
  60924. gammaSpace: boolean;
  60925. /**
  60926. * Internal Use Only
  60927. */
  60928. reserved: boolean;
  60929. /**
  60930. * Gets the loaded texture
  60931. */
  60932. texture: HDRCubeTexture;
  60933. /**
  60934. * Callback called when the task is successful
  60935. */
  60936. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60937. /**
  60938. * Callback called when the task is successful
  60939. */
  60940. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60941. /**
  60942. * Creates a new HDRCubeTextureAssetTask object
  60943. * @param name defines the name of the task
  60944. * @param url defines the location of the file to load
  60945. * @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.
  60946. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60947. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60948. * @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)
  60949. * @param reserved Internal use only
  60950. */
  60951. constructor(
  60952. /**
  60953. * Defines the name of the task
  60954. */
  60955. name: string,
  60956. /**
  60957. * Defines the location of the file to load
  60958. */
  60959. url: string,
  60960. /**
  60961. * Defines the desired size (the more it increases the longer the generation will be)
  60962. */
  60963. size: number,
  60964. /**
  60965. * Defines if mipmaps should not be generated (default is false)
  60966. */
  60967. noMipmap?: boolean,
  60968. /**
  60969. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60970. */
  60971. generateHarmonics?: boolean,
  60972. /**
  60973. * 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)
  60974. */
  60975. gammaSpace?: boolean,
  60976. /**
  60977. * Internal Use Only
  60978. */
  60979. reserved?: boolean);
  60980. /**
  60981. * Execute the current task
  60982. * @param scene defines the scene where you want your assets to be loaded
  60983. * @param onSuccess is a callback called when the task is successfully executed
  60984. * @param onError is a callback called if an error occurs
  60985. */
  60986. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60987. }
  60988. /**
  60989. * Define a task used by AssetsManager to load Equirectangular cube textures
  60990. */
  60991. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60992. /**
  60993. * Defines the name of the task
  60994. */
  60995. name: string;
  60996. /**
  60997. * Defines the location of the file to load
  60998. */
  60999. url: string;
  61000. /**
  61001. * Defines the desired size (the more it increases the longer the generation will be)
  61002. */
  61003. size: number;
  61004. /**
  61005. * Defines if mipmaps should not be generated (default is false)
  61006. */
  61007. noMipmap: boolean;
  61008. /**
  61009. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61010. * but the standard material would require them in Gamma space) (default is true)
  61011. */
  61012. gammaSpace: boolean;
  61013. /**
  61014. * Gets the loaded texture
  61015. */
  61016. texture: EquiRectangularCubeTexture;
  61017. /**
  61018. * Callback called when the task is successful
  61019. */
  61020. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61021. /**
  61022. * Callback called when the task is successful
  61023. */
  61024. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61025. /**
  61026. * Creates a new EquiRectangularCubeTextureAssetTask object
  61027. * @param name defines the name of the task
  61028. * @param url defines the location of the file to load
  61029. * @param size defines the desired size (the more it increases the longer the generation will be)
  61030. * If the size is omitted this implies you are using a preprocessed cubemap.
  61031. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61032. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61033. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61034. * (default is true)
  61035. */
  61036. constructor(
  61037. /**
  61038. * Defines the name of the task
  61039. */
  61040. name: string,
  61041. /**
  61042. * Defines the location of the file to load
  61043. */
  61044. url: string,
  61045. /**
  61046. * Defines the desired size (the more it increases the longer the generation will be)
  61047. */
  61048. size: number,
  61049. /**
  61050. * Defines if mipmaps should not be generated (default is false)
  61051. */
  61052. noMipmap?: boolean,
  61053. /**
  61054. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61055. * but the standard material would require them in Gamma space) (default is true)
  61056. */
  61057. gammaSpace?: boolean);
  61058. /**
  61059. * Execute the current task
  61060. * @param scene defines the scene where you want your assets to be loaded
  61061. * @param onSuccess is a callback called when the task is successfully executed
  61062. * @param onError is a callback called if an error occurs
  61063. */
  61064. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61065. }
  61066. /**
  61067. * This class can be used to easily import assets into a scene
  61068. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61069. */
  61070. export class AssetsManager {
  61071. private _scene;
  61072. private _isLoading;
  61073. protected _tasks: AbstractAssetTask[];
  61074. protected _waitingTasksCount: number;
  61075. protected _totalTasksCount: number;
  61076. /**
  61077. * Callback called when all tasks are processed
  61078. */
  61079. onFinish: (tasks: AbstractAssetTask[]) => void;
  61080. /**
  61081. * Callback called when a task is successful
  61082. */
  61083. onTaskSuccess: (task: AbstractAssetTask) => void;
  61084. /**
  61085. * Callback called when a task had an error
  61086. */
  61087. onTaskError: (task: AbstractAssetTask) => void;
  61088. /**
  61089. * Callback called when a task is done (whatever the result is)
  61090. */
  61091. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61092. /**
  61093. * Observable called when all tasks are processed
  61094. */
  61095. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61096. /**
  61097. * Observable called when a task had an error
  61098. */
  61099. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61100. /**
  61101. * Observable called when all tasks were executed
  61102. */
  61103. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61104. /**
  61105. * Observable called when a task is done (whatever the result is)
  61106. */
  61107. onProgressObservable: Observable<IAssetsProgressEvent>;
  61108. /**
  61109. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61110. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61111. */
  61112. useDefaultLoadingScreen: boolean;
  61113. /**
  61114. * Creates a new AssetsManager
  61115. * @param scene defines the scene to work on
  61116. */
  61117. constructor(scene: Scene);
  61118. /**
  61119. * Add a MeshAssetTask to the list of active tasks
  61120. * @param taskName defines the name of the new task
  61121. * @param meshesNames defines the name of meshes to load
  61122. * @param rootUrl defines the root url to use to locate files
  61123. * @param sceneFilename defines the filename of the scene file
  61124. * @returns a new MeshAssetTask object
  61125. */
  61126. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61127. /**
  61128. * Add a TextFileAssetTask to the list of active tasks
  61129. * @param taskName defines the name of the new task
  61130. * @param url defines the url of the file to load
  61131. * @returns a new TextFileAssetTask object
  61132. */
  61133. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61134. /**
  61135. * Add a BinaryFileAssetTask to the list of active tasks
  61136. * @param taskName defines the name of the new task
  61137. * @param url defines the url of the file to load
  61138. * @returns a new BinaryFileAssetTask object
  61139. */
  61140. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61141. /**
  61142. * Add a ImageAssetTask to the list of active tasks
  61143. * @param taskName defines the name of the new task
  61144. * @param url defines the url of the file to load
  61145. * @returns a new ImageAssetTask object
  61146. */
  61147. addImageTask(taskName: string, url: string): ImageAssetTask;
  61148. /**
  61149. * Add a TextureAssetTask to the list of active tasks
  61150. * @param taskName defines the name of the new task
  61151. * @param url defines the url of the file to load
  61152. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61153. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61154. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61155. * @returns a new TextureAssetTask object
  61156. */
  61157. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61158. /**
  61159. * Add a CubeTextureAssetTask to the list of active tasks
  61160. * @param taskName defines the name of the new task
  61161. * @param url defines the url of the file to load
  61162. * @param extensions defines the extension to use to load the cube map (can be null)
  61163. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61164. * @param files defines the list of files to load (can be null)
  61165. * @returns a new CubeTextureAssetTask object
  61166. */
  61167. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61168. /**
  61169. *
  61170. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61171. * @param taskName defines the name of the new task
  61172. * @param url defines the url of the file to load
  61173. * @param size defines the size you want for the cubemap (can be null)
  61174. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61175. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61176. * @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)
  61177. * @param reserved Internal use only
  61178. * @returns a new HDRCubeTextureAssetTask object
  61179. */
  61180. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61181. /**
  61182. *
  61183. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61184. * @param taskName defines the name of the new task
  61185. * @param url defines the url of the file to load
  61186. * @param size defines the size you want for the cubemap (can be null)
  61187. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61188. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61189. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61190. * @returns a new EquiRectangularCubeTextureAssetTask object
  61191. */
  61192. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61193. /**
  61194. * Remove a task from the assets manager.
  61195. * @param task the task to remove
  61196. */
  61197. removeTask(task: AbstractAssetTask): void;
  61198. private _decreaseWaitingTasksCount;
  61199. private _runTask;
  61200. /**
  61201. * Reset the AssetsManager and remove all tasks
  61202. * @return the current instance of the AssetsManager
  61203. */
  61204. reset(): AssetsManager;
  61205. /**
  61206. * Start the loading process
  61207. * @return the current instance of the AssetsManager
  61208. */
  61209. load(): AssetsManager;
  61210. /**
  61211. * Start the loading process as an async operation
  61212. * @return a promise returning the list of failed tasks
  61213. */
  61214. loadAsync(): Promise<void>;
  61215. }
  61216. }
  61217. declare module "babylonjs/Misc/deferred" {
  61218. /**
  61219. * Wrapper class for promise with external resolve and reject.
  61220. */
  61221. export class Deferred<T> {
  61222. /**
  61223. * The promise associated with this deferred object.
  61224. */
  61225. readonly promise: Promise<T>;
  61226. private _resolve;
  61227. private _reject;
  61228. /**
  61229. * The resolve method of the promise associated with this deferred object.
  61230. */
  61231. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61232. /**
  61233. * The reject method of the promise associated with this deferred object.
  61234. */
  61235. readonly reject: (reason?: any) => void;
  61236. /**
  61237. * Constructor for this deferred object.
  61238. */
  61239. constructor();
  61240. }
  61241. }
  61242. declare module "babylonjs/Misc/meshExploder" {
  61243. import { Mesh } from "babylonjs/Meshes/mesh";
  61244. /**
  61245. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61246. */
  61247. export class MeshExploder {
  61248. private _centerMesh;
  61249. private _meshes;
  61250. private _meshesOrigins;
  61251. private _toCenterVectors;
  61252. private _scaledDirection;
  61253. private _newPosition;
  61254. private _centerPosition;
  61255. /**
  61256. * Explodes meshes from a center mesh.
  61257. * @param meshes The meshes to explode.
  61258. * @param centerMesh The mesh to be center of explosion.
  61259. */
  61260. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61261. private _setCenterMesh;
  61262. /**
  61263. * Get class name
  61264. * @returns "MeshExploder"
  61265. */
  61266. getClassName(): string;
  61267. /**
  61268. * "Exploded meshes"
  61269. * @returns Array of meshes with the centerMesh at index 0.
  61270. */
  61271. getMeshes(): Array<Mesh>;
  61272. /**
  61273. * Explodes meshes giving a specific direction
  61274. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61275. */
  61276. explode(direction?: number): void;
  61277. }
  61278. }
  61279. declare module "babylonjs/Misc/filesInput" {
  61280. import { Engine } from "babylonjs/Engines/engine";
  61281. import { Scene } from "babylonjs/scene";
  61282. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61283. /**
  61284. * Class used to help managing file picking and drag'n'drop
  61285. */
  61286. export class FilesInput {
  61287. /**
  61288. * List of files ready to be loaded
  61289. */
  61290. static readonly FilesToLoad: {
  61291. [key: string]: File;
  61292. };
  61293. /**
  61294. * Callback called when a file is processed
  61295. */
  61296. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61297. private _engine;
  61298. private _currentScene;
  61299. private _sceneLoadedCallback;
  61300. private _progressCallback;
  61301. private _additionalRenderLoopLogicCallback;
  61302. private _textureLoadingCallback;
  61303. private _startingProcessingFilesCallback;
  61304. private _onReloadCallback;
  61305. private _errorCallback;
  61306. private _elementToMonitor;
  61307. private _sceneFileToLoad;
  61308. private _filesToLoad;
  61309. /**
  61310. * Creates a new FilesInput
  61311. * @param engine defines the rendering engine
  61312. * @param scene defines the hosting scene
  61313. * @param sceneLoadedCallback callback called when scene is loaded
  61314. * @param progressCallback callback called to track progress
  61315. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61316. * @param textureLoadingCallback callback called when a texture is loading
  61317. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61318. * @param onReloadCallback callback called when a reload is requested
  61319. * @param errorCallback callback call if an error occurs
  61320. */
  61321. 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);
  61322. private _dragEnterHandler;
  61323. private _dragOverHandler;
  61324. private _dropHandler;
  61325. /**
  61326. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61327. * @param elementToMonitor defines the DOM element to track
  61328. */
  61329. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61330. /**
  61331. * Release all associated resources
  61332. */
  61333. dispose(): void;
  61334. private renderFunction;
  61335. private drag;
  61336. private drop;
  61337. private _traverseFolder;
  61338. private _processFiles;
  61339. /**
  61340. * Load files from a drop event
  61341. * @param event defines the drop event to use as source
  61342. */
  61343. loadFiles(event: any): void;
  61344. private _processReload;
  61345. /**
  61346. * Reload the current scene from the loaded files
  61347. */
  61348. reload(): void;
  61349. }
  61350. }
  61351. declare module "babylonjs/Misc/HighDynamicRange/index" {
  61352. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  61353. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  61354. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61355. }
  61356. declare module "babylonjs/Misc/sceneOptimizer" {
  61357. import { Scene, IDisposable } from "babylonjs/scene";
  61358. import { Observable } from "babylonjs/Misc/observable";
  61359. /**
  61360. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61361. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61362. */
  61363. export class SceneOptimization {
  61364. /**
  61365. * Defines the priority of this optimization (0 by default which means first in the list)
  61366. */
  61367. priority: number;
  61368. /**
  61369. * Gets a string describing the action executed by the current optimization
  61370. * @returns description string
  61371. */
  61372. getDescription(): string;
  61373. /**
  61374. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61375. * @param scene defines the current scene where to apply this optimization
  61376. * @param optimizer defines the current optimizer
  61377. * @returns true if everything that can be done was applied
  61378. */
  61379. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61380. /**
  61381. * Creates the SceneOptimization object
  61382. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61383. * @param desc defines the description associated with the optimization
  61384. */
  61385. constructor(
  61386. /**
  61387. * Defines the priority of this optimization (0 by default which means first in the list)
  61388. */
  61389. priority?: number);
  61390. }
  61391. /**
  61392. * Defines an optimization used to reduce the size of render target textures
  61393. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61394. */
  61395. export class TextureOptimization extends SceneOptimization {
  61396. /**
  61397. * Defines the priority of this optimization (0 by default which means first in the list)
  61398. */
  61399. priority: number;
  61400. /**
  61401. * 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
  61402. */
  61403. maximumSize: number;
  61404. /**
  61405. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61406. */
  61407. step: number;
  61408. /**
  61409. * Gets a string describing the action executed by the current optimization
  61410. * @returns description string
  61411. */
  61412. getDescription(): string;
  61413. /**
  61414. * Creates the TextureOptimization object
  61415. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61416. * @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
  61417. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61418. */
  61419. constructor(
  61420. /**
  61421. * Defines the priority of this optimization (0 by default which means first in the list)
  61422. */
  61423. priority?: number,
  61424. /**
  61425. * 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
  61426. */
  61427. maximumSize?: number,
  61428. /**
  61429. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61430. */
  61431. step?: number);
  61432. /**
  61433. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61434. * @param scene defines the current scene where to apply this optimization
  61435. * @param optimizer defines the current optimizer
  61436. * @returns true if everything that can be done was applied
  61437. */
  61438. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61439. }
  61440. /**
  61441. * Defines an optimization used to increase or decrease the rendering resolution
  61442. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61443. */
  61444. export class HardwareScalingOptimization extends SceneOptimization {
  61445. /**
  61446. * Defines the priority of this optimization (0 by default which means first in the list)
  61447. */
  61448. priority: number;
  61449. /**
  61450. * Defines the maximum scale to use (2 by default)
  61451. */
  61452. maximumScale: number;
  61453. /**
  61454. * Defines the step to use between two passes (0.5 by default)
  61455. */
  61456. step: number;
  61457. private _currentScale;
  61458. private _directionOffset;
  61459. /**
  61460. * Gets a string describing the action executed by the current optimization
  61461. * @return description string
  61462. */
  61463. getDescription(): string;
  61464. /**
  61465. * Creates the HardwareScalingOptimization object
  61466. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61467. * @param maximumScale defines the maximum scale to use (2 by default)
  61468. * @param step defines the step to use between two passes (0.5 by default)
  61469. */
  61470. constructor(
  61471. /**
  61472. * Defines the priority of this optimization (0 by default which means first in the list)
  61473. */
  61474. priority?: number,
  61475. /**
  61476. * Defines the maximum scale to use (2 by default)
  61477. */
  61478. maximumScale?: number,
  61479. /**
  61480. * Defines the step to use between two passes (0.5 by default)
  61481. */
  61482. step?: number);
  61483. /**
  61484. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61485. * @param scene defines the current scene where to apply this optimization
  61486. * @param optimizer defines the current optimizer
  61487. * @returns true if everything that can be done was applied
  61488. */
  61489. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61490. }
  61491. /**
  61492. * Defines an optimization used to remove shadows
  61493. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61494. */
  61495. export class ShadowsOptimization extends SceneOptimization {
  61496. /**
  61497. * Gets a string describing the action executed by the current optimization
  61498. * @return description string
  61499. */
  61500. getDescription(): string;
  61501. /**
  61502. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61503. * @param scene defines the current scene where to apply this optimization
  61504. * @param optimizer defines the current optimizer
  61505. * @returns true if everything that can be done was applied
  61506. */
  61507. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61508. }
  61509. /**
  61510. * Defines an optimization used to turn post-processes off
  61511. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61512. */
  61513. export class PostProcessesOptimization extends SceneOptimization {
  61514. /**
  61515. * Gets a string describing the action executed by the current optimization
  61516. * @return description string
  61517. */
  61518. getDescription(): string;
  61519. /**
  61520. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61521. * @param scene defines the current scene where to apply this optimization
  61522. * @param optimizer defines the current optimizer
  61523. * @returns true if everything that can be done was applied
  61524. */
  61525. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61526. }
  61527. /**
  61528. * Defines an optimization used to turn lens flares off
  61529. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61530. */
  61531. export class LensFlaresOptimization extends SceneOptimization {
  61532. /**
  61533. * Gets a string describing the action executed by the current optimization
  61534. * @return description string
  61535. */
  61536. getDescription(): string;
  61537. /**
  61538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61539. * @param scene defines the current scene where to apply this optimization
  61540. * @param optimizer defines the current optimizer
  61541. * @returns true if everything that can be done was applied
  61542. */
  61543. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61544. }
  61545. /**
  61546. * Defines an optimization based on user defined callback.
  61547. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61548. */
  61549. export class CustomOptimization extends SceneOptimization {
  61550. /**
  61551. * Callback called to apply the custom optimization.
  61552. */
  61553. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61554. /**
  61555. * Callback called to get custom description
  61556. */
  61557. onGetDescription: () => string;
  61558. /**
  61559. * Gets a string describing the action executed by the current optimization
  61560. * @returns description string
  61561. */
  61562. getDescription(): string;
  61563. /**
  61564. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61565. * @param scene defines the current scene where to apply this optimization
  61566. * @param optimizer defines the current optimizer
  61567. * @returns true if everything that can be done was applied
  61568. */
  61569. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61570. }
  61571. /**
  61572. * Defines an optimization used to turn particles off
  61573. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61574. */
  61575. export class ParticlesOptimization extends SceneOptimization {
  61576. /**
  61577. * Gets a string describing the action executed by the current optimization
  61578. * @return description string
  61579. */
  61580. getDescription(): string;
  61581. /**
  61582. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61583. * @param scene defines the current scene where to apply this optimization
  61584. * @param optimizer defines the current optimizer
  61585. * @returns true if everything that can be done was applied
  61586. */
  61587. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61588. }
  61589. /**
  61590. * Defines an optimization used to turn render targets off
  61591. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61592. */
  61593. export class RenderTargetsOptimization extends SceneOptimization {
  61594. /**
  61595. * Gets a string describing the action executed by the current optimization
  61596. * @return description string
  61597. */
  61598. getDescription(): string;
  61599. /**
  61600. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61601. * @param scene defines the current scene where to apply this optimization
  61602. * @param optimizer defines the current optimizer
  61603. * @returns true if everything that can be done was applied
  61604. */
  61605. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61606. }
  61607. /**
  61608. * Defines an optimization used to merge meshes with compatible materials
  61609. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61610. */
  61611. export class MergeMeshesOptimization extends SceneOptimization {
  61612. private static _UpdateSelectionTree;
  61613. /**
  61614. * Gets or sets a boolean which defines if optimization octree has to be updated
  61615. */
  61616. /**
  61617. * Gets or sets a boolean which defines if optimization octree has to be updated
  61618. */
  61619. static UpdateSelectionTree: boolean;
  61620. /**
  61621. * Gets a string describing the action executed by the current optimization
  61622. * @return description string
  61623. */
  61624. getDescription(): string;
  61625. private _canBeMerged;
  61626. /**
  61627. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61628. * @param scene defines the current scene where to apply this optimization
  61629. * @param optimizer defines the current optimizer
  61630. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61631. * @returns true if everything that can be done was applied
  61632. */
  61633. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61634. }
  61635. /**
  61636. * Defines a list of options used by SceneOptimizer
  61637. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61638. */
  61639. export class SceneOptimizerOptions {
  61640. /**
  61641. * Defines the target frame rate to reach (60 by default)
  61642. */
  61643. targetFrameRate: number;
  61644. /**
  61645. * Defines the interval between two checkes (2000ms by default)
  61646. */
  61647. trackerDuration: number;
  61648. /**
  61649. * Gets the list of optimizations to apply
  61650. */
  61651. optimizations: SceneOptimization[];
  61652. /**
  61653. * Creates a new list of options used by SceneOptimizer
  61654. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61655. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61656. */
  61657. constructor(
  61658. /**
  61659. * Defines the target frame rate to reach (60 by default)
  61660. */
  61661. targetFrameRate?: number,
  61662. /**
  61663. * Defines the interval between two checkes (2000ms by default)
  61664. */
  61665. trackerDuration?: number);
  61666. /**
  61667. * Add a new optimization
  61668. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61669. * @returns the current SceneOptimizerOptions
  61670. */
  61671. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61672. /**
  61673. * Add a new custom optimization
  61674. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61675. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61676. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61677. * @returns the current SceneOptimizerOptions
  61678. */
  61679. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61680. /**
  61681. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61682. * @param targetFrameRate defines the target frame rate (60 by default)
  61683. * @returns a SceneOptimizerOptions object
  61684. */
  61685. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61686. /**
  61687. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61688. * @param targetFrameRate defines the target frame rate (60 by default)
  61689. * @returns a SceneOptimizerOptions object
  61690. */
  61691. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61692. /**
  61693. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61694. * @param targetFrameRate defines the target frame rate (60 by default)
  61695. * @returns a SceneOptimizerOptions object
  61696. */
  61697. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61698. }
  61699. /**
  61700. * Class used to run optimizations in order to reach a target frame rate
  61701. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61702. */
  61703. export class SceneOptimizer implements IDisposable {
  61704. private _isRunning;
  61705. private _options;
  61706. private _scene;
  61707. private _currentPriorityLevel;
  61708. private _targetFrameRate;
  61709. private _trackerDuration;
  61710. private _currentFrameRate;
  61711. private _sceneDisposeObserver;
  61712. private _improvementMode;
  61713. /**
  61714. * Defines an observable called when the optimizer reaches the target frame rate
  61715. */
  61716. onSuccessObservable: Observable<SceneOptimizer>;
  61717. /**
  61718. * Defines an observable called when the optimizer enables an optimization
  61719. */
  61720. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61721. /**
  61722. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61723. */
  61724. onFailureObservable: Observable<SceneOptimizer>;
  61725. /**
  61726. * Gets a boolean indicating if the optimizer is in improvement mode
  61727. */
  61728. readonly isInImprovementMode: boolean;
  61729. /**
  61730. * Gets the current priority level (0 at start)
  61731. */
  61732. readonly currentPriorityLevel: number;
  61733. /**
  61734. * Gets the current frame rate checked by the SceneOptimizer
  61735. */
  61736. readonly currentFrameRate: number;
  61737. /**
  61738. * Gets or sets the current target frame rate (60 by default)
  61739. */
  61740. /**
  61741. * Gets or sets the current target frame rate (60 by default)
  61742. */
  61743. targetFrameRate: number;
  61744. /**
  61745. * Gets or sets the current interval between two checks (every 2000ms by default)
  61746. */
  61747. /**
  61748. * Gets or sets the current interval between two checks (every 2000ms by default)
  61749. */
  61750. trackerDuration: number;
  61751. /**
  61752. * Gets the list of active optimizations
  61753. */
  61754. readonly optimizations: SceneOptimization[];
  61755. /**
  61756. * Creates a new SceneOptimizer
  61757. * @param scene defines the scene to work on
  61758. * @param options defines the options to use with the SceneOptimizer
  61759. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61760. * @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)
  61761. */
  61762. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61763. /**
  61764. * Stops the current optimizer
  61765. */
  61766. stop(): void;
  61767. /**
  61768. * Reset the optimizer to initial step (current priority level = 0)
  61769. */
  61770. reset(): void;
  61771. /**
  61772. * Start the optimizer. By default it will try to reach a specific framerate
  61773. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61774. */
  61775. start(): void;
  61776. private _checkCurrentState;
  61777. /**
  61778. * Release all resources
  61779. */
  61780. dispose(): void;
  61781. /**
  61782. * Helper function to create a SceneOptimizer with one single line of code
  61783. * @param scene defines the scene to work on
  61784. * @param options defines the options to use with the SceneOptimizer
  61785. * @param onSuccess defines a callback to call on success
  61786. * @param onFailure defines a callback to call on failure
  61787. * @returns the new SceneOptimizer object
  61788. */
  61789. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61790. }
  61791. }
  61792. declare module "babylonjs/Misc/sceneSerializer" {
  61793. import { Scene } from "babylonjs/scene";
  61794. /**
  61795. * Class used to serialize a scene into a string
  61796. */
  61797. export class SceneSerializer {
  61798. /**
  61799. * Clear cache used by a previous serialization
  61800. */
  61801. static ClearCache(): void;
  61802. /**
  61803. * Serialize a scene into a JSON compatible object
  61804. * @param scene defines the scene to serialize
  61805. * @returns a JSON compatible object
  61806. */
  61807. static Serialize(scene: Scene): any;
  61808. /**
  61809. * Serialize a mesh into a JSON compatible object
  61810. * @param toSerialize defines the mesh to serialize
  61811. * @param withParents defines if parents must be serialized as well
  61812. * @param withChildren defines if children must be serialized as well
  61813. * @returns a JSON compatible object
  61814. */
  61815. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61816. }
  61817. }
  61818. declare module "babylonjs/Misc/textureTools" {
  61819. import { Texture } from "babylonjs/Materials/Textures/texture";
  61820. /**
  61821. * Class used to host texture specific utilities
  61822. */
  61823. export class TextureTools {
  61824. /**
  61825. * Uses the GPU to create a copy texture rescaled at a given size
  61826. * @param texture Texture to copy from
  61827. * @param width defines the desired width
  61828. * @param height defines the desired height
  61829. * @param useBilinearMode defines if bilinear mode has to be used
  61830. * @return the generated texture
  61831. */
  61832. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61833. }
  61834. }
  61835. declare module "babylonjs/Misc/videoRecorder" {
  61836. import { Nullable } from "babylonjs/types";
  61837. import { Engine } from "babylonjs/Engines/engine";
  61838. /**
  61839. * This represents the different options available for the video capture.
  61840. */
  61841. export interface VideoRecorderOptions {
  61842. /** Defines the mime type of the video. */
  61843. mimeType: string;
  61844. /** Defines the FPS the video should be recorded at. */
  61845. fps: number;
  61846. /** Defines the chunk size for the recording data. */
  61847. recordChunckSize: number;
  61848. /** The audio tracks to attach to the recording. */
  61849. audioTracks?: MediaStreamTrack[];
  61850. }
  61851. /**
  61852. * This can help with recording videos from BabylonJS.
  61853. * This is based on the available WebRTC functionalities of the browser.
  61854. *
  61855. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61856. */
  61857. export class VideoRecorder {
  61858. private static readonly _defaultOptions;
  61859. /**
  61860. * Returns whether or not the VideoRecorder is available in your browser.
  61861. * @param engine Defines the Babylon Engine.
  61862. * @returns true if supported otherwise false.
  61863. */
  61864. static IsSupported(engine: Engine): boolean;
  61865. private readonly _options;
  61866. private _canvas;
  61867. private _mediaRecorder;
  61868. private _recordedChunks;
  61869. private _fileName;
  61870. private _resolve;
  61871. private _reject;
  61872. /**
  61873. * True when a recording is already in progress.
  61874. */
  61875. readonly isRecording: boolean;
  61876. /**
  61877. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  61878. * @param engine Defines the BabylonJS Engine you wish to record.
  61879. * @param options Defines options that can be used to customize the capture.
  61880. */
  61881. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61882. /**
  61883. * Stops the current recording before the default capture timeout passed in the startRecording function.
  61884. */
  61885. stopRecording(): void;
  61886. /**
  61887. * Starts recording the canvas for a max duration specified in parameters.
  61888. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  61889. * If null no automatic download will start and you can rely on the promise to get the data back.
  61890. * @param maxDuration Defines the maximum recording time in seconds.
  61891. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61892. * @return A promise callback at the end of the recording with the video data in Blob.
  61893. */
  61894. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61895. /**
  61896. * Releases internal resources used during the recording.
  61897. */
  61898. dispose(): void;
  61899. private _handleDataAvailable;
  61900. private _handleError;
  61901. private _handleStop;
  61902. }
  61903. }
  61904. declare module "babylonjs/Misc/screenshotTools" {
  61905. import { Camera } from "babylonjs/Cameras/camera";
  61906. import { Engine } from "babylonjs/Engines/engine";
  61907. /**
  61908. * Class containing a set of static utilities functions for screenshots
  61909. */
  61910. export class ScreenshotTools {
  61911. /**
  61912. * Captures a screenshot of the current rendering
  61913. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61914. * @param engine defines the rendering engine
  61915. * @param camera defines the source camera
  61916. * @param size This parameter can be set to a single number or to an object with the
  61917. * following (optional) properties: precision, width, height. If a single number is passed,
  61918. * it will be used for both width and height. If an object is passed, the screenshot size
  61919. * will be derived from the parameters. The precision property is a multiplier allowing
  61920. * rendering at a higher or lower resolution
  61921. * @param successCallback defines the callback receives a single parameter which contains the
  61922. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61923. * src parameter of an <img> to display it
  61924. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61925. * Check your browser for supported MIME types
  61926. */
  61927. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  61928. /**
  61929. * Generates an image screenshot from the specified camera.
  61930. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61931. * @param engine The engine to use for rendering
  61932. * @param camera The camera to use for rendering
  61933. * @param size This parameter can be set to a single number or to an object with the
  61934. * following (optional) properties: precision, width, height. If a single number is passed,
  61935. * it will be used for both width and height. If an object is passed, the screenshot size
  61936. * will be derived from the parameters. The precision property is a multiplier allowing
  61937. * rendering at a higher or lower resolution
  61938. * @param successCallback The callback receives a single parameter which contains the
  61939. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61940. * src parameter of an <img> to display it
  61941. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61942. * Check your browser for supported MIME types
  61943. * @param samples Texture samples (default: 1)
  61944. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61945. * @param fileName A name for for the downloaded file.
  61946. */
  61947. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61948. }
  61949. }
  61950. declare module "babylonjs/Misc/index" {
  61951. export * from "babylonjs/Misc/andOrNotEvaluator";
  61952. export * from "babylonjs/Misc/assetsManager";
  61953. export * from "babylonjs/Misc/dds";
  61954. export * from "babylonjs/Misc/decorators";
  61955. export * from "babylonjs/Misc/deferred";
  61956. export * from "babylonjs/Misc/environmentTextureTools";
  61957. export * from "babylonjs/Misc/meshExploder";
  61958. export * from "babylonjs/Misc/filesInput";
  61959. export * from "babylonjs/Misc/HighDynamicRange/index";
  61960. export * from "babylonjs/Misc/khronosTextureContainer";
  61961. export * from "babylonjs/Misc/observable";
  61962. export * from "babylonjs/Misc/performanceMonitor";
  61963. export * from "babylonjs/Misc/promise";
  61964. export * from "babylonjs/Misc/sceneOptimizer";
  61965. export * from "babylonjs/Misc/sceneSerializer";
  61966. export * from "babylonjs/Misc/smartArray";
  61967. export * from "babylonjs/Misc/stringDictionary";
  61968. export * from "babylonjs/Misc/tags";
  61969. export * from "babylonjs/Misc/textureTools";
  61970. export * from "babylonjs/Misc/tga";
  61971. export * from "babylonjs/Misc/tools";
  61972. export * from "babylonjs/Misc/videoRecorder";
  61973. export * from "babylonjs/Misc/virtualJoystick";
  61974. export * from "babylonjs/Misc/workerPool";
  61975. export * from "babylonjs/Misc/logger";
  61976. export * from "babylonjs/Misc/typeStore";
  61977. export * from "babylonjs/Misc/filesInputStore";
  61978. export * from "babylonjs/Misc/deepCopier";
  61979. export * from "babylonjs/Misc/pivotTools";
  61980. export * from "babylonjs/Misc/precisionDate";
  61981. export * from "babylonjs/Misc/screenshotTools";
  61982. export * from "babylonjs/Misc/typeStore";
  61983. export * from "babylonjs/Misc/webRequest";
  61984. export * from "babylonjs/Misc/iInspectable";
  61985. export * from "babylonjs/Misc/brdfTextureTools";
  61986. }
  61987. declare module "babylonjs/index" {
  61988. export * from "babylonjs/abstractScene";
  61989. export * from "babylonjs/Actions/index";
  61990. export * from "babylonjs/Animations/index";
  61991. export * from "babylonjs/assetContainer";
  61992. export * from "babylonjs/Audio/index";
  61993. export * from "babylonjs/Behaviors/index";
  61994. export * from "babylonjs/Bones/index";
  61995. export * from "babylonjs/Cameras/index";
  61996. export * from "babylonjs/Collisions/index";
  61997. export * from "babylonjs/Culling/index";
  61998. export * from "babylonjs/Debug/index";
  61999. export * from "babylonjs/Engines/index";
  62000. export * from "babylonjs/Events/index";
  62001. export * from "babylonjs/Gamepads/index";
  62002. export * from "babylonjs/Gizmos/index";
  62003. export * from "babylonjs/Helpers/index";
  62004. export * from "babylonjs/Instrumentation/index";
  62005. export * from "babylonjs/Layers/index";
  62006. export * from "babylonjs/LensFlares/index";
  62007. export * from "babylonjs/Lights/index";
  62008. export * from "babylonjs/Loading/index";
  62009. export * from "babylonjs/Materials/index";
  62010. export * from "babylonjs/Maths/index";
  62011. export * from "babylonjs/Meshes/index";
  62012. export * from "babylonjs/Morph/index";
  62013. export * from "babylonjs/node";
  62014. export * from "babylonjs/Offline/index";
  62015. export * from "babylonjs/Particles/index";
  62016. export * from "babylonjs/Physics/index";
  62017. export * from "babylonjs/PostProcesses/index";
  62018. export * from "babylonjs/Probes/index";
  62019. export * from "babylonjs/Rendering/index";
  62020. export * from "babylonjs/scene";
  62021. export * from "babylonjs/sceneComponent";
  62022. export * from "babylonjs/Sprites/index";
  62023. export * from "babylonjs/States/index";
  62024. export * from "babylonjs/Misc/index";
  62025. export * from "babylonjs/types";
  62026. }
  62027. declare module "babylonjs/Animations/pathCursor" {
  62028. import { Path2, Vector3 } from "babylonjs/Maths/math";
  62029. /**
  62030. * A cursor which tracks a point on a path
  62031. */
  62032. export class PathCursor {
  62033. private path;
  62034. /**
  62035. * Stores path cursor callbacks for when an onchange event is triggered
  62036. */
  62037. private _onchange;
  62038. /**
  62039. * The value of the path cursor
  62040. */
  62041. value: number;
  62042. /**
  62043. * The animation array of the path cursor
  62044. */
  62045. animations: Animation[];
  62046. /**
  62047. * Initializes the path cursor
  62048. * @param path The path to track
  62049. */
  62050. constructor(path: Path2);
  62051. /**
  62052. * Gets the cursor point on the path
  62053. * @returns A point on the path cursor at the cursor location
  62054. */
  62055. getPoint(): Vector3;
  62056. /**
  62057. * Moves the cursor ahead by the step amount
  62058. * @param step The amount to move the cursor forward
  62059. * @returns This path cursor
  62060. */
  62061. moveAhead(step?: number): PathCursor;
  62062. /**
  62063. * Moves the cursor behind by the step amount
  62064. * @param step The amount to move the cursor back
  62065. * @returns This path cursor
  62066. */
  62067. moveBack(step?: number): PathCursor;
  62068. /**
  62069. * Moves the cursor by the step amount
  62070. * If the step amount is greater than one, an exception is thrown
  62071. * @param step The amount to move the cursor
  62072. * @returns This path cursor
  62073. */
  62074. move(step: number): PathCursor;
  62075. /**
  62076. * Ensures that the value is limited between zero and one
  62077. * @returns This path cursor
  62078. */
  62079. private ensureLimits;
  62080. /**
  62081. * Runs onchange callbacks on change (used by the animation engine)
  62082. * @returns This path cursor
  62083. */
  62084. private raiseOnChange;
  62085. /**
  62086. * Executes a function on change
  62087. * @param f A path cursor onchange callback
  62088. * @returns This path cursor
  62089. */
  62090. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62091. }
  62092. }
  62093. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  62094. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  62095. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  62096. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  62097. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  62098. }
  62099. declare module "babylonjs/Engines/Processors/Expressions/index" {
  62100. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  62101. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  62102. }
  62103. declare module "babylonjs/Engines/Processors/index" {
  62104. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  62105. export * from "babylonjs/Engines/Processors/Expressions/index";
  62106. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  62107. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  62108. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  62109. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  62110. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  62111. export * from "babylonjs/Engines/Processors/shaderProcessor";
  62112. }
  62113. declare module "babylonjs/Legacy/legacy" {
  62114. import * as Babylon from "babylonjs/index";
  62115. export * from "babylonjs/index";
  62116. }
  62117. declare module "babylonjs/Shaders/blur.fragment" {
  62118. /** @hidden */
  62119. export var blurPixelShader: {
  62120. name: string;
  62121. shader: string;
  62122. };
  62123. }
  62124. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  62125. /** @hidden */
  62126. export var bones300Declaration: {
  62127. name: string;
  62128. shader: string;
  62129. };
  62130. }
  62131. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  62132. /** @hidden */
  62133. export var instances300Declaration: {
  62134. name: string;
  62135. shader: string;
  62136. };
  62137. }
  62138. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  62139. /** @hidden */
  62140. export var pointCloudVertexDeclaration: {
  62141. name: string;
  62142. shader: string;
  62143. };
  62144. }
  62145. // Mixins
  62146. interface Window {
  62147. mozIndexedDB: IDBFactory;
  62148. webkitIndexedDB: IDBFactory;
  62149. msIndexedDB: IDBFactory;
  62150. webkitURL: typeof URL;
  62151. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62152. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62153. WebGLRenderingContext: WebGLRenderingContext;
  62154. MSGesture: MSGesture;
  62155. CANNON: any;
  62156. AudioContext: AudioContext;
  62157. webkitAudioContext: AudioContext;
  62158. PointerEvent: any;
  62159. Math: Math;
  62160. Uint8Array: Uint8ArrayConstructor;
  62161. Float32Array: Float32ArrayConstructor;
  62162. mozURL: typeof URL;
  62163. msURL: typeof URL;
  62164. VRFrameData: any; // WebVR, from specs 1.1
  62165. DracoDecoderModule: any;
  62166. setImmediate(handler: (...args: any[]) => void): number;
  62167. }
  62168. interface HTMLCanvasElement {
  62169. requestPointerLock(): void;
  62170. msRequestPointerLock?(): void;
  62171. mozRequestPointerLock?(): void;
  62172. webkitRequestPointerLock?(): void;
  62173. /** Track wether a record is in progress */
  62174. isRecording: boolean;
  62175. /** Capture Stream method defined by some browsers */
  62176. captureStream(fps?: number): MediaStream;
  62177. }
  62178. interface CanvasRenderingContext2D {
  62179. msImageSmoothingEnabled: boolean;
  62180. }
  62181. interface MouseEvent {
  62182. mozMovementX: number;
  62183. mozMovementY: number;
  62184. webkitMovementX: number;
  62185. webkitMovementY: number;
  62186. msMovementX: number;
  62187. msMovementY: number;
  62188. }
  62189. interface Navigator {
  62190. mozGetVRDevices: (any: any) => any;
  62191. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62192. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62193. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62194. webkitGetGamepads(): Gamepad[];
  62195. msGetGamepads(): Gamepad[];
  62196. webkitGamepads(): Gamepad[];
  62197. }
  62198. interface HTMLVideoElement {
  62199. mozSrcObject: any;
  62200. }
  62201. interface Math {
  62202. fround(x: number): number;
  62203. imul(a: number, b: number): number;
  62204. }
  62205. interface WebGLRenderingContext {
  62206. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62207. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62208. vertexAttribDivisor(index: number, divisor: number): void;
  62209. createVertexArray(): any;
  62210. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62211. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62212. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62213. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62214. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62215. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62216. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62217. // Queries
  62218. createQuery(): WebGLQuery;
  62219. deleteQuery(query: WebGLQuery): void;
  62220. beginQuery(target: number, query: WebGLQuery): void;
  62221. endQuery(target: number): void;
  62222. getQueryParameter(query: WebGLQuery, pname: number): any;
  62223. getQuery(target: number, pname: number): any;
  62224. MAX_SAMPLES: number;
  62225. RGBA8: number;
  62226. READ_FRAMEBUFFER: number;
  62227. DRAW_FRAMEBUFFER: number;
  62228. UNIFORM_BUFFER: number;
  62229. HALF_FLOAT_OES: number;
  62230. RGBA16F: number;
  62231. RGBA32F: number;
  62232. R32F: number;
  62233. RG32F: number;
  62234. RGB32F: number;
  62235. R16F: number;
  62236. RG16F: number;
  62237. RGB16F: number;
  62238. RED: number;
  62239. RG: number;
  62240. R8: number;
  62241. RG8: number;
  62242. UNSIGNED_INT_24_8: number;
  62243. DEPTH24_STENCIL8: number;
  62244. /* Multiple Render Targets */
  62245. drawBuffers(buffers: number[]): void;
  62246. readBuffer(src: number): void;
  62247. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62248. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62249. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62250. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62251. // Occlusion Query
  62252. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62253. ANY_SAMPLES_PASSED: number;
  62254. QUERY_RESULT_AVAILABLE: number;
  62255. QUERY_RESULT: number;
  62256. }
  62257. interface WebGLProgram {
  62258. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62259. }
  62260. interface EXT_disjoint_timer_query {
  62261. QUERY_COUNTER_BITS_EXT: number;
  62262. TIME_ELAPSED_EXT: number;
  62263. TIMESTAMP_EXT: number;
  62264. GPU_DISJOINT_EXT: number;
  62265. QUERY_RESULT_EXT: number;
  62266. QUERY_RESULT_AVAILABLE_EXT: number;
  62267. queryCounterEXT(query: WebGLQuery, target: number): void;
  62268. createQueryEXT(): WebGLQuery;
  62269. beginQueryEXT(target: number, query: WebGLQuery): void;
  62270. endQueryEXT(target: number): void;
  62271. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62272. deleteQueryEXT(query: WebGLQuery): void;
  62273. }
  62274. interface WebGLUniformLocation {
  62275. _currentState: any;
  62276. }
  62277. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62278. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62279. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62280. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62281. interface WebGLRenderingContext {
  62282. readonly RASTERIZER_DISCARD: number;
  62283. readonly DEPTH_COMPONENT24: number;
  62284. readonly TEXTURE_3D: number;
  62285. readonly TEXTURE_2D_ARRAY: number;
  62286. readonly TEXTURE_COMPARE_FUNC: number;
  62287. readonly TEXTURE_COMPARE_MODE: number;
  62288. readonly COMPARE_REF_TO_TEXTURE: number;
  62289. readonly TEXTURE_WRAP_R: number;
  62290. readonly HALF_FLOAT: number;
  62291. readonly RGB8: number;
  62292. readonly RED_INTEGER: number;
  62293. readonly RG_INTEGER: number;
  62294. readonly RGB_INTEGER: number;
  62295. readonly RGBA_INTEGER: number;
  62296. readonly R8_SNORM: number;
  62297. readonly RG8_SNORM: number;
  62298. readonly RGB8_SNORM: number;
  62299. readonly RGBA8_SNORM: number;
  62300. readonly R8I: number;
  62301. readonly RG8I: number;
  62302. readonly RGB8I: number;
  62303. readonly RGBA8I: number;
  62304. readonly R8UI: number;
  62305. readonly RG8UI: number;
  62306. readonly RGB8UI: number;
  62307. readonly RGBA8UI: number;
  62308. readonly R16I: number;
  62309. readonly RG16I: number;
  62310. readonly RGB16I: number;
  62311. readonly RGBA16I: number;
  62312. readonly R16UI: number;
  62313. readonly RG16UI: number;
  62314. readonly RGB16UI: number;
  62315. readonly RGBA16UI: number;
  62316. readonly R32I: number;
  62317. readonly RG32I: number;
  62318. readonly RGB32I: number;
  62319. readonly RGBA32I: number;
  62320. readonly R32UI: number;
  62321. readonly RG32UI: number;
  62322. readonly RGB32UI: number;
  62323. readonly RGBA32UI: number;
  62324. readonly RGB10_A2UI: number;
  62325. readonly R11F_G11F_B10F: number;
  62326. readonly RGB9_E5: number;
  62327. readonly RGB10_A2: number;
  62328. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62329. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62330. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62331. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62332. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62333. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62334. 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;
  62335. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62336. readonly TRANSFORM_FEEDBACK: number;
  62337. readonly INTERLEAVED_ATTRIBS: number;
  62338. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62339. createTransformFeedback(): WebGLTransformFeedback;
  62340. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62341. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62342. beginTransformFeedback(primitiveMode: number): void;
  62343. endTransformFeedback(): void;
  62344. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62345. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62346. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62347. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62348. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62349. }
  62350. interface ImageBitmap {
  62351. readonly width: number;
  62352. readonly height: number;
  62353. close(): void;
  62354. }
  62355. interface WebGLQuery extends WebGLObject {
  62356. }
  62357. declare var WebGLQuery: {
  62358. prototype: WebGLQuery;
  62359. new(): WebGLQuery;
  62360. };
  62361. interface WebGLSampler extends WebGLObject {
  62362. }
  62363. declare var WebGLSampler: {
  62364. prototype: WebGLSampler;
  62365. new(): WebGLSampler;
  62366. };
  62367. interface WebGLSync extends WebGLObject {
  62368. }
  62369. declare var WebGLSync: {
  62370. prototype: WebGLSync;
  62371. new(): WebGLSync;
  62372. };
  62373. interface WebGLTransformFeedback extends WebGLObject {
  62374. }
  62375. declare var WebGLTransformFeedback: {
  62376. prototype: WebGLTransformFeedback;
  62377. new(): WebGLTransformFeedback;
  62378. };
  62379. interface WebGLVertexArrayObject extends WebGLObject {
  62380. }
  62381. declare var WebGLVertexArrayObject: {
  62382. prototype: WebGLVertexArrayObject;
  62383. new(): WebGLVertexArrayObject;
  62384. };
  62385. // Type definitions for WebVR API
  62386. // Project: https://w3c.github.io/webvr/
  62387. // Definitions by: six a <https://github.com/lostfictions>
  62388. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62389. interface VRDisplay extends EventTarget {
  62390. /**
  62391. * Dictionary of capabilities describing the VRDisplay.
  62392. */
  62393. readonly capabilities: VRDisplayCapabilities;
  62394. /**
  62395. * z-depth defining the far plane of the eye view frustum
  62396. * enables mapping of values in the render target depth
  62397. * attachment to scene coordinates. Initially set to 10000.0.
  62398. */
  62399. depthFar: number;
  62400. /**
  62401. * z-depth defining the near plane of the eye view frustum
  62402. * enables mapping of values in the render target depth
  62403. * attachment to scene coordinates. Initially set to 0.01.
  62404. */
  62405. depthNear: number;
  62406. /**
  62407. * An identifier for this distinct VRDisplay. Used as an
  62408. * association point in the Gamepad API.
  62409. */
  62410. readonly displayId: number;
  62411. /**
  62412. * A display name, a user-readable name identifying it.
  62413. */
  62414. readonly displayName: string;
  62415. readonly isConnected: boolean;
  62416. readonly isPresenting: boolean;
  62417. /**
  62418. * If this VRDisplay supports room-scale experiences, the optional
  62419. * stage attribute contains details on the room-scale parameters.
  62420. */
  62421. readonly stageParameters: VRStageParameters | null;
  62422. /**
  62423. * Passing the value returned by `requestAnimationFrame` to
  62424. * `cancelAnimationFrame` will unregister the callback.
  62425. * @param handle Define the hanle of the request to cancel
  62426. */
  62427. cancelAnimationFrame(handle: number): void;
  62428. /**
  62429. * Stops presenting to the VRDisplay.
  62430. * @returns a promise to know when it stopped
  62431. */
  62432. exitPresent(): Promise<void>;
  62433. /**
  62434. * Return the current VREyeParameters for the given eye.
  62435. * @param whichEye Define the eye we want the parameter for
  62436. * @returns the eye parameters
  62437. */
  62438. getEyeParameters(whichEye: string): VREyeParameters;
  62439. /**
  62440. * Populates the passed VRFrameData with the information required to render
  62441. * the current frame.
  62442. * @param frameData Define the data structure to populate
  62443. * @returns true if ok otherwise false
  62444. */
  62445. getFrameData(frameData: VRFrameData): boolean;
  62446. /**
  62447. * Get the layers currently being presented.
  62448. * @returns the list of VR layers
  62449. */
  62450. getLayers(): VRLayer[];
  62451. /**
  62452. * Return a VRPose containing the future predicted pose of the VRDisplay
  62453. * when the current frame will be presented. The value returned will not
  62454. * change until JavaScript has returned control to the browser.
  62455. *
  62456. * The VRPose will contain the position, orientation, velocity,
  62457. * and acceleration of each of these properties.
  62458. * @returns the pose object
  62459. */
  62460. getPose(): VRPose;
  62461. /**
  62462. * Return the current instantaneous pose of the VRDisplay, with no
  62463. * prediction applied.
  62464. * @returns the current instantaneous pose
  62465. */
  62466. getImmediatePose(): VRPose;
  62467. /**
  62468. * The callback passed to `requestAnimationFrame` will be called
  62469. * any time a new frame should be rendered. When the VRDisplay is
  62470. * presenting the callback will be called at the native refresh
  62471. * rate of the HMD. When not presenting this function acts
  62472. * identically to how window.requestAnimationFrame acts. Content should
  62473. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62474. * asynchronously from other displays and at differing refresh rates.
  62475. * @param callback Define the eaction to run next frame
  62476. * @returns the request handle it
  62477. */
  62478. requestAnimationFrame(callback: FrameRequestCallback): number;
  62479. /**
  62480. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62481. * Repeat calls while already presenting will update the VRLayers being displayed.
  62482. * @param layers Define the list of layer to present
  62483. * @returns a promise to know when the request has been fulfilled
  62484. */
  62485. requestPresent(layers: VRLayer[]): Promise<void>;
  62486. /**
  62487. * Reset the pose for this display, treating its current position and
  62488. * orientation as the "origin/zero" values. VRPose.position,
  62489. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62490. * updated when calling resetPose(). This should be called in only
  62491. * sitting-space experiences.
  62492. */
  62493. resetPose(): void;
  62494. /**
  62495. * The VRLayer provided to the VRDisplay will be captured and presented
  62496. * in the HMD. Calling this function has the same effect on the source
  62497. * canvas as any other operation that uses its source image, and canvases
  62498. * created without preserveDrawingBuffer set to true will be cleared.
  62499. * @param pose Define the pose to submit
  62500. */
  62501. submitFrame(pose?: VRPose): void;
  62502. }
  62503. declare var VRDisplay: {
  62504. prototype: VRDisplay;
  62505. new(): VRDisplay;
  62506. };
  62507. interface VRLayer {
  62508. leftBounds?: number[] | Float32Array | null;
  62509. rightBounds?: number[] | Float32Array | null;
  62510. source?: HTMLCanvasElement | null;
  62511. }
  62512. interface VRDisplayCapabilities {
  62513. readonly canPresent: boolean;
  62514. readonly hasExternalDisplay: boolean;
  62515. readonly hasOrientation: boolean;
  62516. readonly hasPosition: boolean;
  62517. readonly maxLayers: number;
  62518. }
  62519. interface VREyeParameters {
  62520. /** @deprecated */
  62521. readonly fieldOfView: VRFieldOfView;
  62522. readonly offset: Float32Array;
  62523. readonly renderHeight: number;
  62524. readonly renderWidth: number;
  62525. }
  62526. interface VRFieldOfView {
  62527. readonly downDegrees: number;
  62528. readonly leftDegrees: number;
  62529. readonly rightDegrees: number;
  62530. readonly upDegrees: number;
  62531. }
  62532. interface VRFrameData {
  62533. readonly leftProjectionMatrix: Float32Array;
  62534. readonly leftViewMatrix: Float32Array;
  62535. readonly pose: VRPose;
  62536. readonly rightProjectionMatrix: Float32Array;
  62537. readonly rightViewMatrix: Float32Array;
  62538. readonly timestamp: number;
  62539. }
  62540. interface VRPose {
  62541. readonly angularAcceleration: Float32Array | null;
  62542. readonly angularVelocity: Float32Array | null;
  62543. readonly linearAcceleration: Float32Array | null;
  62544. readonly linearVelocity: Float32Array | null;
  62545. readonly orientation: Float32Array | null;
  62546. readonly position: Float32Array | null;
  62547. readonly timestamp: number;
  62548. }
  62549. interface VRStageParameters {
  62550. sittingToStandingTransform?: Float32Array;
  62551. sizeX?: number;
  62552. sizeY?: number;
  62553. }
  62554. interface Navigator {
  62555. getVRDisplays(): Promise<VRDisplay[]>;
  62556. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62557. }
  62558. interface Window {
  62559. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62560. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62561. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62562. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62563. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62564. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62565. }
  62566. interface Gamepad {
  62567. readonly displayId: number;
  62568. }
  62569. interface XRDevice {
  62570. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  62571. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  62572. }
  62573. interface XRSession {
  62574. getInputSources(): Array<any>;
  62575. baseLayer: XRWebGLLayer;
  62576. requestFrameOfReference(type: string): Promise<void>;
  62577. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  62578. end(): Promise<void>;
  62579. requestAnimationFrame: Function;
  62580. addEventListener: Function;
  62581. }
  62582. interface XRSessionCreationOptions {
  62583. outputContext?: WebGLRenderingContext | null;
  62584. immersive?: boolean;
  62585. environmentIntegration?: boolean;
  62586. }
  62587. interface XRLayer {
  62588. getViewport: Function;
  62589. framebufferWidth: number;
  62590. framebufferHeight: number;
  62591. }
  62592. interface XRView {
  62593. projectionMatrix: Float32Array;
  62594. }
  62595. interface XRFrame {
  62596. getDevicePose: Function;
  62597. getInputPose: Function;
  62598. views: Array<XRView>;
  62599. baseLayer: XRLayer;
  62600. }
  62601. interface XRFrameOfReference {
  62602. }
  62603. interface XRWebGLLayer extends XRLayer {
  62604. framebuffer: WebGLFramebuffer;
  62605. }
  62606. declare var XRWebGLLayer: {
  62607. prototype: XRWebGLLayer;
  62608. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  62609. };
  62610. declare module "babylonjs" {
  62611. export * from "babylonjs/Legacy/legacy";
  62612. }
  62613. declare module BABYLON {
  62614. /** Alias type for value that can be null */
  62615. export type Nullable<T> = T | null;
  62616. /**
  62617. * Alias type for number that are floats
  62618. * @ignorenaming
  62619. */
  62620. export type float = number;
  62621. /**
  62622. * Alias type for number that are doubles.
  62623. * @ignorenaming
  62624. */
  62625. export type double = number;
  62626. /**
  62627. * Alias type for number that are integer
  62628. * @ignorenaming
  62629. */
  62630. export type int = number;
  62631. /** Alias type for number array or Float32Array */
  62632. export type FloatArray = number[] | Float32Array;
  62633. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62634. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62635. /**
  62636. * Alias for types that can be used by a Buffer or VertexBuffer.
  62637. */
  62638. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62639. /**
  62640. * Alias type for primitive types
  62641. * @ignorenaming
  62642. */
  62643. type Primitive = undefined | null | boolean | string | number | Function;
  62644. /**
  62645. * Type modifier to make all the properties of an object Readonly
  62646. */
  62647. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62648. /**
  62649. * Type modifier to make all the properties of an object Readonly recursively
  62650. */
  62651. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62652. /** @hidden */
  62653. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62654. }
  62655. /** @hidden */
  62656. /** @hidden */
  62657. type DeepImmutableObject<T> = {
  62658. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62659. };
  62660. }
  62661. declare module BABYLON {
  62662. /**
  62663. * Class containing a set of static utilities functions for arrays.
  62664. */
  62665. export class ArrayTools {
  62666. /**
  62667. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62668. * @param size the number of element to construct and put in the array
  62669. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62670. * @returns a new array filled with new objects
  62671. */
  62672. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62673. }
  62674. }
  62675. declare module BABYLON {
  62676. /**
  62677. * Scalar computation library
  62678. */
  62679. export class Scalar {
  62680. /**
  62681. * Two pi constants convenient for computation.
  62682. */
  62683. static TwoPi: number;
  62684. /**
  62685. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62686. * @param a number
  62687. * @param b number
  62688. * @param epsilon (default = 1.401298E-45)
  62689. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62690. */
  62691. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  62692. /**
  62693. * Returns a string : the upper case translation of the number i to hexadecimal.
  62694. * @param i number
  62695. * @returns the upper case translation of the number i to hexadecimal.
  62696. */
  62697. static ToHex(i: number): string;
  62698. /**
  62699. * Returns -1 if value is negative and +1 is value is positive.
  62700. * @param value the value
  62701. * @returns the value itself if it's equal to zero.
  62702. */
  62703. static Sign(value: number): number;
  62704. /**
  62705. * Returns the value itself if it's between min and max.
  62706. * Returns min if the value is lower than min.
  62707. * Returns max if the value is greater than max.
  62708. * @param value the value to clmap
  62709. * @param min the min value to clamp to (default: 0)
  62710. * @param max the max value to clamp to (default: 1)
  62711. * @returns the clamped value
  62712. */
  62713. static Clamp(value: number, min?: number, max?: number): number;
  62714. /**
  62715. * the log2 of value.
  62716. * @param value the value to compute log2 of
  62717. * @returns the log2 of value.
  62718. */
  62719. static Log2(value: number): number;
  62720. /**
  62721. * Loops the value, so that it is never larger than length and never smaller than 0.
  62722. *
  62723. * This is similar to the modulo operator but it works with floating point numbers.
  62724. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  62725. * With t = 5 and length = 2.5, the result would be 0.0.
  62726. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  62727. * @param value the value
  62728. * @param length the length
  62729. * @returns the looped value
  62730. */
  62731. static Repeat(value: number, length: number): number;
  62732. /**
  62733. * Normalize the value between 0.0 and 1.0 using min and max values
  62734. * @param value value to normalize
  62735. * @param min max to normalize between
  62736. * @param max min to normalize between
  62737. * @returns the normalized value
  62738. */
  62739. static Normalize(value: number, min: number, max: number): number;
  62740. /**
  62741. * Denormalize the value from 0.0 and 1.0 using min and max values
  62742. * @param normalized value to denormalize
  62743. * @param min max to denormalize between
  62744. * @param max min to denormalize between
  62745. * @returns the denormalized value
  62746. */
  62747. static Denormalize(normalized: number, min: number, max: number): number;
  62748. /**
  62749. * Calculates the shortest difference between two given angles given in degrees.
  62750. * @param current current angle in degrees
  62751. * @param target target angle in degrees
  62752. * @returns the delta
  62753. */
  62754. static DeltaAngle(current: number, target: number): number;
  62755. /**
  62756. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  62757. * @param tx value
  62758. * @param length length
  62759. * @returns The returned value will move back and forth between 0 and length
  62760. */
  62761. static PingPong(tx: number, length: number): number;
  62762. /**
  62763. * Interpolates between min and max with smoothing at the limits.
  62764. *
  62765. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  62766. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  62767. * @param from from
  62768. * @param to to
  62769. * @param tx value
  62770. * @returns the smooth stepped value
  62771. */
  62772. static SmoothStep(from: number, to: number, tx: number): number;
  62773. /**
  62774. * Moves a value current towards target.
  62775. *
  62776. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  62777. * Negative values of maxDelta pushes the value away from target.
  62778. * @param current current value
  62779. * @param target target value
  62780. * @param maxDelta max distance to move
  62781. * @returns resulting value
  62782. */
  62783. static MoveTowards(current: number, target: number, maxDelta: number): number;
  62784. /**
  62785. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62786. *
  62787. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  62788. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  62789. * @param current current value
  62790. * @param target target value
  62791. * @param maxDelta max distance to move
  62792. * @returns resulting angle
  62793. */
  62794. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  62795. /**
  62796. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  62797. * @param start start value
  62798. * @param end target value
  62799. * @param amount amount to lerp between
  62800. * @returns the lerped value
  62801. */
  62802. static Lerp(start: number, end: number, amount: number): number;
  62803. /**
  62804. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62805. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  62806. * @param start start value
  62807. * @param end target value
  62808. * @param amount amount to lerp between
  62809. * @returns the lerped value
  62810. */
  62811. static LerpAngle(start: number, end: number, amount: number): number;
  62812. /**
  62813. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  62814. * @param a start value
  62815. * @param b target value
  62816. * @param value value between a and b
  62817. * @returns the inverseLerp value
  62818. */
  62819. static InverseLerp(a: number, b: number, value: number): number;
  62820. /**
  62821. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  62822. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  62823. * @param value1 spline value
  62824. * @param tangent1 spline value
  62825. * @param value2 spline value
  62826. * @param tangent2 spline value
  62827. * @param amount input value
  62828. * @returns hermite result
  62829. */
  62830. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  62831. /**
  62832. * Returns a random float number between and min and max values
  62833. * @param min min value of random
  62834. * @param max max value of random
  62835. * @returns random value
  62836. */
  62837. static RandomRange(min: number, max: number): number;
  62838. /**
  62839. * This function returns percentage of a number in a given range.
  62840. *
  62841. * RangeToPercent(40,20,60) will return 0.5 (50%)
  62842. * RangeToPercent(34,0,100) will return 0.34 (34%)
  62843. * @param number to convert to percentage
  62844. * @param min min range
  62845. * @param max max range
  62846. * @returns the percentage
  62847. */
  62848. static RangeToPercent(number: number, min: number, max: number): number;
  62849. /**
  62850. * This function returns number that corresponds to the percentage in a given range.
  62851. *
  62852. * PercentToRange(0.34,0,100) will return 34.
  62853. * @param percent to convert to number
  62854. * @param min min range
  62855. * @param max max range
  62856. * @returns the number
  62857. */
  62858. static PercentToRange(percent: number, min: number, max: number): number;
  62859. /**
  62860. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  62861. * @param angle The angle to normalize in radian.
  62862. * @return The converted angle.
  62863. */
  62864. static NormalizeRadians(angle: number): number;
  62865. }
  62866. }
  62867. declare module BABYLON {
  62868. /**
  62869. * Constant used to convert a value to gamma space
  62870. * @ignorenaming
  62871. */
  62872. export const ToGammaSpace: number;
  62873. /**
  62874. * Constant used to convert a value to linear space
  62875. * @ignorenaming
  62876. */
  62877. export const ToLinearSpace = 2.2;
  62878. /**
  62879. * Constant used to define the minimal number value in Babylon.js
  62880. * @ignorenaming
  62881. */
  62882. let Epsilon: number;
  62883. /**
  62884. * Class used to hold a RBG color
  62885. */
  62886. export class Color3 {
  62887. /**
  62888. * Defines the red component (between 0 and 1, default is 0)
  62889. */
  62890. r: number;
  62891. /**
  62892. * Defines the green component (between 0 and 1, default is 0)
  62893. */
  62894. g: number;
  62895. /**
  62896. * Defines the blue component (between 0 and 1, default is 0)
  62897. */
  62898. b: number;
  62899. /**
  62900. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  62901. * @param r defines the red component (between 0 and 1, default is 0)
  62902. * @param g defines the green component (between 0 and 1, default is 0)
  62903. * @param b defines the blue component (between 0 and 1, default is 0)
  62904. */
  62905. constructor(
  62906. /**
  62907. * Defines the red component (between 0 and 1, default is 0)
  62908. */
  62909. r?: number,
  62910. /**
  62911. * Defines the green component (between 0 and 1, default is 0)
  62912. */
  62913. g?: number,
  62914. /**
  62915. * Defines the blue component (between 0 and 1, default is 0)
  62916. */
  62917. b?: number);
  62918. /**
  62919. * Creates a string with the Color3 current values
  62920. * @returns the string representation of the Color3 object
  62921. */
  62922. toString(): string;
  62923. /**
  62924. * Returns the string "Color3"
  62925. * @returns "Color3"
  62926. */
  62927. getClassName(): string;
  62928. /**
  62929. * Compute the Color3 hash code
  62930. * @returns an unique number that can be used to hash Color3 objects
  62931. */
  62932. getHashCode(): number;
  62933. /**
  62934. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  62935. * @param array defines the array where to store the r,g,b components
  62936. * @param index defines an optional index in the target array to define where to start storing values
  62937. * @returns the current Color3 object
  62938. */
  62939. toArray(array: FloatArray, index?: number): Color3;
  62940. /**
  62941. * Returns a new Color4 object from the current Color3 and the given alpha
  62942. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  62943. * @returns a new Color4 object
  62944. */
  62945. toColor4(alpha?: number): Color4;
  62946. /**
  62947. * Returns a new array populated with 3 numeric elements : red, green and blue values
  62948. * @returns the new array
  62949. */
  62950. asArray(): number[];
  62951. /**
  62952. * Returns the luminance value
  62953. * @returns a float value
  62954. */
  62955. toLuminance(): number;
  62956. /**
  62957. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  62958. * @param otherColor defines the second operand
  62959. * @returns the new Color3 object
  62960. */
  62961. multiply(otherColor: DeepImmutable<Color3>): Color3;
  62962. /**
  62963. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  62964. * @param otherColor defines the second operand
  62965. * @param result defines the Color3 object where to store the result
  62966. * @returns the current Color3
  62967. */
  62968. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62969. /**
  62970. * Determines equality between Color3 objects
  62971. * @param otherColor defines the second operand
  62972. * @returns true if the rgb values are equal to the given ones
  62973. */
  62974. equals(otherColor: DeepImmutable<Color3>): boolean;
  62975. /**
  62976. * Determines equality between the current Color3 object and a set of r,b,g values
  62977. * @param r defines the red component to check
  62978. * @param g defines the green component to check
  62979. * @param b defines the blue component to check
  62980. * @returns true if the rgb values are equal to the given ones
  62981. */
  62982. equalsFloats(r: number, g: number, b: number): boolean;
  62983. /**
  62984. * Multiplies in place each rgb value by scale
  62985. * @param scale defines the scaling factor
  62986. * @returns the updated Color3
  62987. */
  62988. scale(scale: number): Color3;
  62989. /**
  62990. * Multiplies the rgb values by scale and stores the result into "result"
  62991. * @param scale defines the scaling factor
  62992. * @param result defines the Color3 object where to store the result
  62993. * @returns the unmodified current Color3
  62994. */
  62995. scaleToRef(scale: number, result: Color3): Color3;
  62996. /**
  62997. * Scale the current Color3 values by a factor and add the result to a given Color3
  62998. * @param scale defines the scale factor
  62999. * @param result defines color to store the result into
  63000. * @returns the unmodified current Color3
  63001. */
  63002. scaleAndAddToRef(scale: number, result: Color3): Color3;
  63003. /**
  63004. * Clamps the rgb values by the min and max values and stores the result into "result"
  63005. * @param min defines minimum clamping value (default is 0)
  63006. * @param max defines maximum clamping value (default is 1)
  63007. * @param result defines color to store the result into
  63008. * @returns the original Color3
  63009. */
  63010. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  63011. /**
  63012. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  63013. * @param otherColor defines the second operand
  63014. * @returns the new Color3
  63015. */
  63016. add(otherColor: DeepImmutable<Color3>): Color3;
  63017. /**
  63018. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  63019. * @param otherColor defines the second operand
  63020. * @param result defines Color3 object to store the result into
  63021. * @returns the unmodified current Color3
  63022. */
  63023. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63024. /**
  63025. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  63026. * @param otherColor defines the second operand
  63027. * @returns the new Color3
  63028. */
  63029. subtract(otherColor: DeepImmutable<Color3>): Color3;
  63030. /**
  63031. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  63032. * @param otherColor defines the second operand
  63033. * @param result defines Color3 object to store the result into
  63034. * @returns the unmodified current Color3
  63035. */
  63036. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63037. /**
  63038. * Copy the current object
  63039. * @returns a new Color3 copied the current one
  63040. */
  63041. clone(): Color3;
  63042. /**
  63043. * Copies the rgb values from the source in the current Color3
  63044. * @param source defines the source Color3 object
  63045. * @returns the updated Color3 object
  63046. */
  63047. copyFrom(source: DeepImmutable<Color3>): Color3;
  63048. /**
  63049. * Updates the Color3 rgb values from the given floats
  63050. * @param r defines the red component to read from
  63051. * @param g defines the green component to read from
  63052. * @param b defines the blue component to read from
  63053. * @returns the current Color3 object
  63054. */
  63055. copyFromFloats(r: number, g: number, b: number): Color3;
  63056. /**
  63057. * Updates the Color3 rgb values from the given floats
  63058. * @param r defines the red component to read from
  63059. * @param g defines the green component to read from
  63060. * @param b defines the blue component to read from
  63061. * @returns the current Color3 object
  63062. */
  63063. set(r: number, g: number, b: number): Color3;
  63064. /**
  63065. * Compute the Color3 hexadecimal code as a string
  63066. * @returns a string containing the hexadecimal representation of the Color3 object
  63067. */
  63068. toHexString(): string;
  63069. /**
  63070. * Computes a new Color3 converted from the current one to linear space
  63071. * @returns a new Color3 object
  63072. */
  63073. toLinearSpace(): Color3;
  63074. /**
  63075. * Converts current color in rgb space to HSV values
  63076. * @returns a new color3 representing the HSV values
  63077. */
  63078. toHSV(): Color3;
  63079. /**
  63080. * Converts current color in rgb space to HSV values
  63081. * @param result defines the Color3 where to store the HSV values
  63082. */
  63083. toHSVToRef(result: Color3): void;
  63084. /**
  63085. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  63086. * @param convertedColor defines the Color3 object where to store the linear space version
  63087. * @returns the unmodified Color3
  63088. */
  63089. toLinearSpaceToRef(convertedColor: Color3): Color3;
  63090. /**
  63091. * Computes a new Color3 converted from the current one to gamma space
  63092. * @returns a new Color3 object
  63093. */
  63094. toGammaSpace(): Color3;
  63095. /**
  63096. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  63097. * @param convertedColor defines the Color3 object where to store the gamma space version
  63098. * @returns the unmodified Color3
  63099. */
  63100. toGammaSpaceToRef(convertedColor: Color3): Color3;
  63101. private static _BlackReadOnly;
  63102. /**
  63103. * Convert Hue, saturation and value to a Color3 (RGB)
  63104. * @param hue defines the hue
  63105. * @param saturation defines the saturation
  63106. * @param value defines the value
  63107. * @param result defines the Color3 where to store the RGB values
  63108. */
  63109. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  63110. /**
  63111. * Creates a new Color3 from the string containing valid hexadecimal values
  63112. * @param hex defines a string containing valid hexadecimal values
  63113. * @returns a new Color3 object
  63114. */
  63115. static FromHexString(hex: string): Color3;
  63116. /**
  63117. * Creates a new Color3 from the starting index of the given array
  63118. * @param array defines the source array
  63119. * @param offset defines an offset in the source array
  63120. * @returns a new Color3 object
  63121. */
  63122. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  63123. /**
  63124. * Creates a new Color3 from integer values (< 256)
  63125. * @param r defines the red component to read from (value between 0 and 255)
  63126. * @param g defines the green component to read from (value between 0 and 255)
  63127. * @param b defines the blue component to read from (value between 0 and 255)
  63128. * @returns a new Color3 object
  63129. */
  63130. static FromInts(r: number, g: number, b: number): Color3;
  63131. /**
  63132. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63133. * @param start defines the start Color3 value
  63134. * @param end defines the end Color3 value
  63135. * @param amount defines the gradient value between start and end
  63136. * @returns a new Color3 object
  63137. */
  63138. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  63139. /**
  63140. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63141. * @param left defines the start value
  63142. * @param right defines the end value
  63143. * @param amount defines the gradient factor
  63144. * @param result defines the Color3 object where to store the result
  63145. */
  63146. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  63147. /**
  63148. * Returns a Color3 value containing a red color
  63149. * @returns a new Color3 object
  63150. */
  63151. static Red(): Color3;
  63152. /**
  63153. * Returns a Color3 value containing a green color
  63154. * @returns a new Color3 object
  63155. */
  63156. static Green(): Color3;
  63157. /**
  63158. * Returns a Color3 value containing a blue color
  63159. * @returns a new Color3 object
  63160. */
  63161. static Blue(): Color3;
  63162. /**
  63163. * Returns a Color3 value containing a black color
  63164. * @returns a new Color3 object
  63165. */
  63166. static Black(): Color3;
  63167. /**
  63168. * Gets a Color3 value containing a black color that must not be updated
  63169. */
  63170. static readonly BlackReadOnly: DeepImmutable<Color3>;
  63171. /**
  63172. * Returns a Color3 value containing a white color
  63173. * @returns a new Color3 object
  63174. */
  63175. static White(): Color3;
  63176. /**
  63177. * Returns a Color3 value containing a purple color
  63178. * @returns a new Color3 object
  63179. */
  63180. static Purple(): Color3;
  63181. /**
  63182. * Returns a Color3 value containing a magenta color
  63183. * @returns a new Color3 object
  63184. */
  63185. static Magenta(): Color3;
  63186. /**
  63187. * Returns a Color3 value containing a yellow color
  63188. * @returns a new Color3 object
  63189. */
  63190. static Yellow(): Color3;
  63191. /**
  63192. * Returns a Color3 value containing a gray color
  63193. * @returns a new Color3 object
  63194. */
  63195. static Gray(): Color3;
  63196. /**
  63197. * Returns a Color3 value containing a teal color
  63198. * @returns a new Color3 object
  63199. */
  63200. static Teal(): Color3;
  63201. /**
  63202. * Returns a Color3 value containing a random color
  63203. * @returns a new Color3 object
  63204. */
  63205. static Random(): Color3;
  63206. }
  63207. /**
  63208. * Class used to hold a RBGA color
  63209. */
  63210. export class Color4 {
  63211. /**
  63212. * Defines the red component (between 0 and 1, default is 0)
  63213. */
  63214. r: number;
  63215. /**
  63216. * Defines the green component (between 0 and 1, default is 0)
  63217. */
  63218. g: number;
  63219. /**
  63220. * Defines the blue component (between 0 and 1, default is 0)
  63221. */
  63222. b: number;
  63223. /**
  63224. * Defines the alpha component (between 0 and 1, default is 1)
  63225. */
  63226. a: number;
  63227. /**
  63228. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  63229. * @param r defines the red component (between 0 and 1, default is 0)
  63230. * @param g defines the green component (between 0 and 1, default is 0)
  63231. * @param b defines the blue component (between 0 and 1, default is 0)
  63232. * @param a defines the alpha component (between 0 and 1, default is 1)
  63233. */
  63234. constructor(
  63235. /**
  63236. * Defines the red component (between 0 and 1, default is 0)
  63237. */
  63238. r?: number,
  63239. /**
  63240. * Defines the green component (between 0 and 1, default is 0)
  63241. */
  63242. g?: number,
  63243. /**
  63244. * Defines the blue component (between 0 and 1, default is 0)
  63245. */
  63246. b?: number,
  63247. /**
  63248. * Defines the alpha component (between 0 and 1, default is 1)
  63249. */
  63250. a?: number);
  63251. /**
  63252. * Adds in place the given Color4 values to the current Color4 object
  63253. * @param right defines the second operand
  63254. * @returns the current updated Color4 object
  63255. */
  63256. addInPlace(right: DeepImmutable<Color4>): Color4;
  63257. /**
  63258. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  63259. * @returns the new array
  63260. */
  63261. asArray(): number[];
  63262. /**
  63263. * Stores from the starting index in the given array the Color4 successive values
  63264. * @param array defines the array where to store the r,g,b components
  63265. * @param index defines an optional index in the target array to define where to start storing values
  63266. * @returns the current Color4 object
  63267. */
  63268. toArray(array: number[], index?: number): Color4;
  63269. /**
  63270. * Determines equality between Color4 objects
  63271. * @param otherColor defines the second operand
  63272. * @returns true if the rgba values are equal to the given ones
  63273. */
  63274. equals(otherColor: DeepImmutable<Color4>): boolean;
  63275. /**
  63276. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  63277. * @param right defines the second operand
  63278. * @returns a new Color4 object
  63279. */
  63280. add(right: DeepImmutable<Color4>): Color4;
  63281. /**
  63282. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63283. * @param right defines the second operand
  63284. * @returns a new Color4 object
  63285. */
  63286. subtract(right: DeepImmutable<Color4>): Color4;
  63287. /**
  63288. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63289. * @param right defines the second operand
  63290. * @param result defines the Color4 object where to store the result
  63291. * @returns the current Color4 object
  63292. */
  63293. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63294. /**
  63295. * Creates a new Color4 with the current Color4 values multiplied by scale
  63296. * @param scale defines the scaling factor to apply
  63297. * @returns a new Color4 object
  63298. */
  63299. scale(scale: number): Color4;
  63300. /**
  63301. * Multiplies the current Color4 values by scale and stores the result in "result"
  63302. * @param scale defines the scaling factor to apply
  63303. * @param result defines the Color4 object where to store the result
  63304. * @returns the current unmodified Color4
  63305. */
  63306. scaleToRef(scale: number, result: Color4): Color4;
  63307. /**
  63308. * Scale the current Color4 values by a factor and add the result to a given Color4
  63309. * @param scale defines the scale factor
  63310. * @param result defines the Color4 object where to store the result
  63311. * @returns the unmodified current Color4
  63312. */
  63313. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63314. /**
  63315. * Clamps the rgb values by the min and max values and stores the result into "result"
  63316. * @param min defines minimum clamping value (default is 0)
  63317. * @param max defines maximum clamping value (default is 1)
  63318. * @param result defines color to store the result into.
  63319. * @returns the cuurent Color4
  63320. */
  63321. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63322. /**
  63323. * Multipy an Color4 value by another and return a new Color4 object
  63324. * @param color defines the Color4 value to multiply by
  63325. * @returns a new Color4 object
  63326. */
  63327. multiply(color: Color4): Color4;
  63328. /**
  63329. * Multipy a Color4 value by another and push the result in a reference value
  63330. * @param color defines the Color4 value to multiply by
  63331. * @param result defines the Color4 to fill the result in
  63332. * @returns the result Color4
  63333. */
  63334. multiplyToRef(color: Color4, result: Color4): Color4;
  63335. /**
  63336. * Creates a string with the Color4 current values
  63337. * @returns the string representation of the Color4 object
  63338. */
  63339. toString(): string;
  63340. /**
  63341. * Returns the string "Color4"
  63342. * @returns "Color4"
  63343. */
  63344. getClassName(): string;
  63345. /**
  63346. * Compute the Color4 hash code
  63347. * @returns an unique number that can be used to hash Color4 objects
  63348. */
  63349. getHashCode(): number;
  63350. /**
  63351. * Creates a new Color4 copied from the current one
  63352. * @returns a new Color4 object
  63353. */
  63354. clone(): Color4;
  63355. /**
  63356. * Copies the given Color4 values into the current one
  63357. * @param source defines the source Color4 object
  63358. * @returns the current updated Color4 object
  63359. */
  63360. copyFrom(source: Color4): Color4;
  63361. /**
  63362. * Copies the given float values into the current one
  63363. * @param r defines the red component to read from
  63364. * @param g defines the green component to read from
  63365. * @param b defines the blue component to read from
  63366. * @param a defines the alpha component to read from
  63367. * @returns the current updated Color4 object
  63368. */
  63369. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63370. /**
  63371. * Copies the given float values into the current one
  63372. * @param r defines the red component to read from
  63373. * @param g defines the green component to read from
  63374. * @param b defines the blue component to read from
  63375. * @param a defines the alpha component to read from
  63376. * @returns the current updated Color4 object
  63377. */
  63378. set(r: number, g: number, b: number, a: number): Color4;
  63379. /**
  63380. * Compute the Color4 hexadecimal code as a string
  63381. * @returns a string containing the hexadecimal representation of the Color4 object
  63382. */
  63383. toHexString(): string;
  63384. /**
  63385. * Computes a new Color4 converted from the current one to linear space
  63386. * @returns a new Color4 object
  63387. */
  63388. toLinearSpace(): Color4;
  63389. /**
  63390. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63391. * @param convertedColor defines the Color4 object where to store the linear space version
  63392. * @returns the unmodified Color4
  63393. */
  63394. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63395. /**
  63396. * Computes a new Color4 converted from the current one to gamma space
  63397. * @returns a new Color4 object
  63398. */
  63399. toGammaSpace(): Color4;
  63400. /**
  63401. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63402. * @param convertedColor defines the Color4 object where to store the gamma space version
  63403. * @returns the unmodified Color4
  63404. */
  63405. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63406. /**
  63407. * Creates a new Color4 from the string containing valid hexadecimal values
  63408. * @param hex defines a string containing valid hexadecimal values
  63409. * @returns a new Color4 object
  63410. */
  63411. static FromHexString(hex: string): Color4;
  63412. /**
  63413. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63414. * @param left defines the start value
  63415. * @param right defines the end value
  63416. * @param amount defines the gradient factor
  63417. * @returns a new Color4 object
  63418. */
  63419. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63420. /**
  63421. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63422. * @param left defines the start value
  63423. * @param right defines the end value
  63424. * @param amount defines the gradient factor
  63425. * @param result defines the Color4 object where to store data
  63426. */
  63427. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63428. /**
  63429. * Creates a new Color4 from a Color3 and an alpha value
  63430. * @param color3 defines the source Color3 to read from
  63431. * @param alpha defines the alpha component (1.0 by default)
  63432. * @returns a new Color4 object
  63433. */
  63434. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63435. /**
  63436. * Creates a new Color4 from the starting index element of the given array
  63437. * @param array defines the source array to read from
  63438. * @param offset defines the offset in the source array
  63439. * @returns a new Color4 object
  63440. */
  63441. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63442. /**
  63443. * Creates a new Color3 from integer values (< 256)
  63444. * @param r defines the red component to read from (value between 0 and 255)
  63445. * @param g defines the green component to read from (value between 0 and 255)
  63446. * @param b defines the blue component to read from (value between 0 and 255)
  63447. * @param a defines the alpha component to read from (value between 0 and 255)
  63448. * @returns a new Color3 object
  63449. */
  63450. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63451. /**
  63452. * Check the content of a given array and convert it to an array containing RGBA data
  63453. * If the original array was already containing count * 4 values then it is returned directly
  63454. * @param colors defines the array to check
  63455. * @param count defines the number of RGBA data to expect
  63456. * @returns an array containing count * 4 values (RGBA)
  63457. */
  63458. static CheckColors4(colors: number[], count: number): number[];
  63459. }
  63460. /**
  63461. * Class representing a vector containing 2 coordinates
  63462. */
  63463. export class Vector2 {
  63464. /** defines the first coordinate */
  63465. x: number;
  63466. /** defines the second coordinate */
  63467. y: number;
  63468. /**
  63469. * Creates a new Vector2 from the given x and y coordinates
  63470. * @param x defines the first coordinate
  63471. * @param y defines the second coordinate
  63472. */
  63473. constructor(
  63474. /** defines the first coordinate */
  63475. x?: number,
  63476. /** defines the second coordinate */
  63477. y?: number);
  63478. /**
  63479. * Gets a string with the Vector2 coordinates
  63480. * @returns a string with the Vector2 coordinates
  63481. */
  63482. toString(): string;
  63483. /**
  63484. * Gets class name
  63485. * @returns the string "Vector2"
  63486. */
  63487. getClassName(): string;
  63488. /**
  63489. * Gets current vector hash code
  63490. * @returns the Vector2 hash code as a number
  63491. */
  63492. getHashCode(): number;
  63493. /**
  63494. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63495. * @param array defines the source array
  63496. * @param index defines the offset in source array
  63497. * @returns the current Vector2
  63498. */
  63499. toArray(array: FloatArray, index?: number): Vector2;
  63500. /**
  63501. * Copy the current vector to an array
  63502. * @returns a new array with 2 elements: the Vector2 coordinates.
  63503. */
  63504. asArray(): number[];
  63505. /**
  63506. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63507. * @param source defines the source Vector2
  63508. * @returns the current updated Vector2
  63509. */
  63510. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63511. /**
  63512. * Sets the Vector2 coordinates with the given floats
  63513. * @param x defines the first coordinate
  63514. * @param y defines the second coordinate
  63515. * @returns the current updated Vector2
  63516. */
  63517. copyFromFloats(x: number, y: number): Vector2;
  63518. /**
  63519. * Sets the Vector2 coordinates with the given floats
  63520. * @param x defines the first coordinate
  63521. * @param y defines the second coordinate
  63522. * @returns the current updated Vector2
  63523. */
  63524. set(x: number, y: number): Vector2;
  63525. /**
  63526. * Add another vector with the current one
  63527. * @param otherVector defines the other vector
  63528. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63529. */
  63530. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63531. /**
  63532. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63533. * @param otherVector defines the other vector
  63534. * @param result defines the target vector
  63535. * @returns the unmodified current Vector2
  63536. */
  63537. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63538. /**
  63539. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63540. * @param otherVector defines the other vector
  63541. * @returns the current updated Vector2
  63542. */
  63543. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63544. /**
  63545. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63546. * @param otherVector defines the other vector
  63547. * @returns a new Vector2
  63548. */
  63549. addVector3(otherVector: Vector3): Vector2;
  63550. /**
  63551. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63552. * @param otherVector defines the other vector
  63553. * @returns a new Vector2
  63554. */
  63555. subtract(otherVector: Vector2): Vector2;
  63556. /**
  63557. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63558. * @param otherVector defines the other vector
  63559. * @param result defines the target vector
  63560. * @returns the unmodified current Vector2
  63561. */
  63562. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63563. /**
  63564. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63565. * @param otherVector defines the other vector
  63566. * @returns the current updated Vector2
  63567. */
  63568. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63569. /**
  63570. * Multiplies in place the current Vector2 coordinates by the given ones
  63571. * @param otherVector defines the other vector
  63572. * @returns the current updated Vector2
  63573. */
  63574. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63575. /**
  63576. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63577. * @param otherVector defines the other vector
  63578. * @returns a new Vector2
  63579. */
  63580. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63581. /**
  63582. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63583. * @param otherVector defines the other vector
  63584. * @param result defines the target vector
  63585. * @returns the unmodified current Vector2
  63586. */
  63587. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63588. /**
  63589. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63590. * @param x defines the first coordinate
  63591. * @param y defines the second coordinate
  63592. * @returns a new Vector2
  63593. */
  63594. multiplyByFloats(x: number, y: number): Vector2;
  63595. /**
  63596. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63597. * @param otherVector defines the other vector
  63598. * @returns a new Vector2
  63599. */
  63600. divide(otherVector: Vector2): Vector2;
  63601. /**
  63602. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63603. * @param otherVector defines the other vector
  63604. * @param result defines the target vector
  63605. * @returns the unmodified current Vector2
  63606. */
  63607. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63608. /**
  63609. * Divides the current Vector2 coordinates by the given ones
  63610. * @param otherVector defines the other vector
  63611. * @returns the current updated Vector2
  63612. */
  63613. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63614. /**
  63615. * Gets a new Vector2 with current Vector2 negated coordinates
  63616. * @returns a new Vector2
  63617. */
  63618. negate(): Vector2;
  63619. /**
  63620. * Multiply the Vector2 coordinates by scale
  63621. * @param scale defines the scaling factor
  63622. * @returns the current updated Vector2
  63623. */
  63624. scaleInPlace(scale: number): Vector2;
  63625. /**
  63626. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63627. * @param scale defines the scaling factor
  63628. * @returns a new Vector2
  63629. */
  63630. scale(scale: number): Vector2;
  63631. /**
  63632. * Scale the current Vector2 values by a factor to a given Vector2
  63633. * @param scale defines the scale factor
  63634. * @param result defines the Vector2 object where to store the result
  63635. * @returns the unmodified current Vector2
  63636. */
  63637. scaleToRef(scale: number, result: Vector2): Vector2;
  63638. /**
  63639. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63640. * @param scale defines the scale factor
  63641. * @param result defines the Vector2 object where to store the result
  63642. * @returns the unmodified current Vector2
  63643. */
  63644. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63645. /**
  63646. * Gets a boolean if two vectors are equals
  63647. * @param otherVector defines the other vector
  63648. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63649. */
  63650. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63651. /**
  63652. * Gets a boolean if two vectors are equals (using an epsilon value)
  63653. * @param otherVector defines the other vector
  63654. * @param epsilon defines the minimal distance to consider equality
  63655. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63656. */
  63657. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63658. /**
  63659. * Gets a new Vector2 from current Vector2 floored values
  63660. * @returns a new Vector2
  63661. */
  63662. floor(): Vector2;
  63663. /**
  63664. * Gets a new Vector2 from current Vector2 floored values
  63665. * @returns a new Vector2
  63666. */
  63667. fract(): Vector2;
  63668. /**
  63669. * Gets the length of the vector
  63670. * @returns the vector length (float)
  63671. */
  63672. length(): number;
  63673. /**
  63674. * Gets the vector squared length
  63675. * @returns the vector squared length (float)
  63676. */
  63677. lengthSquared(): number;
  63678. /**
  63679. * Normalize the vector
  63680. * @returns the current updated Vector2
  63681. */
  63682. normalize(): Vector2;
  63683. /**
  63684. * Gets a new Vector2 copied from the Vector2
  63685. * @returns a new Vector2
  63686. */
  63687. clone(): Vector2;
  63688. /**
  63689. * Gets a new Vector2(0, 0)
  63690. * @returns a new Vector2
  63691. */
  63692. static Zero(): Vector2;
  63693. /**
  63694. * Gets a new Vector2(1, 1)
  63695. * @returns a new Vector2
  63696. */
  63697. static One(): Vector2;
  63698. /**
  63699. * Gets a new Vector2 set from the given index element of the given array
  63700. * @param array defines the data source
  63701. * @param offset defines the offset in the data source
  63702. * @returns a new Vector2
  63703. */
  63704. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  63705. /**
  63706. * Sets "result" from the given index element of the given array
  63707. * @param array defines the data source
  63708. * @param offset defines the offset in the data source
  63709. * @param result defines the target vector
  63710. */
  63711. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  63712. /**
  63713. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  63714. * @param value1 defines 1st point of control
  63715. * @param value2 defines 2nd point of control
  63716. * @param value3 defines 3rd point of control
  63717. * @param value4 defines 4th point of control
  63718. * @param amount defines the interpolation factor
  63719. * @returns a new Vector2
  63720. */
  63721. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  63722. /**
  63723. * 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".
  63724. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  63725. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  63726. * @param value defines the value to clamp
  63727. * @param min defines the lower limit
  63728. * @param max defines the upper limit
  63729. * @returns a new Vector2
  63730. */
  63731. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  63732. /**
  63733. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  63734. * @param value1 defines the 1st control point
  63735. * @param tangent1 defines the outgoing tangent
  63736. * @param value2 defines the 2nd control point
  63737. * @param tangent2 defines the incoming tangent
  63738. * @param amount defines the interpolation factor
  63739. * @returns a new Vector2
  63740. */
  63741. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  63742. /**
  63743. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  63744. * @param start defines the start vector
  63745. * @param end defines the end vector
  63746. * @param amount defines the interpolation factor
  63747. * @returns a new Vector2
  63748. */
  63749. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  63750. /**
  63751. * Gets the dot product of the vector "left" and the vector "right"
  63752. * @param left defines first vector
  63753. * @param right defines second vector
  63754. * @returns the dot product (float)
  63755. */
  63756. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  63757. /**
  63758. * Returns a new Vector2 equal to the normalized given vector
  63759. * @param vector defines the vector to normalize
  63760. * @returns a new Vector2
  63761. */
  63762. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  63763. /**
  63764. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  63765. * @param left defines 1st vector
  63766. * @param right defines 2nd vector
  63767. * @returns a new Vector2
  63768. */
  63769. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63770. /**
  63771. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  63772. * @param left defines 1st vector
  63773. * @param right defines 2nd vector
  63774. * @returns a new Vector2
  63775. */
  63776. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63777. /**
  63778. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  63779. * @param vector defines the vector to transform
  63780. * @param transformation defines the matrix to apply
  63781. * @returns a new Vector2
  63782. */
  63783. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  63784. /**
  63785. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  63786. * @param vector defines the vector to transform
  63787. * @param transformation defines the matrix to apply
  63788. * @param result defines the target vector
  63789. */
  63790. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  63791. /**
  63792. * Determines if a given vector is included in a triangle
  63793. * @param p defines the vector to test
  63794. * @param p0 defines 1st triangle point
  63795. * @param p1 defines 2nd triangle point
  63796. * @param p2 defines 3rd triangle point
  63797. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  63798. */
  63799. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  63800. /**
  63801. * Gets the distance between the vectors "value1" and "value2"
  63802. * @param value1 defines first vector
  63803. * @param value2 defines second vector
  63804. * @returns the distance between vectors
  63805. */
  63806. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63807. /**
  63808. * Returns the squared distance between the vectors "value1" and "value2"
  63809. * @param value1 defines first vector
  63810. * @param value2 defines second vector
  63811. * @returns the squared distance between vectors
  63812. */
  63813. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63814. /**
  63815. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  63816. * @param value1 defines first vector
  63817. * @param value2 defines second vector
  63818. * @returns a new Vector2
  63819. */
  63820. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  63821. /**
  63822. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  63823. * @param p defines the middle point
  63824. * @param segA defines one point of the segment
  63825. * @param segB defines the other point of the segment
  63826. * @returns the shortest distance
  63827. */
  63828. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  63829. }
  63830. /**
  63831. * Classed used to store (x,y,z) vector representation
  63832. * A Vector3 is the main object used in 3D geometry
  63833. * It can represent etiher the coordinates of a point the space, either a direction
  63834. * Reminder: js uses a left handed forward facing system
  63835. */
  63836. export class Vector3 {
  63837. /**
  63838. * Defines the first coordinates (on X axis)
  63839. */
  63840. x: number;
  63841. /**
  63842. * Defines the second coordinates (on Y axis)
  63843. */
  63844. y: number;
  63845. /**
  63846. * Defines the third coordinates (on Z axis)
  63847. */
  63848. z: number;
  63849. private static _UpReadOnly;
  63850. private static _ZeroReadOnly;
  63851. /**
  63852. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  63853. * @param x defines the first coordinates (on X axis)
  63854. * @param y defines the second coordinates (on Y axis)
  63855. * @param z defines the third coordinates (on Z axis)
  63856. */
  63857. constructor(
  63858. /**
  63859. * Defines the first coordinates (on X axis)
  63860. */
  63861. x?: number,
  63862. /**
  63863. * Defines the second coordinates (on Y axis)
  63864. */
  63865. y?: number,
  63866. /**
  63867. * Defines the third coordinates (on Z axis)
  63868. */
  63869. z?: number);
  63870. /**
  63871. * Creates a string representation of the Vector3
  63872. * @returns a string with the Vector3 coordinates.
  63873. */
  63874. toString(): string;
  63875. /**
  63876. * Gets the class name
  63877. * @returns the string "Vector3"
  63878. */
  63879. getClassName(): string;
  63880. /**
  63881. * Creates the Vector3 hash code
  63882. * @returns a number which tends to be unique between Vector3 instances
  63883. */
  63884. getHashCode(): number;
  63885. /**
  63886. * Creates an array containing three elements : the coordinates of the Vector3
  63887. * @returns a new array of numbers
  63888. */
  63889. asArray(): number[];
  63890. /**
  63891. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  63892. * @param array defines the destination array
  63893. * @param index defines the offset in the destination array
  63894. * @returns the current Vector3
  63895. */
  63896. toArray(array: FloatArray, index?: number): Vector3;
  63897. /**
  63898. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  63899. * @returns a new Quaternion object, computed from the Vector3 coordinates
  63900. */
  63901. toQuaternion(): Quaternion;
  63902. /**
  63903. * Adds the given vector to the current Vector3
  63904. * @param otherVector defines the second operand
  63905. * @returns the current updated Vector3
  63906. */
  63907. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63908. /**
  63909. * Adds the given coordinates to the current Vector3
  63910. * @param x defines the x coordinate of the operand
  63911. * @param y defines the y coordinate of the operand
  63912. * @param z defines the z coordinate of the operand
  63913. * @returns the current updated Vector3
  63914. */
  63915. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63916. /**
  63917. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  63918. * @param otherVector defines the second operand
  63919. * @returns the resulting Vector3
  63920. */
  63921. add(otherVector: DeepImmutable<Vector3>): Vector3;
  63922. /**
  63923. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  63924. * @param otherVector defines the second operand
  63925. * @param result defines the Vector3 object where to store the result
  63926. * @returns the current Vector3
  63927. */
  63928. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63929. /**
  63930. * Subtract the given vector from the current Vector3
  63931. * @param otherVector defines the second operand
  63932. * @returns the current updated Vector3
  63933. */
  63934. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63935. /**
  63936. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  63937. * @param otherVector defines the second operand
  63938. * @returns the resulting Vector3
  63939. */
  63940. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  63941. /**
  63942. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  63943. * @param otherVector defines the second operand
  63944. * @param result defines the Vector3 object where to store the result
  63945. * @returns the current Vector3
  63946. */
  63947. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63948. /**
  63949. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  63950. * @param x defines the x coordinate of the operand
  63951. * @param y defines the y coordinate of the operand
  63952. * @param z defines the z coordinate of the operand
  63953. * @returns the resulting Vector3
  63954. */
  63955. subtractFromFloats(x: number, y: number, z: number): Vector3;
  63956. /**
  63957. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  63958. * @param x defines the x coordinate of the operand
  63959. * @param y defines the y coordinate of the operand
  63960. * @param z defines the z coordinate of the operand
  63961. * @param result defines the Vector3 object where to store the result
  63962. * @returns the current Vector3
  63963. */
  63964. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  63965. /**
  63966. * Gets a new Vector3 set with the current Vector3 negated coordinates
  63967. * @returns a new Vector3
  63968. */
  63969. negate(): Vector3;
  63970. /**
  63971. * Multiplies the Vector3 coordinates by the float "scale"
  63972. * @param scale defines the multiplier factor
  63973. * @returns the current updated Vector3
  63974. */
  63975. scaleInPlace(scale: number): Vector3;
  63976. /**
  63977. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  63978. * @param scale defines the multiplier factor
  63979. * @returns a new Vector3
  63980. */
  63981. scale(scale: number): Vector3;
  63982. /**
  63983. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  63984. * @param scale defines the multiplier factor
  63985. * @param result defines the Vector3 object where to store the result
  63986. * @returns the current Vector3
  63987. */
  63988. scaleToRef(scale: number, result: Vector3): Vector3;
  63989. /**
  63990. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  63991. * @param scale defines the scale factor
  63992. * @param result defines the Vector3 object where to store the result
  63993. * @returns the unmodified current Vector3
  63994. */
  63995. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  63996. /**
  63997. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  63998. * @param otherVector defines the second operand
  63999. * @returns true if both vectors are equals
  64000. */
  64001. equals(otherVector: DeepImmutable<Vector3>): boolean;
  64002. /**
  64003. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  64004. * @param otherVector defines the second operand
  64005. * @param epsilon defines the minimal distance to define values as equals
  64006. * @returns true if both vectors are distant less than epsilon
  64007. */
  64008. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  64009. /**
  64010. * Returns true if the current Vector3 coordinates equals the given floats
  64011. * @param x defines the x coordinate of the operand
  64012. * @param y defines the y coordinate of the operand
  64013. * @param z defines the z coordinate of the operand
  64014. * @returns true if both vectors are equals
  64015. */
  64016. equalsToFloats(x: number, y: number, z: number): boolean;
  64017. /**
  64018. * Multiplies the current Vector3 coordinates by the given ones
  64019. * @param otherVector defines the second operand
  64020. * @returns the current updated Vector3
  64021. */
  64022. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64023. /**
  64024. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  64025. * @param otherVector defines the second operand
  64026. * @returns the new Vector3
  64027. */
  64028. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  64029. /**
  64030. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  64031. * @param otherVector defines the second operand
  64032. * @param result defines the Vector3 object where to store the result
  64033. * @returns the current Vector3
  64034. */
  64035. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64036. /**
  64037. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  64038. * @param x defines the x coordinate of the operand
  64039. * @param y defines the y coordinate of the operand
  64040. * @param z defines the z coordinate of the operand
  64041. * @returns the new Vector3
  64042. */
  64043. multiplyByFloats(x: number, y: number, z: number): Vector3;
  64044. /**
  64045. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  64046. * @param otherVector defines the second operand
  64047. * @returns the new Vector3
  64048. */
  64049. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  64050. /**
  64051. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  64052. * @param otherVector defines the second operand
  64053. * @param result defines the Vector3 object where to store the result
  64054. * @returns the current Vector3
  64055. */
  64056. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64057. /**
  64058. * Divides the current Vector3 coordinates by the given ones.
  64059. * @param otherVector defines the second operand
  64060. * @returns the current updated Vector3
  64061. */
  64062. divideInPlace(otherVector: Vector3): Vector3;
  64063. /**
  64064. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  64065. * @param other defines the second operand
  64066. * @returns the current updated Vector3
  64067. */
  64068. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64069. /**
  64070. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  64071. * @param other defines the second operand
  64072. * @returns the current updated Vector3
  64073. */
  64074. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64075. /**
  64076. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  64077. * @param x defines the x coordinate of the operand
  64078. * @param y defines the y coordinate of the operand
  64079. * @param z defines the z coordinate of the operand
  64080. * @returns the current updated Vector3
  64081. */
  64082. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64083. /**
  64084. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  64085. * @param x defines the x coordinate of the operand
  64086. * @param y defines the y coordinate of the operand
  64087. * @param z defines the z coordinate of the operand
  64088. * @returns the current updated Vector3
  64089. */
  64090. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64091. /**
  64092. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  64093. * Check if is non uniform within a certain amount of decimal places to account for this
  64094. * @param epsilon the amount the values can differ
  64095. * @returns if the the vector is non uniform to a certain number of decimal places
  64096. */
  64097. isNonUniformWithinEpsilon(epsilon: number): boolean;
  64098. /**
  64099. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  64100. */
  64101. readonly isNonUniform: boolean;
  64102. /**
  64103. * Gets a new Vector3 from current Vector3 floored values
  64104. * @returns a new Vector3
  64105. */
  64106. floor(): Vector3;
  64107. /**
  64108. * Gets a new Vector3 from current Vector3 floored values
  64109. * @returns a new Vector3
  64110. */
  64111. fract(): Vector3;
  64112. /**
  64113. * Gets the length of the Vector3
  64114. * @returns the length of the Vector3
  64115. */
  64116. length(): number;
  64117. /**
  64118. * Gets the squared length of the Vector3
  64119. * @returns squared length of the Vector3
  64120. */
  64121. lengthSquared(): number;
  64122. /**
  64123. * Normalize the current Vector3.
  64124. * Please note that this is an in place operation.
  64125. * @returns the current updated Vector3
  64126. */
  64127. normalize(): Vector3;
  64128. /**
  64129. * Reorders the x y z properties of the vector in place
  64130. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  64131. * @returns the current updated vector
  64132. */
  64133. reorderInPlace(order: string): this;
  64134. /**
  64135. * Rotates the vector around 0,0,0 by a quaternion
  64136. * @param quaternion the rotation quaternion
  64137. * @param result vector to store the result
  64138. * @returns the resulting vector
  64139. */
  64140. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  64141. /**
  64142. * Rotates a vector around a given point
  64143. * @param quaternion the rotation quaternion
  64144. * @param point the point to rotate around
  64145. * @param result vector to store the result
  64146. * @returns the resulting vector
  64147. */
  64148. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  64149. /**
  64150. * Normalize the current Vector3 with the given input length.
  64151. * Please note that this is an in place operation.
  64152. * @param len the length of the vector
  64153. * @returns the current updated Vector3
  64154. */
  64155. normalizeFromLength(len: number): Vector3;
  64156. /**
  64157. * Normalize the current Vector3 to a new vector
  64158. * @returns the new Vector3
  64159. */
  64160. normalizeToNew(): Vector3;
  64161. /**
  64162. * Normalize the current Vector3 to the reference
  64163. * @param reference define the Vector3 to update
  64164. * @returns the updated Vector3
  64165. */
  64166. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  64167. /**
  64168. * Creates a new Vector3 copied from the current Vector3
  64169. * @returns the new Vector3
  64170. */
  64171. clone(): Vector3;
  64172. /**
  64173. * Copies the given vector coordinates to the current Vector3 ones
  64174. * @param source defines the source Vector3
  64175. * @returns the current updated Vector3
  64176. */
  64177. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  64178. /**
  64179. * Copies the given floats to the current Vector3 coordinates
  64180. * @param x defines the x coordinate of the operand
  64181. * @param y defines the y coordinate of the operand
  64182. * @param z defines the z coordinate of the operand
  64183. * @returns the current updated Vector3
  64184. */
  64185. copyFromFloats(x: number, y: number, z: number): Vector3;
  64186. /**
  64187. * Copies the given floats to the current Vector3 coordinates
  64188. * @param x defines the x coordinate of the operand
  64189. * @param y defines the y coordinate of the operand
  64190. * @param z defines the z coordinate of the operand
  64191. * @returns the current updated Vector3
  64192. */
  64193. set(x: number, y: number, z: number): Vector3;
  64194. /**
  64195. * Copies the given float to the current Vector3 coordinates
  64196. * @param v defines the x, y and z coordinates of the operand
  64197. * @returns the current updated Vector3
  64198. */
  64199. setAll(v: number): Vector3;
  64200. /**
  64201. * Get the clip factor between two vectors
  64202. * @param vector0 defines the first operand
  64203. * @param vector1 defines the second operand
  64204. * @param axis defines the axis to use
  64205. * @param size defines the size along the axis
  64206. * @returns the clip factor
  64207. */
  64208. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  64209. /**
  64210. * Get angle between two vectors
  64211. * @param vector0 angle between vector0 and vector1
  64212. * @param vector1 angle between vector0 and vector1
  64213. * @param normal direction of the normal
  64214. * @return the angle between vector0 and vector1
  64215. */
  64216. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  64217. /**
  64218. * Returns a new Vector3 set from the index "offset" of the given array
  64219. * @param array defines the source array
  64220. * @param offset defines the offset in the source array
  64221. * @returns the new Vector3
  64222. */
  64223. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  64224. /**
  64225. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  64226. * This function is deprecated. Use FromArray instead
  64227. * @param array defines the source array
  64228. * @param offset defines the offset in the source array
  64229. * @returns the new Vector3
  64230. */
  64231. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  64232. /**
  64233. * Sets the given vector "result" with the element values from the index "offset" of the given array
  64234. * @param array defines the source array
  64235. * @param offset defines the offset in the source array
  64236. * @param result defines the Vector3 where to store the result
  64237. */
  64238. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  64239. /**
  64240. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  64241. * This function is deprecated. Use FromArrayToRef instead.
  64242. * @param array defines the source array
  64243. * @param offset defines the offset in the source array
  64244. * @param result defines the Vector3 where to store the result
  64245. */
  64246. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  64247. /**
  64248. * Sets the given vector "result" with the given floats.
  64249. * @param x defines the x coordinate of the source
  64250. * @param y defines the y coordinate of the source
  64251. * @param z defines the z coordinate of the source
  64252. * @param result defines the Vector3 where to store the result
  64253. */
  64254. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  64255. /**
  64256. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  64257. * @returns a new empty Vector3
  64258. */
  64259. static Zero(): Vector3;
  64260. /**
  64261. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  64262. * @returns a new unit Vector3
  64263. */
  64264. static One(): Vector3;
  64265. /**
  64266. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  64267. * @returns a new up Vector3
  64268. */
  64269. static Up(): Vector3;
  64270. /**
  64271. * Gets a up Vector3 that must not be updated
  64272. */
  64273. static readonly UpReadOnly: DeepImmutable<Vector3>;
  64274. /**
  64275. * Gets a zero Vector3 that must not be updated
  64276. */
  64277. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  64278. /**
  64279. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  64280. * @returns a new down Vector3
  64281. */
  64282. static Down(): Vector3;
  64283. /**
  64284. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64285. * @returns a new forward Vector3
  64286. */
  64287. static Forward(): Vector3;
  64288. /**
  64289. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64290. * @returns a new forward Vector3
  64291. */
  64292. static Backward(): Vector3;
  64293. /**
  64294. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64295. * @returns a new right Vector3
  64296. */
  64297. static Right(): Vector3;
  64298. /**
  64299. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64300. * @returns a new left Vector3
  64301. */
  64302. static Left(): Vector3;
  64303. /**
  64304. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64305. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64306. * @param vector defines the Vector3 to transform
  64307. * @param transformation defines the transformation matrix
  64308. * @returns the transformed Vector3
  64309. */
  64310. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64311. /**
  64312. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64313. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64314. * @param vector defines the Vector3 to transform
  64315. * @param transformation defines the transformation matrix
  64316. * @param result defines the Vector3 where to store the result
  64317. */
  64318. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64319. /**
  64320. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64321. * This method computes tranformed coordinates only, not transformed direction vectors
  64322. * @param x define the x coordinate of the source vector
  64323. * @param y define the y coordinate of the source vector
  64324. * @param z define the z coordinate of the source vector
  64325. * @param transformation defines the transformation matrix
  64326. * @param result defines the Vector3 where to store the result
  64327. */
  64328. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64329. /**
  64330. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64331. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64332. * @param vector defines the Vector3 to transform
  64333. * @param transformation defines the transformation matrix
  64334. * @returns the new Vector3
  64335. */
  64336. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64337. /**
  64338. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64339. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64340. * @param vector defines the Vector3 to transform
  64341. * @param transformation defines the transformation matrix
  64342. * @param result defines the Vector3 where to store the result
  64343. */
  64344. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64345. /**
  64346. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64347. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64348. * @param x define the x coordinate of the source vector
  64349. * @param y define the y coordinate of the source vector
  64350. * @param z define the z coordinate of the source vector
  64351. * @param transformation defines the transformation matrix
  64352. * @param result defines the Vector3 where to store the result
  64353. */
  64354. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64355. /**
  64356. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64357. * @param value1 defines the first control point
  64358. * @param value2 defines the second control point
  64359. * @param value3 defines the third control point
  64360. * @param value4 defines the fourth control point
  64361. * @param amount defines the amount on the spline to use
  64362. * @returns the new Vector3
  64363. */
  64364. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64365. /**
  64366. * 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"
  64367. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64368. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64369. * @param value defines the current value
  64370. * @param min defines the lower range value
  64371. * @param max defines the upper range value
  64372. * @returns the new Vector3
  64373. */
  64374. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64375. /**
  64376. * 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"
  64377. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64378. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64379. * @param value defines the current value
  64380. * @param min defines the lower range value
  64381. * @param max defines the upper range value
  64382. * @param result defines the Vector3 where to store the result
  64383. */
  64384. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64385. /**
  64386. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64387. * @param value1 defines the first control point
  64388. * @param tangent1 defines the first tangent vector
  64389. * @param value2 defines the second control point
  64390. * @param tangent2 defines the second tangent vector
  64391. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64392. * @returns the new Vector3
  64393. */
  64394. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64395. /**
  64396. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64397. * @param start defines the start value
  64398. * @param end defines the end value
  64399. * @param amount max defines amount between both (between 0 and 1)
  64400. * @returns the new Vector3
  64401. */
  64402. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64403. /**
  64404. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64405. * @param start defines the start value
  64406. * @param end defines the end value
  64407. * @param amount max defines amount between both (between 0 and 1)
  64408. * @param result defines the Vector3 where to store the result
  64409. */
  64410. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64411. /**
  64412. * Returns the dot product (float) between the vectors "left" and "right"
  64413. * @param left defines the left operand
  64414. * @param right defines the right operand
  64415. * @returns the dot product
  64416. */
  64417. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64418. /**
  64419. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64420. * The cross product is then orthogonal to both "left" and "right"
  64421. * @param left defines the left operand
  64422. * @param right defines the right operand
  64423. * @returns the cross product
  64424. */
  64425. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64426. /**
  64427. * Sets the given vector "result" with the cross product of "left" and "right"
  64428. * The cross product is then orthogonal to both "left" and "right"
  64429. * @param left defines the left operand
  64430. * @param right defines the right operand
  64431. * @param result defines the Vector3 where to store the result
  64432. */
  64433. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64434. /**
  64435. * Returns a new Vector3 as the normalization of the given vector
  64436. * @param vector defines the Vector3 to normalize
  64437. * @returns the new Vector3
  64438. */
  64439. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64440. /**
  64441. * Sets the given vector "result" with the normalization of the given first vector
  64442. * @param vector defines the Vector3 to normalize
  64443. * @param result defines the Vector3 where to store the result
  64444. */
  64445. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64446. /**
  64447. * Project a Vector3 onto screen space
  64448. * @param vector defines the Vector3 to project
  64449. * @param world defines the world matrix to use
  64450. * @param transform defines the transform (view x projection) matrix to use
  64451. * @param viewport defines the screen viewport to use
  64452. * @returns the new Vector3
  64453. */
  64454. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64455. /** @hidden */
  64456. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64457. /**
  64458. * Unproject from screen space to object space
  64459. * @param source defines the screen space Vector3 to use
  64460. * @param viewportWidth defines the current width of the viewport
  64461. * @param viewportHeight defines the current height of the viewport
  64462. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64463. * @param transform defines the transform (view x projection) matrix to use
  64464. * @returns the new Vector3
  64465. */
  64466. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64467. /**
  64468. * Unproject from screen space to object space
  64469. * @param source defines the screen space Vector3 to use
  64470. * @param viewportWidth defines the current width of the viewport
  64471. * @param viewportHeight defines the current height of the viewport
  64472. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64473. * @param view defines the view matrix to use
  64474. * @param projection defines the projection matrix to use
  64475. * @returns the new Vector3
  64476. */
  64477. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64478. /**
  64479. * Unproject from screen space to object space
  64480. * @param source defines the screen space Vector3 to use
  64481. * @param viewportWidth defines the current width of the viewport
  64482. * @param viewportHeight defines the current height of the viewport
  64483. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64484. * @param view defines the view matrix to use
  64485. * @param projection defines the projection matrix to use
  64486. * @param result defines the Vector3 where to store the result
  64487. */
  64488. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64489. /**
  64490. * Unproject from screen space to object space
  64491. * @param sourceX defines the screen space x coordinate to use
  64492. * @param sourceY defines the screen space y coordinate to use
  64493. * @param sourceZ defines the screen space z coordinate to use
  64494. * @param viewportWidth defines the current width of the viewport
  64495. * @param viewportHeight defines the current height of the viewport
  64496. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64497. * @param view defines the view matrix to use
  64498. * @param projection defines the projection matrix to use
  64499. * @param result defines the Vector3 where to store the result
  64500. */
  64501. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64502. /**
  64503. * Gets the minimal coordinate values between two Vector3
  64504. * @param left defines the first operand
  64505. * @param right defines the second operand
  64506. * @returns the new Vector3
  64507. */
  64508. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64509. /**
  64510. * Gets the maximal coordinate values between two Vector3
  64511. * @param left defines the first operand
  64512. * @param right defines the second operand
  64513. * @returns the new Vector3
  64514. */
  64515. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64516. /**
  64517. * Returns the distance between the vectors "value1" and "value2"
  64518. * @param value1 defines the first operand
  64519. * @param value2 defines the second operand
  64520. * @returns the distance
  64521. */
  64522. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64523. /**
  64524. * Returns the squared distance between the vectors "value1" and "value2"
  64525. * @param value1 defines the first operand
  64526. * @param value2 defines the second operand
  64527. * @returns the squared distance
  64528. */
  64529. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64530. /**
  64531. * Returns a new Vector3 located at the center between "value1" and "value2"
  64532. * @param value1 defines the first operand
  64533. * @param value2 defines the second operand
  64534. * @returns the new Vector3
  64535. */
  64536. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64537. /**
  64538. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64539. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64540. * to something in order to rotate it from its local system to the given target system
  64541. * Note: axis1, axis2 and axis3 are normalized during this operation
  64542. * @param axis1 defines the first axis
  64543. * @param axis2 defines the second axis
  64544. * @param axis3 defines the third axis
  64545. * @returns a new Vector3
  64546. */
  64547. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64548. /**
  64549. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64550. * @param axis1 defines the first axis
  64551. * @param axis2 defines the second axis
  64552. * @param axis3 defines the third axis
  64553. * @param ref defines the Vector3 where to store the result
  64554. */
  64555. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64556. }
  64557. /**
  64558. * Vector4 class created for EulerAngle class conversion to Quaternion
  64559. */
  64560. export class Vector4 {
  64561. /** x value of the vector */
  64562. x: number;
  64563. /** y value of the vector */
  64564. y: number;
  64565. /** z value of the vector */
  64566. z: number;
  64567. /** w value of the vector */
  64568. w: number;
  64569. /**
  64570. * Creates a Vector4 object from the given floats.
  64571. * @param x x value of the vector
  64572. * @param y y value of the vector
  64573. * @param z z value of the vector
  64574. * @param w w value of the vector
  64575. */
  64576. constructor(
  64577. /** x value of the vector */
  64578. x: number,
  64579. /** y value of the vector */
  64580. y: number,
  64581. /** z value of the vector */
  64582. z: number,
  64583. /** w value of the vector */
  64584. w: number);
  64585. /**
  64586. * Returns the string with the Vector4 coordinates.
  64587. * @returns a string containing all the vector values
  64588. */
  64589. toString(): string;
  64590. /**
  64591. * Returns the string "Vector4".
  64592. * @returns "Vector4"
  64593. */
  64594. getClassName(): string;
  64595. /**
  64596. * Returns the Vector4 hash code.
  64597. * @returns a unique hash code
  64598. */
  64599. getHashCode(): number;
  64600. /**
  64601. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64602. * @returns the resulting array
  64603. */
  64604. asArray(): number[];
  64605. /**
  64606. * Populates the given array from the given index with the Vector4 coordinates.
  64607. * @param array array to populate
  64608. * @param index index of the array to start at (default: 0)
  64609. * @returns the Vector4.
  64610. */
  64611. toArray(array: FloatArray, index?: number): Vector4;
  64612. /**
  64613. * Adds the given vector to the current Vector4.
  64614. * @param otherVector the vector to add
  64615. * @returns the updated Vector4.
  64616. */
  64617. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64618. /**
  64619. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64620. * @param otherVector the vector to add
  64621. * @returns the resulting vector
  64622. */
  64623. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64624. /**
  64625. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64626. * @param otherVector the vector to add
  64627. * @param result the vector to store the result
  64628. * @returns the current Vector4.
  64629. */
  64630. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64631. /**
  64632. * Subtract in place the given vector from the current Vector4.
  64633. * @param otherVector the vector to subtract
  64634. * @returns the updated Vector4.
  64635. */
  64636. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64637. /**
  64638. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64639. * @param otherVector the vector to add
  64640. * @returns the new vector with the result
  64641. */
  64642. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64643. /**
  64644. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64645. * @param otherVector the vector to subtract
  64646. * @param result the vector to store the result
  64647. * @returns the current Vector4.
  64648. */
  64649. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64650. /**
  64651. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64652. */
  64653. /**
  64654. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64655. * @param x value to subtract
  64656. * @param y value to subtract
  64657. * @param z value to subtract
  64658. * @param w value to subtract
  64659. * @returns new vector containing the result
  64660. */
  64661. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64662. /**
  64663. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64664. * @param x value to subtract
  64665. * @param y value to subtract
  64666. * @param z value to subtract
  64667. * @param w value to subtract
  64668. * @param result the vector to store the result in
  64669. * @returns the current Vector4.
  64670. */
  64671. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64672. /**
  64673. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64674. * @returns a new vector with the negated values
  64675. */
  64676. negate(): Vector4;
  64677. /**
  64678. * Multiplies the current Vector4 coordinates by scale (float).
  64679. * @param scale the number to scale with
  64680. * @returns the updated Vector4.
  64681. */
  64682. scaleInPlace(scale: number): Vector4;
  64683. /**
  64684. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  64685. * @param scale the number to scale with
  64686. * @returns a new vector with the result
  64687. */
  64688. scale(scale: number): Vector4;
  64689. /**
  64690. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  64691. * @param scale the number to scale with
  64692. * @param result a vector to store the result in
  64693. * @returns the current Vector4.
  64694. */
  64695. scaleToRef(scale: number, result: Vector4): Vector4;
  64696. /**
  64697. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  64698. * @param scale defines the scale factor
  64699. * @param result defines the Vector4 object where to store the result
  64700. * @returns the unmodified current Vector4
  64701. */
  64702. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  64703. /**
  64704. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  64705. * @param otherVector the vector to compare against
  64706. * @returns true if they are equal
  64707. */
  64708. equals(otherVector: DeepImmutable<Vector4>): boolean;
  64709. /**
  64710. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  64711. * @param otherVector vector to compare against
  64712. * @param epsilon (Default: very small number)
  64713. * @returns true if they are equal
  64714. */
  64715. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  64716. /**
  64717. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  64718. * @param x x value to compare against
  64719. * @param y y value to compare against
  64720. * @param z z value to compare against
  64721. * @param w w value to compare against
  64722. * @returns true if equal
  64723. */
  64724. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  64725. /**
  64726. * Multiplies in place the current Vector4 by the given one.
  64727. * @param otherVector vector to multiple with
  64728. * @returns the updated Vector4.
  64729. */
  64730. multiplyInPlace(otherVector: Vector4): Vector4;
  64731. /**
  64732. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  64733. * @param otherVector vector to multiple with
  64734. * @returns resulting new vector
  64735. */
  64736. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  64737. /**
  64738. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  64739. * @param otherVector vector to multiple with
  64740. * @param result vector to store the result
  64741. * @returns the current Vector4.
  64742. */
  64743. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64744. /**
  64745. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  64746. * @param x x value multiply with
  64747. * @param y y value multiply with
  64748. * @param z z value multiply with
  64749. * @param w w value multiply with
  64750. * @returns resulting new vector
  64751. */
  64752. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  64753. /**
  64754. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  64755. * @param otherVector vector to devide with
  64756. * @returns resulting new vector
  64757. */
  64758. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  64759. /**
  64760. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  64761. * @param otherVector vector to devide with
  64762. * @param result vector to store the result
  64763. * @returns the current Vector4.
  64764. */
  64765. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64766. /**
  64767. * Divides the current Vector3 coordinates by the given ones.
  64768. * @param otherVector vector to devide with
  64769. * @returns the updated Vector3.
  64770. */
  64771. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64772. /**
  64773. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  64774. * @param other defines the second operand
  64775. * @returns the current updated Vector4
  64776. */
  64777. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64778. /**
  64779. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  64780. * @param other defines the second operand
  64781. * @returns the current updated Vector4
  64782. */
  64783. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64784. /**
  64785. * Gets a new Vector4 from current Vector4 floored values
  64786. * @returns a new Vector4
  64787. */
  64788. floor(): Vector4;
  64789. /**
  64790. * Gets a new Vector4 from current Vector3 floored values
  64791. * @returns a new Vector4
  64792. */
  64793. fract(): Vector4;
  64794. /**
  64795. * Returns the Vector4 length (float).
  64796. * @returns the length
  64797. */
  64798. length(): number;
  64799. /**
  64800. * Returns the Vector4 squared length (float).
  64801. * @returns the length squared
  64802. */
  64803. lengthSquared(): number;
  64804. /**
  64805. * Normalizes in place the Vector4.
  64806. * @returns the updated Vector4.
  64807. */
  64808. normalize(): Vector4;
  64809. /**
  64810. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  64811. * @returns this converted to a new vector3
  64812. */
  64813. toVector3(): Vector3;
  64814. /**
  64815. * Returns a new Vector4 copied from the current one.
  64816. * @returns the new cloned vector
  64817. */
  64818. clone(): Vector4;
  64819. /**
  64820. * Updates the current Vector4 with the given one coordinates.
  64821. * @param source the source vector to copy from
  64822. * @returns the updated Vector4.
  64823. */
  64824. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  64825. /**
  64826. * Updates the current Vector4 coordinates with the given floats.
  64827. * @param x float to copy from
  64828. * @param y float to copy from
  64829. * @param z float to copy from
  64830. * @param w float to copy from
  64831. * @returns the updated Vector4.
  64832. */
  64833. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64834. /**
  64835. * Updates the current Vector4 coordinates with the given floats.
  64836. * @param x float to set from
  64837. * @param y float to set from
  64838. * @param z float to set from
  64839. * @param w float to set from
  64840. * @returns the updated Vector4.
  64841. */
  64842. set(x: number, y: number, z: number, w: number): Vector4;
  64843. /**
  64844. * Copies the given float to the current Vector3 coordinates
  64845. * @param v defines the x, y, z and w coordinates of the operand
  64846. * @returns the current updated Vector3
  64847. */
  64848. setAll(v: number): Vector4;
  64849. /**
  64850. * Returns a new Vector4 set from the starting index of the given array.
  64851. * @param array the array to pull values from
  64852. * @param offset the offset into the array to start at
  64853. * @returns the new vector
  64854. */
  64855. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  64856. /**
  64857. * Updates the given vector "result" from the starting index of the given array.
  64858. * @param array the array to pull values from
  64859. * @param offset the offset into the array to start at
  64860. * @param result the vector to store the result in
  64861. */
  64862. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  64863. /**
  64864. * Updates the given vector "result" from the starting index of the given Float32Array.
  64865. * @param array the array to pull values from
  64866. * @param offset the offset into the array to start at
  64867. * @param result the vector to store the result in
  64868. */
  64869. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  64870. /**
  64871. * Updates the given vector "result" coordinates from the given floats.
  64872. * @param x float to set from
  64873. * @param y float to set from
  64874. * @param z float to set from
  64875. * @param w float to set from
  64876. * @param result the vector to the floats in
  64877. */
  64878. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  64879. /**
  64880. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  64881. * @returns the new vector
  64882. */
  64883. static Zero(): Vector4;
  64884. /**
  64885. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  64886. * @returns the new vector
  64887. */
  64888. static One(): Vector4;
  64889. /**
  64890. * Returns a new normalized Vector4 from the given one.
  64891. * @param vector the vector to normalize
  64892. * @returns the vector
  64893. */
  64894. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  64895. /**
  64896. * Updates the given vector "result" from the normalization of the given one.
  64897. * @param vector the vector to normalize
  64898. * @param result the vector to store the result in
  64899. */
  64900. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  64901. /**
  64902. * Returns a vector with the minimum values from the left and right vectors
  64903. * @param left left vector to minimize
  64904. * @param right right vector to minimize
  64905. * @returns a new vector with the minimum of the left and right vector values
  64906. */
  64907. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64908. /**
  64909. * Returns a vector with the maximum values from the left and right vectors
  64910. * @param left left vector to maximize
  64911. * @param right right vector to maximize
  64912. * @returns a new vector with the maximum of the left and right vector values
  64913. */
  64914. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64915. /**
  64916. * Returns the distance (float) between the vectors "value1" and "value2".
  64917. * @param value1 value to calulate the distance between
  64918. * @param value2 value to calulate the distance between
  64919. * @return the distance between the two vectors
  64920. */
  64921. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64922. /**
  64923. * Returns the squared distance (float) between the vectors "value1" and "value2".
  64924. * @param value1 value to calulate the distance between
  64925. * @param value2 value to calulate the distance between
  64926. * @return the distance between the two vectors squared
  64927. */
  64928. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64929. /**
  64930. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  64931. * @param value1 value to calulate the center between
  64932. * @param value2 value to calulate the center between
  64933. * @return the center between the two vectors
  64934. */
  64935. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  64936. /**
  64937. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  64938. * This methods computes transformed normalized direction vectors only.
  64939. * @param vector the vector to transform
  64940. * @param transformation the transformation matrix to apply
  64941. * @returns the new vector
  64942. */
  64943. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  64944. /**
  64945. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  64946. * This methods computes transformed normalized direction vectors only.
  64947. * @param vector the vector to transform
  64948. * @param transformation the transformation matrix to apply
  64949. * @param result the vector to store the result in
  64950. */
  64951. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64952. /**
  64953. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  64954. * This methods computes transformed normalized direction vectors only.
  64955. * @param x value to transform
  64956. * @param y value to transform
  64957. * @param z value to transform
  64958. * @param w value to transform
  64959. * @param transformation the transformation matrix to apply
  64960. * @param result the vector to store the results in
  64961. */
  64962. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64963. /**
  64964. * Creates a new Vector4 from a Vector3
  64965. * @param source defines the source data
  64966. * @param w defines the 4th component (default is 0)
  64967. * @returns a new Vector4
  64968. */
  64969. static FromVector3(source: Vector3, w?: number): Vector4;
  64970. }
  64971. /**
  64972. * Interface for the size containing width and height
  64973. */
  64974. export interface ISize {
  64975. /**
  64976. * Width
  64977. */
  64978. width: number;
  64979. /**
  64980. * Heighht
  64981. */
  64982. height: number;
  64983. }
  64984. /**
  64985. * Size containing widht and height
  64986. */
  64987. export class Size implements ISize {
  64988. /**
  64989. * Width
  64990. */
  64991. width: number;
  64992. /**
  64993. * Height
  64994. */
  64995. height: number;
  64996. /**
  64997. * Creates a Size object from the given width and height (floats).
  64998. * @param width width of the new size
  64999. * @param height height of the new size
  65000. */
  65001. constructor(width: number, height: number);
  65002. /**
  65003. * Returns a string with the Size width and height
  65004. * @returns a string with the Size width and height
  65005. */
  65006. toString(): string;
  65007. /**
  65008. * "Size"
  65009. * @returns the string "Size"
  65010. */
  65011. getClassName(): string;
  65012. /**
  65013. * Returns the Size hash code.
  65014. * @returns a hash code for a unique width and height
  65015. */
  65016. getHashCode(): number;
  65017. /**
  65018. * Updates the current size from the given one.
  65019. * @param src the given size
  65020. */
  65021. copyFrom(src: Size): void;
  65022. /**
  65023. * Updates in place the current Size from the given floats.
  65024. * @param width width of the new size
  65025. * @param height height of the new size
  65026. * @returns the updated Size.
  65027. */
  65028. copyFromFloats(width: number, height: number): Size;
  65029. /**
  65030. * Updates in place the current Size from the given floats.
  65031. * @param width width to set
  65032. * @param height height to set
  65033. * @returns the updated Size.
  65034. */
  65035. set(width: number, height: number): Size;
  65036. /**
  65037. * Multiplies the width and height by numbers
  65038. * @param w factor to multiple the width by
  65039. * @param h factor to multiple the height by
  65040. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  65041. */
  65042. multiplyByFloats(w: number, h: number): Size;
  65043. /**
  65044. * Clones the size
  65045. * @returns a new Size copied from the given one.
  65046. */
  65047. clone(): Size;
  65048. /**
  65049. * True if the current Size and the given one width and height are strictly equal.
  65050. * @param other the other size to compare against
  65051. * @returns True if the current Size and the given one width and height are strictly equal.
  65052. */
  65053. equals(other: Size): boolean;
  65054. /**
  65055. * The surface of the Size : width * height (float).
  65056. */
  65057. readonly surface: number;
  65058. /**
  65059. * Create a new size of zero
  65060. * @returns a new Size set to (0.0, 0.0)
  65061. */
  65062. static Zero(): Size;
  65063. /**
  65064. * Sums the width and height of two sizes
  65065. * @param otherSize size to add to this size
  65066. * @returns a new Size set as the addition result of the current Size and the given one.
  65067. */
  65068. add(otherSize: Size): Size;
  65069. /**
  65070. * Subtracts the width and height of two
  65071. * @param otherSize size to subtract to this size
  65072. * @returns a new Size set as the subtraction result of the given one from the current Size.
  65073. */
  65074. subtract(otherSize: Size): Size;
  65075. /**
  65076. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  65077. * @param start starting size to lerp between
  65078. * @param end end size to lerp between
  65079. * @param amount amount to lerp between the start and end values
  65080. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  65081. */
  65082. static Lerp(start: Size, end: Size, amount: number): Size;
  65083. }
  65084. /**
  65085. * Class used to store quaternion data
  65086. * @see https://en.wikipedia.org/wiki/Quaternion
  65087. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  65088. */
  65089. export class Quaternion {
  65090. /** defines the first component (0 by default) */
  65091. x: number;
  65092. /** defines the second component (0 by default) */
  65093. y: number;
  65094. /** defines the third component (0 by default) */
  65095. z: number;
  65096. /** defines the fourth component (1.0 by default) */
  65097. w: number;
  65098. /**
  65099. * Creates a new Quaternion from the given floats
  65100. * @param x defines the first component (0 by default)
  65101. * @param y defines the second component (0 by default)
  65102. * @param z defines the third component (0 by default)
  65103. * @param w defines the fourth component (1.0 by default)
  65104. */
  65105. constructor(
  65106. /** defines the first component (0 by default) */
  65107. x?: number,
  65108. /** defines the second component (0 by default) */
  65109. y?: number,
  65110. /** defines the third component (0 by default) */
  65111. z?: number,
  65112. /** defines the fourth component (1.0 by default) */
  65113. w?: number);
  65114. /**
  65115. * Gets a string representation for the current quaternion
  65116. * @returns a string with the Quaternion coordinates
  65117. */
  65118. toString(): string;
  65119. /**
  65120. * Gets the class name of the quaternion
  65121. * @returns the string "Quaternion"
  65122. */
  65123. getClassName(): string;
  65124. /**
  65125. * Gets a hash code for this quaternion
  65126. * @returns the quaternion hash code
  65127. */
  65128. getHashCode(): number;
  65129. /**
  65130. * Copy the quaternion to an array
  65131. * @returns a new array populated with 4 elements from the quaternion coordinates
  65132. */
  65133. asArray(): number[];
  65134. /**
  65135. * Check if two quaternions are equals
  65136. * @param otherQuaternion defines the second operand
  65137. * @return true if the current quaternion and the given one coordinates are strictly equals
  65138. */
  65139. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  65140. /**
  65141. * Clone the current quaternion
  65142. * @returns a new quaternion copied from the current one
  65143. */
  65144. clone(): Quaternion;
  65145. /**
  65146. * Copy a quaternion to the current one
  65147. * @param other defines the other quaternion
  65148. * @returns the updated current quaternion
  65149. */
  65150. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  65151. /**
  65152. * Updates the current quaternion with the given float coordinates
  65153. * @param x defines the x coordinate
  65154. * @param y defines the y coordinate
  65155. * @param z defines the z coordinate
  65156. * @param w defines the w coordinate
  65157. * @returns the updated current quaternion
  65158. */
  65159. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  65160. /**
  65161. * Updates the current quaternion from the given float coordinates
  65162. * @param x defines the x coordinate
  65163. * @param y defines the y coordinate
  65164. * @param z defines the z coordinate
  65165. * @param w defines the w coordinate
  65166. * @returns the updated current quaternion
  65167. */
  65168. set(x: number, y: number, z: number, w: number): Quaternion;
  65169. /**
  65170. * Adds two quaternions
  65171. * @param other defines the second operand
  65172. * @returns a new quaternion as the addition result of the given one and the current quaternion
  65173. */
  65174. add(other: DeepImmutable<Quaternion>): Quaternion;
  65175. /**
  65176. * Add a quaternion to the current one
  65177. * @param other defines the quaternion to add
  65178. * @returns the current quaternion
  65179. */
  65180. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  65181. /**
  65182. * Subtract two quaternions
  65183. * @param other defines the second operand
  65184. * @returns a new quaternion as the subtraction result of the given one from the current one
  65185. */
  65186. subtract(other: Quaternion): Quaternion;
  65187. /**
  65188. * Multiplies the current quaternion by a scale factor
  65189. * @param value defines the scale factor
  65190. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  65191. */
  65192. scale(value: number): Quaternion;
  65193. /**
  65194. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  65195. * @param scale defines the scale factor
  65196. * @param result defines the Quaternion object where to store the result
  65197. * @returns the unmodified current quaternion
  65198. */
  65199. scaleToRef(scale: number, result: Quaternion): Quaternion;
  65200. /**
  65201. * Multiplies in place the current quaternion by a scale factor
  65202. * @param value defines the scale factor
  65203. * @returns the current modified quaternion
  65204. */
  65205. scaleInPlace(value: number): Quaternion;
  65206. /**
  65207. * Scale the current quaternion values by a factor and add the result to a given quaternion
  65208. * @param scale defines the scale factor
  65209. * @param result defines the Quaternion object where to store the result
  65210. * @returns the unmodified current quaternion
  65211. */
  65212. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  65213. /**
  65214. * Multiplies two quaternions
  65215. * @param q1 defines the second operand
  65216. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  65217. */
  65218. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  65219. /**
  65220. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  65221. * @param q1 defines the second operand
  65222. * @param result defines the target quaternion
  65223. * @returns the current quaternion
  65224. */
  65225. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  65226. /**
  65227. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  65228. * @param q1 defines the second operand
  65229. * @returns the currentupdated quaternion
  65230. */
  65231. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  65232. /**
  65233. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  65234. * @param ref defines the target quaternion
  65235. * @returns the current quaternion
  65236. */
  65237. conjugateToRef(ref: Quaternion): Quaternion;
  65238. /**
  65239. * Conjugates in place (1-q) the current quaternion
  65240. * @returns the current updated quaternion
  65241. */
  65242. conjugateInPlace(): Quaternion;
  65243. /**
  65244. * Conjugates in place (1-q) the current quaternion
  65245. * @returns a new quaternion
  65246. */
  65247. conjugate(): Quaternion;
  65248. /**
  65249. * Gets length of current quaternion
  65250. * @returns the quaternion length (float)
  65251. */
  65252. length(): number;
  65253. /**
  65254. * Normalize in place the current quaternion
  65255. * @returns the current updated quaternion
  65256. */
  65257. normalize(): Quaternion;
  65258. /**
  65259. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  65260. * @param order is a reserved parameter and is ignore for now
  65261. * @returns a new Vector3 containing the Euler angles
  65262. */
  65263. toEulerAngles(order?: string): Vector3;
  65264. /**
  65265. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  65266. * @param result defines the vector which will be filled with the Euler angles
  65267. * @param order is a reserved parameter and is ignore for now
  65268. * @returns the current unchanged quaternion
  65269. */
  65270. toEulerAnglesToRef(result: Vector3): Quaternion;
  65271. /**
  65272. * Updates the given rotation matrix with the current quaternion values
  65273. * @param result defines the target matrix
  65274. * @returns the current unchanged quaternion
  65275. */
  65276. toRotationMatrix(result: Matrix): Quaternion;
  65277. /**
  65278. * Updates the current quaternion from the given rotation matrix values
  65279. * @param matrix defines the source matrix
  65280. * @returns the current updated quaternion
  65281. */
  65282. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65283. /**
  65284. * Creates a new quaternion from a rotation matrix
  65285. * @param matrix defines the source matrix
  65286. * @returns a new quaternion created from the given rotation matrix values
  65287. */
  65288. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65289. /**
  65290. * Updates the given quaternion with the given rotation matrix values
  65291. * @param matrix defines the source matrix
  65292. * @param result defines the target quaternion
  65293. */
  65294. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65295. /**
  65296. * Returns the dot product (float) between the quaternions "left" and "right"
  65297. * @param left defines the left operand
  65298. * @param right defines the right operand
  65299. * @returns the dot product
  65300. */
  65301. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65302. /**
  65303. * Checks if the two quaternions are close to each other
  65304. * @param quat0 defines the first quaternion to check
  65305. * @param quat1 defines the second quaternion to check
  65306. * @returns true if the two quaternions are close to each other
  65307. */
  65308. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65309. /**
  65310. * Creates an empty quaternion
  65311. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65312. */
  65313. static Zero(): Quaternion;
  65314. /**
  65315. * Inverse a given quaternion
  65316. * @param q defines the source quaternion
  65317. * @returns a new quaternion as the inverted current quaternion
  65318. */
  65319. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65320. /**
  65321. * Inverse a given quaternion
  65322. * @param q defines the source quaternion
  65323. * @param result the quaternion the result will be stored in
  65324. * @returns the result quaternion
  65325. */
  65326. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65327. /**
  65328. * Creates an identity quaternion
  65329. * @returns the identity quaternion
  65330. */
  65331. static Identity(): Quaternion;
  65332. /**
  65333. * Gets a boolean indicating if the given quaternion is identity
  65334. * @param quaternion defines the quaternion to check
  65335. * @returns true if the quaternion is identity
  65336. */
  65337. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65338. /**
  65339. * Creates a quaternion from a rotation around an axis
  65340. * @param axis defines the axis to use
  65341. * @param angle defines the angle to use
  65342. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65343. */
  65344. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65345. /**
  65346. * Creates a rotation around an axis and stores it into the given quaternion
  65347. * @param axis defines the axis to use
  65348. * @param angle defines the angle to use
  65349. * @param result defines the target quaternion
  65350. * @returns the target quaternion
  65351. */
  65352. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65353. /**
  65354. * Creates a new quaternion from data stored into an array
  65355. * @param array defines the data source
  65356. * @param offset defines the offset in the source array where the data starts
  65357. * @returns a new quaternion
  65358. */
  65359. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65360. /**
  65361. * Create a quaternion from Euler rotation angles
  65362. * @param x Pitch
  65363. * @param y Yaw
  65364. * @param z Roll
  65365. * @returns the new Quaternion
  65366. */
  65367. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65368. /**
  65369. * Updates a quaternion from Euler rotation angles
  65370. * @param x Pitch
  65371. * @param y Yaw
  65372. * @param z Roll
  65373. * @param result the quaternion to store the result
  65374. * @returns the updated quaternion
  65375. */
  65376. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65377. /**
  65378. * Create a quaternion from Euler rotation vector
  65379. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65380. * @returns the new Quaternion
  65381. */
  65382. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65383. /**
  65384. * Updates a quaternion from Euler rotation vector
  65385. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65386. * @param result the quaternion to store the result
  65387. * @returns the updated quaternion
  65388. */
  65389. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65390. /**
  65391. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65392. * @param yaw defines the rotation around Y axis
  65393. * @param pitch defines the rotation around X axis
  65394. * @param roll defines the rotation around Z axis
  65395. * @returns the new quaternion
  65396. */
  65397. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65398. /**
  65399. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65400. * @param yaw defines the rotation around Y axis
  65401. * @param pitch defines the rotation around X axis
  65402. * @param roll defines the rotation around Z axis
  65403. * @param result defines the target quaternion
  65404. */
  65405. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65406. /**
  65407. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65408. * @param alpha defines the rotation around first axis
  65409. * @param beta defines the rotation around second axis
  65410. * @param gamma defines the rotation around third axis
  65411. * @returns the new quaternion
  65412. */
  65413. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65414. /**
  65415. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65416. * @param alpha defines the rotation around first axis
  65417. * @param beta defines the rotation around second axis
  65418. * @param gamma defines the rotation around third axis
  65419. * @param result defines the target quaternion
  65420. */
  65421. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65422. /**
  65423. * 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)
  65424. * @param axis1 defines the first axis
  65425. * @param axis2 defines the second axis
  65426. * @param axis3 defines the third axis
  65427. * @returns the new quaternion
  65428. */
  65429. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65430. /**
  65431. * 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
  65432. * @param axis1 defines the first axis
  65433. * @param axis2 defines the second axis
  65434. * @param axis3 defines the third axis
  65435. * @param ref defines the target quaternion
  65436. */
  65437. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65438. /**
  65439. * Interpolates between two quaternions
  65440. * @param left defines first quaternion
  65441. * @param right defines second quaternion
  65442. * @param amount defines the gradient to use
  65443. * @returns the new interpolated quaternion
  65444. */
  65445. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65446. /**
  65447. * Interpolates between two quaternions and stores it into a target quaternion
  65448. * @param left defines first quaternion
  65449. * @param right defines second quaternion
  65450. * @param amount defines the gradient to use
  65451. * @param result defines the target quaternion
  65452. */
  65453. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65454. /**
  65455. * Interpolate between two quaternions using Hermite interpolation
  65456. * @param value1 defines first quaternion
  65457. * @param tangent1 defines the incoming tangent
  65458. * @param value2 defines second quaternion
  65459. * @param tangent2 defines the outgoing tangent
  65460. * @param amount defines the target quaternion
  65461. * @returns the new interpolated quaternion
  65462. */
  65463. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65464. }
  65465. /**
  65466. * Class used to store matrix data (4x4)
  65467. */
  65468. export class Matrix {
  65469. private static _updateFlagSeed;
  65470. private static _identityReadOnly;
  65471. private _isIdentity;
  65472. private _isIdentityDirty;
  65473. private _isIdentity3x2;
  65474. private _isIdentity3x2Dirty;
  65475. /**
  65476. * Gets the update flag of the matrix which is an unique number for the matrix.
  65477. * It will be incremented every time the matrix data change.
  65478. * You can use it to speed the comparison between two versions of the same matrix.
  65479. */
  65480. updateFlag: number;
  65481. private readonly _m;
  65482. /**
  65483. * Gets the internal data of the matrix
  65484. */
  65485. readonly m: DeepImmutable<Float32Array>;
  65486. /** @hidden */
  65487. _markAsUpdated(): void;
  65488. /** @hidden */
  65489. private _updateIdentityStatus;
  65490. /**
  65491. * Creates an empty matrix (filled with zeros)
  65492. */
  65493. constructor();
  65494. /**
  65495. * Check if the current matrix is identity
  65496. * @returns true is the matrix is the identity matrix
  65497. */
  65498. isIdentity(): boolean;
  65499. /**
  65500. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65501. * @returns true is the matrix is the identity matrix
  65502. */
  65503. isIdentityAs3x2(): boolean;
  65504. /**
  65505. * Gets the determinant of the matrix
  65506. * @returns the matrix determinant
  65507. */
  65508. determinant(): number;
  65509. /**
  65510. * Returns the matrix as a Float32Array
  65511. * @returns the matrix underlying array
  65512. */
  65513. toArray(): DeepImmutable<Float32Array>;
  65514. /**
  65515. * Returns the matrix as a Float32Array
  65516. * @returns the matrix underlying array.
  65517. */
  65518. asArray(): DeepImmutable<Float32Array>;
  65519. /**
  65520. * Inverts the current matrix in place
  65521. * @returns the current inverted matrix
  65522. */
  65523. invert(): Matrix;
  65524. /**
  65525. * Sets all the matrix elements to zero
  65526. * @returns the current matrix
  65527. */
  65528. reset(): Matrix;
  65529. /**
  65530. * Adds the current matrix with a second one
  65531. * @param other defines the matrix to add
  65532. * @returns a new matrix as the addition of the current matrix and the given one
  65533. */
  65534. add(other: DeepImmutable<Matrix>): Matrix;
  65535. /**
  65536. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65537. * @param other defines the matrix to add
  65538. * @param result defines the target matrix
  65539. * @returns the current matrix
  65540. */
  65541. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65542. /**
  65543. * Adds in place the given matrix to the current matrix
  65544. * @param other defines the second operand
  65545. * @returns the current updated matrix
  65546. */
  65547. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65548. /**
  65549. * Sets the given matrix to the current inverted Matrix
  65550. * @param other defines the target matrix
  65551. * @returns the unmodified current matrix
  65552. */
  65553. invertToRef(other: Matrix): Matrix;
  65554. /**
  65555. * add a value at the specified position in the current Matrix
  65556. * @param index the index of the value within the matrix. between 0 and 15.
  65557. * @param value the value to be added
  65558. * @returns the current updated matrix
  65559. */
  65560. addAtIndex(index: number, value: number): Matrix;
  65561. /**
  65562. * mutiply the specified position in the current Matrix by a value
  65563. * @param index the index of the value within the matrix. between 0 and 15.
  65564. * @param value the value to be added
  65565. * @returns the current updated matrix
  65566. */
  65567. multiplyAtIndex(index: number, value: number): Matrix;
  65568. /**
  65569. * Inserts the translation vector (using 3 floats) in the current matrix
  65570. * @param x defines the 1st component of the translation
  65571. * @param y defines the 2nd component of the translation
  65572. * @param z defines the 3rd component of the translation
  65573. * @returns the current updated matrix
  65574. */
  65575. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65576. /**
  65577. * Adds the translation vector (using 3 floats) in the current matrix
  65578. * @param x defines the 1st component of the translation
  65579. * @param y defines the 2nd component of the translation
  65580. * @param z defines the 3rd component of the translation
  65581. * @returns the current updated matrix
  65582. */
  65583. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65584. /**
  65585. * Inserts the translation vector in the current matrix
  65586. * @param vector3 defines the translation to insert
  65587. * @returns the current updated matrix
  65588. */
  65589. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65590. /**
  65591. * Gets the translation value of the current matrix
  65592. * @returns a new Vector3 as the extracted translation from the matrix
  65593. */
  65594. getTranslation(): Vector3;
  65595. /**
  65596. * Fill a Vector3 with the extracted translation from the matrix
  65597. * @param result defines the Vector3 where to store the translation
  65598. * @returns the current matrix
  65599. */
  65600. getTranslationToRef(result: Vector3): Matrix;
  65601. /**
  65602. * Remove rotation and scaling part from the matrix
  65603. * @returns the updated matrix
  65604. */
  65605. removeRotationAndScaling(): Matrix;
  65606. /**
  65607. * Multiply two matrices
  65608. * @param other defines the second operand
  65609. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65610. */
  65611. multiply(other: DeepImmutable<Matrix>): Matrix;
  65612. /**
  65613. * Copy the current matrix from the given one
  65614. * @param other defines the source matrix
  65615. * @returns the current updated matrix
  65616. */
  65617. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65618. /**
  65619. * Populates the given array from the starting index with the current matrix values
  65620. * @param array defines the target array
  65621. * @param offset defines the offset in the target array where to start storing values
  65622. * @returns the current matrix
  65623. */
  65624. copyToArray(array: Float32Array, offset?: number): Matrix;
  65625. /**
  65626. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65627. * @param other defines the second operand
  65628. * @param result defines the matrix where to store the multiplication
  65629. * @returns the current matrix
  65630. */
  65631. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65632. /**
  65633. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65634. * @param other defines the second operand
  65635. * @param result defines the array where to store the multiplication
  65636. * @param offset defines the offset in the target array where to start storing values
  65637. * @returns the current matrix
  65638. */
  65639. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65640. /**
  65641. * Check equality between this matrix and a second one
  65642. * @param value defines the second matrix to compare
  65643. * @returns true is the current matrix and the given one values are strictly equal
  65644. */
  65645. equals(value: DeepImmutable<Matrix>): boolean;
  65646. /**
  65647. * Clone the current matrix
  65648. * @returns a new matrix from the current matrix
  65649. */
  65650. clone(): Matrix;
  65651. /**
  65652. * Returns the name of the current matrix class
  65653. * @returns the string "Matrix"
  65654. */
  65655. getClassName(): string;
  65656. /**
  65657. * Gets the hash code of the current matrix
  65658. * @returns the hash code
  65659. */
  65660. getHashCode(): number;
  65661. /**
  65662. * Decomposes the current Matrix into a translation, rotation and scaling components
  65663. * @param scale defines the scale vector3 given as a reference to update
  65664. * @param rotation defines the rotation quaternion given as a reference to update
  65665. * @param translation defines the translation vector3 given as a reference to update
  65666. * @returns true if operation was successful
  65667. */
  65668. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65669. /**
  65670. * Gets specific row of the matrix
  65671. * @param index defines the number of the row to get
  65672. * @returns the index-th row of the current matrix as a new Vector4
  65673. */
  65674. getRow(index: number): Nullable<Vector4>;
  65675. /**
  65676. * Sets the index-th row of the current matrix to the vector4 values
  65677. * @param index defines the number of the row to set
  65678. * @param row defines the target vector4
  65679. * @returns the updated current matrix
  65680. */
  65681. setRow(index: number, row: Vector4): Matrix;
  65682. /**
  65683. * Compute the transpose of the matrix
  65684. * @returns the new transposed matrix
  65685. */
  65686. transpose(): Matrix;
  65687. /**
  65688. * Compute the transpose of the matrix and store it in a given matrix
  65689. * @param result defines the target matrix
  65690. * @returns the current matrix
  65691. */
  65692. transposeToRef(result: Matrix): Matrix;
  65693. /**
  65694. * Sets the index-th row of the current matrix with the given 4 x float values
  65695. * @param index defines the row index
  65696. * @param x defines the x component to set
  65697. * @param y defines the y component to set
  65698. * @param z defines the z component to set
  65699. * @param w defines the w component to set
  65700. * @returns the updated current matrix
  65701. */
  65702. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  65703. /**
  65704. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  65705. * @param scale defines the scale factor
  65706. * @returns a new matrix
  65707. */
  65708. scale(scale: number): Matrix;
  65709. /**
  65710. * Scale the current matrix values by a factor to a given result matrix
  65711. * @param scale defines the scale factor
  65712. * @param result defines the matrix to store the result
  65713. * @returns the current matrix
  65714. */
  65715. scaleToRef(scale: number, result: Matrix): Matrix;
  65716. /**
  65717. * Scale the current matrix values by a factor and add the result to a given matrix
  65718. * @param scale defines the scale factor
  65719. * @param result defines the Matrix to store the result
  65720. * @returns the current matrix
  65721. */
  65722. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  65723. /**
  65724. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  65725. * @param ref matrix to store the result
  65726. */
  65727. toNormalMatrix(ref: Matrix): void;
  65728. /**
  65729. * Gets only rotation part of the current matrix
  65730. * @returns a new matrix sets to the extracted rotation matrix from the current one
  65731. */
  65732. getRotationMatrix(): Matrix;
  65733. /**
  65734. * Extracts the rotation matrix from the current one and sets it as the given "result"
  65735. * @param result defines the target matrix to store data to
  65736. * @returns the current matrix
  65737. */
  65738. getRotationMatrixToRef(result: Matrix): Matrix;
  65739. /**
  65740. * Toggles model matrix from being right handed to left handed in place and vice versa
  65741. */
  65742. toggleModelMatrixHandInPlace(): void;
  65743. /**
  65744. * Toggles projection matrix from being right handed to left handed in place and vice versa
  65745. */
  65746. toggleProjectionMatrixHandInPlace(): void;
  65747. /**
  65748. * Creates a matrix from an array
  65749. * @param array defines the source array
  65750. * @param offset defines an offset in the source array
  65751. * @returns a new Matrix set from the starting index of the given array
  65752. */
  65753. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  65754. /**
  65755. * Copy the content of an array into a given matrix
  65756. * @param array defines the source array
  65757. * @param offset defines an offset in the source array
  65758. * @param result defines the target matrix
  65759. */
  65760. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  65761. /**
  65762. * Stores an array into a matrix after having multiplied each component by a given factor
  65763. * @param array defines the source array
  65764. * @param offset defines the offset in the source array
  65765. * @param scale defines the scaling factor
  65766. * @param result defines the target matrix
  65767. */
  65768. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  65769. /**
  65770. * Gets an identity matrix that must not be updated
  65771. */
  65772. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  65773. /**
  65774. * Stores a list of values (16) inside a given matrix
  65775. * @param initialM11 defines 1st value of 1st row
  65776. * @param initialM12 defines 2nd value of 1st row
  65777. * @param initialM13 defines 3rd value of 1st row
  65778. * @param initialM14 defines 4th value of 1st row
  65779. * @param initialM21 defines 1st value of 2nd row
  65780. * @param initialM22 defines 2nd value of 2nd row
  65781. * @param initialM23 defines 3rd value of 2nd row
  65782. * @param initialM24 defines 4th value of 2nd row
  65783. * @param initialM31 defines 1st value of 3rd row
  65784. * @param initialM32 defines 2nd value of 3rd row
  65785. * @param initialM33 defines 3rd value of 3rd row
  65786. * @param initialM34 defines 4th value of 3rd row
  65787. * @param initialM41 defines 1st value of 4th row
  65788. * @param initialM42 defines 2nd value of 4th row
  65789. * @param initialM43 defines 3rd value of 4th row
  65790. * @param initialM44 defines 4th value of 4th row
  65791. * @param result defines the target matrix
  65792. */
  65793. 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;
  65794. /**
  65795. * Creates new matrix from a list of values (16)
  65796. * @param initialM11 defines 1st value of 1st row
  65797. * @param initialM12 defines 2nd value of 1st row
  65798. * @param initialM13 defines 3rd value of 1st row
  65799. * @param initialM14 defines 4th value of 1st row
  65800. * @param initialM21 defines 1st value of 2nd row
  65801. * @param initialM22 defines 2nd value of 2nd row
  65802. * @param initialM23 defines 3rd value of 2nd row
  65803. * @param initialM24 defines 4th value of 2nd row
  65804. * @param initialM31 defines 1st value of 3rd row
  65805. * @param initialM32 defines 2nd value of 3rd row
  65806. * @param initialM33 defines 3rd value of 3rd row
  65807. * @param initialM34 defines 4th value of 3rd row
  65808. * @param initialM41 defines 1st value of 4th row
  65809. * @param initialM42 defines 2nd value of 4th row
  65810. * @param initialM43 defines 3rd value of 4th row
  65811. * @param initialM44 defines 4th value of 4th row
  65812. * @returns the new matrix
  65813. */
  65814. 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;
  65815. /**
  65816. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65817. * @param scale defines the scale vector3
  65818. * @param rotation defines the rotation quaternion
  65819. * @param translation defines the translation vector3
  65820. * @returns a new matrix
  65821. */
  65822. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  65823. /**
  65824. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65825. * @param scale defines the scale vector3
  65826. * @param rotation defines the rotation quaternion
  65827. * @param translation defines the translation vector3
  65828. * @param result defines the target matrix
  65829. */
  65830. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  65831. /**
  65832. * Creates a new identity matrix
  65833. * @returns a new identity matrix
  65834. */
  65835. static Identity(): Matrix;
  65836. /**
  65837. * Creates a new identity matrix and stores the result in a given matrix
  65838. * @param result defines the target matrix
  65839. */
  65840. static IdentityToRef(result: Matrix): void;
  65841. /**
  65842. * Creates a new zero matrix
  65843. * @returns a new zero matrix
  65844. */
  65845. static Zero(): Matrix;
  65846. /**
  65847. * Creates a new rotation matrix for "angle" radians around the X axis
  65848. * @param angle defines the angle (in radians) to use
  65849. * @return the new matrix
  65850. */
  65851. static RotationX(angle: number): Matrix;
  65852. /**
  65853. * Creates a new matrix as the invert of a given matrix
  65854. * @param source defines the source matrix
  65855. * @returns the new matrix
  65856. */
  65857. static Invert(source: DeepImmutable<Matrix>): Matrix;
  65858. /**
  65859. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  65860. * @param angle defines the angle (in radians) to use
  65861. * @param result defines the target matrix
  65862. */
  65863. static RotationXToRef(angle: number, result: Matrix): void;
  65864. /**
  65865. * Creates a new rotation matrix for "angle" radians around the Y axis
  65866. * @param angle defines the angle (in radians) to use
  65867. * @return the new matrix
  65868. */
  65869. static RotationY(angle: number): Matrix;
  65870. /**
  65871. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  65872. * @param angle defines the angle (in radians) to use
  65873. * @param result defines the target matrix
  65874. */
  65875. static RotationYToRef(angle: number, result: Matrix): void;
  65876. /**
  65877. * Creates a new rotation matrix for "angle" radians around the Z axis
  65878. * @param angle defines the angle (in radians) to use
  65879. * @return the new matrix
  65880. */
  65881. static RotationZ(angle: number): Matrix;
  65882. /**
  65883. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  65884. * @param angle defines the angle (in radians) to use
  65885. * @param result defines the target matrix
  65886. */
  65887. static RotationZToRef(angle: number, result: Matrix): void;
  65888. /**
  65889. * Creates a new rotation matrix for "angle" radians around the given axis
  65890. * @param axis defines the axis to use
  65891. * @param angle defines the angle (in radians) to use
  65892. * @return the new matrix
  65893. */
  65894. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  65895. /**
  65896. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  65897. * @param axis defines the axis to use
  65898. * @param angle defines the angle (in radians) to use
  65899. * @param result defines the target matrix
  65900. */
  65901. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  65902. /**
  65903. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  65904. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  65905. * @param from defines the vector to align
  65906. * @param to defines the vector to align to
  65907. * @param result defines the target matrix
  65908. */
  65909. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  65910. /**
  65911. * Creates a rotation matrix
  65912. * @param yaw defines the yaw angle in radians (Y axis)
  65913. * @param pitch defines the pitch angle in radians (X axis)
  65914. * @param roll defines the roll angle in radians (X axis)
  65915. * @returns the new rotation matrix
  65916. */
  65917. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  65918. /**
  65919. * Creates a rotation matrix and stores it in a given matrix
  65920. * @param yaw defines the yaw angle in radians (Y axis)
  65921. * @param pitch defines the pitch angle in radians (X axis)
  65922. * @param roll defines the roll angle in radians (X axis)
  65923. * @param result defines the target matrix
  65924. */
  65925. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  65926. /**
  65927. * Creates a scaling matrix
  65928. * @param x defines the scale factor on X axis
  65929. * @param y defines the scale factor on Y axis
  65930. * @param z defines the scale factor on Z axis
  65931. * @returns the new matrix
  65932. */
  65933. static Scaling(x: number, y: number, z: number): Matrix;
  65934. /**
  65935. * Creates a scaling matrix and stores it in a given matrix
  65936. * @param x defines the scale factor on X axis
  65937. * @param y defines the scale factor on Y axis
  65938. * @param z defines the scale factor on Z axis
  65939. * @param result defines the target matrix
  65940. */
  65941. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  65942. /**
  65943. * Creates a translation matrix
  65944. * @param x defines the translation on X axis
  65945. * @param y defines the translation on Y axis
  65946. * @param z defines the translationon Z axis
  65947. * @returns the new matrix
  65948. */
  65949. static Translation(x: number, y: number, z: number): Matrix;
  65950. /**
  65951. * Creates a translation matrix and stores it in a given matrix
  65952. * @param x defines the translation on X axis
  65953. * @param y defines the translation on Y axis
  65954. * @param z defines the translationon Z axis
  65955. * @param result defines the target matrix
  65956. */
  65957. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  65958. /**
  65959. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65960. * @param startValue defines the start value
  65961. * @param endValue defines the end value
  65962. * @param gradient defines the gradient factor
  65963. * @returns the new matrix
  65964. */
  65965. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65966. /**
  65967. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65968. * @param startValue defines the start value
  65969. * @param endValue defines the end value
  65970. * @param gradient defines the gradient factor
  65971. * @param result defines the Matrix object where to store data
  65972. */
  65973. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65974. /**
  65975. * Builds a new matrix whose values are computed by:
  65976. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65977. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65978. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65979. * @param startValue defines the first matrix
  65980. * @param endValue defines the second matrix
  65981. * @param gradient defines the gradient between the two matrices
  65982. * @returns the new matrix
  65983. */
  65984. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65985. /**
  65986. * Update a matrix to values which are computed by:
  65987. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65988. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65989. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65990. * @param startValue defines the first matrix
  65991. * @param endValue defines the second matrix
  65992. * @param gradient defines the gradient between the two matrices
  65993. * @param result defines the target matrix
  65994. */
  65995. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65996. /**
  65997. * 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"
  65998. * This function works in left handed mode
  65999. * @param eye defines the final position of the entity
  66000. * @param target defines where the entity should look at
  66001. * @param up defines the up vector for the entity
  66002. * @returns the new matrix
  66003. */
  66004. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66005. /**
  66006. * 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".
  66007. * This function works in left handed mode
  66008. * @param eye defines the final position of the entity
  66009. * @param target defines where the entity should look at
  66010. * @param up defines the up vector for the entity
  66011. * @param result defines the target matrix
  66012. */
  66013. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66014. /**
  66015. * 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"
  66016. * This function works in right handed mode
  66017. * @param eye defines the final position of the entity
  66018. * @param target defines where the entity should look at
  66019. * @param up defines the up vector for the entity
  66020. * @returns the new matrix
  66021. */
  66022. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66023. /**
  66024. * 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".
  66025. * This function works in right handed mode
  66026. * @param eye defines the final position of the entity
  66027. * @param target defines where the entity should look at
  66028. * @param up defines the up vector for the entity
  66029. * @param result defines the target matrix
  66030. */
  66031. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66032. /**
  66033. * Create a left-handed orthographic projection matrix
  66034. * @param width defines the viewport width
  66035. * @param height defines the viewport height
  66036. * @param znear defines the near clip plane
  66037. * @param zfar defines the far clip plane
  66038. * @returns a new matrix as a left-handed orthographic projection matrix
  66039. */
  66040. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66041. /**
  66042. * Store a left-handed orthographic projection to a given matrix
  66043. * @param width defines the viewport width
  66044. * @param height defines the viewport height
  66045. * @param znear defines the near clip plane
  66046. * @param zfar defines the far clip plane
  66047. * @param result defines the target matrix
  66048. */
  66049. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  66050. /**
  66051. * Create a left-handed orthographic projection matrix
  66052. * @param left defines the viewport left coordinate
  66053. * @param right defines the viewport right coordinate
  66054. * @param bottom defines the viewport bottom coordinate
  66055. * @param top defines the viewport top coordinate
  66056. * @param znear defines the near clip plane
  66057. * @param zfar defines the far clip plane
  66058. * @returns a new matrix as a left-handed orthographic projection matrix
  66059. */
  66060. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66061. /**
  66062. * Stores a left-handed orthographic projection into a given matrix
  66063. * @param left defines the viewport left coordinate
  66064. * @param right defines the viewport right coordinate
  66065. * @param bottom defines the viewport bottom coordinate
  66066. * @param top defines the viewport top coordinate
  66067. * @param znear defines the near clip plane
  66068. * @param zfar defines the far clip plane
  66069. * @param result defines the target matrix
  66070. */
  66071. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66072. /**
  66073. * Creates a right-handed orthographic projection matrix
  66074. * @param left defines the viewport left coordinate
  66075. * @param right defines the viewport right coordinate
  66076. * @param bottom defines the viewport bottom coordinate
  66077. * @param top defines the viewport top coordinate
  66078. * @param znear defines the near clip plane
  66079. * @param zfar defines the far clip plane
  66080. * @returns a new matrix as a right-handed orthographic projection matrix
  66081. */
  66082. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66083. /**
  66084. * Stores a right-handed orthographic projection into a given matrix
  66085. * @param left defines the viewport left coordinate
  66086. * @param right defines the viewport right coordinate
  66087. * @param bottom defines the viewport bottom coordinate
  66088. * @param top defines the viewport top coordinate
  66089. * @param znear defines the near clip plane
  66090. * @param zfar defines the far clip plane
  66091. * @param result defines the target matrix
  66092. */
  66093. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66094. /**
  66095. * Creates a left-handed perspective projection matrix
  66096. * @param width defines the viewport width
  66097. * @param height defines the viewport height
  66098. * @param znear defines the near clip plane
  66099. * @param zfar defines the far clip plane
  66100. * @returns a new matrix as a left-handed perspective projection matrix
  66101. */
  66102. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66103. /**
  66104. * Creates a left-handed perspective projection matrix
  66105. * @param fov defines the horizontal field of view
  66106. * @param aspect defines the aspect ratio
  66107. * @param znear defines the near clip plane
  66108. * @param zfar defines the far clip plane
  66109. * @returns a new matrix as a left-handed perspective projection matrix
  66110. */
  66111. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66112. /**
  66113. * Stores a left-handed perspective projection into a given matrix
  66114. * @param fov defines the horizontal field of view
  66115. * @param aspect defines the aspect ratio
  66116. * @param znear defines the near clip plane
  66117. * @param zfar defines the far clip plane
  66118. * @param result defines the target matrix
  66119. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66120. */
  66121. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66122. /**
  66123. * Creates a right-handed perspective projection matrix
  66124. * @param fov defines the horizontal field of view
  66125. * @param aspect defines the aspect ratio
  66126. * @param znear defines the near clip plane
  66127. * @param zfar defines the far clip plane
  66128. * @returns a new matrix as a right-handed perspective projection matrix
  66129. */
  66130. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66131. /**
  66132. * Stores a right-handed perspective projection into a given matrix
  66133. * @param fov defines the horizontal field of view
  66134. * @param aspect defines the aspect ratio
  66135. * @param znear defines the near clip plane
  66136. * @param zfar defines the far clip plane
  66137. * @param result defines the target matrix
  66138. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66139. */
  66140. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66141. /**
  66142. * Stores a perspective projection for WebVR info a given matrix
  66143. * @param fov defines the field of view
  66144. * @param znear defines the near clip plane
  66145. * @param zfar defines the far clip plane
  66146. * @param result defines the target matrix
  66147. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  66148. */
  66149. static PerspectiveFovWebVRToRef(fov: {
  66150. upDegrees: number;
  66151. downDegrees: number;
  66152. leftDegrees: number;
  66153. rightDegrees: number;
  66154. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  66155. /**
  66156. * Computes a complete transformation matrix
  66157. * @param viewport defines the viewport to use
  66158. * @param world defines the world matrix
  66159. * @param view defines the view matrix
  66160. * @param projection defines the projection matrix
  66161. * @param zmin defines the near clip plane
  66162. * @param zmax defines the far clip plane
  66163. * @returns the transformation matrix
  66164. */
  66165. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  66166. /**
  66167. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  66168. * @param matrix defines the matrix to use
  66169. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  66170. */
  66171. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  66172. /**
  66173. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  66174. * @param matrix defines the matrix to use
  66175. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  66176. */
  66177. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  66178. /**
  66179. * Compute the transpose of a given matrix
  66180. * @param matrix defines the matrix to transpose
  66181. * @returns the new matrix
  66182. */
  66183. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  66184. /**
  66185. * Compute the transpose of a matrix and store it in a target matrix
  66186. * @param matrix defines the matrix to transpose
  66187. * @param result defines the target matrix
  66188. */
  66189. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  66190. /**
  66191. * Computes a reflection matrix from a plane
  66192. * @param plane defines the reflection plane
  66193. * @returns a new matrix
  66194. */
  66195. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  66196. /**
  66197. * Computes a reflection matrix from a plane
  66198. * @param plane defines the reflection plane
  66199. * @param result defines the target matrix
  66200. */
  66201. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  66202. /**
  66203. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  66204. * @param xaxis defines the value of the 1st axis
  66205. * @param yaxis defines the value of the 2nd axis
  66206. * @param zaxis defines the value of the 3rd axis
  66207. * @param result defines the target matrix
  66208. */
  66209. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  66210. /**
  66211. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  66212. * @param quat defines the quaternion to use
  66213. * @param result defines the target matrix
  66214. */
  66215. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  66216. }
  66217. /**
  66218. * Represens a plane by the equation ax + by + cz + d = 0
  66219. */
  66220. export class Plane {
  66221. /**
  66222. * Normal of the plane (a,b,c)
  66223. */
  66224. normal: Vector3;
  66225. /**
  66226. * d component of the plane
  66227. */
  66228. d: number;
  66229. /**
  66230. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  66231. * @param a a component of the plane
  66232. * @param b b component of the plane
  66233. * @param c c component of the plane
  66234. * @param d d component of the plane
  66235. */
  66236. constructor(a: number, b: number, c: number, d: number);
  66237. /**
  66238. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  66239. */
  66240. asArray(): number[];
  66241. /**
  66242. * @returns a new plane copied from the current Plane.
  66243. */
  66244. clone(): Plane;
  66245. /**
  66246. * @returns the string "Plane".
  66247. */
  66248. getClassName(): string;
  66249. /**
  66250. * @returns the Plane hash code.
  66251. */
  66252. getHashCode(): number;
  66253. /**
  66254. * Normalize the current Plane in place.
  66255. * @returns the updated Plane.
  66256. */
  66257. normalize(): Plane;
  66258. /**
  66259. * Applies a transformation the plane and returns the result
  66260. * @param transformation the transformation matrix to be applied to the plane
  66261. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  66262. */
  66263. transform(transformation: DeepImmutable<Matrix>): Plane;
  66264. /**
  66265. * Calcualtte the dot product between the point and the plane normal
  66266. * @param point point to calculate the dot product with
  66267. * @returns the dot product (float) of the point coordinates and the plane normal.
  66268. */
  66269. dotCoordinate(point: DeepImmutable<Vector3>): number;
  66270. /**
  66271. * Updates the current Plane from the plane defined by the three given points.
  66272. * @param point1 one of the points used to contruct the plane
  66273. * @param point2 one of the points used to contruct the plane
  66274. * @param point3 one of the points used to contruct the plane
  66275. * @returns the updated Plane.
  66276. */
  66277. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66278. /**
  66279. * Checks if the plane is facing a given direction
  66280. * @param direction the direction to check if the plane is facing
  66281. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66282. * @returns True is the vector "direction" is the same side than the plane normal.
  66283. */
  66284. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66285. /**
  66286. * Calculates the distance to a point
  66287. * @param point point to calculate distance to
  66288. * @returns the signed distance (float) from the given point to the Plane.
  66289. */
  66290. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66291. /**
  66292. * Creates a plane from an array
  66293. * @param array the array to create a plane from
  66294. * @returns a new Plane from the given array.
  66295. */
  66296. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66297. /**
  66298. * Creates a plane from three points
  66299. * @param point1 point used to create the plane
  66300. * @param point2 point used to create the plane
  66301. * @param point3 point used to create the plane
  66302. * @returns a new Plane defined by the three given points.
  66303. */
  66304. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66305. /**
  66306. * Creates a plane from an origin point and a normal
  66307. * @param origin origin of the plane to be constructed
  66308. * @param normal normal of the plane to be constructed
  66309. * @returns a new Plane the normal vector to this plane at the given origin point.
  66310. * Note : the vector "normal" is updated because normalized.
  66311. */
  66312. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66313. /**
  66314. * Calculates the distance from a plane and a point
  66315. * @param origin origin of the plane to be constructed
  66316. * @param normal normal of the plane to be constructed
  66317. * @param point point to calculate distance to
  66318. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66319. */
  66320. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66321. }
  66322. /**
  66323. * Class used to represent a viewport on screen
  66324. */
  66325. export class Viewport {
  66326. /** viewport left coordinate */
  66327. x: number;
  66328. /** viewport top coordinate */
  66329. y: number;
  66330. /**viewport width */
  66331. width: number;
  66332. /** viewport height */
  66333. height: number;
  66334. /**
  66335. * Creates a Viewport object located at (x, y) and sized (width, height)
  66336. * @param x defines viewport left coordinate
  66337. * @param y defines viewport top coordinate
  66338. * @param width defines the viewport width
  66339. * @param height defines the viewport height
  66340. */
  66341. constructor(
  66342. /** viewport left coordinate */
  66343. x: number,
  66344. /** viewport top coordinate */
  66345. y: number,
  66346. /**viewport width */
  66347. width: number,
  66348. /** viewport height */
  66349. height: number);
  66350. /**
  66351. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66352. * @param renderWidth defines the rendering width
  66353. * @param renderHeight defines the rendering height
  66354. * @returns a new Viewport
  66355. */
  66356. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66357. /**
  66358. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66359. * @param renderWidth defines the rendering width
  66360. * @param renderHeight defines the rendering height
  66361. * @param ref defines the target viewport
  66362. * @returns the current viewport
  66363. */
  66364. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66365. /**
  66366. * Returns a new Viewport copied from the current one
  66367. * @returns a new Viewport
  66368. */
  66369. clone(): Viewport;
  66370. }
  66371. /**
  66372. * Reprasents a camera frustum
  66373. */
  66374. export class Frustum {
  66375. /**
  66376. * Gets the planes representing the frustum
  66377. * @param transform matrix to be applied to the returned planes
  66378. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66379. */
  66380. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66381. /**
  66382. * Gets the near frustum plane transformed by the transform matrix
  66383. * @param transform transformation matrix to be applied to the resulting frustum plane
  66384. * @param frustumPlane the resuling frustum plane
  66385. */
  66386. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66387. /**
  66388. * Gets the far frustum plane transformed by the transform matrix
  66389. * @param transform transformation matrix to be applied to the resulting frustum plane
  66390. * @param frustumPlane the resuling frustum plane
  66391. */
  66392. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66393. /**
  66394. * Gets the left frustum plane transformed by the transform matrix
  66395. * @param transform transformation matrix to be applied to the resulting frustum plane
  66396. * @param frustumPlane the resuling frustum plane
  66397. */
  66398. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66399. /**
  66400. * Gets the right frustum plane transformed by the transform matrix
  66401. * @param transform transformation matrix to be applied to the resulting frustum plane
  66402. * @param frustumPlane the resuling frustum plane
  66403. */
  66404. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66405. /**
  66406. * Gets the top frustum plane transformed by the transform matrix
  66407. * @param transform transformation matrix to be applied to the resulting frustum plane
  66408. * @param frustumPlane the resuling frustum plane
  66409. */
  66410. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66411. /**
  66412. * Gets the bottom frustum plane transformed by the transform matrix
  66413. * @param transform transformation matrix to be applied to the resulting frustum plane
  66414. * @param frustumPlane the resuling frustum plane
  66415. */
  66416. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66417. /**
  66418. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66419. * @param transform transformation matrix to be applied to the resulting frustum planes
  66420. * @param frustumPlanes the resuling frustum planes
  66421. */
  66422. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66423. }
  66424. /** Defines supported spaces */
  66425. export enum Space {
  66426. /** Local (object) space */
  66427. LOCAL = 0,
  66428. /** World space */
  66429. WORLD = 1,
  66430. /** Bone space */
  66431. BONE = 2
  66432. }
  66433. /** Defines the 3 main axes */
  66434. export class Axis {
  66435. /** X axis */
  66436. static X: Vector3;
  66437. /** Y axis */
  66438. static Y: Vector3;
  66439. /** Z axis */
  66440. static Z: Vector3;
  66441. }
  66442. /** Class used to represent a Bezier curve */
  66443. export class BezierCurve {
  66444. /**
  66445. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66446. * @param t defines the time
  66447. * @param x1 defines the left coordinate on X axis
  66448. * @param y1 defines the left coordinate on Y axis
  66449. * @param x2 defines the right coordinate on X axis
  66450. * @param y2 defines the right coordinate on Y axis
  66451. * @returns the interpolated value
  66452. */
  66453. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66454. }
  66455. /**
  66456. * Defines potential orientation for back face culling
  66457. */
  66458. export enum Orientation {
  66459. /**
  66460. * Clockwise
  66461. */
  66462. CW = 0,
  66463. /** Counter clockwise */
  66464. CCW = 1
  66465. }
  66466. /**
  66467. * Defines angle representation
  66468. */
  66469. export class Angle {
  66470. private _radians;
  66471. /**
  66472. * Creates an Angle object of "radians" radians (float).
  66473. * @param radians the angle in radians
  66474. */
  66475. constructor(radians: number);
  66476. /**
  66477. * Get value in degrees
  66478. * @returns the Angle value in degrees (float)
  66479. */
  66480. degrees(): number;
  66481. /**
  66482. * Get value in radians
  66483. * @returns the Angle value in radians (float)
  66484. */
  66485. radians(): number;
  66486. /**
  66487. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66488. * @param a defines first vector
  66489. * @param b defines second vector
  66490. * @returns a new Angle
  66491. */
  66492. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66493. /**
  66494. * Gets a new Angle object from the given float in radians
  66495. * @param radians defines the angle value in radians
  66496. * @returns a new Angle
  66497. */
  66498. static FromRadians(radians: number): Angle;
  66499. /**
  66500. * Gets a new Angle object from the given float in degrees
  66501. * @param degrees defines the angle value in degrees
  66502. * @returns a new Angle
  66503. */
  66504. static FromDegrees(degrees: number): Angle;
  66505. }
  66506. /**
  66507. * This represents an arc in a 2d space.
  66508. */
  66509. export class Arc2 {
  66510. /** Defines the start point of the arc */
  66511. startPoint: Vector2;
  66512. /** Defines the mid point of the arc */
  66513. midPoint: Vector2;
  66514. /** Defines the end point of the arc */
  66515. endPoint: Vector2;
  66516. /**
  66517. * Defines the center point of the arc.
  66518. */
  66519. centerPoint: Vector2;
  66520. /**
  66521. * Defines the radius of the arc.
  66522. */
  66523. radius: number;
  66524. /**
  66525. * Defines the angle of the arc (from mid point to end point).
  66526. */
  66527. angle: Angle;
  66528. /**
  66529. * Defines the start angle of the arc (from start point to middle point).
  66530. */
  66531. startAngle: Angle;
  66532. /**
  66533. * Defines the orientation of the arc (clock wise/counter clock wise).
  66534. */
  66535. orientation: Orientation;
  66536. /**
  66537. * Creates an Arc object from the three given points : start, middle and end.
  66538. * @param startPoint Defines the start point of the arc
  66539. * @param midPoint Defines the midlle point of the arc
  66540. * @param endPoint Defines the end point of the arc
  66541. */
  66542. constructor(
  66543. /** Defines the start point of the arc */
  66544. startPoint: Vector2,
  66545. /** Defines the mid point of the arc */
  66546. midPoint: Vector2,
  66547. /** Defines the end point of the arc */
  66548. endPoint: Vector2);
  66549. }
  66550. /**
  66551. * Represents a 2D path made up of multiple 2D points
  66552. */
  66553. export class Path2 {
  66554. private _points;
  66555. private _length;
  66556. /**
  66557. * If the path start and end point are the same
  66558. */
  66559. closed: boolean;
  66560. /**
  66561. * Creates a Path2 object from the starting 2D coordinates x and y.
  66562. * @param x the starting points x value
  66563. * @param y the starting points y value
  66564. */
  66565. constructor(x: number, y: number);
  66566. /**
  66567. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66568. * @param x the added points x value
  66569. * @param y the added points y value
  66570. * @returns the updated Path2.
  66571. */
  66572. addLineTo(x: number, y: number): Path2;
  66573. /**
  66574. * 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.
  66575. * @param midX middle point x value
  66576. * @param midY middle point y value
  66577. * @param endX end point x value
  66578. * @param endY end point y value
  66579. * @param numberOfSegments (default: 36)
  66580. * @returns the updated Path2.
  66581. */
  66582. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66583. /**
  66584. * Closes the Path2.
  66585. * @returns the Path2.
  66586. */
  66587. close(): Path2;
  66588. /**
  66589. * Gets the sum of the distance between each sequential point in the path
  66590. * @returns the Path2 total length (float).
  66591. */
  66592. length(): number;
  66593. /**
  66594. * Gets the points which construct the path
  66595. * @returns the Path2 internal array of points.
  66596. */
  66597. getPoints(): Vector2[];
  66598. /**
  66599. * Retreives the point at the distance aways from the starting point
  66600. * @param normalizedLengthPosition the length along the path to retreive the point from
  66601. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66602. */
  66603. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66604. /**
  66605. * Creates a new path starting from an x and y position
  66606. * @param x starting x value
  66607. * @param y starting y value
  66608. * @returns a new Path2 starting at the coordinates (x, y).
  66609. */
  66610. static StartingAt(x: number, y: number): Path2;
  66611. }
  66612. /**
  66613. * Represents a 3D path made up of multiple 3D points
  66614. */
  66615. export class Path3D {
  66616. /**
  66617. * an array of Vector3, the curve axis of the Path3D
  66618. */
  66619. path: Vector3[];
  66620. private _curve;
  66621. private _distances;
  66622. private _tangents;
  66623. private _normals;
  66624. private _binormals;
  66625. private _raw;
  66626. /**
  66627. * new Path3D(path, normal, raw)
  66628. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66629. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66630. * @param path an array of Vector3, the curve axis of the Path3D
  66631. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66632. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66633. */
  66634. constructor(
  66635. /**
  66636. * an array of Vector3, the curve axis of the Path3D
  66637. */
  66638. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66639. /**
  66640. * Returns the Path3D array of successive Vector3 designing its curve.
  66641. * @returns the Path3D array of successive Vector3 designing its curve.
  66642. */
  66643. getCurve(): Vector3[];
  66644. /**
  66645. * Returns an array populated with tangent vectors on each Path3D curve point.
  66646. * @returns an array populated with tangent vectors on each Path3D curve point.
  66647. */
  66648. getTangents(): Vector3[];
  66649. /**
  66650. * Returns an array populated with normal vectors on each Path3D curve point.
  66651. * @returns an array populated with normal vectors on each Path3D curve point.
  66652. */
  66653. getNormals(): Vector3[];
  66654. /**
  66655. * Returns an array populated with binormal vectors on each Path3D curve point.
  66656. * @returns an array populated with binormal vectors on each Path3D curve point.
  66657. */
  66658. getBinormals(): Vector3[];
  66659. /**
  66660. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66661. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66662. */
  66663. getDistances(): number[];
  66664. /**
  66665. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66666. * @param path path which all values are copied into the curves points
  66667. * @param firstNormal which should be projected onto the curve
  66668. * @returns the same object updated.
  66669. */
  66670. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66671. private _compute;
  66672. private _getFirstNonNullVector;
  66673. private _getLastNonNullVector;
  66674. private _normalVector;
  66675. }
  66676. /**
  66677. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66678. * A Curve3 is designed from a series of successive Vector3.
  66679. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66680. */
  66681. export class Curve3 {
  66682. private _points;
  66683. private _length;
  66684. /**
  66685. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  66686. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  66687. * @param v1 (Vector3) the control point
  66688. * @param v2 (Vector3) the end point of the Quadratic Bezier
  66689. * @param nbPoints (integer) the wanted number of points in the curve
  66690. * @returns the created Curve3
  66691. */
  66692. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66693. /**
  66694. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  66695. * @param v0 (Vector3) the origin point of the Cubic Bezier
  66696. * @param v1 (Vector3) the first control point
  66697. * @param v2 (Vector3) the second control point
  66698. * @param v3 (Vector3) the end point of the Cubic Bezier
  66699. * @param nbPoints (integer) the wanted number of points in the curve
  66700. * @returns the created Curve3
  66701. */
  66702. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66703. /**
  66704. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  66705. * @param p1 (Vector3) the origin point of the Hermite Spline
  66706. * @param t1 (Vector3) the tangent vector at the origin point
  66707. * @param p2 (Vector3) the end point of the Hermite Spline
  66708. * @param t2 (Vector3) the tangent vector at the end point
  66709. * @param nbPoints (integer) the wanted number of points in the curve
  66710. * @returns the created Curve3
  66711. */
  66712. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66713. /**
  66714. * Returns a Curve3 object along a CatmullRom Spline curve :
  66715. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  66716. * @param nbPoints (integer) the wanted number of points between each curve control points
  66717. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  66718. * @returns the created Curve3
  66719. */
  66720. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  66721. /**
  66722. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66723. * A Curve3 is designed from a series of successive Vector3.
  66724. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  66725. * @param points points which make up the curve
  66726. */
  66727. constructor(points: Vector3[]);
  66728. /**
  66729. * @returns the Curve3 stored array of successive Vector3
  66730. */
  66731. getPoints(): Vector3[];
  66732. /**
  66733. * @returns the computed length (float) of the curve.
  66734. */
  66735. length(): number;
  66736. /**
  66737. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  66738. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  66739. * curveA and curveB keep unchanged.
  66740. * @param curve the curve to continue from this curve
  66741. * @returns the newly constructed curve
  66742. */
  66743. continue(curve: DeepImmutable<Curve3>): Curve3;
  66744. private _computeLength;
  66745. }
  66746. /**
  66747. * Contains position and normal vectors for a vertex
  66748. */
  66749. export class PositionNormalVertex {
  66750. /** the position of the vertex (defaut: 0,0,0) */
  66751. position: Vector3;
  66752. /** the normal of the vertex (defaut: 0,1,0) */
  66753. normal: Vector3;
  66754. /**
  66755. * Creates a PositionNormalVertex
  66756. * @param position the position of the vertex (defaut: 0,0,0)
  66757. * @param normal the normal of the vertex (defaut: 0,1,0)
  66758. */
  66759. constructor(
  66760. /** the position of the vertex (defaut: 0,0,0) */
  66761. position?: Vector3,
  66762. /** the normal of the vertex (defaut: 0,1,0) */
  66763. normal?: Vector3);
  66764. /**
  66765. * Clones the PositionNormalVertex
  66766. * @returns the cloned PositionNormalVertex
  66767. */
  66768. clone(): PositionNormalVertex;
  66769. }
  66770. /**
  66771. * Contains position, normal and uv vectors for a vertex
  66772. */
  66773. export class PositionNormalTextureVertex {
  66774. /** the position of the vertex (defaut: 0,0,0) */
  66775. position: Vector3;
  66776. /** the normal of the vertex (defaut: 0,1,0) */
  66777. normal: Vector3;
  66778. /** the uv of the vertex (default: 0,0) */
  66779. uv: Vector2;
  66780. /**
  66781. * Creates a PositionNormalTextureVertex
  66782. * @param position the position of the vertex (defaut: 0,0,0)
  66783. * @param normal the normal of the vertex (defaut: 0,1,0)
  66784. * @param uv the uv of the vertex (default: 0,0)
  66785. */
  66786. constructor(
  66787. /** the position of the vertex (defaut: 0,0,0) */
  66788. position?: Vector3,
  66789. /** the normal of the vertex (defaut: 0,1,0) */
  66790. normal?: Vector3,
  66791. /** the uv of the vertex (default: 0,0) */
  66792. uv?: Vector2);
  66793. /**
  66794. * Clones the PositionNormalTextureVertex
  66795. * @returns the cloned PositionNormalTextureVertex
  66796. */
  66797. clone(): PositionNormalTextureVertex;
  66798. }
  66799. /**
  66800. * @hidden
  66801. */
  66802. export class Tmp {
  66803. static Color3: Color3[];
  66804. static Color4: Color4[];
  66805. static Vector2: Vector2[];
  66806. static Vector3: Vector3[];
  66807. static Vector4: Vector4[];
  66808. static Quaternion: Quaternion[];
  66809. static Matrix: Matrix[];
  66810. }
  66811. }
  66812. declare module BABYLON {
  66813. /**
  66814. * Class used to enable access to offline support
  66815. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66816. */
  66817. export interface IOfflineProvider {
  66818. /**
  66819. * Gets a boolean indicating if scene must be saved in the database
  66820. */
  66821. enableSceneOffline: boolean;
  66822. /**
  66823. * Gets a boolean indicating if textures must be saved in the database
  66824. */
  66825. enableTexturesOffline: boolean;
  66826. /**
  66827. * Open the offline support and make it available
  66828. * @param successCallback defines the callback to call on success
  66829. * @param errorCallback defines the callback to call on error
  66830. */
  66831. open(successCallback: () => void, errorCallback: () => void): void;
  66832. /**
  66833. * Loads an image from the offline support
  66834. * @param url defines the url to load from
  66835. * @param image defines the target DOM image
  66836. */
  66837. loadImage(url: string, image: HTMLImageElement): void;
  66838. /**
  66839. * Loads a file from offline support
  66840. * @param url defines the URL to load from
  66841. * @param sceneLoaded defines a callback to call on success
  66842. * @param progressCallBack defines a callback to call when progress changed
  66843. * @param errorCallback defines a callback to call on error
  66844. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66845. */
  66846. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66847. }
  66848. }
  66849. declare module BABYLON {
  66850. /**
  66851. * A class serves as a medium between the observable and its observers
  66852. */
  66853. export class EventState {
  66854. /**
  66855. * Create a new EventState
  66856. * @param mask defines the mask associated with this state
  66857. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66858. * @param target defines the original target of the state
  66859. * @param currentTarget defines the current target of the state
  66860. */
  66861. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66862. /**
  66863. * Initialize the current event state
  66864. * @param mask defines the mask associated with this state
  66865. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66866. * @param target defines the original target of the state
  66867. * @param currentTarget defines the current target of the state
  66868. * @returns the current event state
  66869. */
  66870. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66871. /**
  66872. * An Observer can set this property to true to prevent subsequent observers of being notified
  66873. */
  66874. skipNextObservers: boolean;
  66875. /**
  66876. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66877. */
  66878. mask: number;
  66879. /**
  66880. * The object that originally notified the event
  66881. */
  66882. target?: any;
  66883. /**
  66884. * The current object in the bubbling phase
  66885. */
  66886. currentTarget?: any;
  66887. /**
  66888. * This will be populated with the return value of the last function that was executed.
  66889. * If it is the first function in the callback chain it will be the event data.
  66890. */
  66891. lastReturnValue?: any;
  66892. }
  66893. /**
  66894. * Represent an Observer registered to a given Observable object.
  66895. */
  66896. export class Observer<T> {
  66897. /**
  66898. * Defines the callback to call when the observer is notified
  66899. */
  66900. callback: (eventData: T, eventState: EventState) => void;
  66901. /**
  66902. * Defines the mask of the observer (used to filter notifications)
  66903. */
  66904. mask: number;
  66905. /**
  66906. * Defines the current scope used to restore the JS context
  66907. */
  66908. scope: any;
  66909. /** @hidden */
  66910. _willBeUnregistered: boolean;
  66911. /**
  66912. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66913. */
  66914. unregisterOnNextCall: boolean;
  66915. /**
  66916. * Creates a new observer
  66917. * @param callback defines the callback to call when the observer is notified
  66918. * @param mask defines the mask of the observer (used to filter notifications)
  66919. * @param scope defines the current scope used to restore the JS context
  66920. */
  66921. constructor(
  66922. /**
  66923. * Defines the callback to call when the observer is notified
  66924. */
  66925. callback: (eventData: T, eventState: EventState) => void,
  66926. /**
  66927. * Defines the mask of the observer (used to filter notifications)
  66928. */
  66929. mask: number,
  66930. /**
  66931. * Defines the current scope used to restore the JS context
  66932. */
  66933. scope?: any);
  66934. }
  66935. /**
  66936. * Represent a list of observers registered to multiple Observables object.
  66937. */
  66938. export class MultiObserver<T> {
  66939. private _observers;
  66940. private _observables;
  66941. /**
  66942. * Release associated resources
  66943. */
  66944. dispose(): void;
  66945. /**
  66946. * Raise a callback when one of the observable will notify
  66947. * @param observables defines a list of observables to watch
  66948. * @param callback defines the callback to call on notification
  66949. * @param mask defines the mask used to filter notifications
  66950. * @param scope defines the current scope used to restore the JS context
  66951. * @returns the new MultiObserver
  66952. */
  66953. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66954. }
  66955. /**
  66956. * The Observable class is a simple implementation of the Observable pattern.
  66957. *
  66958. * 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.
  66959. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66960. * 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).
  66961. * 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.
  66962. */
  66963. export class Observable<T> {
  66964. private _observers;
  66965. private _eventState;
  66966. private _onObserverAdded;
  66967. /**
  66968. * Creates a new observable
  66969. * @param onObserverAdded defines a callback to call when a new observer is added
  66970. */
  66971. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66972. /**
  66973. * Create a new Observer with the specified callback
  66974. * @param callback the callback that will be executed for that Observer
  66975. * @param mask the mask used to filter observers
  66976. * @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.
  66977. * @param scope optional scope for the callback to be called from
  66978. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66979. * @returns the new observer created for the callback
  66980. */
  66981. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66982. /**
  66983. * Create a new Observer with the specified callback and unregisters after the next notification
  66984. * @param callback the callback that will be executed for that Observer
  66985. * @returns the new observer created for the callback
  66986. */
  66987. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66988. /**
  66989. * Remove an Observer from the Observable object
  66990. * @param observer the instance of the Observer to remove
  66991. * @returns false if it doesn't belong to this Observable
  66992. */
  66993. remove(observer: Nullable<Observer<T>>): boolean;
  66994. /**
  66995. * Remove a callback from the Observable object
  66996. * @param callback the callback to remove
  66997. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66998. * @returns false if it doesn't belong to this Observable
  66999. */
  67000. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67001. private _deferUnregister;
  67002. private _remove;
  67003. /**
  67004. * Moves the observable to the top of the observer list making it get called first when notified
  67005. * @param observer the observer to move
  67006. */
  67007. makeObserverTopPriority(observer: Observer<T>): void;
  67008. /**
  67009. * Moves the observable to the bottom of the observer list making it get called last when notified
  67010. * @param observer the observer to move
  67011. */
  67012. makeObserverBottomPriority(observer: Observer<T>): void;
  67013. /**
  67014. * Notify all Observers by calling their respective callback with the given data
  67015. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67016. * @param eventData defines the data to send to all observers
  67017. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67018. * @param target defines the original target of the state
  67019. * @param currentTarget defines the current target of the state
  67020. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67021. */
  67022. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67023. /**
  67024. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67025. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67026. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67027. * and it is crucial that all callbacks will be executed.
  67028. * The order of the callbacks is kept, callbacks are not executed parallel.
  67029. *
  67030. * @param eventData The data to be sent to each callback
  67031. * @param mask is used to filter observers defaults to -1
  67032. * @param target defines the callback target (see EventState)
  67033. * @param currentTarget defines he current object in the bubbling phase
  67034. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67035. */
  67036. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67037. /**
  67038. * Notify a specific observer
  67039. * @param observer defines the observer to notify
  67040. * @param eventData defines the data to be sent to each callback
  67041. * @param mask is used to filter observers defaults to -1
  67042. */
  67043. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67044. /**
  67045. * Gets a boolean indicating if the observable has at least one observer
  67046. * @returns true is the Observable has at least one Observer registered
  67047. */
  67048. hasObservers(): boolean;
  67049. /**
  67050. * Clear the list of observers
  67051. */
  67052. clear(): void;
  67053. /**
  67054. * Clone the current observable
  67055. * @returns a new observable
  67056. */
  67057. clone(): Observable<T>;
  67058. /**
  67059. * Does this observable handles observer registered with a given mask
  67060. * @param mask defines the mask to be tested
  67061. * @return whether or not one observer registered with the given mask is handeled
  67062. **/
  67063. hasSpecificMask(mask?: number): boolean;
  67064. }
  67065. }
  67066. declare module BABYLON {
  67067. /**
  67068. * Class used to help managing file picking and drag'n'drop
  67069. * File Storage
  67070. */
  67071. export class FilesInputStore {
  67072. /**
  67073. * List of files ready to be loaded
  67074. */
  67075. static FilesToLoad: {
  67076. [key: string]: File;
  67077. };
  67078. }
  67079. }
  67080. declare module BABYLON {
  67081. /** Defines the cross module used constants to avoid circular dependncies */
  67082. export class Constants {
  67083. /** Defines that alpha blending is disabled */
  67084. static readonly ALPHA_DISABLE: number;
  67085. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67086. static readonly ALPHA_ADD: number;
  67087. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67088. static readonly ALPHA_COMBINE: number;
  67089. /** Defines that alpha blending to DEST - SRC * DEST */
  67090. static readonly ALPHA_SUBTRACT: number;
  67091. /** Defines that alpha blending to SRC * DEST */
  67092. static readonly ALPHA_MULTIPLY: number;
  67093. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67094. static readonly ALPHA_MAXIMIZED: number;
  67095. /** Defines that alpha blending to SRC + DEST */
  67096. static readonly ALPHA_ONEONE: number;
  67097. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67098. static readonly ALPHA_PREMULTIPLIED: number;
  67099. /**
  67100. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67101. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67102. */
  67103. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67104. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67105. static readonly ALPHA_INTERPOLATE: number;
  67106. /**
  67107. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67108. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67109. */
  67110. static readonly ALPHA_SCREENMODE: number;
  67111. /** Defines that the ressource is not delayed*/
  67112. static readonly DELAYLOADSTATE_NONE: number;
  67113. /** Defines that the ressource was successfully delay loaded */
  67114. static readonly DELAYLOADSTATE_LOADED: number;
  67115. /** Defines that the ressource is currently delay loading */
  67116. static readonly DELAYLOADSTATE_LOADING: number;
  67117. /** Defines that the ressource is delayed and has not started loading */
  67118. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67119. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67120. static readonly NEVER: number;
  67121. /** 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 */
  67122. static readonly ALWAYS: number;
  67123. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67124. static readonly LESS: number;
  67125. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67126. static readonly EQUAL: number;
  67127. /** 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 */
  67128. static readonly LEQUAL: number;
  67129. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67130. static readonly GREATER: number;
  67131. /** 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 */
  67132. static readonly GEQUAL: number;
  67133. /** 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 */
  67134. static readonly NOTEQUAL: number;
  67135. /** Passed to stencilOperation to specify that stencil value must be kept */
  67136. static readonly KEEP: number;
  67137. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67138. static readonly REPLACE: number;
  67139. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67140. static readonly INCR: number;
  67141. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67142. static readonly DECR: number;
  67143. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67144. static readonly INVERT: number;
  67145. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67146. static readonly INCR_WRAP: number;
  67147. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67148. static readonly DECR_WRAP: number;
  67149. /** Texture is not repeating outside of 0..1 UVs */
  67150. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67151. /** Texture is repeating outside of 0..1 UVs */
  67152. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67153. /** Texture is repeating and mirrored */
  67154. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67155. /** ALPHA */
  67156. static readonly TEXTUREFORMAT_ALPHA: number;
  67157. /** LUMINANCE */
  67158. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67159. /** LUMINANCE_ALPHA */
  67160. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67161. /** RGB */
  67162. static readonly TEXTUREFORMAT_RGB: number;
  67163. /** RGBA */
  67164. static readonly TEXTUREFORMAT_RGBA: number;
  67165. /** RED */
  67166. static readonly TEXTUREFORMAT_RED: number;
  67167. /** RED (2nd reference) */
  67168. static readonly TEXTUREFORMAT_R: number;
  67169. /** RG */
  67170. static readonly TEXTUREFORMAT_RG: number;
  67171. /** RED_INTEGER */
  67172. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67173. /** RED_INTEGER (2nd reference) */
  67174. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67175. /** RG_INTEGER */
  67176. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67177. /** RGB_INTEGER */
  67178. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67179. /** RGBA_INTEGER */
  67180. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67181. /** UNSIGNED_BYTE */
  67182. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67183. /** UNSIGNED_BYTE (2nd reference) */
  67184. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67185. /** FLOAT */
  67186. static readonly TEXTURETYPE_FLOAT: number;
  67187. /** HALF_FLOAT */
  67188. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67189. /** BYTE */
  67190. static readonly TEXTURETYPE_BYTE: number;
  67191. /** SHORT */
  67192. static readonly TEXTURETYPE_SHORT: number;
  67193. /** UNSIGNED_SHORT */
  67194. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67195. /** INT */
  67196. static readonly TEXTURETYPE_INT: number;
  67197. /** UNSIGNED_INT */
  67198. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67199. /** UNSIGNED_SHORT_4_4_4_4 */
  67200. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67201. /** UNSIGNED_SHORT_5_5_5_1 */
  67202. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67203. /** UNSIGNED_SHORT_5_6_5 */
  67204. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67205. /** UNSIGNED_INT_2_10_10_10_REV */
  67206. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67207. /** UNSIGNED_INT_24_8 */
  67208. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67209. /** UNSIGNED_INT_10F_11F_11F_REV */
  67210. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67211. /** UNSIGNED_INT_5_9_9_9_REV */
  67212. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67213. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67214. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67215. /** nearest is mag = nearest and min = nearest and mip = linear */
  67216. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67217. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67218. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67219. /** Trilinear is mag = linear and min = linear and mip = linear */
  67220. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67221. /** nearest is mag = nearest and min = nearest and mip = linear */
  67222. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67223. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67224. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67225. /** Trilinear is mag = linear and min = linear and mip = linear */
  67226. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67227. /** mag = nearest and min = nearest and mip = nearest */
  67228. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67229. /** mag = nearest and min = linear and mip = nearest */
  67230. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67231. /** mag = nearest and min = linear and mip = linear */
  67232. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67233. /** mag = nearest and min = linear and mip = none */
  67234. static readonly TEXTURE_NEAREST_LINEAR: number;
  67235. /** mag = nearest and min = nearest and mip = none */
  67236. static readonly TEXTURE_NEAREST_NEAREST: number;
  67237. /** mag = linear and min = nearest and mip = nearest */
  67238. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67239. /** mag = linear and min = nearest and mip = linear */
  67240. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67241. /** mag = linear and min = linear and mip = none */
  67242. static readonly TEXTURE_LINEAR_LINEAR: number;
  67243. /** mag = linear and min = nearest and mip = none */
  67244. static readonly TEXTURE_LINEAR_NEAREST: number;
  67245. /** Explicit coordinates mode */
  67246. static readonly TEXTURE_EXPLICIT_MODE: number;
  67247. /** Spherical coordinates mode */
  67248. static readonly TEXTURE_SPHERICAL_MODE: number;
  67249. /** Planar coordinates mode */
  67250. static readonly TEXTURE_PLANAR_MODE: number;
  67251. /** Cubic coordinates mode */
  67252. static readonly TEXTURE_CUBIC_MODE: number;
  67253. /** Projection coordinates mode */
  67254. static readonly TEXTURE_PROJECTION_MODE: number;
  67255. /** Skybox coordinates mode */
  67256. static readonly TEXTURE_SKYBOX_MODE: number;
  67257. /** Inverse Cubic coordinates mode */
  67258. static readonly TEXTURE_INVCUBIC_MODE: number;
  67259. /** Equirectangular coordinates mode */
  67260. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67261. /** Equirectangular Fixed coordinates mode */
  67262. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67263. /** Equirectangular Fixed Mirrored coordinates mode */
  67264. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67265. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67266. static readonly SCALEMODE_FLOOR: number;
  67267. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67268. static readonly SCALEMODE_NEAREST: number;
  67269. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67270. static readonly SCALEMODE_CEILING: number;
  67271. /**
  67272. * The dirty texture flag value
  67273. */
  67274. static readonly MATERIAL_TextureDirtyFlag: number;
  67275. /**
  67276. * The dirty light flag value
  67277. */
  67278. static readonly MATERIAL_LightDirtyFlag: number;
  67279. /**
  67280. * The dirty fresnel flag value
  67281. */
  67282. static readonly MATERIAL_FresnelDirtyFlag: number;
  67283. /**
  67284. * The dirty attribute flag value
  67285. */
  67286. static readonly MATERIAL_AttributesDirtyFlag: number;
  67287. /**
  67288. * The dirty misc flag value
  67289. */
  67290. static readonly MATERIAL_MiscDirtyFlag: number;
  67291. /**
  67292. * The all dirty flag value
  67293. */
  67294. static readonly MATERIAL_AllDirtyFlag: number;
  67295. /**
  67296. * Returns the triangle fill mode
  67297. */
  67298. static readonly MATERIAL_TriangleFillMode: number;
  67299. /**
  67300. * Returns the wireframe mode
  67301. */
  67302. static readonly MATERIAL_WireFrameFillMode: number;
  67303. /**
  67304. * Returns the point fill mode
  67305. */
  67306. static readonly MATERIAL_PointFillMode: number;
  67307. /**
  67308. * Returns the point list draw mode
  67309. */
  67310. static readonly MATERIAL_PointListDrawMode: number;
  67311. /**
  67312. * Returns the line list draw mode
  67313. */
  67314. static readonly MATERIAL_LineListDrawMode: number;
  67315. /**
  67316. * Returns the line loop draw mode
  67317. */
  67318. static readonly MATERIAL_LineLoopDrawMode: number;
  67319. /**
  67320. * Returns the line strip draw mode
  67321. */
  67322. static readonly MATERIAL_LineStripDrawMode: number;
  67323. /**
  67324. * Returns the triangle strip draw mode
  67325. */
  67326. static readonly MATERIAL_TriangleStripDrawMode: number;
  67327. /**
  67328. * Returns the triangle fan draw mode
  67329. */
  67330. static readonly MATERIAL_TriangleFanDrawMode: number;
  67331. /**
  67332. * Stores the clock-wise side orientation
  67333. */
  67334. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67335. /**
  67336. * Stores the counter clock-wise side orientation
  67337. */
  67338. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67339. /**
  67340. * Nothing
  67341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67342. */
  67343. static readonly ACTION_NothingTrigger: number;
  67344. /**
  67345. * On pick
  67346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67347. */
  67348. static readonly ACTION_OnPickTrigger: number;
  67349. /**
  67350. * On left pick
  67351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67352. */
  67353. static readonly ACTION_OnLeftPickTrigger: number;
  67354. /**
  67355. * On right pick
  67356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67357. */
  67358. static readonly ACTION_OnRightPickTrigger: number;
  67359. /**
  67360. * On center pick
  67361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67362. */
  67363. static readonly ACTION_OnCenterPickTrigger: number;
  67364. /**
  67365. * On pick down
  67366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67367. */
  67368. static readonly ACTION_OnPickDownTrigger: number;
  67369. /**
  67370. * On double pick
  67371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67372. */
  67373. static readonly ACTION_OnDoublePickTrigger: number;
  67374. /**
  67375. * On pick up
  67376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67377. */
  67378. static readonly ACTION_OnPickUpTrigger: number;
  67379. /**
  67380. * On pick out.
  67381. * This trigger will only be raised if you also declared a OnPickDown
  67382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67383. */
  67384. static readonly ACTION_OnPickOutTrigger: number;
  67385. /**
  67386. * On long press
  67387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67388. */
  67389. static readonly ACTION_OnLongPressTrigger: number;
  67390. /**
  67391. * On pointer over
  67392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67393. */
  67394. static readonly ACTION_OnPointerOverTrigger: number;
  67395. /**
  67396. * On pointer out
  67397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67398. */
  67399. static readonly ACTION_OnPointerOutTrigger: number;
  67400. /**
  67401. * On every frame
  67402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67403. */
  67404. static readonly ACTION_OnEveryFrameTrigger: number;
  67405. /**
  67406. * On intersection enter
  67407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67408. */
  67409. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67410. /**
  67411. * On intersection exit
  67412. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67413. */
  67414. static readonly ACTION_OnIntersectionExitTrigger: number;
  67415. /**
  67416. * On key down
  67417. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67418. */
  67419. static readonly ACTION_OnKeyDownTrigger: number;
  67420. /**
  67421. * On key up
  67422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67423. */
  67424. static readonly ACTION_OnKeyUpTrigger: number;
  67425. /**
  67426. * Billboard mode will only apply to Y axis
  67427. */
  67428. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67429. /**
  67430. * Billboard mode will apply to all axes
  67431. */
  67432. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67433. /**
  67434. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67435. */
  67436. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67437. /**
  67438. * Gets or sets base Assets URL
  67439. */
  67440. static PARTICLES_BaseAssetsUrl: string;
  67441. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67442. * Test order :
  67443. * Is the bounding sphere outside the frustum ?
  67444. * If not, are the bounding box vertices outside the frustum ?
  67445. * It not, then the cullable object is in the frustum.
  67446. */
  67447. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67448. /** Culling strategy : Bounding Sphere Only.
  67449. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67450. * It's also less accurate than the standard because some not visible objects can still be selected.
  67451. * Test : is the bounding sphere outside the frustum ?
  67452. * If not, then the cullable object is in the frustum.
  67453. */
  67454. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67455. /** Culling strategy : Optimistic Inclusion.
  67456. * This in an inclusion test first, then the standard exclusion test.
  67457. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67458. * 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.
  67459. * Anyway, it's as accurate as the standard strategy.
  67460. * Test :
  67461. * Is the cullable object bounding sphere center in the frustum ?
  67462. * If not, apply the default culling strategy.
  67463. */
  67464. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67465. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67466. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67467. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67468. * 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.
  67469. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67470. * Test :
  67471. * Is the cullable object bounding sphere center in the frustum ?
  67472. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67473. */
  67474. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67475. /**
  67476. * No logging while loading
  67477. */
  67478. static readonly SCENELOADER_NO_LOGGING: number;
  67479. /**
  67480. * Minimal logging while loading
  67481. */
  67482. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67483. /**
  67484. * Summary logging while loading
  67485. */
  67486. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67487. /**
  67488. * Detailled logging while loading
  67489. */
  67490. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67491. }
  67492. }
  67493. declare module BABYLON {
  67494. /**
  67495. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67496. * Babylon.js
  67497. */
  67498. export class DomManagement {
  67499. /**
  67500. * Checks if the window object exists
  67501. * @returns true if the window object exists
  67502. */
  67503. static IsWindowObjectExist(): boolean;
  67504. /**
  67505. * Extracts text content from a DOM element hierarchy
  67506. * @param element defines the root element
  67507. * @returns a string
  67508. */
  67509. static GetDOMTextContent(element: HTMLElement): string;
  67510. }
  67511. }
  67512. declare module BABYLON {
  67513. /**
  67514. * Logger used througouht the application to allow configuration of
  67515. * the log level required for the messages.
  67516. */
  67517. export class Logger {
  67518. /**
  67519. * No log
  67520. */
  67521. static readonly NoneLogLevel: number;
  67522. /**
  67523. * Only message logs
  67524. */
  67525. static readonly MessageLogLevel: number;
  67526. /**
  67527. * Only warning logs
  67528. */
  67529. static readonly WarningLogLevel: number;
  67530. /**
  67531. * Only error logs
  67532. */
  67533. static readonly ErrorLogLevel: number;
  67534. /**
  67535. * All logs
  67536. */
  67537. static readonly AllLogLevel: number;
  67538. private static _LogCache;
  67539. /**
  67540. * Gets a value indicating the number of loading errors
  67541. * @ignorenaming
  67542. */
  67543. static errorsCount: number;
  67544. /**
  67545. * Callback called when a new log is added
  67546. */
  67547. static OnNewCacheEntry: (entry: string) => void;
  67548. private static _AddLogEntry;
  67549. private static _FormatMessage;
  67550. private static _LogDisabled;
  67551. private static _LogEnabled;
  67552. private static _WarnDisabled;
  67553. private static _WarnEnabled;
  67554. private static _ErrorDisabled;
  67555. private static _ErrorEnabled;
  67556. /**
  67557. * Log a message to the console
  67558. */
  67559. static Log: (message: string) => void;
  67560. /**
  67561. * Write a warning message to the console
  67562. */
  67563. static Warn: (message: string) => void;
  67564. /**
  67565. * Write an error message to the console
  67566. */
  67567. static Error: (message: string) => void;
  67568. /**
  67569. * Gets current log cache (list of logs)
  67570. */
  67571. static readonly LogCache: string;
  67572. /**
  67573. * Clears the log cache
  67574. */
  67575. static ClearLogCache(): void;
  67576. /**
  67577. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67578. */
  67579. static LogLevels: number;
  67580. }
  67581. }
  67582. declare module BABYLON {
  67583. /** @hidden */
  67584. export class _TypeStore {
  67585. /** @hidden */
  67586. static RegisteredTypes: {
  67587. [key: string]: Object;
  67588. };
  67589. /** @hidden */
  67590. static GetClass(fqdn: string): any;
  67591. }
  67592. }
  67593. declare module BABYLON {
  67594. /**
  67595. * Class containing a set of static utilities functions for deep copy.
  67596. */
  67597. export class DeepCopier {
  67598. /**
  67599. * Tries to copy an object by duplicating every property
  67600. * @param source defines the source object
  67601. * @param destination defines the target object
  67602. * @param doNotCopyList defines a list of properties to avoid
  67603. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67604. */
  67605. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67606. }
  67607. }
  67608. declare module BABYLON {
  67609. /**
  67610. * Class containing a set of static utilities functions for precision date
  67611. */
  67612. export class PrecisionDate {
  67613. /**
  67614. * Gets either window.performance.now() if supported or Date.now() else
  67615. */
  67616. static readonly Now: number;
  67617. }
  67618. }
  67619. declare module BABYLON {
  67620. /** @hidden */
  67621. export class _DevTools {
  67622. static WarnImport(name: string): string;
  67623. }
  67624. }
  67625. declare module BABYLON {
  67626. /**
  67627. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67628. */
  67629. export class WebRequest {
  67630. private _xhr;
  67631. /**
  67632. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67633. * i.e. when loading files, where the server/service expects an Authorization header
  67634. */
  67635. static CustomRequestHeaders: {
  67636. [key: string]: string;
  67637. };
  67638. /**
  67639. * Add callback functions in this array to update all the requests before they get sent to the network
  67640. */
  67641. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  67642. private _injectCustomRequestHeaders;
  67643. /**
  67644. * Gets or sets a function to be called when loading progress changes
  67645. */
  67646. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67647. /**
  67648. * Returns client's state
  67649. */
  67650. readonly readyState: number;
  67651. /**
  67652. * Returns client's status
  67653. */
  67654. readonly status: number;
  67655. /**
  67656. * Returns client's status as a text
  67657. */
  67658. readonly statusText: string;
  67659. /**
  67660. * Returns client's response
  67661. */
  67662. readonly response: any;
  67663. /**
  67664. * Returns client's response url
  67665. */
  67666. readonly responseURL: string;
  67667. /**
  67668. * Returns client's response as text
  67669. */
  67670. readonly responseText: string;
  67671. /**
  67672. * Gets or sets the expected response type
  67673. */
  67674. responseType: XMLHttpRequestResponseType;
  67675. /** @hidden */
  67676. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67677. /** @hidden */
  67678. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67679. /**
  67680. * Cancels any network activity
  67681. */
  67682. abort(): void;
  67683. /**
  67684. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67685. * @param body defines an optional request body
  67686. */
  67687. send(body?: Document | BodyInit | null): void;
  67688. /**
  67689. * Sets the request method, request URL
  67690. * @param method defines the method to use (GET, POST, etc..)
  67691. * @param url defines the url to connect with
  67692. */
  67693. open(method: string, url: string): void;
  67694. }
  67695. }
  67696. declare module BABYLON {
  67697. /**
  67698. * Class used to evalaute queries containing `and` and `or` operators
  67699. */
  67700. export class AndOrNotEvaluator {
  67701. /**
  67702. * Evaluate a query
  67703. * @param query defines the query to evaluate
  67704. * @param evaluateCallback defines the callback used to filter result
  67705. * @returns true if the query matches
  67706. */
  67707. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  67708. private static _HandleParenthesisContent;
  67709. private static _SimplifyNegation;
  67710. }
  67711. }
  67712. declare module BABYLON {
  67713. /**
  67714. * Class used to store custom tags
  67715. */
  67716. export class Tags {
  67717. /**
  67718. * Adds support for tags on the given object
  67719. * @param obj defines the object to use
  67720. */
  67721. static EnableFor(obj: any): void;
  67722. /**
  67723. * Removes tags support
  67724. * @param obj defines the object to use
  67725. */
  67726. static DisableFor(obj: any): void;
  67727. /**
  67728. * Gets a boolean indicating if the given object has tags
  67729. * @param obj defines the object to use
  67730. * @returns a boolean
  67731. */
  67732. static HasTags(obj: any): boolean;
  67733. /**
  67734. * Gets the tags available on a given object
  67735. * @param obj defines the object to use
  67736. * @param asString defines if the tags must be returned as a string instead of an array of strings
  67737. * @returns the tags
  67738. */
  67739. static GetTags(obj: any, asString?: boolean): any;
  67740. /**
  67741. * Adds tags to an object
  67742. * @param obj defines the object to use
  67743. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  67744. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  67745. */
  67746. static AddTagsTo(obj: any, tagsString: string): void;
  67747. /**
  67748. * @hidden
  67749. */
  67750. static _AddTagTo(obj: any, tag: string): void;
  67751. /**
  67752. * Removes specific tags from a specific object
  67753. * @param obj defines the object to use
  67754. * @param tagsString defines the tags to remove
  67755. */
  67756. static RemoveTagsFrom(obj: any, tagsString: string): void;
  67757. /**
  67758. * @hidden
  67759. */
  67760. static _RemoveTagFrom(obj: any, tag: string): void;
  67761. /**
  67762. * Defines if tags hosted on an object match a given query
  67763. * @param obj defines the object to use
  67764. * @param tagsQuery defines the tag query
  67765. * @returns a boolean
  67766. */
  67767. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  67768. }
  67769. }
  67770. declare module BABYLON {
  67771. /**
  67772. * Manages the defines for the Material
  67773. */
  67774. export class MaterialDefines {
  67775. /** @hidden */
  67776. protected _keys: string[];
  67777. private _isDirty;
  67778. /** @hidden */
  67779. _renderId: number;
  67780. /** @hidden */
  67781. _areLightsDirty: boolean;
  67782. /** @hidden */
  67783. _areAttributesDirty: boolean;
  67784. /** @hidden */
  67785. _areTexturesDirty: boolean;
  67786. /** @hidden */
  67787. _areFresnelDirty: boolean;
  67788. /** @hidden */
  67789. _areMiscDirty: boolean;
  67790. /** @hidden */
  67791. _areImageProcessingDirty: boolean;
  67792. /** @hidden */
  67793. _normals: boolean;
  67794. /** @hidden */
  67795. _uvs: boolean;
  67796. /** @hidden */
  67797. _needNormals: boolean;
  67798. /** @hidden */
  67799. _needUVs: boolean;
  67800. [id: string]: any;
  67801. /**
  67802. * Specifies if the material needs to be re-calculated
  67803. */
  67804. readonly isDirty: boolean;
  67805. /**
  67806. * Marks the material to indicate that it has been re-calculated
  67807. */
  67808. markAsProcessed(): void;
  67809. /**
  67810. * Marks the material to indicate that it needs to be re-calculated
  67811. */
  67812. markAsUnprocessed(): void;
  67813. /**
  67814. * Marks the material to indicate all of its defines need to be re-calculated
  67815. */
  67816. markAllAsDirty(): void;
  67817. /**
  67818. * Marks the material to indicate that image processing needs to be re-calculated
  67819. */
  67820. markAsImageProcessingDirty(): void;
  67821. /**
  67822. * Marks the material to indicate the lights need to be re-calculated
  67823. */
  67824. markAsLightDirty(): void;
  67825. /**
  67826. * Marks the attribute state as changed
  67827. */
  67828. markAsAttributesDirty(): void;
  67829. /**
  67830. * Marks the texture state as changed
  67831. */
  67832. markAsTexturesDirty(): void;
  67833. /**
  67834. * Marks the fresnel state as changed
  67835. */
  67836. markAsFresnelDirty(): void;
  67837. /**
  67838. * Marks the misc state as changed
  67839. */
  67840. markAsMiscDirty(): void;
  67841. /**
  67842. * Rebuilds the material defines
  67843. */
  67844. rebuild(): void;
  67845. /**
  67846. * Specifies if two material defines are equal
  67847. * @param other - A material define instance to compare to
  67848. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  67849. */
  67850. isEqual(other: MaterialDefines): boolean;
  67851. /**
  67852. * Clones this instance's defines to another instance
  67853. * @param other - material defines to clone values to
  67854. */
  67855. cloneTo(other: MaterialDefines): void;
  67856. /**
  67857. * Resets the material define values
  67858. */
  67859. reset(): void;
  67860. /**
  67861. * Converts the material define values to a string
  67862. * @returns - String of material define information
  67863. */
  67864. toString(): string;
  67865. }
  67866. }
  67867. declare module BABYLON {
  67868. /**
  67869. * Class used to store and describe the pipeline context associated with an effect
  67870. */
  67871. export interface IPipelineContext {
  67872. /**
  67873. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67874. */
  67875. isAsync: boolean;
  67876. /**
  67877. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67878. */
  67879. isReady: boolean;
  67880. /** @hidden */
  67881. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67882. }
  67883. }
  67884. declare module BABYLON {
  67885. /**
  67886. * Class used to store gfx data (like WebGLBuffer)
  67887. */
  67888. export class DataBuffer {
  67889. /**
  67890. * Gets or sets the number of objects referencing this buffer
  67891. */
  67892. references: number;
  67893. /** Gets or sets the size of the underlying buffer */
  67894. capacity: number;
  67895. /**
  67896. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67897. */
  67898. is32Bits: boolean;
  67899. /**
  67900. * Gets the underlying buffer
  67901. */
  67902. readonly underlyingResource: any;
  67903. }
  67904. }
  67905. declare module BABYLON {
  67906. /** @hidden */
  67907. export interface IShaderProcessor {
  67908. attributeProcessor?: (attribute: string) => string;
  67909. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67910. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  67911. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  67912. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  67913. lineProcessor?: (line: string, isFragment: boolean) => string;
  67914. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67915. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67916. }
  67917. }
  67918. declare module BABYLON {
  67919. /** @hidden */
  67920. export interface ProcessingOptions {
  67921. defines: string[];
  67922. indexParameters: any;
  67923. isFragment: boolean;
  67924. shouldUseHighPrecisionShader: boolean;
  67925. supportsUniformBuffers: boolean;
  67926. shadersRepository: string;
  67927. includesShadersStore: {
  67928. [key: string]: string;
  67929. };
  67930. processor?: IShaderProcessor;
  67931. version: string;
  67932. platformName: string;
  67933. lookForClosingBracketForUniformBuffer?: boolean;
  67934. }
  67935. }
  67936. declare module BABYLON {
  67937. /** @hidden */
  67938. export class ShaderCodeNode {
  67939. line: string;
  67940. children: ShaderCodeNode[];
  67941. additionalDefineKey?: string;
  67942. additionalDefineValue?: string;
  67943. isValid(preprocessors: {
  67944. [key: string]: string;
  67945. }): boolean;
  67946. process(preprocessors: {
  67947. [key: string]: string;
  67948. }, options: ProcessingOptions): string;
  67949. }
  67950. }
  67951. declare module BABYLON {
  67952. /** @hidden */
  67953. export class ShaderCodeCursor {
  67954. private _lines;
  67955. lineIndex: number;
  67956. readonly currentLine: string;
  67957. readonly canRead: boolean;
  67958. lines: string[];
  67959. }
  67960. }
  67961. declare module BABYLON {
  67962. /** @hidden */
  67963. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67964. process(preprocessors: {
  67965. [key: string]: string;
  67966. }, options: ProcessingOptions): string;
  67967. }
  67968. }
  67969. declare module BABYLON {
  67970. /** @hidden */
  67971. export class ShaderDefineExpression {
  67972. isTrue(preprocessors: {
  67973. [key: string]: string;
  67974. }): boolean;
  67975. }
  67976. }
  67977. declare module BABYLON {
  67978. /** @hidden */
  67979. export class ShaderCodeTestNode extends ShaderCodeNode {
  67980. testExpression: ShaderDefineExpression;
  67981. isValid(preprocessors: {
  67982. [key: string]: string;
  67983. }): boolean;
  67984. }
  67985. }
  67986. declare module BABYLON {
  67987. /** @hidden */
  67988. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  67989. define: string;
  67990. not: boolean;
  67991. constructor(define: string, not?: boolean);
  67992. isTrue(preprocessors: {
  67993. [key: string]: string;
  67994. }): boolean;
  67995. }
  67996. }
  67997. declare module BABYLON {
  67998. /** @hidden */
  67999. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68000. leftOperand: ShaderDefineExpression;
  68001. rightOperand: ShaderDefineExpression;
  68002. isTrue(preprocessors: {
  68003. [key: string]: string;
  68004. }): boolean;
  68005. }
  68006. }
  68007. declare module BABYLON {
  68008. /** @hidden */
  68009. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68010. leftOperand: ShaderDefineExpression;
  68011. rightOperand: ShaderDefineExpression;
  68012. isTrue(preprocessors: {
  68013. [key: string]: string;
  68014. }): boolean;
  68015. }
  68016. }
  68017. declare module BABYLON {
  68018. /** @hidden */
  68019. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68020. define: string;
  68021. operand: string;
  68022. testValue: string;
  68023. constructor(define: string, operand: string, testValue: string);
  68024. isTrue(preprocessors: {
  68025. [key: string]: string;
  68026. }): boolean;
  68027. }
  68028. }
  68029. declare module BABYLON {
  68030. /** @hidden */
  68031. export class ShaderProcessor {
  68032. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68033. private static _ProcessPrecision;
  68034. private static _ExtractOperation;
  68035. private static _BuildSubExpression;
  68036. private static _BuildExpression;
  68037. private static _MoveCursorWithinIf;
  68038. private static _MoveCursor;
  68039. private static _EvaluatePreProcessors;
  68040. private static _PreparePreProcessors;
  68041. private static _ProcessShaderConversion;
  68042. private static _ProcessIncludes;
  68043. }
  68044. }
  68045. declare module BABYLON {
  68046. /**
  68047. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  68048. */
  68049. export class PerformanceMonitor {
  68050. private _enabled;
  68051. private _rollingFrameTime;
  68052. private _lastFrameTimeMs;
  68053. /**
  68054. * constructor
  68055. * @param frameSampleSize The number of samples required to saturate the sliding window
  68056. */
  68057. constructor(frameSampleSize?: number);
  68058. /**
  68059. * Samples current frame
  68060. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  68061. */
  68062. sampleFrame(timeMs?: number): void;
  68063. /**
  68064. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68065. */
  68066. readonly averageFrameTime: number;
  68067. /**
  68068. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68069. */
  68070. readonly averageFrameTimeVariance: number;
  68071. /**
  68072. * Returns the frame time of the most recent frame
  68073. */
  68074. readonly instantaneousFrameTime: number;
  68075. /**
  68076. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  68077. */
  68078. readonly averageFPS: number;
  68079. /**
  68080. * Returns the average framerate in frames per second using the most recent frame time
  68081. */
  68082. readonly instantaneousFPS: number;
  68083. /**
  68084. * Returns true if enough samples have been taken to completely fill the sliding window
  68085. */
  68086. readonly isSaturated: boolean;
  68087. /**
  68088. * Enables contributions to the sliding window sample set
  68089. */
  68090. enable(): void;
  68091. /**
  68092. * Disables contributions to the sliding window sample set
  68093. * Samples will not be interpolated over the disabled period
  68094. */
  68095. disable(): void;
  68096. /**
  68097. * Returns true if sampling is enabled
  68098. */
  68099. readonly isEnabled: boolean;
  68100. /**
  68101. * Resets performance monitor
  68102. */
  68103. reset(): void;
  68104. }
  68105. /**
  68106. * RollingAverage
  68107. *
  68108. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  68109. */
  68110. export class RollingAverage {
  68111. /**
  68112. * Current average
  68113. */
  68114. average: number;
  68115. /**
  68116. * Current variance
  68117. */
  68118. variance: number;
  68119. protected _samples: Array<number>;
  68120. protected _sampleCount: number;
  68121. protected _pos: number;
  68122. protected _m2: number;
  68123. /**
  68124. * constructor
  68125. * @param length The number of samples required to saturate the sliding window
  68126. */
  68127. constructor(length: number);
  68128. /**
  68129. * Adds a sample to the sample set
  68130. * @param v The sample value
  68131. */
  68132. add(v: number): void;
  68133. /**
  68134. * Returns previously added values or null if outside of history or outside the sliding window domain
  68135. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  68136. * @return Value previously recorded with add() or null if outside of range
  68137. */
  68138. history(i: number): number;
  68139. /**
  68140. * Returns true if enough samples have been taken to completely fill the sliding window
  68141. * @return true if sample-set saturated
  68142. */
  68143. isSaturated(): boolean;
  68144. /**
  68145. * Resets the rolling average (equivalent to 0 samples taken so far)
  68146. */
  68147. reset(): void;
  68148. /**
  68149. * Wraps a value around the sample range boundaries
  68150. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  68151. * @return Wrapped position in sample range
  68152. */
  68153. protected _wrapPosition(i: number): number;
  68154. }
  68155. }
  68156. declare module BABYLON {
  68157. /**
  68158. * This class implement a typical dictionary using a string as key and the generic type T as value.
  68159. * The underlying implementation relies on an associative array to ensure the best performances.
  68160. * The value can be anything including 'null' but except 'undefined'
  68161. */
  68162. export class StringDictionary<T> {
  68163. /**
  68164. * This will clear this dictionary and copy the content from the 'source' one.
  68165. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  68166. * @param source the dictionary to take the content from and copy to this dictionary
  68167. */
  68168. copyFrom(source: StringDictionary<T>): void;
  68169. /**
  68170. * Get a value based from its key
  68171. * @param key the given key to get the matching value from
  68172. * @return the value if found, otherwise undefined is returned
  68173. */
  68174. get(key: string): T | undefined;
  68175. /**
  68176. * Get a value from its key or add it if it doesn't exist.
  68177. * This method will ensure you that a given key/data will be present in the dictionary.
  68178. * @param key the given key to get the matching value from
  68179. * @param factory the factory that will create the value if the key is not present in the dictionary.
  68180. * The factory will only be invoked if there's no data for the given key.
  68181. * @return the value corresponding to the key.
  68182. */
  68183. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  68184. /**
  68185. * Get a value from its key if present in the dictionary otherwise add it
  68186. * @param key the key to get the value from
  68187. * @param val if there's no such key/value pair in the dictionary add it with this value
  68188. * @return the value corresponding to the key
  68189. */
  68190. getOrAdd(key: string, val: T): T;
  68191. /**
  68192. * Check if there's a given key in the dictionary
  68193. * @param key the key to check for
  68194. * @return true if the key is present, false otherwise
  68195. */
  68196. contains(key: string): boolean;
  68197. /**
  68198. * Add a new key and its corresponding value
  68199. * @param key the key to add
  68200. * @param value the value corresponding to the key
  68201. * @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
  68202. */
  68203. add(key: string, value: T): boolean;
  68204. /**
  68205. * Update a specific value associated to a key
  68206. * @param key defines the key to use
  68207. * @param value defines the value to store
  68208. * @returns true if the value was updated (or false if the key was not found)
  68209. */
  68210. set(key: string, value: T): boolean;
  68211. /**
  68212. * Get the element of the given key and remove it from the dictionary
  68213. * @param key defines the key to search
  68214. * @returns the value associated with the key or null if not found
  68215. */
  68216. getAndRemove(key: string): Nullable<T>;
  68217. /**
  68218. * Remove a key/value from the dictionary.
  68219. * @param key the key to remove
  68220. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  68221. */
  68222. remove(key: string): boolean;
  68223. /**
  68224. * Clear the whole content of the dictionary
  68225. */
  68226. clear(): void;
  68227. /**
  68228. * Gets the current count
  68229. */
  68230. readonly count: number;
  68231. /**
  68232. * Execute a callback on each key/val of the dictionary.
  68233. * Note that you can remove any element in this dictionary in the callback implementation
  68234. * @param callback the callback to execute on a given key/value pair
  68235. */
  68236. forEach(callback: (key: string, val: T) => void): void;
  68237. /**
  68238. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  68239. * If the callback returns null or undefined the method will iterate to the next key/value pair
  68240. * Note that you can remove any element in this dictionary in the callback implementation
  68241. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  68242. * @returns the first item
  68243. */
  68244. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  68245. private _count;
  68246. private _data;
  68247. }
  68248. }
  68249. declare module BABYLON {
  68250. /**
  68251. * Helper class that provides a small promise polyfill
  68252. */
  68253. export class PromisePolyfill {
  68254. /**
  68255. * Static function used to check if the polyfill is required
  68256. * If this is the case then the function will inject the polyfill to window.Promise
  68257. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  68258. */
  68259. static Apply(force?: boolean): void;
  68260. }
  68261. }
  68262. declare module BABYLON {
  68263. /**
  68264. * Class used to store data that will be store in GPU memory
  68265. */
  68266. export class Buffer {
  68267. private _engine;
  68268. private _buffer;
  68269. /** @hidden */
  68270. _data: Nullable<DataArray>;
  68271. private _updatable;
  68272. private _instanced;
  68273. /**
  68274. * Gets the byte stride.
  68275. */
  68276. readonly byteStride: number;
  68277. /**
  68278. * Constructor
  68279. * @param engine the engine
  68280. * @param data the data to use for this buffer
  68281. * @param updatable whether the data is updatable
  68282. * @param stride the stride (optional)
  68283. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68284. * @param instanced whether the buffer is instanced (optional)
  68285. * @param useBytes set to true if the stride in in bytes (optional)
  68286. */
  68287. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68288. /**
  68289. * Create a new VertexBuffer based on the current buffer
  68290. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68291. * @param offset defines offset in the buffer (0 by default)
  68292. * @param size defines the size in floats of attributes (position is 3 for instance)
  68293. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68294. * @param instanced defines if the vertex buffer contains indexed data
  68295. * @param useBytes defines if the offset and stride are in bytes
  68296. * @returns the new vertex buffer
  68297. */
  68298. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68299. /**
  68300. * Gets a boolean indicating if the Buffer is updatable?
  68301. * @returns true if the buffer is updatable
  68302. */
  68303. isUpdatable(): boolean;
  68304. /**
  68305. * Gets current buffer's data
  68306. * @returns a DataArray or null
  68307. */
  68308. getData(): Nullable<DataArray>;
  68309. /**
  68310. * Gets underlying native buffer
  68311. * @returns underlying native buffer
  68312. */
  68313. getBuffer(): Nullable<DataBuffer>;
  68314. /**
  68315. * Gets the stride in float32 units (i.e. byte stride / 4).
  68316. * May not be an integer if the byte stride is not divisible by 4.
  68317. * DEPRECATED. Use byteStride instead.
  68318. * @returns the stride in float32 units
  68319. */
  68320. getStrideSize(): number;
  68321. /**
  68322. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68323. * @param data defines the data to store
  68324. */
  68325. create(data?: Nullable<DataArray>): void;
  68326. /** @hidden */
  68327. _rebuild(): void;
  68328. /**
  68329. * Update current buffer data
  68330. * @param data defines the data to store
  68331. */
  68332. update(data: DataArray): void;
  68333. /**
  68334. * Updates the data directly.
  68335. * @param data the new data
  68336. * @param offset the new offset
  68337. * @param vertexCount the vertex count (optional)
  68338. * @param useBytes set to true if the offset is in bytes
  68339. */
  68340. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68341. /**
  68342. * Release all resources
  68343. */
  68344. dispose(): void;
  68345. }
  68346. /**
  68347. * Specialized buffer used to store vertex data
  68348. */
  68349. export class VertexBuffer {
  68350. /** @hidden */
  68351. _buffer: Buffer;
  68352. private _kind;
  68353. private _size;
  68354. private _ownsBuffer;
  68355. private _instanced;
  68356. private _instanceDivisor;
  68357. /**
  68358. * The byte type.
  68359. */
  68360. static readonly BYTE: number;
  68361. /**
  68362. * The unsigned byte type.
  68363. */
  68364. static readonly UNSIGNED_BYTE: number;
  68365. /**
  68366. * The short type.
  68367. */
  68368. static readonly SHORT: number;
  68369. /**
  68370. * The unsigned short type.
  68371. */
  68372. static readonly UNSIGNED_SHORT: number;
  68373. /**
  68374. * The integer type.
  68375. */
  68376. static readonly INT: number;
  68377. /**
  68378. * The unsigned integer type.
  68379. */
  68380. static readonly UNSIGNED_INT: number;
  68381. /**
  68382. * The float type.
  68383. */
  68384. static readonly FLOAT: number;
  68385. /**
  68386. * Gets or sets the instance divisor when in instanced mode
  68387. */
  68388. instanceDivisor: number;
  68389. /**
  68390. * Gets the byte stride.
  68391. */
  68392. readonly byteStride: number;
  68393. /**
  68394. * Gets the byte offset.
  68395. */
  68396. readonly byteOffset: number;
  68397. /**
  68398. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68399. */
  68400. readonly normalized: boolean;
  68401. /**
  68402. * Gets the data type of each component in the array.
  68403. */
  68404. readonly type: number;
  68405. /**
  68406. * Constructor
  68407. * @param engine the engine
  68408. * @param data the data to use for this vertex buffer
  68409. * @param kind the vertex buffer kind
  68410. * @param updatable whether the data is updatable
  68411. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68412. * @param stride the stride (optional)
  68413. * @param instanced whether the buffer is instanced (optional)
  68414. * @param offset the offset of the data (optional)
  68415. * @param size the number of components (optional)
  68416. * @param type the type of the component (optional)
  68417. * @param normalized whether the data contains normalized data (optional)
  68418. * @param useBytes set to true if stride and offset are in bytes (optional)
  68419. */
  68420. 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);
  68421. /** @hidden */
  68422. _rebuild(): void;
  68423. /**
  68424. * Returns the kind of the VertexBuffer (string)
  68425. * @returns a string
  68426. */
  68427. getKind(): string;
  68428. /**
  68429. * Gets a boolean indicating if the VertexBuffer is updatable?
  68430. * @returns true if the buffer is updatable
  68431. */
  68432. isUpdatable(): boolean;
  68433. /**
  68434. * Gets current buffer's data
  68435. * @returns a DataArray or null
  68436. */
  68437. getData(): Nullable<DataArray>;
  68438. /**
  68439. * Gets underlying native buffer
  68440. * @returns underlying native buffer
  68441. */
  68442. getBuffer(): Nullable<DataBuffer>;
  68443. /**
  68444. * Gets the stride in float32 units (i.e. byte stride / 4).
  68445. * May not be an integer if the byte stride is not divisible by 4.
  68446. * DEPRECATED. Use byteStride instead.
  68447. * @returns the stride in float32 units
  68448. */
  68449. getStrideSize(): number;
  68450. /**
  68451. * Returns the offset as a multiple of the type byte length.
  68452. * DEPRECATED. Use byteOffset instead.
  68453. * @returns the offset in bytes
  68454. */
  68455. getOffset(): number;
  68456. /**
  68457. * Returns the number of components per vertex attribute (integer)
  68458. * @returns the size in float
  68459. */
  68460. getSize(): number;
  68461. /**
  68462. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68463. * @returns true if this buffer is instanced
  68464. */
  68465. getIsInstanced(): boolean;
  68466. /**
  68467. * Returns the instancing divisor, zero for non-instanced (integer).
  68468. * @returns a number
  68469. */
  68470. getInstanceDivisor(): number;
  68471. /**
  68472. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68473. * @param data defines the data to store
  68474. */
  68475. create(data?: DataArray): void;
  68476. /**
  68477. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68478. * This function will create a new buffer if the current one is not updatable
  68479. * @param data defines the data to store
  68480. */
  68481. update(data: DataArray): void;
  68482. /**
  68483. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68484. * Returns the directly updated WebGLBuffer.
  68485. * @param data the new data
  68486. * @param offset the new offset
  68487. * @param useBytes set to true if the offset is in bytes
  68488. */
  68489. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68490. /**
  68491. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68492. */
  68493. dispose(): void;
  68494. /**
  68495. * Enumerates each value of this vertex buffer as numbers.
  68496. * @param count the number of values to enumerate
  68497. * @param callback the callback function called for each value
  68498. */
  68499. forEach(count: number, callback: (value: number, index: number) => void): void;
  68500. /**
  68501. * Positions
  68502. */
  68503. static readonly PositionKind: string;
  68504. /**
  68505. * Normals
  68506. */
  68507. static readonly NormalKind: string;
  68508. /**
  68509. * Tangents
  68510. */
  68511. static readonly TangentKind: string;
  68512. /**
  68513. * Texture coordinates
  68514. */
  68515. static readonly UVKind: string;
  68516. /**
  68517. * Texture coordinates 2
  68518. */
  68519. static readonly UV2Kind: string;
  68520. /**
  68521. * Texture coordinates 3
  68522. */
  68523. static readonly UV3Kind: string;
  68524. /**
  68525. * Texture coordinates 4
  68526. */
  68527. static readonly UV4Kind: string;
  68528. /**
  68529. * Texture coordinates 5
  68530. */
  68531. static readonly UV5Kind: string;
  68532. /**
  68533. * Texture coordinates 6
  68534. */
  68535. static readonly UV6Kind: string;
  68536. /**
  68537. * Colors
  68538. */
  68539. static readonly ColorKind: string;
  68540. /**
  68541. * Matrix indices (for bones)
  68542. */
  68543. static readonly MatricesIndicesKind: string;
  68544. /**
  68545. * Matrix weights (for bones)
  68546. */
  68547. static readonly MatricesWeightsKind: string;
  68548. /**
  68549. * Additional matrix indices (for bones)
  68550. */
  68551. static readonly MatricesIndicesExtraKind: string;
  68552. /**
  68553. * Additional matrix weights (for bones)
  68554. */
  68555. static readonly MatricesWeightsExtraKind: string;
  68556. /**
  68557. * Deduces the stride given a kind.
  68558. * @param kind The kind string to deduce
  68559. * @returns The deduced stride
  68560. */
  68561. static DeduceStride(kind: string): number;
  68562. /**
  68563. * Gets the byte length of the given type.
  68564. * @param type the type
  68565. * @returns the number of bytes
  68566. */
  68567. static GetTypeByteLength(type: number): number;
  68568. /**
  68569. * Enumerates each value of the given parameters as numbers.
  68570. * @param data the data to enumerate
  68571. * @param byteOffset the byte offset of the data
  68572. * @param byteStride the byte stride of the data
  68573. * @param componentCount the number of components per element
  68574. * @param componentType the type of the component
  68575. * @param count the number of values to enumerate
  68576. * @param normalized whether the data is normalized
  68577. * @param callback the callback function called for each value
  68578. */
  68579. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68580. private static _GetFloatValue;
  68581. }
  68582. }
  68583. declare module BABYLON {
  68584. /**
  68585. * Class representing spherical harmonics coefficients to the 3rd degree
  68586. */
  68587. export class SphericalHarmonics {
  68588. /**
  68589. * Defines whether or not the harmonics have been prescaled for rendering.
  68590. */
  68591. preScaled: boolean;
  68592. /**
  68593. * The l0,0 coefficients of the spherical harmonics
  68594. */
  68595. l00: Vector3;
  68596. /**
  68597. * The l1,-1 coefficients of the spherical harmonics
  68598. */
  68599. l1_1: Vector3;
  68600. /**
  68601. * The l1,0 coefficients of the spherical harmonics
  68602. */
  68603. l10: Vector3;
  68604. /**
  68605. * The l1,1 coefficients of the spherical harmonics
  68606. */
  68607. l11: Vector3;
  68608. /**
  68609. * The l2,-2 coefficients of the spherical harmonics
  68610. */
  68611. l2_2: Vector3;
  68612. /**
  68613. * The l2,-1 coefficients of the spherical harmonics
  68614. */
  68615. l2_1: Vector3;
  68616. /**
  68617. * The l2,0 coefficients of the spherical harmonics
  68618. */
  68619. l20: Vector3;
  68620. /**
  68621. * The l2,1 coefficients of the spherical harmonics
  68622. */
  68623. l21: Vector3;
  68624. /**
  68625. * The l2,2 coefficients of the spherical harmonics
  68626. */
  68627. l22: Vector3;
  68628. /**
  68629. * Adds a light to the spherical harmonics
  68630. * @param direction the direction of the light
  68631. * @param color the color of the light
  68632. * @param deltaSolidAngle the delta solid angle of the light
  68633. */
  68634. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  68635. /**
  68636. * Scales the spherical harmonics by the given amount
  68637. * @param scale the amount to scale
  68638. */
  68639. scaleInPlace(scale: number): void;
  68640. /**
  68641. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  68642. *
  68643. * ```
  68644. * E_lm = A_l * L_lm
  68645. * ```
  68646. *
  68647. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  68648. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68649. * the scaling factors are given in equation 9.
  68650. */
  68651. convertIncidentRadianceToIrradiance(): void;
  68652. /**
  68653. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68654. *
  68655. * ```
  68656. * L = (1/pi) * E * rho
  68657. * ```
  68658. *
  68659. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68660. */
  68661. convertIrradianceToLambertianRadiance(): void;
  68662. /**
  68663. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68664. * required operations at run time.
  68665. *
  68666. * This is simply done by scaling back the SH with Ylm constants parameter.
  68667. * The trigonometric part being applied by the shader at run time.
  68668. */
  68669. preScaleForRendering(): void;
  68670. /**
  68671. * Constructs a spherical harmonics from an array.
  68672. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68673. * @returns the spherical harmonics
  68674. */
  68675. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68676. /**
  68677. * Gets the spherical harmonics from polynomial
  68678. * @param polynomial the spherical polynomial
  68679. * @returns the spherical harmonics
  68680. */
  68681. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  68682. }
  68683. /**
  68684. * Class representing spherical polynomial coefficients to the 3rd degree
  68685. */
  68686. export class SphericalPolynomial {
  68687. private _harmonics;
  68688. /**
  68689. * The spherical harmonics used to create the polynomials.
  68690. */
  68691. readonly preScaledHarmonics: SphericalHarmonics;
  68692. /**
  68693. * The x coefficients of the spherical polynomial
  68694. */
  68695. x: Vector3;
  68696. /**
  68697. * The y coefficients of the spherical polynomial
  68698. */
  68699. y: Vector3;
  68700. /**
  68701. * The z coefficients of the spherical polynomial
  68702. */
  68703. z: Vector3;
  68704. /**
  68705. * The xx coefficients of the spherical polynomial
  68706. */
  68707. xx: Vector3;
  68708. /**
  68709. * The yy coefficients of the spherical polynomial
  68710. */
  68711. yy: Vector3;
  68712. /**
  68713. * The zz coefficients of the spherical polynomial
  68714. */
  68715. zz: Vector3;
  68716. /**
  68717. * The xy coefficients of the spherical polynomial
  68718. */
  68719. xy: Vector3;
  68720. /**
  68721. * The yz coefficients of the spherical polynomial
  68722. */
  68723. yz: Vector3;
  68724. /**
  68725. * The zx coefficients of the spherical polynomial
  68726. */
  68727. zx: Vector3;
  68728. /**
  68729. * Adds an ambient color to the spherical polynomial
  68730. * @param color the color to add
  68731. */
  68732. addAmbient(color: Color3): void;
  68733. /**
  68734. * Scales the spherical polynomial by the given amount
  68735. * @param scale the amount to scale
  68736. */
  68737. scaleInPlace(scale: number): void;
  68738. /**
  68739. * Gets the spherical polynomial from harmonics
  68740. * @param harmonics the spherical harmonics
  68741. * @returns the spherical polynomial
  68742. */
  68743. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  68744. /**
  68745. * Constructs a spherical polynomial from an array.
  68746. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  68747. * @returns the spherical polynomial
  68748. */
  68749. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  68750. }
  68751. }
  68752. declare module BABYLON {
  68753. /**
  68754. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  68755. */
  68756. export interface CubeMapInfo {
  68757. /**
  68758. * The pixel array for the front face.
  68759. * This is stored in format, left to right, up to down format.
  68760. */
  68761. front: Nullable<ArrayBufferView>;
  68762. /**
  68763. * The pixel array for the back face.
  68764. * This is stored in format, left to right, up to down format.
  68765. */
  68766. back: Nullable<ArrayBufferView>;
  68767. /**
  68768. * The pixel array for the left face.
  68769. * This is stored in format, left to right, up to down format.
  68770. */
  68771. left: Nullable<ArrayBufferView>;
  68772. /**
  68773. * The pixel array for the right face.
  68774. * This is stored in format, left to right, up to down format.
  68775. */
  68776. right: Nullable<ArrayBufferView>;
  68777. /**
  68778. * The pixel array for the up face.
  68779. * This is stored in format, left to right, up to down format.
  68780. */
  68781. up: Nullable<ArrayBufferView>;
  68782. /**
  68783. * The pixel array for the down face.
  68784. * This is stored in format, left to right, up to down format.
  68785. */
  68786. down: Nullable<ArrayBufferView>;
  68787. /**
  68788. * The size of the cubemap stored.
  68789. *
  68790. * Each faces will be size * size pixels.
  68791. */
  68792. size: number;
  68793. /**
  68794. * The format of the texture.
  68795. *
  68796. * RGBA, RGB.
  68797. */
  68798. format: number;
  68799. /**
  68800. * The type of the texture data.
  68801. *
  68802. * UNSIGNED_INT, FLOAT.
  68803. */
  68804. type: number;
  68805. /**
  68806. * Specifies whether the texture is in gamma space.
  68807. */
  68808. gammaSpace: boolean;
  68809. }
  68810. /**
  68811. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  68812. */
  68813. export class PanoramaToCubeMapTools {
  68814. private static FACE_FRONT;
  68815. private static FACE_BACK;
  68816. private static FACE_RIGHT;
  68817. private static FACE_LEFT;
  68818. private static FACE_DOWN;
  68819. private static FACE_UP;
  68820. /**
  68821. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  68822. *
  68823. * @param float32Array The source data.
  68824. * @param inputWidth The width of the input panorama.
  68825. * @param inputHeight The height of the input panorama.
  68826. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  68827. * @return The cubemap data
  68828. */
  68829. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  68830. private static CreateCubemapTexture;
  68831. private static CalcProjectionSpherical;
  68832. }
  68833. }
  68834. declare module BABYLON {
  68835. /**
  68836. * Helper class dealing with the extraction of spherical polynomial dataArray
  68837. * from a cube map.
  68838. */
  68839. export class CubeMapToSphericalPolynomialTools {
  68840. private static FileFaces;
  68841. /**
  68842. * Converts a texture to the according Spherical Polynomial data.
  68843. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68844. *
  68845. * @param texture The texture to extract the information from.
  68846. * @return The Spherical Polynomial data.
  68847. */
  68848. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  68849. /**
  68850. * Converts a cubemap to the according Spherical Polynomial data.
  68851. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68852. *
  68853. * @param cubeInfo The Cube map to extract the information from.
  68854. * @return The Spherical Polynomial data.
  68855. */
  68856. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  68857. }
  68858. }
  68859. declare module BABYLON {
  68860. /**
  68861. * The engine store class is responsible to hold all the instances of Engine and Scene created
  68862. * during the life time of the application.
  68863. */
  68864. export class EngineStore {
  68865. /** Gets the list of created engines */
  68866. static Instances: Engine[];
  68867. /** @hidden */
  68868. static _LastCreatedScene: Nullable<Scene>;
  68869. /**
  68870. * Gets the latest created engine
  68871. */
  68872. static readonly LastCreatedEngine: Nullable<Engine>;
  68873. /**
  68874. * Gets the latest created scene
  68875. */
  68876. static readonly LastCreatedScene: Nullable<Scene>;
  68877. }
  68878. }
  68879. declare module BABYLON {
  68880. /**
  68881. * Define options used to create a render target texture
  68882. */
  68883. export class RenderTargetCreationOptions {
  68884. /**
  68885. * Specifies is mipmaps must be generated
  68886. */
  68887. generateMipMaps?: boolean;
  68888. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68889. generateDepthBuffer?: boolean;
  68890. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68891. generateStencilBuffer?: boolean;
  68892. /** Defines texture type (int by default) */
  68893. type?: number;
  68894. /** Defines sampling mode (trilinear by default) */
  68895. samplingMode?: number;
  68896. /** Defines format (RGBA by default) */
  68897. format?: number;
  68898. }
  68899. }
  68900. declare module BABYLON {
  68901. /**
  68902. * @hidden
  68903. **/
  68904. export class _AlphaState {
  68905. private _isAlphaBlendDirty;
  68906. private _isBlendFunctionParametersDirty;
  68907. private _isBlendEquationParametersDirty;
  68908. private _isBlendConstantsDirty;
  68909. private _alphaBlend;
  68910. private _blendFunctionParameters;
  68911. private _blendEquationParameters;
  68912. private _blendConstants;
  68913. /**
  68914. * Initializes the state.
  68915. */
  68916. constructor();
  68917. readonly isDirty: boolean;
  68918. alphaBlend: boolean;
  68919. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  68920. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  68921. setAlphaEquationParameters(rgb: number, alpha: number): void;
  68922. reset(): void;
  68923. apply(gl: WebGLRenderingContext): void;
  68924. }
  68925. }
  68926. declare module BABYLON {
  68927. /**
  68928. * @hidden
  68929. **/
  68930. export class _DepthCullingState {
  68931. private _isDepthTestDirty;
  68932. private _isDepthMaskDirty;
  68933. private _isDepthFuncDirty;
  68934. private _isCullFaceDirty;
  68935. private _isCullDirty;
  68936. private _isZOffsetDirty;
  68937. private _isFrontFaceDirty;
  68938. private _depthTest;
  68939. private _depthMask;
  68940. private _depthFunc;
  68941. private _cull;
  68942. private _cullFace;
  68943. private _zOffset;
  68944. private _frontFace;
  68945. /**
  68946. * Initializes the state.
  68947. */
  68948. constructor();
  68949. readonly isDirty: boolean;
  68950. zOffset: number;
  68951. cullFace: Nullable<number>;
  68952. cull: Nullable<boolean>;
  68953. depthFunc: Nullable<number>;
  68954. depthMask: boolean;
  68955. depthTest: boolean;
  68956. frontFace: Nullable<number>;
  68957. reset(): void;
  68958. apply(gl: WebGLRenderingContext): void;
  68959. }
  68960. }
  68961. declare module BABYLON {
  68962. /**
  68963. * @hidden
  68964. **/
  68965. export class _StencilState {
  68966. /** 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 */
  68967. static readonly ALWAYS: number;
  68968. /** Passed to stencilOperation to specify that stencil value must be kept */
  68969. static readonly KEEP: number;
  68970. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68971. static readonly REPLACE: number;
  68972. private _isStencilTestDirty;
  68973. private _isStencilMaskDirty;
  68974. private _isStencilFuncDirty;
  68975. private _isStencilOpDirty;
  68976. private _stencilTest;
  68977. private _stencilMask;
  68978. private _stencilFunc;
  68979. private _stencilFuncRef;
  68980. private _stencilFuncMask;
  68981. private _stencilOpStencilFail;
  68982. private _stencilOpDepthFail;
  68983. private _stencilOpStencilDepthPass;
  68984. readonly isDirty: boolean;
  68985. stencilFunc: number;
  68986. stencilFuncRef: number;
  68987. stencilFuncMask: number;
  68988. stencilOpStencilFail: number;
  68989. stencilOpDepthFail: number;
  68990. stencilOpStencilDepthPass: number;
  68991. stencilMask: number;
  68992. stencilTest: boolean;
  68993. constructor();
  68994. reset(): void;
  68995. apply(gl: WebGLRenderingContext): void;
  68996. }
  68997. }
  68998. declare module BABYLON {
  68999. /**
  69000. * @hidden
  69001. **/
  69002. export class _TimeToken {
  69003. _startTimeQuery: Nullable<WebGLQuery>;
  69004. _endTimeQuery: Nullable<WebGLQuery>;
  69005. _timeElapsedQuery: Nullable<WebGLQuery>;
  69006. _timeElapsedQueryEnded: boolean;
  69007. }
  69008. }
  69009. declare module BABYLON {
  69010. /**
  69011. * Class used to store data associated with WebGL texture data for the engine
  69012. * This class should not be used directly
  69013. */
  69014. export class InternalTexture {
  69015. /** @hidden */
  69016. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  69017. /**
  69018. * The source of the texture data is unknown
  69019. */
  69020. static DATASOURCE_UNKNOWN: number;
  69021. /**
  69022. * Texture data comes from an URL
  69023. */
  69024. static DATASOURCE_URL: number;
  69025. /**
  69026. * Texture data is only used for temporary storage
  69027. */
  69028. static DATASOURCE_TEMP: number;
  69029. /**
  69030. * Texture data comes from raw data (ArrayBuffer)
  69031. */
  69032. static DATASOURCE_RAW: number;
  69033. /**
  69034. * Texture content is dynamic (video or dynamic texture)
  69035. */
  69036. static DATASOURCE_DYNAMIC: number;
  69037. /**
  69038. * Texture content is generated by rendering to it
  69039. */
  69040. static DATASOURCE_RENDERTARGET: number;
  69041. /**
  69042. * Texture content is part of a multi render target process
  69043. */
  69044. static DATASOURCE_MULTIRENDERTARGET: number;
  69045. /**
  69046. * Texture data comes from a cube data file
  69047. */
  69048. static DATASOURCE_CUBE: number;
  69049. /**
  69050. * Texture data comes from a raw cube data
  69051. */
  69052. static DATASOURCE_CUBERAW: number;
  69053. /**
  69054. * Texture data come from a prefiltered cube data file
  69055. */
  69056. static DATASOURCE_CUBEPREFILTERED: number;
  69057. /**
  69058. * Texture content is raw 3D data
  69059. */
  69060. static DATASOURCE_RAW3D: number;
  69061. /**
  69062. * Texture content is a depth texture
  69063. */
  69064. static DATASOURCE_DEPTHTEXTURE: number;
  69065. /**
  69066. * Texture data comes from a raw cube data encoded with RGBD
  69067. */
  69068. static DATASOURCE_CUBERAW_RGBD: number;
  69069. /**
  69070. * Defines if the texture is ready
  69071. */
  69072. isReady: boolean;
  69073. /**
  69074. * Defines if the texture is a cube texture
  69075. */
  69076. isCube: boolean;
  69077. /**
  69078. * Defines if the texture contains 3D data
  69079. */
  69080. is3D: boolean;
  69081. /**
  69082. * Defines if the texture contains multiview data
  69083. */
  69084. isMultiview: boolean;
  69085. /**
  69086. * Gets the URL used to load this texture
  69087. */
  69088. url: string;
  69089. /**
  69090. * Gets the sampling mode of the texture
  69091. */
  69092. samplingMode: number;
  69093. /**
  69094. * Gets a boolean indicating if the texture needs mipmaps generation
  69095. */
  69096. generateMipMaps: boolean;
  69097. /**
  69098. * Gets the number of samples used by the texture (WebGL2+ only)
  69099. */
  69100. samples: number;
  69101. /**
  69102. * Gets the type of the texture (int, float...)
  69103. */
  69104. type: number;
  69105. /**
  69106. * Gets the format of the texture (RGB, RGBA...)
  69107. */
  69108. format: number;
  69109. /**
  69110. * Observable called when the texture is loaded
  69111. */
  69112. onLoadedObservable: Observable<InternalTexture>;
  69113. /**
  69114. * Gets the width of the texture
  69115. */
  69116. width: number;
  69117. /**
  69118. * Gets the height of the texture
  69119. */
  69120. height: number;
  69121. /**
  69122. * Gets the depth of the texture
  69123. */
  69124. depth: number;
  69125. /**
  69126. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  69127. */
  69128. baseWidth: number;
  69129. /**
  69130. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  69131. */
  69132. baseHeight: number;
  69133. /**
  69134. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  69135. */
  69136. baseDepth: number;
  69137. /**
  69138. * Gets a boolean indicating if the texture is inverted on Y axis
  69139. */
  69140. invertY: boolean;
  69141. /** @hidden */
  69142. _invertVScale: boolean;
  69143. /** @hidden */
  69144. _associatedChannel: number;
  69145. /** @hidden */
  69146. _dataSource: number;
  69147. /** @hidden */
  69148. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  69149. /** @hidden */
  69150. _bufferView: Nullable<ArrayBufferView>;
  69151. /** @hidden */
  69152. _bufferViewArray: Nullable<ArrayBufferView[]>;
  69153. /** @hidden */
  69154. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  69155. /** @hidden */
  69156. _size: number;
  69157. /** @hidden */
  69158. _extension: string;
  69159. /** @hidden */
  69160. _files: Nullable<string[]>;
  69161. /** @hidden */
  69162. _workingCanvas: Nullable<HTMLCanvasElement>;
  69163. /** @hidden */
  69164. _workingContext: Nullable<CanvasRenderingContext2D>;
  69165. /** @hidden */
  69166. _framebuffer: Nullable<WebGLFramebuffer>;
  69167. /** @hidden */
  69168. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  69169. /** @hidden */
  69170. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  69171. /** @hidden */
  69172. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  69173. /** @hidden */
  69174. _attachments: Nullable<number[]>;
  69175. /** @hidden */
  69176. _cachedCoordinatesMode: Nullable<number>;
  69177. /** @hidden */
  69178. _cachedWrapU: Nullable<number>;
  69179. /** @hidden */
  69180. _cachedWrapV: Nullable<number>;
  69181. /** @hidden */
  69182. _cachedWrapR: Nullable<number>;
  69183. /** @hidden */
  69184. _cachedAnisotropicFilteringLevel: Nullable<number>;
  69185. /** @hidden */
  69186. _isDisabled: boolean;
  69187. /** @hidden */
  69188. _compression: Nullable<string>;
  69189. /** @hidden */
  69190. _generateStencilBuffer: boolean;
  69191. /** @hidden */
  69192. _generateDepthBuffer: boolean;
  69193. /** @hidden */
  69194. _comparisonFunction: number;
  69195. /** @hidden */
  69196. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  69197. /** @hidden */
  69198. _lodGenerationScale: number;
  69199. /** @hidden */
  69200. _lodGenerationOffset: number;
  69201. /** @hidden */
  69202. _colorTextureArray: Nullable<WebGLTexture>;
  69203. /** @hidden */
  69204. _depthStencilTextureArray: Nullable<WebGLTexture>;
  69205. /** @hidden */
  69206. _lodTextureHigh: Nullable<BaseTexture>;
  69207. /** @hidden */
  69208. _lodTextureMid: Nullable<BaseTexture>;
  69209. /** @hidden */
  69210. _lodTextureLow: Nullable<BaseTexture>;
  69211. /** @hidden */
  69212. _isRGBD: boolean;
  69213. /** @hidden */
  69214. _linearSpecularLOD: boolean;
  69215. /** @hidden */
  69216. _irradianceTexture: Nullable<BaseTexture>;
  69217. /** @hidden */
  69218. _webGLTexture: Nullable<WebGLTexture>;
  69219. /** @hidden */
  69220. _references: number;
  69221. private _engine;
  69222. /**
  69223. * Gets the Engine the texture belongs to.
  69224. * @returns The babylon engine
  69225. */
  69226. getEngine(): Engine;
  69227. /**
  69228. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  69229. */
  69230. readonly dataSource: number;
  69231. /**
  69232. * Creates a new InternalTexture
  69233. * @param engine defines the engine to use
  69234. * @param dataSource defines the type of data that will be used
  69235. * @param delayAllocation if the texture allocation should be delayed (default: false)
  69236. */
  69237. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  69238. /**
  69239. * Increments the number of references (ie. the number of Texture that point to it)
  69240. */
  69241. incrementReferences(): void;
  69242. /**
  69243. * Change the size of the texture (not the size of the content)
  69244. * @param width defines the new width
  69245. * @param height defines the new height
  69246. * @param depth defines the new depth (1 by default)
  69247. */
  69248. updateSize(width: int, height: int, depth?: int): void;
  69249. /** @hidden */
  69250. _rebuild(): void;
  69251. /** @hidden */
  69252. _swapAndDie(target: InternalTexture): void;
  69253. /**
  69254. * Dispose the current allocated resources
  69255. */
  69256. dispose(): void;
  69257. }
  69258. }
  69259. declare module BABYLON {
  69260. /**
  69261. * This represents the main contract an easing function should follow.
  69262. * Easing functions are used throughout the animation system.
  69263. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69264. */
  69265. export interface IEasingFunction {
  69266. /**
  69267. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69268. * of the easing function.
  69269. * The link below provides some of the most common examples of easing functions.
  69270. * @see https://easings.net/
  69271. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69272. * @returns the corresponding value on the curve defined by the easing function
  69273. */
  69274. ease(gradient: number): number;
  69275. }
  69276. /**
  69277. * Base class used for every default easing function.
  69278. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69279. */
  69280. export class EasingFunction implements IEasingFunction {
  69281. /**
  69282. * Interpolation follows the mathematical formula associated with the easing function.
  69283. */
  69284. static readonly EASINGMODE_EASEIN: number;
  69285. /**
  69286. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69287. */
  69288. static readonly EASINGMODE_EASEOUT: number;
  69289. /**
  69290. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69291. */
  69292. static readonly EASINGMODE_EASEINOUT: number;
  69293. private _easingMode;
  69294. /**
  69295. * Sets the easing mode of the current function.
  69296. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69297. */
  69298. setEasingMode(easingMode: number): void;
  69299. /**
  69300. * Gets the current easing mode.
  69301. * @returns the easing mode
  69302. */
  69303. getEasingMode(): number;
  69304. /**
  69305. * @hidden
  69306. */
  69307. easeInCore(gradient: number): number;
  69308. /**
  69309. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69310. * of the easing function.
  69311. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69312. * @returns the corresponding value on the curve defined by the easing function
  69313. */
  69314. ease(gradient: number): number;
  69315. }
  69316. /**
  69317. * Easing function with a circle shape (see link below).
  69318. * @see https://easings.net/#easeInCirc
  69319. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69320. */
  69321. export class CircleEase extends EasingFunction implements IEasingFunction {
  69322. /** @hidden */
  69323. easeInCore(gradient: number): number;
  69324. }
  69325. /**
  69326. * Easing function with a ease back shape (see link below).
  69327. * @see https://easings.net/#easeInBack
  69328. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69329. */
  69330. export class BackEase extends EasingFunction implements IEasingFunction {
  69331. /** Defines the amplitude of the function */
  69332. amplitude: number;
  69333. /**
  69334. * Instantiates a back ease easing
  69335. * @see https://easings.net/#easeInBack
  69336. * @param amplitude Defines the amplitude of the function
  69337. */
  69338. constructor(
  69339. /** Defines the amplitude of the function */
  69340. amplitude?: number);
  69341. /** @hidden */
  69342. easeInCore(gradient: number): number;
  69343. }
  69344. /**
  69345. * Easing function with a bouncing shape (see link below).
  69346. * @see https://easings.net/#easeInBounce
  69347. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69348. */
  69349. export class BounceEase extends EasingFunction implements IEasingFunction {
  69350. /** Defines the number of bounces */
  69351. bounces: number;
  69352. /** Defines the amplitude of the bounce */
  69353. bounciness: number;
  69354. /**
  69355. * Instantiates a bounce easing
  69356. * @see https://easings.net/#easeInBounce
  69357. * @param bounces Defines the number of bounces
  69358. * @param bounciness Defines the amplitude of the bounce
  69359. */
  69360. constructor(
  69361. /** Defines the number of bounces */
  69362. bounces?: number,
  69363. /** Defines the amplitude of the bounce */
  69364. bounciness?: number);
  69365. /** @hidden */
  69366. easeInCore(gradient: number): number;
  69367. }
  69368. /**
  69369. * Easing function with a power of 3 shape (see link below).
  69370. * @see https://easings.net/#easeInCubic
  69371. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69372. */
  69373. export class CubicEase extends EasingFunction implements IEasingFunction {
  69374. /** @hidden */
  69375. easeInCore(gradient: number): number;
  69376. }
  69377. /**
  69378. * Easing function with an elastic shape (see link below).
  69379. * @see https://easings.net/#easeInElastic
  69380. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69381. */
  69382. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69383. /** Defines the number of oscillations*/
  69384. oscillations: number;
  69385. /** Defines the amplitude of the oscillations*/
  69386. springiness: number;
  69387. /**
  69388. * Instantiates an elastic easing function
  69389. * @see https://easings.net/#easeInElastic
  69390. * @param oscillations Defines the number of oscillations
  69391. * @param springiness Defines the amplitude of the oscillations
  69392. */
  69393. constructor(
  69394. /** Defines the number of oscillations*/
  69395. oscillations?: number,
  69396. /** Defines the amplitude of the oscillations*/
  69397. springiness?: number);
  69398. /** @hidden */
  69399. easeInCore(gradient: number): number;
  69400. }
  69401. /**
  69402. * Easing function with an exponential shape (see link below).
  69403. * @see https://easings.net/#easeInExpo
  69404. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69405. */
  69406. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69407. /** Defines the exponent of the function */
  69408. exponent: number;
  69409. /**
  69410. * Instantiates an exponential easing function
  69411. * @see https://easings.net/#easeInExpo
  69412. * @param exponent Defines the exponent of the function
  69413. */
  69414. constructor(
  69415. /** Defines the exponent of the function */
  69416. exponent?: number);
  69417. /** @hidden */
  69418. easeInCore(gradient: number): number;
  69419. }
  69420. /**
  69421. * Easing function with a power shape (see link below).
  69422. * @see https://easings.net/#easeInQuad
  69423. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69424. */
  69425. export class PowerEase extends EasingFunction implements IEasingFunction {
  69426. /** Defines the power of the function */
  69427. power: number;
  69428. /**
  69429. * Instantiates an power base easing function
  69430. * @see https://easings.net/#easeInQuad
  69431. * @param power Defines the power of the function
  69432. */
  69433. constructor(
  69434. /** Defines the power of the function */
  69435. power?: number);
  69436. /** @hidden */
  69437. easeInCore(gradient: number): number;
  69438. }
  69439. /**
  69440. * Easing function with a power of 2 shape (see link below).
  69441. * @see https://easings.net/#easeInQuad
  69442. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69443. */
  69444. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69445. /** @hidden */
  69446. easeInCore(gradient: number): number;
  69447. }
  69448. /**
  69449. * Easing function with a power of 4 shape (see link below).
  69450. * @see https://easings.net/#easeInQuart
  69451. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69452. */
  69453. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69454. /** @hidden */
  69455. easeInCore(gradient: number): number;
  69456. }
  69457. /**
  69458. * Easing function with a power of 5 shape (see link below).
  69459. * @see https://easings.net/#easeInQuint
  69460. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69461. */
  69462. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69463. /** @hidden */
  69464. easeInCore(gradient: number): number;
  69465. }
  69466. /**
  69467. * Easing function with a sin shape (see link below).
  69468. * @see https://easings.net/#easeInSine
  69469. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69470. */
  69471. export class SineEase extends EasingFunction implements IEasingFunction {
  69472. /** @hidden */
  69473. easeInCore(gradient: number): number;
  69474. }
  69475. /**
  69476. * Easing function with a bezier shape (see link below).
  69477. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69478. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69479. */
  69480. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69481. /** Defines the x component of the start tangent in the bezier curve */
  69482. x1: number;
  69483. /** Defines the y component of the start tangent in the bezier curve */
  69484. y1: number;
  69485. /** Defines the x component of the end tangent in the bezier curve */
  69486. x2: number;
  69487. /** Defines the y component of the end tangent in the bezier curve */
  69488. y2: number;
  69489. /**
  69490. * Instantiates a bezier function
  69491. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69492. * @param x1 Defines the x component of the start tangent in the bezier curve
  69493. * @param y1 Defines the y component of the start tangent in the bezier curve
  69494. * @param x2 Defines the x component of the end tangent in the bezier curve
  69495. * @param y2 Defines the y component of the end tangent in the bezier curve
  69496. */
  69497. constructor(
  69498. /** Defines the x component of the start tangent in the bezier curve */
  69499. x1?: number,
  69500. /** Defines the y component of the start tangent in the bezier curve */
  69501. y1?: number,
  69502. /** Defines the x component of the end tangent in the bezier curve */
  69503. x2?: number,
  69504. /** Defines the y component of the end tangent in the bezier curve */
  69505. y2?: number);
  69506. /** @hidden */
  69507. easeInCore(gradient: number): number;
  69508. }
  69509. }
  69510. declare module BABYLON {
  69511. /**
  69512. * Defines an interface which represents an animation key frame
  69513. */
  69514. export interface IAnimationKey {
  69515. /**
  69516. * Frame of the key frame
  69517. */
  69518. frame: number;
  69519. /**
  69520. * Value at the specifies key frame
  69521. */
  69522. value: any;
  69523. /**
  69524. * The input tangent for the cubic hermite spline
  69525. */
  69526. inTangent?: any;
  69527. /**
  69528. * The output tangent for the cubic hermite spline
  69529. */
  69530. outTangent?: any;
  69531. /**
  69532. * The animation interpolation type
  69533. */
  69534. interpolation?: AnimationKeyInterpolation;
  69535. }
  69536. /**
  69537. * Enum for the animation key frame interpolation type
  69538. */
  69539. export enum AnimationKeyInterpolation {
  69540. /**
  69541. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69542. */
  69543. STEP = 1
  69544. }
  69545. }
  69546. declare module BABYLON {
  69547. /**
  69548. * Represents the range of an animation
  69549. */
  69550. export class AnimationRange {
  69551. /**The name of the animation range**/
  69552. name: string;
  69553. /**The starting frame of the animation */
  69554. from: number;
  69555. /**The ending frame of the animation*/
  69556. to: number;
  69557. /**
  69558. * Initializes the range of an animation
  69559. * @param name The name of the animation range
  69560. * @param from The starting frame of the animation
  69561. * @param to The ending frame of the animation
  69562. */
  69563. constructor(
  69564. /**The name of the animation range**/
  69565. name: string,
  69566. /**The starting frame of the animation */
  69567. from: number,
  69568. /**The ending frame of the animation*/
  69569. to: number);
  69570. /**
  69571. * Makes a copy of the animation range
  69572. * @returns A copy of the animation range
  69573. */
  69574. clone(): AnimationRange;
  69575. }
  69576. }
  69577. declare module BABYLON {
  69578. /**
  69579. * Composed of a frame, and an action function
  69580. */
  69581. export class AnimationEvent {
  69582. /** The frame for which the event is triggered **/
  69583. frame: number;
  69584. /** The event to perform when triggered **/
  69585. action: (currentFrame: number) => void;
  69586. /** Specifies if the event should be triggered only once**/
  69587. onlyOnce?: boolean | undefined;
  69588. /**
  69589. * Specifies if the animation event is done
  69590. */
  69591. isDone: boolean;
  69592. /**
  69593. * Initializes the animation event
  69594. * @param frame The frame for which the event is triggered
  69595. * @param action The event to perform when triggered
  69596. * @param onlyOnce Specifies if the event should be triggered only once
  69597. */
  69598. constructor(
  69599. /** The frame for which the event is triggered **/
  69600. frame: number,
  69601. /** The event to perform when triggered **/
  69602. action: (currentFrame: number) => void,
  69603. /** Specifies if the event should be triggered only once**/
  69604. onlyOnce?: boolean | undefined);
  69605. /** @hidden */
  69606. _clone(): AnimationEvent;
  69607. }
  69608. }
  69609. declare module BABYLON {
  69610. /**
  69611. * Interface used to define a behavior
  69612. */
  69613. export interface Behavior<T> {
  69614. /** gets or sets behavior's name */
  69615. name: string;
  69616. /**
  69617. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69618. */
  69619. init(): void;
  69620. /**
  69621. * Called when the behavior is attached to a target
  69622. * @param target defines the target where the behavior is attached to
  69623. */
  69624. attach(target: T): void;
  69625. /**
  69626. * Called when the behavior is detached from its target
  69627. */
  69628. detach(): void;
  69629. }
  69630. /**
  69631. * Interface implemented by classes supporting behaviors
  69632. */
  69633. export interface IBehaviorAware<T> {
  69634. /**
  69635. * Attach a behavior
  69636. * @param behavior defines the behavior to attach
  69637. * @returns the current host
  69638. */
  69639. addBehavior(behavior: Behavior<T>): T;
  69640. /**
  69641. * Remove a behavior from the current object
  69642. * @param behavior defines the behavior to detach
  69643. * @returns the current host
  69644. */
  69645. removeBehavior(behavior: Behavior<T>): T;
  69646. /**
  69647. * Gets a behavior using its name to search
  69648. * @param name defines the name to search
  69649. * @returns the behavior or null if not found
  69650. */
  69651. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  69652. }
  69653. }
  69654. declare module BABYLON {
  69655. /**
  69656. * @hidden
  69657. */
  69658. export class IntersectionInfo {
  69659. bu: Nullable<number>;
  69660. bv: Nullable<number>;
  69661. distance: number;
  69662. faceId: number;
  69663. subMeshId: number;
  69664. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69665. }
  69666. }
  69667. declare module BABYLON {
  69668. /**
  69669. * Class used to store bounding sphere information
  69670. */
  69671. export class BoundingSphere {
  69672. /**
  69673. * Gets the center of the bounding sphere in local space
  69674. */
  69675. readonly center: Vector3;
  69676. /**
  69677. * Radius of the bounding sphere in local space
  69678. */
  69679. radius: number;
  69680. /**
  69681. * Gets the center of the bounding sphere in world space
  69682. */
  69683. readonly centerWorld: Vector3;
  69684. /**
  69685. * Radius of the bounding sphere in world space
  69686. */
  69687. radiusWorld: number;
  69688. /**
  69689. * Gets the minimum vector in local space
  69690. */
  69691. readonly minimum: Vector3;
  69692. /**
  69693. * Gets the maximum vector in local space
  69694. */
  69695. readonly maximum: Vector3;
  69696. private _worldMatrix;
  69697. private static readonly TmpVector3;
  69698. /**
  69699. * Creates a new bounding sphere
  69700. * @param min defines the minimum vector (in local space)
  69701. * @param max defines the maximum vector (in local space)
  69702. * @param worldMatrix defines the new world matrix
  69703. */
  69704. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69705. /**
  69706. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  69707. * @param min defines the new minimum vector (in local space)
  69708. * @param max defines the new maximum vector (in local space)
  69709. * @param worldMatrix defines the new world matrix
  69710. */
  69711. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69712. /**
  69713. * Scale the current bounding sphere by applying a scale factor
  69714. * @param factor defines the scale factor to apply
  69715. * @returns the current bounding box
  69716. */
  69717. scale(factor: number): BoundingSphere;
  69718. /**
  69719. * Gets the world matrix of the bounding box
  69720. * @returns a matrix
  69721. */
  69722. getWorldMatrix(): DeepImmutable<Matrix>;
  69723. /** @hidden */
  69724. _update(worldMatrix: DeepImmutable<Matrix>): void;
  69725. /**
  69726. * Tests if the bounding sphere is intersecting the frustum planes
  69727. * @param frustumPlanes defines the frustum planes to test
  69728. * @returns true if there is an intersection
  69729. */
  69730. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69731. /**
  69732. * Tests if the bounding sphere center is in between the frustum planes.
  69733. * Used for optimistic fast inclusion.
  69734. * @param frustumPlanes defines the frustum planes to test
  69735. * @returns true if the sphere center is in between the frustum planes
  69736. */
  69737. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69738. /**
  69739. * Tests if a point is inside the bounding sphere
  69740. * @param point defines the point to test
  69741. * @returns true if the point is inside the bounding sphere
  69742. */
  69743. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69744. /**
  69745. * Checks if two sphere intersct
  69746. * @param sphere0 sphere 0
  69747. * @param sphere1 sphere 1
  69748. * @returns true if the speres intersect
  69749. */
  69750. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  69751. }
  69752. }
  69753. declare module BABYLON {
  69754. /**
  69755. * Class used to store bounding box information
  69756. */
  69757. export class BoundingBox implements ICullable {
  69758. /**
  69759. * Gets the 8 vectors representing the bounding box in local space
  69760. */
  69761. readonly vectors: Vector3[];
  69762. /**
  69763. * Gets the center of the bounding box in local space
  69764. */
  69765. readonly center: Vector3;
  69766. /**
  69767. * Gets the center of the bounding box in world space
  69768. */
  69769. readonly centerWorld: Vector3;
  69770. /**
  69771. * Gets the extend size in local space
  69772. */
  69773. readonly extendSize: Vector3;
  69774. /**
  69775. * Gets the extend size in world space
  69776. */
  69777. readonly extendSizeWorld: Vector3;
  69778. /**
  69779. * Gets the OBB (object bounding box) directions
  69780. */
  69781. readonly directions: Vector3[];
  69782. /**
  69783. * Gets the 8 vectors representing the bounding box in world space
  69784. */
  69785. readonly vectorsWorld: Vector3[];
  69786. /**
  69787. * Gets the minimum vector in world space
  69788. */
  69789. readonly minimumWorld: Vector3;
  69790. /**
  69791. * Gets the maximum vector in world space
  69792. */
  69793. readonly maximumWorld: Vector3;
  69794. /**
  69795. * Gets the minimum vector in local space
  69796. */
  69797. readonly minimum: Vector3;
  69798. /**
  69799. * Gets the maximum vector in local space
  69800. */
  69801. readonly maximum: Vector3;
  69802. private _worldMatrix;
  69803. private static readonly TmpVector3;
  69804. /**
  69805. * @hidden
  69806. */
  69807. _tag: number;
  69808. /**
  69809. * Creates a new bounding box
  69810. * @param min defines the minimum vector (in local space)
  69811. * @param max defines the maximum vector (in local space)
  69812. * @param worldMatrix defines the new world matrix
  69813. */
  69814. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69815. /**
  69816. * Recreates the entire bounding box from scratch as if we call the constructor in place
  69817. * @param min defines the new minimum vector (in local space)
  69818. * @param max defines the new maximum vector (in local space)
  69819. * @param worldMatrix defines the new world matrix
  69820. */
  69821. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69822. /**
  69823. * Scale the current bounding box by applying a scale factor
  69824. * @param factor defines the scale factor to apply
  69825. * @returns the current bounding box
  69826. */
  69827. scale(factor: number): BoundingBox;
  69828. /**
  69829. * Gets the world matrix of the bounding box
  69830. * @returns a matrix
  69831. */
  69832. getWorldMatrix(): DeepImmutable<Matrix>;
  69833. /** @hidden */
  69834. _update(world: DeepImmutable<Matrix>): void;
  69835. /**
  69836. * Tests if the bounding box is intersecting the frustum planes
  69837. * @param frustumPlanes defines the frustum planes to test
  69838. * @returns true if there is an intersection
  69839. */
  69840. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69841. /**
  69842. * Tests if the bounding box is entirely inside the frustum planes
  69843. * @param frustumPlanes defines the frustum planes to test
  69844. * @returns true if there is an inclusion
  69845. */
  69846. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69847. /**
  69848. * Tests if a point is inside the bounding box
  69849. * @param point defines the point to test
  69850. * @returns true if the point is inside the bounding box
  69851. */
  69852. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69853. /**
  69854. * Tests if the bounding box intersects with a bounding sphere
  69855. * @param sphere defines the sphere to test
  69856. * @returns true if there is an intersection
  69857. */
  69858. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  69859. /**
  69860. * Tests if the bounding box intersects with a box defined by a min and max vectors
  69861. * @param min defines the min vector to use
  69862. * @param max defines the max vector to use
  69863. * @returns true if there is an intersection
  69864. */
  69865. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  69866. /**
  69867. * Tests if two bounding boxes are intersections
  69868. * @param box0 defines the first box to test
  69869. * @param box1 defines the second box to test
  69870. * @returns true if there is an intersection
  69871. */
  69872. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  69873. /**
  69874. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  69875. * @param minPoint defines the minimum vector of the bounding box
  69876. * @param maxPoint defines the maximum vector of the bounding box
  69877. * @param sphereCenter defines the sphere center
  69878. * @param sphereRadius defines the sphere radius
  69879. * @returns true if there is an intersection
  69880. */
  69881. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  69882. /**
  69883. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  69884. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69885. * @param frustumPlanes defines the frustum planes to test
  69886. * @return true if there is an inclusion
  69887. */
  69888. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69889. /**
  69890. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  69891. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69892. * @param frustumPlanes defines the frustum planes to test
  69893. * @return true if there is an intersection
  69894. */
  69895. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69896. }
  69897. }
  69898. declare module BABYLON {
  69899. /** @hidden */
  69900. export class Collider {
  69901. /** Define if a collision was found */
  69902. collisionFound: boolean;
  69903. /**
  69904. * Define last intersection point in local space
  69905. */
  69906. intersectionPoint: Vector3;
  69907. /**
  69908. * Define last collided mesh
  69909. */
  69910. collidedMesh: Nullable<AbstractMesh>;
  69911. private _collisionPoint;
  69912. private _planeIntersectionPoint;
  69913. private _tempVector;
  69914. private _tempVector2;
  69915. private _tempVector3;
  69916. private _tempVector4;
  69917. private _edge;
  69918. private _baseToVertex;
  69919. private _destinationPoint;
  69920. private _slidePlaneNormal;
  69921. private _displacementVector;
  69922. /** @hidden */
  69923. _radius: Vector3;
  69924. /** @hidden */
  69925. _retry: number;
  69926. private _velocity;
  69927. private _basePoint;
  69928. private _epsilon;
  69929. /** @hidden */
  69930. _velocityWorldLength: number;
  69931. /** @hidden */
  69932. _basePointWorld: Vector3;
  69933. private _velocityWorld;
  69934. private _normalizedVelocity;
  69935. /** @hidden */
  69936. _initialVelocity: Vector3;
  69937. /** @hidden */
  69938. _initialPosition: Vector3;
  69939. private _nearestDistance;
  69940. private _collisionMask;
  69941. collisionMask: number;
  69942. /**
  69943. * Gets the plane normal used to compute the sliding response (in local space)
  69944. */
  69945. readonly slidePlaneNormal: Vector3;
  69946. /** @hidden */
  69947. _initialize(source: Vector3, dir: Vector3, e: number): void;
  69948. /** @hidden */
  69949. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  69950. /** @hidden */
  69951. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  69952. /** @hidden */
  69953. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  69954. /** @hidden */
  69955. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  69956. /** @hidden */
  69957. _getResponse(pos: Vector3, vel: Vector3): void;
  69958. }
  69959. }
  69960. declare module BABYLON {
  69961. /**
  69962. * Interface for cullable objects
  69963. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  69964. */
  69965. export interface ICullable {
  69966. /**
  69967. * Checks if the object or part of the object is in the frustum
  69968. * @param frustumPlanes Camera near/planes
  69969. * @returns true if the object is in frustum otherwise false
  69970. */
  69971. isInFrustum(frustumPlanes: Plane[]): boolean;
  69972. /**
  69973. * Checks if a cullable object (mesh...) is in the camera frustum
  69974. * Unlike isInFrustum this cheks the full bounding box
  69975. * @param frustumPlanes Camera near/planes
  69976. * @returns true if the object is in frustum otherwise false
  69977. */
  69978. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  69979. }
  69980. /**
  69981. * Info for a bounding data of a mesh
  69982. */
  69983. export class BoundingInfo implements ICullable {
  69984. /**
  69985. * Bounding box for the mesh
  69986. */
  69987. readonly boundingBox: BoundingBox;
  69988. /**
  69989. * Bounding sphere for the mesh
  69990. */
  69991. readonly boundingSphere: BoundingSphere;
  69992. private _isLocked;
  69993. private static readonly TmpVector3;
  69994. /**
  69995. * Constructs bounding info
  69996. * @param minimum min vector of the bounding box/sphere
  69997. * @param maximum max vector of the bounding box/sphere
  69998. * @param worldMatrix defines the new world matrix
  69999. */
  70000. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70001. /**
  70002. * Recreates the entire bounding info from scratch as if we call the constructor in place
  70003. * @param min defines the new minimum vector (in local space)
  70004. * @param max defines the new maximum vector (in local space)
  70005. * @param worldMatrix defines the new world matrix
  70006. */
  70007. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70008. /**
  70009. * min vector of the bounding box/sphere
  70010. */
  70011. readonly minimum: Vector3;
  70012. /**
  70013. * max vector of the bounding box/sphere
  70014. */
  70015. readonly maximum: Vector3;
  70016. /**
  70017. * If the info is locked and won't be updated to avoid perf overhead
  70018. */
  70019. isLocked: boolean;
  70020. /**
  70021. * Updates the bounding sphere and box
  70022. * @param world world matrix to be used to update
  70023. */
  70024. update(world: DeepImmutable<Matrix>): void;
  70025. /**
  70026. * Recreate the bounding info to be centered around a specific point given a specific extend.
  70027. * @param center New center of the bounding info
  70028. * @param extend New extend of the bounding info
  70029. * @returns the current bounding info
  70030. */
  70031. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  70032. /**
  70033. * Scale the current bounding info by applying a scale factor
  70034. * @param factor defines the scale factor to apply
  70035. * @returns the current bounding info
  70036. */
  70037. scale(factor: number): BoundingInfo;
  70038. /**
  70039. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  70040. * @param frustumPlanes defines the frustum to test
  70041. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  70042. * @returns true if the bounding info is in the frustum planes
  70043. */
  70044. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  70045. /**
  70046. * Gets the world distance between the min and max points of the bounding box
  70047. */
  70048. readonly diagonalLength: number;
  70049. /**
  70050. * Checks if a cullable object (mesh...) is in the camera frustum
  70051. * Unlike isInFrustum this cheks the full bounding box
  70052. * @param frustumPlanes Camera near/planes
  70053. * @returns true if the object is in frustum otherwise false
  70054. */
  70055. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70056. /** @hidden */
  70057. _checkCollision(collider: Collider): boolean;
  70058. /**
  70059. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  70060. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70061. * @param point the point to check intersection with
  70062. * @returns if the point intersects
  70063. */
  70064. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70065. /**
  70066. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70067. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70068. * @param boundingInfo the bounding info to check intersection with
  70069. * @param precise if the intersection should be done using OBB
  70070. * @returns if the bounding info intersects
  70071. */
  70072. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70073. }
  70074. }
  70075. declare module BABYLON {
  70076. /**
  70077. * Defines an array and its length.
  70078. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70079. */
  70080. export interface ISmartArrayLike<T> {
  70081. /**
  70082. * The data of the array.
  70083. */
  70084. data: Array<T>;
  70085. /**
  70086. * The active length of the array.
  70087. */
  70088. length: number;
  70089. }
  70090. /**
  70091. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70092. */
  70093. export class SmartArray<T> implements ISmartArrayLike<T> {
  70094. /**
  70095. * The full set of data from the array.
  70096. */
  70097. data: Array<T>;
  70098. /**
  70099. * The active length of the array.
  70100. */
  70101. length: number;
  70102. protected _id: number;
  70103. /**
  70104. * Instantiates a Smart Array.
  70105. * @param capacity defines the default capacity of the array.
  70106. */
  70107. constructor(capacity: number);
  70108. /**
  70109. * Pushes a value at the end of the active data.
  70110. * @param value defines the object to push in the array.
  70111. */
  70112. push(value: T): void;
  70113. /**
  70114. * Iterates over the active data and apply the lambda to them.
  70115. * @param func defines the action to apply on each value.
  70116. */
  70117. forEach(func: (content: T) => void): void;
  70118. /**
  70119. * Sorts the full sets of data.
  70120. * @param compareFn defines the comparison function to apply.
  70121. */
  70122. sort(compareFn: (a: T, b: T) => number): void;
  70123. /**
  70124. * Resets the active data to an empty array.
  70125. */
  70126. reset(): void;
  70127. /**
  70128. * Releases all the data from the array as well as the array.
  70129. */
  70130. dispose(): void;
  70131. /**
  70132. * Concats the active data with a given array.
  70133. * @param array defines the data to concatenate with.
  70134. */
  70135. concat(array: any): void;
  70136. /**
  70137. * Returns the position of a value in the active data.
  70138. * @param value defines the value to find the index for
  70139. * @returns the index if found in the active data otherwise -1
  70140. */
  70141. indexOf(value: T): number;
  70142. /**
  70143. * Returns whether an element is part of the active data.
  70144. * @param value defines the value to look for
  70145. * @returns true if found in the active data otherwise false
  70146. */
  70147. contains(value: T): boolean;
  70148. private static _GlobalId;
  70149. }
  70150. /**
  70151. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70152. * The data in this array can only be present once
  70153. */
  70154. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70155. private _duplicateId;
  70156. /**
  70157. * Pushes a value at the end of the active data.
  70158. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70159. * @param value defines the object to push in the array.
  70160. */
  70161. push(value: T): void;
  70162. /**
  70163. * Pushes a value at the end of the active data.
  70164. * If the data is already present, it won t be added again
  70165. * @param value defines the object to push in the array.
  70166. * @returns true if added false if it was already present
  70167. */
  70168. pushNoDuplicate(value: T): boolean;
  70169. /**
  70170. * Resets the active data to an empty array.
  70171. */
  70172. reset(): void;
  70173. /**
  70174. * Concats the active data with a given array.
  70175. * This ensures no dupplicate will be present in the result.
  70176. * @param array defines the data to concatenate with.
  70177. */
  70178. concatWithNoDuplicate(array: any): void;
  70179. }
  70180. }
  70181. declare module BABYLON {
  70182. /**
  70183. * Enum that determines the text-wrapping mode to use.
  70184. */
  70185. export enum InspectableType {
  70186. /**
  70187. * Checkbox for booleans
  70188. */
  70189. Checkbox = 0,
  70190. /**
  70191. * Sliders for numbers
  70192. */
  70193. Slider = 1,
  70194. /**
  70195. * Vector3
  70196. */
  70197. Vector3 = 2,
  70198. /**
  70199. * Quaternions
  70200. */
  70201. Quaternion = 3,
  70202. /**
  70203. * Color3
  70204. */
  70205. Color3 = 4
  70206. }
  70207. /**
  70208. * Interface used to define custom inspectable properties.
  70209. * This interface is used by the inspector to display custom property grids
  70210. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70211. */
  70212. export interface IInspectable {
  70213. /**
  70214. * Gets the label to display
  70215. */
  70216. label: string;
  70217. /**
  70218. * Gets the name of the property to edit
  70219. */
  70220. propertyName: string;
  70221. /**
  70222. * Gets the type of the editor to use
  70223. */
  70224. type: InspectableType;
  70225. /**
  70226. * Gets the minimum value of the property when using in "slider" mode
  70227. */
  70228. min?: number;
  70229. /**
  70230. * Gets the maximum value of the property when using in "slider" mode
  70231. */
  70232. max?: number;
  70233. /**
  70234. * Gets the setp to use when using in "slider" mode
  70235. */
  70236. step?: number;
  70237. }
  70238. }
  70239. declare module BABYLON {
  70240. /**
  70241. * This represents the required contract to create a new type of texture loader.
  70242. */
  70243. export interface IInternalTextureLoader {
  70244. /**
  70245. * Defines wether the loader supports cascade loading the different faces.
  70246. */
  70247. supportCascades: boolean;
  70248. /**
  70249. * This returns if the loader support the current file information.
  70250. * @param extension defines the file extension of the file being loaded
  70251. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70252. * @param fallback defines the fallback internal texture if any
  70253. * @param isBase64 defines whether the texture is encoded as a base64
  70254. * @param isBuffer defines whether the texture data are stored as a buffer
  70255. * @returns true if the loader can load the specified file
  70256. */
  70257. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70258. /**
  70259. * Transform the url before loading if required.
  70260. * @param rootUrl the url of the texture
  70261. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70262. * @returns the transformed texture
  70263. */
  70264. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70265. /**
  70266. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70267. * @param rootUrl the url of the texture
  70268. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70269. * @returns the fallback texture
  70270. */
  70271. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70272. /**
  70273. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70274. * @param data contains the texture data
  70275. * @param texture defines the BabylonJS internal texture
  70276. * @param createPolynomials will be true if polynomials have been requested
  70277. * @param onLoad defines the callback to trigger once the texture is ready
  70278. * @param onError defines the callback to trigger in case of error
  70279. */
  70280. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70281. /**
  70282. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70283. * @param data contains the texture data
  70284. * @param texture defines the BabylonJS internal texture
  70285. * @param callback defines the method to call once ready to upload
  70286. */
  70287. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70288. }
  70289. }
  70290. declare module BABYLON {
  70291. interface Engine {
  70292. /**
  70293. * Creates a depth stencil cube texture.
  70294. * This is only available in WebGL 2.
  70295. * @param size The size of face edge in the cube texture.
  70296. * @param options The options defining the cube texture.
  70297. * @returns The cube texture
  70298. */
  70299. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70300. /**
  70301. * Creates a cube texture
  70302. * @param rootUrl defines the url where the files to load is located
  70303. * @param scene defines the current scene
  70304. * @param files defines the list of files to load (1 per face)
  70305. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70306. * @param onLoad defines an optional callback raised when the texture is loaded
  70307. * @param onError defines an optional callback raised if there is an issue to load the texture
  70308. * @param format defines the format of the data
  70309. * @param forcedExtension defines the extension to use to pick the right loader
  70310. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70311. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70312. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70313. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70314. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70315. * @returns the cube texture as an InternalTexture
  70316. */
  70317. 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;
  70318. /**
  70319. * Creates a cube texture
  70320. * @param rootUrl defines the url where the files to load is located
  70321. * @param scene defines the current scene
  70322. * @param files defines the list of files to load (1 per face)
  70323. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70324. * @param onLoad defines an optional callback raised when the texture is loaded
  70325. * @param onError defines an optional callback raised if there is an issue to load the texture
  70326. * @param format defines the format of the data
  70327. * @param forcedExtension defines the extension to use to pick the right loader
  70328. * @returns the cube texture as an InternalTexture
  70329. */
  70330. 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;
  70331. /**
  70332. * Creates a cube texture
  70333. * @param rootUrl defines the url where the files to load is located
  70334. * @param scene defines the current scene
  70335. * @param files defines the list of files to load (1 per face)
  70336. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70337. * @param onLoad defines an optional callback raised when the texture is loaded
  70338. * @param onError defines an optional callback raised if there is an issue to load the texture
  70339. * @param format defines the format of the data
  70340. * @param forcedExtension defines the extension to use to pick the right loader
  70341. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70342. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70343. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70344. * @returns the cube texture as an InternalTexture
  70345. */
  70346. 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;
  70347. /** @hidden */
  70348. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70349. /** @hidden */
  70350. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70351. /** @hidden */
  70352. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70353. /** @hidden */
  70354. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70355. }
  70356. }
  70357. declare module BABYLON {
  70358. /**
  70359. * Class for creating a cube texture
  70360. */
  70361. export class CubeTexture extends BaseTexture {
  70362. private _delayedOnLoad;
  70363. /**
  70364. * The url of the texture
  70365. */
  70366. url: string;
  70367. /**
  70368. * Gets or sets the center of the bounding box associated with the cube texture.
  70369. * It must define where the camera used to render the texture was set
  70370. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70371. */
  70372. boundingBoxPosition: Vector3;
  70373. private _boundingBoxSize;
  70374. /**
  70375. * Gets or sets the size of the bounding box associated with the cube texture
  70376. * When defined, the cubemap will switch to local mode
  70377. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70378. * @example https://www.babylonjs-playground.com/#RNASML
  70379. */
  70380. /**
  70381. * Returns the bounding box size
  70382. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70383. */
  70384. boundingBoxSize: Vector3;
  70385. protected _rotationY: number;
  70386. /**
  70387. * Sets texture matrix rotation angle around Y axis in radians.
  70388. */
  70389. /**
  70390. * Gets texture matrix rotation angle around Y axis radians.
  70391. */
  70392. rotationY: number;
  70393. /**
  70394. * Are mip maps generated for this texture or not.
  70395. */
  70396. readonly noMipmap: boolean;
  70397. private _noMipmap;
  70398. private _files;
  70399. private _extensions;
  70400. private _textureMatrix;
  70401. private _format;
  70402. private _createPolynomials;
  70403. /** @hidden */
  70404. _prefiltered: boolean;
  70405. /**
  70406. * Creates a cube texture from an array of image urls
  70407. * @param files defines an array of image urls
  70408. * @param scene defines the hosting scene
  70409. * @param noMipmap specifies if mip maps are not used
  70410. * @returns a cube texture
  70411. */
  70412. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70413. /**
  70414. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70415. * @param url defines the url of the prefiltered texture
  70416. * @param scene defines the scene the texture is attached to
  70417. * @param forcedExtension defines the extension of the file if different from the url
  70418. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70419. * @return the prefiltered texture
  70420. */
  70421. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70422. /**
  70423. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70424. * as prefiltered data.
  70425. * @param rootUrl defines the url of the texture or the root name of the six images
  70426. * @param scene defines the scene the texture is attached to
  70427. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70428. * @param noMipmap defines if mipmaps should be created or not
  70429. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70430. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70431. * @param onError defines a callback triggered in case of error during load
  70432. * @param format defines the internal format to use for the texture once loaded
  70433. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70434. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70435. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70436. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70437. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70438. * @return the cube texture
  70439. */
  70440. 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);
  70441. /**
  70442. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70443. */
  70444. readonly isPrefiltered: boolean;
  70445. /**
  70446. * Get the current class name of the texture useful for serialization or dynamic coding.
  70447. * @returns "CubeTexture"
  70448. */
  70449. getClassName(): string;
  70450. /**
  70451. * Update the url (and optional buffer) of this texture if url was null during construction.
  70452. * @param url the url of the texture
  70453. * @param forcedExtension defines the extension to use
  70454. * @param onLoad callback called when the texture is loaded (defaults to null)
  70455. */
  70456. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70457. /**
  70458. * Delays loading of the cube texture
  70459. * @param forcedExtension defines the extension to use
  70460. */
  70461. delayLoad(forcedExtension?: string): void;
  70462. /**
  70463. * Returns the reflection texture matrix
  70464. * @returns the reflection texture matrix
  70465. */
  70466. getReflectionTextureMatrix(): Matrix;
  70467. /**
  70468. * Sets the reflection texture matrix
  70469. * @param value Reflection texture matrix
  70470. */
  70471. setReflectionTextureMatrix(value: Matrix): void;
  70472. /**
  70473. * Parses text to create a cube texture
  70474. * @param parsedTexture define the serialized text to read from
  70475. * @param scene defines the hosting scene
  70476. * @param rootUrl defines the root url of the cube texture
  70477. * @returns a cube texture
  70478. */
  70479. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70480. /**
  70481. * Makes a clone, or deep copy, of the cube texture
  70482. * @returns a new cube texture
  70483. */
  70484. clone(): CubeTexture;
  70485. }
  70486. }
  70487. declare module BABYLON {
  70488. /** @hidden */
  70489. export var postprocessVertexShader: {
  70490. name: string;
  70491. shader: string;
  70492. };
  70493. }
  70494. declare module BABYLON {
  70495. /**
  70496. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  70497. * This is the base of the follow, arc rotate cameras and Free camera
  70498. * @see http://doc.babylonjs.com/features/cameras
  70499. */
  70500. export class TargetCamera extends Camera {
  70501. private static _RigCamTransformMatrix;
  70502. private static _TargetTransformMatrix;
  70503. private static _TargetFocalPoint;
  70504. /**
  70505. * Define the current direction the camera is moving to
  70506. */
  70507. cameraDirection: Vector3;
  70508. /**
  70509. * Define the current rotation the camera is rotating to
  70510. */
  70511. cameraRotation: Vector2;
  70512. /**
  70513. * When set, the up vector of the camera will be updated by the rotation of the camera
  70514. */
  70515. updateUpVectorFromRotation: boolean;
  70516. private _tmpQuaternion;
  70517. /**
  70518. * Define the current rotation of the camera
  70519. */
  70520. rotation: Vector3;
  70521. /**
  70522. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  70523. */
  70524. rotationQuaternion: Quaternion;
  70525. /**
  70526. * Define the current speed of the camera
  70527. */
  70528. speed: number;
  70529. /**
  70530. * Add cconstraint to the camera to prevent it to move freely in all directions and
  70531. * around all axis.
  70532. */
  70533. noRotationConstraint: boolean;
  70534. /**
  70535. * Define the current target of the camera as an object or a position.
  70536. */
  70537. lockedTarget: any;
  70538. /** @hidden */
  70539. _currentTarget: Vector3;
  70540. /** @hidden */
  70541. _initialFocalDistance: number;
  70542. /** @hidden */
  70543. _viewMatrix: Matrix;
  70544. /** @hidden */
  70545. _camMatrix: Matrix;
  70546. /** @hidden */
  70547. _cameraTransformMatrix: Matrix;
  70548. /** @hidden */
  70549. _cameraRotationMatrix: Matrix;
  70550. /** @hidden */
  70551. _referencePoint: Vector3;
  70552. /** @hidden */
  70553. _transformedReferencePoint: Vector3;
  70554. protected _globalCurrentTarget: Vector3;
  70555. protected _globalCurrentUpVector: Vector3;
  70556. /** @hidden */
  70557. _reset: () => void;
  70558. private _defaultUp;
  70559. /**
  70560. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  70561. * This is the base of the follow, arc rotate cameras and Free camera
  70562. * @see http://doc.babylonjs.com/features/cameras
  70563. * @param name Defines the name of the camera in the scene
  70564. * @param position Defines the start position of the camera in the scene
  70565. * @param scene Defines the scene the camera belongs to
  70566. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70567. */
  70568. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70569. /**
  70570. * Gets the position in front of the camera at a given distance.
  70571. * @param distance The distance from the camera we want the position to be
  70572. * @returns the position
  70573. */
  70574. getFrontPosition(distance: number): Vector3;
  70575. /** @hidden */
  70576. _getLockedTargetPosition(): Nullable<Vector3>;
  70577. private _storedPosition;
  70578. private _storedRotation;
  70579. private _storedRotationQuaternion;
  70580. /**
  70581. * Store current camera state of the camera (fov, position, rotation, etc..)
  70582. * @returns the camera
  70583. */
  70584. storeState(): Camera;
  70585. /**
  70586. * Restored camera state. You must call storeState() first
  70587. * @returns whether it was successful or not
  70588. * @hidden
  70589. */
  70590. _restoreStateValues(): boolean;
  70591. /** @hidden */
  70592. _initCache(): void;
  70593. /** @hidden */
  70594. _updateCache(ignoreParentClass?: boolean): void;
  70595. /** @hidden */
  70596. _isSynchronizedViewMatrix(): boolean;
  70597. /** @hidden */
  70598. _computeLocalCameraSpeed(): number;
  70599. /**
  70600. * Defines the target the camera should look at.
  70601. * This will automatically adapt alpha beta and radius to fit within the new target.
  70602. * @param target Defines the new target as a Vector or a mesh
  70603. */
  70604. setTarget(target: Vector3): void;
  70605. /**
  70606. * Return the current target position of the camera. This value is expressed in local space.
  70607. * @returns the target position
  70608. */
  70609. getTarget(): Vector3;
  70610. /** @hidden */
  70611. _decideIfNeedsToMove(): boolean;
  70612. /** @hidden */
  70613. _updatePosition(): void;
  70614. /** @hidden */
  70615. _checkInputs(): void;
  70616. protected _updateCameraRotationMatrix(): void;
  70617. /**
  70618. * 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)
  70619. * @returns the current camera
  70620. */
  70621. private _rotateUpVectorWithCameraRotationMatrix;
  70622. private _cachedRotationZ;
  70623. private _cachedQuaternionRotationZ;
  70624. /** @hidden */
  70625. _getViewMatrix(): Matrix;
  70626. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  70627. /**
  70628. * @hidden
  70629. */
  70630. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  70631. /**
  70632. * @hidden
  70633. */
  70634. _updateRigCameras(): void;
  70635. private _getRigCamPositionAndTarget;
  70636. /**
  70637. * Gets the current object class name.
  70638. * @return the class name
  70639. */
  70640. getClassName(): string;
  70641. }
  70642. }
  70643. declare module BABYLON {
  70644. /**
  70645. * @ignore
  70646. * This is a list of all the different input types that are available in the application.
  70647. * Fo instance: ArcRotateCameraGamepadInput...
  70648. */
  70649. export var CameraInputTypes: {};
  70650. /**
  70651. * This is the contract to implement in order to create a new input class.
  70652. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70653. */
  70654. export interface ICameraInput<TCamera extends Camera> {
  70655. /**
  70656. * Defines the camera the input is attached to.
  70657. */
  70658. camera: Nullable<TCamera>;
  70659. /**
  70660. * Gets the class name of the current intput.
  70661. * @returns the class name
  70662. */
  70663. getClassName(): string;
  70664. /**
  70665. * Get the friendly name associated with the input class.
  70666. * @returns the input friendly name
  70667. */
  70668. getSimpleName(): string;
  70669. /**
  70670. * Attach the input controls to a specific dom element to get the input from.
  70671. * @param element Defines the element the controls should be listened from
  70672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70673. */
  70674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70675. /**
  70676. * Detach the current controls from the specified dom element.
  70677. * @param element Defines the element to stop listening the inputs from
  70678. */
  70679. detachControl(element: Nullable<HTMLElement>): void;
  70680. /**
  70681. * Update the current camera state depending on the inputs that have been used this frame.
  70682. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70683. */
  70684. checkInputs?: () => void;
  70685. }
  70686. /**
  70687. * Represents a map of input types to input instance or input index to input instance.
  70688. */
  70689. export interface CameraInputsMap<TCamera extends Camera> {
  70690. /**
  70691. * Accessor to the input by input type.
  70692. */
  70693. [name: string]: ICameraInput<TCamera>;
  70694. /**
  70695. * Accessor to the input by input index.
  70696. */
  70697. [idx: number]: ICameraInput<TCamera>;
  70698. }
  70699. /**
  70700. * This represents the input manager used within a camera.
  70701. * It helps dealing with all the different kind of input attached to a camera.
  70702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70703. */
  70704. export class CameraInputsManager<TCamera extends Camera> {
  70705. /**
  70706. * Defines the list of inputs attahed to the camera.
  70707. */
  70708. attached: CameraInputsMap<TCamera>;
  70709. /**
  70710. * Defines the dom element the camera is collecting inputs from.
  70711. * This is null if the controls have not been attached.
  70712. */
  70713. attachedElement: Nullable<HTMLElement>;
  70714. /**
  70715. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70716. */
  70717. noPreventDefault: boolean;
  70718. /**
  70719. * Defined the camera the input manager belongs to.
  70720. */
  70721. camera: TCamera;
  70722. /**
  70723. * Update the current camera state depending on the inputs that have been used this frame.
  70724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70725. */
  70726. checkInputs: () => void;
  70727. /**
  70728. * Instantiate a new Camera Input Manager.
  70729. * @param camera Defines the camera the input manager blongs to
  70730. */
  70731. constructor(camera: TCamera);
  70732. /**
  70733. * Add an input method to a camera
  70734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70735. * @param input camera input method
  70736. */
  70737. add(input: ICameraInput<TCamera>): void;
  70738. /**
  70739. * Remove a specific input method from a camera
  70740. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70741. * @param inputToRemove camera input method
  70742. */
  70743. remove(inputToRemove: ICameraInput<TCamera>): void;
  70744. /**
  70745. * Remove a specific input type from a camera
  70746. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70747. * @param inputType the type of the input to remove
  70748. */
  70749. removeByType(inputType: string): void;
  70750. private _addCheckInputs;
  70751. /**
  70752. * Attach the input controls to the currently attached dom element to listen the events from.
  70753. * @param input Defines the input to attach
  70754. */
  70755. attachInput(input: ICameraInput<TCamera>): void;
  70756. /**
  70757. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70758. * @param element Defines the dom element to collect the events from
  70759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70760. */
  70761. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70762. /**
  70763. * Detach the current manager inputs controls from a specific dom element.
  70764. * @param element Defines the dom element to collect the events from
  70765. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70766. */
  70767. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70768. /**
  70769. * Rebuild the dynamic inputCheck function from the current list of
  70770. * defined inputs in the manager.
  70771. */
  70772. rebuildInputCheck(): void;
  70773. /**
  70774. * Remove all attached input methods from a camera
  70775. */
  70776. clear(): void;
  70777. /**
  70778. * Serialize the current input manager attached to a camera.
  70779. * This ensures than once parsed,
  70780. * the input associated to the camera will be identical to the current ones
  70781. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70782. */
  70783. serialize(serializedCamera: any): void;
  70784. /**
  70785. * Parses an input manager serialized JSON to restore the previous list of inputs
  70786. * and states associated to a camera.
  70787. * @param parsedCamera Defines the JSON to parse
  70788. */
  70789. parse(parsedCamera: any): void;
  70790. }
  70791. }
  70792. declare module BABYLON {
  70793. /**
  70794. * Gather the list of keyboard event types as constants.
  70795. */
  70796. export class KeyboardEventTypes {
  70797. /**
  70798. * The keydown event is fired when a key becomes active (pressed).
  70799. */
  70800. static readonly KEYDOWN: number;
  70801. /**
  70802. * The keyup event is fired when a key has been released.
  70803. */
  70804. static readonly KEYUP: number;
  70805. }
  70806. /**
  70807. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70808. */
  70809. export class KeyboardInfo {
  70810. /**
  70811. * Defines the type of event (KeyboardEventTypes)
  70812. */
  70813. type: number;
  70814. /**
  70815. * Defines the related dom event
  70816. */
  70817. event: KeyboardEvent;
  70818. /**
  70819. * Instantiates a new keyboard info.
  70820. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70821. * @param type Defines the type of event (KeyboardEventTypes)
  70822. * @param event Defines the related dom event
  70823. */
  70824. constructor(
  70825. /**
  70826. * Defines the type of event (KeyboardEventTypes)
  70827. */
  70828. type: number,
  70829. /**
  70830. * Defines the related dom event
  70831. */
  70832. event: KeyboardEvent);
  70833. }
  70834. /**
  70835. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70836. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  70837. */
  70838. export class KeyboardInfoPre extends KeyboardInfo {
  70839. /**
  70840. * Defines the type of event (KeyboardEventTypes)
  70841. */
  70842. type: number;
  70843. /**
  70844. * Defines the related dom event
  70845. */
  70846. event: KeyboardEvent;
  70847. /**
  70848. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  70849. */
  70850. skipOnPointerObservable: boolean;
  70851. /**
  70852. * Instantiates a new keyboard pre info.
  70853. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70854. * @param type Defines the type of event (KeyboardEventTypes)
  70855. * @param event Defines the related dom event
  70856. */
  70857. constructor(
  70858. /**
  70859. * Defines the type of event (KeyboardEventTypes)
  70860. */
  70861. type: number,
  70862. /**
  70863. * Defines the related dom event
  70864. */
  70865. event: KeyboardEvent);
  70866. }
  70867. }
  70868. declare module BABYLON {
  70869. /**
  70870. * Manage the keyboard inputs to control the movement of a free camera.
  70871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70872. */
  70873. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  70874. /**
  70875. * Defines the camera the input is attached to.
  70876. */
  70877. camera: FreeCamera;
  70878. /**
  70879. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70880. */
  70881. keysUp: number[];
  70882. /**
  70883. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70884. */
  70885. keysDown: number[];
  70886. /**
  70887. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70888. */
  70889. keysLeft: number[];
  70890. /**
  70891. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70892. */
  70893. keysRight: number[];
  70894. private _keys;
  70895. private _onCanvasBlurObserver;
  70896. private _onKeyboardObserver;
  70897. private _engine;
  70898. private _scene;
  70899. /**
  70900. * Attach the input controls to a specific dom element to get the input from.
  70901. * @param element Defines the element the controls should be listened from
  70902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70903. */
  70904. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70905. /**
  70906. * Detach the current controls from the specified dom element.
  70907. * @param element Defines the element to stop listening the inputs from
  70908. */
  70909. detachControl(element: Nullable<HTMLElement>): void;
  70910. /**
  70911. * Update the current camera state depending on the inputs that have been used this frame.
  70912. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70913. */
  70914. checkInputs(): void;
  70915. /**
  70916. * Gets the class name of the current intput.
  70917. * @returns the class name
  70918. */
  70919. getClassName(): string;
  70920. /** @hidden */
  70921. _onLostFocus(): void;
  70922. /**
  70923. * Get the friendly name associated with the input class.
  70924. * @returns the input friendly name
  70925. */
  70926. getSimpleName(): string;
  70927. }
  70928. }
  70929. declare module BABYLON {
  70930. /**
  70931. * A multi-material is used to apply different materials to different parts of the same object without the need of
  70932. * separate meshes. This can be use to improve performances.
  70933. * @see http://doc.babylonjs.com/how_to/multi_materials
  70934. */
  70935. export class MultiMaterial extends Material {
  70936. private _subMaterials;
  70937. /**
  70938. * Gets or Sets the list of Materials used within the multi material.
  70939. * They need to be ordered according to the submeshes order in the associated mesh
  70940. */
  70941. subMaterials: Nullable<Material>[];
  70942. /**
  70943. * Function used to align with Node.getChildren()
  70944. * @returns the list of Materials used within the multi material
  70945. */
  70946. getChildren(): Nullable<Material>[];
  70947. /**
  70948. * Instantiates a new Multi Material
  70949. * A multi-material is used to apply different materials to different parts of the same object without the need of
  70950. * separate meshes. This can be use to improve performances.
  70951. * @see http://doc.babylonjs.com/how_to/multi_materials
  70952. * @param name Define the name in the scene
  70953. * @param scene Define the scene the material belongs to
  70954. */
  70955. constructor(name: string, scene: Scene);
  70956. private _hookArray;
  70957. /**
  70958. * Get one of the submaterial by its index in the submaterials array
  70959. * @param index The index to look the sub material at
  70960. * @returns The Material if the index has been defined
  70961. */
  70962. getSubMaterial(index: number): Nullable<Material>;
  70963. /**
  70964. * Get the list of active textures for the whole sub materials list.
  70965. * @returns All the textures that will be used during the rendering
  70966. */
  70967. getActiveTextures(): BaseTexture[];
  70968. /**
  70969. * Gets the current class name of the material e.g. "MultiMaterial"
  70970. * Mainly use in serialization.
  70971. * @returns the class name
  70972. */
  70973. getClassName(): string;
  70974. /**
  70975. * Checks if the material is ready to render the requested sub mesh
  70976. * @param mesh Define the mesh the submesh belongs to
  70977. * @param subMesh Define the sub mesh to look readyness for
  70978. * @param useInstances Define whether or not the material is used with instances
  70979. * @returns true if ready, otherwise false
  70980. */
  70981. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  70982. /**
  70983. * Clones the current material and its related sub materials
  70984. * @param name Define the name of the newly cloned material
  70985. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  70986. * @returns the cloned material
  70987. */
  70988. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  70989. /**
  70990. * Serializes the materials into a JSON representation.
  70991. * @returns the JSON representation
  70992. */
  70993. serialize(): any;
  70994. /**
  70995. * Dispose the material and release its associated resources
  70996. * @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)
  70997. * @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)
  70998. * @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)
  70999. */
  71000. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  71001. /**
  71002. * Creates a MultiMaterial from parsed MultiMaterial data.
  71003. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  71004. * @param scene defines the hosting scene
  71005. * @returns a new MultiMaterial
  71006. */
  71007. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  71008. }
  71009. }
  71010. declare module BABYLON {
  71011. /**
  71012. * Class used to represent data loading progression
  71013. */
  71014. export class SceneLoaderFlags {
  71015. private static _ForceFullSceneLoadingForIncremental;
  71016. private static _ShowLoadingScreen;
  71017. private static _CleanBoneMatrixWeights;
  71018. private static _loggingLevel;
  71019. /**
  71020. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  71021. */
  71022. static ForceFullSceneLoadingForIncremental: boolean;
  71023. /**
  71024. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  71025. */
  71026. static ShowLoadingScreen: boolean;
  71027. /**
  71028. * Defines the current logging level (while loading the scene)
  71029. * @ignorenaming
  71030. */
  71031. static loggingLevel: number;
  71032. /**
  71033. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  71034. */
  71035. static CleanBoneMatrixWeights: boolean;
  71036. }
  71037. }
  71038. declare module BABYLON {
  71039. /**
  71040. * 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.
  71041. * @see https://doc.babylonjs.com/how_to/transformnode
  71042. */
  71043. export class TransformNode extends Node {
  71044. /**
  71045. * Object will not rotate to face the camera
  71046. */
  71047. static BILLBOARDMODE_NONE: number;
  71048. /**
  71049. * Object will rotate to face the camera but only on the x axis
  71050. */
  71051. static BILLBOARDMODE_X: number;
  71052. /**
  71053. * Object will rotate to face the camera but only on the y axis
  71054. */
  71055. static BILLBOARDMODE_Y: number;
  71056. /**
  71057. * Object will rotate to face the camera but only on the z axis
  71058. */
  71059. static BILLBOARDMODE_Z: number;
  71060. /**
  71061. * Object will rotate to face the camera
  71062. */
  71063. static BILLBOARDMODE_ALL: number;
  71064. private _forward;
  71065. private _forwardInverted;
  71066. private _up;
  71067. private _right;
  71068. private _rightInverted;
  71069. private _position;
  71070. private _rotation;
  71071. private _rotationQuaternion;
  71072. protected _scaling: Vector3;
  71073. protected _isDirty: boolean;
  71074. private _transformToBoneReferal;
  71075. private _billboardMode;
  71076. /**
  71077. * Gets or sets the billboard mode. Default is 0.
  71078. *
  71079. * | Value | Type | Description |
  71080. * | --- | --- | --- |
  71081. * | 0 | BILLBOARDMODE_NONE | |
  71082. * | 1 | BILLBOARDMODE_X | |
  71083. * | 2 | BILLBOARDMODE_Y | |
  71084. * | 4 | BILLBOARDMODE_Z | |
  71085. * | 7 | BILLBOARDMODE_ALL | |
  71086. *
  71087. */
  71088. billboardMode: number;
  71089. private _preserveParentRotationForBillboard;
  71090. /**
  71091. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  71092. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  71093. */
  71094. preserveParentRotationForBillboard: boolean;
  71095. /**
  71096. * 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
  71097. */
  71098. scalingDeterminant: number;
  71099. private _infiniteDistance;
  71100. /**
  71101. * Gets or sets the distance of the object to max, often used by skybox
  71102. */
  71103. infiniteDistance: boolean;
  71104. /**
  71105. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  71106. * By default the system will update normals to compensate
  71107. */
  71108. ignoreNonUniformScaling: boolean;
  71109. /**
  71110. * 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
  71111. */
  71112. reIntegrateRotationIntoRotationQuaternion: boolean;
  71113. /** @hidden */
  71114. _poseMatrix: Nullable<Matrix>;
  71115. /** @hidden */
  71116. _localMatrix: Matrix;
  71117. private _usePivotMatrix;
  71118. private _absolutePosition;
  71119. private _pivotMatrix;
  71120. private _pivotMatrixInverse;
  71121. protected _postMultiplyPivotMatrix: boolean;
  71122. protected _isWorldMatrixFrozen: boolean;
  71123. /** @hidden */
  71124. _indexInSceneTransformNodesArray: number;
  71125. /**
  71126. * An event triggered after the world matrix is updated
  71127. */
  71128. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  71129. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  71130. /**
  71131. * Gets a string identifying the name of the class
  71132. * @returns "TransformNode" string
  71133. */
  71134. getClassName(): string;
  71135. /**
  71136. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  71137. */
  71138. position: Vector3;
  71139. /**
  71140. * 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)).
  71141. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  71142. */
  71143. rotation: Vector3;
  71144. /**
  71145. * 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)).
  71146. */
  71147. scaling: Vector3;
  71148. /**
  71149. * 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).
  71150. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  71151. */
  71152. rotationQuaternion: Nullable<Quaternion>;
  71153. /**
  71154. * The forward direction of that transform in world space.
  71155. */
  71156. readonly forward: Vector3;
  71157. /**
  71158. * The up direction of that transform in world space.
  71159. */
  71160. readonly up: Vector3;
  71161. /**
  71162. * The right direction of that transform in world space.
  71163. */
  71164. readonly right: Vector3;
  71165. /**
  71166. * Copies the parameter passed Matrix into the mesh Pose matrix.
  71167. * @param matrix the matrix to copy the pose from
  71168. * @returns this TransformNode.
  71169. */
  71170. updatePoseMatrix(matrix: Matrix): TransformNode;
  71171. /**
  71172. * Returns the mesh Pose matrix.
  71173. * @returns the pose matrix
  71174. */
  71175. getPoseMatrix(): Matrix;
  71176. /** @hidden */
  71177. _isSynchronized(): boolean;
  71178. /** @hidden */
  71179. _initCache(): void;
  71180. /**
  71181. * Flag the transform node as dirty (Forcing it to update everything)
  71182. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  71183. * @returns this transform node
  71184. */
  71185. markAsDirty(property: string): TransformNode;
  71186. /**
  71187. * Returns the current mesh absolute position.
  71188. * Returns a Vector3.
  71189. */
  71190. readonly absolutePosition: Vector3;
  71191. /**
  71192. * Sets a new matrix to apply before all other transformation
  71193. * @param matrix defines the transform matrix
  71194. * @returns the current TransformNode
  71195. */
  71196. setPreTransformMatrix(matrix: Matrix): TransformNode;
  71197. /**
  71198. * Sets a new pivot matrix to the current node
  71199. * @param matrix defines the new pivot matrix to use
  71200. * @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
  71201. * @returns the current TransformNode
  71202. */
  71203. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  71204. /**
  71205. * Returns the mesh pivot matrix.
  71206. * Default : Identity.
  71207. * @returns the matrix
  71208. */
  71209. getPivotMatrix(): Matrix;
  71210. /**
  71211. * Prevents the World matrix to be computed any longer.
  71212. * @returns the TransformNode.
  71213. */
  71214. freezeWorldMatrix(): TransformNode;
  71215. /**
  71216. * Allows back the World matrix computation.
  71217. * @returns the TransformNode.
  71218. */
  71219. unfreezeWorldMatrix(): this;
  71220. /**
  71221. * True if the World matrix has been frozen.
  71222. */
  71223. readonly isWorldMatrixFrozen: boolean;
  71224. /**
  71225. * Retuns the mesh absolute position in the World.
  71226. * @returns a Vector3.
  71227. */
  71228. getAbsolutePosition(): Vector3;
  71229. /**
  71230. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  71231. * @param absolutePosition the absolute position to set
  71232. * @returns the TransformNode.
  71233. */
  71234. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  71235. /**
  71236. * Sets the mesh position in its local space.
  71237. * @param vector3 the position to set in localspace
  71238. * @returns the TransformNode.
  71239. */
  71240. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  71241. /**
  71242. * Returns the mesh position in the local space from the current World matrix values.
  71243. * @returns a new Vector3.
  71244. */
  71245. getPositionExpressedInLocalSpace(): Vector3;
  71246. /**
  71247. * Translates the mesh along the passed Vector3 in its local space.
  71248. * @param vector3 the distance to translate in localspace
  71249. * @returns the TransformNode.
  71250. */
  71251. locallyTranslate(vector3: Vector3): TransformNode;
  71252. private static _lookAtVectorCache;
  71253. /**
  71254. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  71255. * @param targetPoint the position (must be in same space as current mesh) to look at
  71256. * @param yawCor optional yaw (y-axis) correction in radians
  71257. * @param pitchCor optional pitch (x-axis) correction in radians
  71258. * @param rollCor optional roll (z-axis) correction in radians
  71259. * @param space the choosen space of the target
  71260. * @returns the TransformNode.
  71261. */
  71262. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  71263. /**
  71264. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71265. * This Vector3 is expressed in the World space.
  71266. * @param localAxis axis to rotate
  71267. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71268. */
  71269. getDirection(localAxis: Vector3): Vector3;
  71270. /**
  71271. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  71272. * localAxis is expressed in the mesh local space.
  71273. * result is computed in the Wordl space from the mesh World matrix.
  71274. * @param localAxis axis to rotate
  71275. * @param result the resulting transformnode
  71276. * @returns this TransformNode.
  71277. */
  71278. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  71279. /**
  71280. * Sets this transform node rotation to the given local axis.
  71281. * @param localAxis the axis in local space
  71282. * @param yawCor optional yaw (y-axis) correction in radians
  71283. * @param pitchCor optional pitch (x-axis) correction in radians
  71284. * @param rollCor optional roll (z-axis) correction in radians
  71285. * @returns this TransformNode
  71286. */
  71287. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  71288. /**
  71289. * Sets a new pivot point to the current node
  71290. * @param point defines the new pivot point to use
  71291. * @param space defines if the point is in world or local space (local by default)
  71292. * @returns the current TransformNode
  71293. */
  71294. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  71295. /**
  71296. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  71297. * @returns the pivot point
  71298. */
  71299. getPivotPoint(): Vector3;
  71300. /**
  71301. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  71302. * @param result the vector3 to store the result
  71303. * @returns this TransformNode.
  71304. */
  71305. getPivotPointToRef(result: Vector3): TransformNode;
  71306. /**
  71307. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  71308. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  71309. */
  71310. getAbsolutePivotPoint(): Vector3;
  71311. /**
  71312. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  71313. * @param result vector3 to store the result
  71314. * @returns this TransformNode.
  71315. */
  71316. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  71317. /**
  71318. * Defines the passed node as the parent of the current node.
  71319. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  71320. * @see https://doc.babylonjs.com/how_to/parenting
  71321. * @param node the node ot set as the parent
  71322. * @returns this TransformNode.
  71323. */
  71324. setParent(node: Nullable<Node>): TransformNode;
  71325. private _nonUniformScaling;
  71326. /**
  71327. * True if the scaling property of this object is non uniform eg. (1,2,1)
  71328. */
  71329. readonly nonUniformScaling: boolean;
  71330. /** @hidden */
  71331. _updateNonUniformScalingState(value: boolean): boolean;
  71332. /**
  71333. * Attach the current TransformNode to another TransformNode associated with a bone
  71334. * @param bone Bone affecting the TransformNode
  71335. * @param affectedTransformNode TransformNode associated with the bone
  71336. * @returns this object
  71337. */
  71338. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  71339. /**
  71340. * Detach the transform node if its associated with a bone
  71341. * @returns this object
  71342. */
  71343. detachFromBone(): TransformNode;
  71344. private static _rotationAxisCache;
  71345. /**
  71346. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  71347. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71348. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71349. * The passed axis is also normalized.
  71350. * @param axis the axis to rotate around
  71351. * @param amount the amount to rotate in radians
  71352. * @param space Space to rotate in (Default: local)
  71353. * @returns the TransformNode.
  71354. */
  71355. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  71356. /**
  71357. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  71358. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71359. * The passed axis is also normalized. .
  71360. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  71361. * @param point the point to rotate around
  71362. * @param axis the axis to rotate around
  71363. * @param amount the amount to rotate in radians
  71364. * @returns the TransformNode
  71365. */
  71366. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  71367. /**
  71368. * Translates the mesh along the axis vector for the passed distance in the given space.
  71369. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71370. * @param axis the axis to translate in
  71371. * @param distance the distance to translate
  71372. * @param space Space to rotate in (Default: local)
  71373. * @returns the TransformNode.
  71374. */
  71375. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  71376. /**
  71377. * Adds a rotation step to the mesh current rotation.
  71378. * x, y, z are Euler angles expressed in radians.
  71379. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  71380. * This means this rotation is made in the mesh local space only.
  71381. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  71382. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  71383. * ```javascript
  71384. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  71385. * ```
  71386. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  71387. * 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.
  71388. * @param x Rotation to add
  71389. * @param y Rotation to add
  71390. * @param z Rotation to add
  71391. * @returns the TransformNode.
  71392. */
  71393. addRotation(x: number, y: number, z: number): TransformNode;
  71394. /**
  71395. * @hidden
  71396. */
  71397. protected _getEffectiveParent(): Nullable<Node>;
  71398. /**
  71399. * Computes the world matrix of the node
  71400. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71401. * @returns the world matrix
  71402. */
  71403. computeWorldMatrix(force?: boolean): Matrix;
  71404. protected _afterComputeWorldMatrix(): void;
  71405. /**
  71406. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  71407. * @param func callback function to add
  71408. *
  71409. * @returns the TransformNode.
  71410. */
  71411. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71412. /**
  71413. * Removes a registered callback function.
  71414. * @param func callback function to remove
  71415. * @returns the TransformNode.
  71416. */
  71417. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71418. /**
  71419. * Gets the position of the current mesh in camera space
  71420. * @param camera defines the camera to use
  71421. * @returns a position
  71422. */
  71423. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  71424. /**
  71425. * Returns the distance from the mesh to the active camera
  71426. * @param camera defines the camera to use
  71427. * @returns the distance
  71428. */
  71429. getDistanceToCamera(camera?: Nullable<Camera>): number;
  71430. /**
  71431. * Clone the current transform node
  71432. * @param name Name of the new clone
  71433. * @param newParent New parent for the clone
  71434. * @param doNotCloneChildren Do not clone children hierarchy
  71435. * @returns the new transform node
  71436. */
  71437. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  71438. /**
  71439. * Serializes the objects information.
  71440. * @param currentSerializationObject defines the object to serialize in
  71441. * @returns the serialized object
  71442. */
  71443. serialize(currentSerializationObject?: any): any;
  71444. /**
  71445. * Returns a new TransformNode object parsed from the source provided.
  71446. * @param parsedTransformNode is the source.
  71447. * @param scene the scne the object belongs to
  71448. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  71449. * @returns a new TransformNode object parsed from the source provided.
  71450. */
  71451. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  71452. /**
  71453. * Get all child-transformNodes of this node
  71454. * @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
  71455. * @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
  71456. * @returns an array of TransformNode
  71457. */
  71458. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  71459. /**
  71460. * Releases resources associated with this transform node.
  71461. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  71462. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  71463. */
  71464. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  71465. /**
  71466. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  71467. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  71468. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  71469. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  71470. * @returns the current mesh
  71471. */
  71472. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  71473. }
  71474. }
  71475. declare module BABYLON {
  71476. /**
  71477. * Class used to override all child animations of a given target
  71478. */
  71479. export class AnimationPropertiesOverride {
  71480. /**
  71481. * Gets or sets a value indicating if animation blending must be used
  71482. */
  71483. enableBlending: boolean;
  71484. /**
  71485. * Gets or sets the blending speed to use when enableBlending is true
  71486. */
  71487. blendingSpeed: number;
  71488. /**
  71489. * Gets or sets the default loop mode to use
  71490. */
  71491. loopMode: number;
  71492. }
  71493. }
  71494. declare module BABYLON {
  71495. /**
  71496. * Class used to store bone information
  71497. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  71498. */
  71499. export class Bone extends Node {
  71500. /**
  71501. * defines the bone name
  71502. */
  71503. name: string;
  71504. private static _tmpVecs;
  71505. private static _tmpQuat;
  71506. private static _tmpMats;
  71507. /**
  71508. * Gets the list of child bones
  71509. */
  71510. children: Bone[];
  71511. /** Gets the animations associated with this bone */
  71512. animations: Animation[];
  71513. /**
  71514. * Gets or sets bone length
  71515. */
  71516. length: number;
  71517. /**
  71518. * @hidden Internal only
  71519. * Set this value to map this bone to a different index in the transform matrices
  71520. * Set this value to -1 to exclude the bone from the transform matrices
  71521. */
  71522. _index: Nullable<number>;
  71523. private _skeleton;
  71524. private _localMatrix;
  71525. private _restPose;
  71526. private _baseMatrix;
  71527. private _absoluteTransform;
  71528. private _invertedAbsoluteTransform;
  71529. private _parent;
  71530. private _scalingDeterminant;
  71531. private _worldTransform;
  71532. private _localScaling;
  71533. private _localRotation;
  71534. private _localPosition;
  71535. private _needToDecompose;
  71536. private _needToCompose;
  71537. /** @hidden */
  71538. _linkedTransformNode: Nullable<TransformNode>;
  71539. /** @hidden */
  71540. _waitingTransformNodeId: Nullable<string>;
  71541. /** @hidden */
  71542. /** @hidden */
  71543. _matrix: Matrix;
  71544. /**
  71545. * Create a new bone
  71546. * @param name defines the bone name
  71547. * @param skeleton defines the parent skeleton
  71548. * @param parentBone defines the parent (can be null if the bone is the root)
  71549. * @param localMatrix defines the local matrix
  71550. * @param restPose defines the rest pose matrix
  71551. * @param baseMatrix defines the base matrix
  71552. * @param index defines index of the bone in the hiearchy
  71553. */
  71554. constructor(
  71555. /**
  71556. * defines the bone name
  71557. */
  71558. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  71559. /**
  71560. * Gets the current object class name.
  71561. * @return the class name
  71562. */
  71563. getClassName(): string;
  71564. /**
  71565. * Gets the parent skeleton
  71566. * @returns a skeleton
  71567. */
  71568. getSkeleton(): Skeleton;
  71569. /**
  71570. * Gets parent bone
  71571. * @returns a bone or null if the bone is the root of the bone hierarchy
  71572. */
  71573. getParent(): Nullable<Bone>;
  71574. /**
  71575. * Returns an array containing the root bones
  71576. * @returns an array containing the root bones
  71577. */
  71578. getChildren(): Array<Bone>;
  71579. /**
  71580. * Sets the parent bone
  71581. * @param parent defines the parent (can be null if the bone is the root)
  71582. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71583. */
  71584. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  71585. /**
  71586. * Gets the local matrix
  71587. * @returns a matrix
  71588. */
  71589. getLocalMatrix(): Matrix;
  71590. /**
  71591. * Gets the base matrix (initial matrix which remains unchanged)
  71592. * @returns a matrix
  71593. */
  71594. getBaseMatrix(): Matrix;
  71595. /**
  71596. * Gets the rest pose matrix
  71597. * @returns a matrix
  71598. */
  71599. getRestPose(): Matrix;
  71600. /**
  71601. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  71602. */
  71603. getWorldMatrix(): Matrix;
  71604. /**
  71605. * Sets the local matrix to rest pose matrix
  71606. */
  71607. returnToRest(): void;
  71608. /**
  71609. * Gets the inverse of the absolute transform matrix.
  71610. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  71611. * @returns a matrix
  71612. */
  71613. getInvertedAbsoluteTransform(): Matrix;
  71614. /**
  71615. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  71616. * @returns a matrix
  71617. */
  71618. getAbsoluteTransform(): Matrix;
  71619. /**
  71620. * Links with the given transform node.
  71621. * The local matrix of this bone is copied from the transform node every frame.
  71622. * @param transformNode defines the transform node to link to
  71623. */
  71624. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  71625. /** Gets or sets current position (in local space) */
  71626. position: Vector3;
  71627. /** Gets or sets current rotation (in local space) */
  71628. rotation: Vector3;
  71629. /** Gets or sets current rotation quaternion (in local space) */
  71630. rotationQuaternion: Quaternion;
  71631. /** Gets or sets current scaling (in local space) */
  71632. scaling: Vector3;
  71633. /**
  71634. * Gets the animation properties override
  71635. */
  71636. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  71637. private _decompose;
  71638. private _compose;
  71639. /**
  71640. * Update the base and local matrices
  71641. * @param matrix defines the new base or local matrix
  71642. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71643. * @param updateLocalMatrix defines if the local matrix should be updated
  71644. */
  71645. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  71646. /** @hidden */
  71647. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  71648. /**
  71649. * Flag the bone as dirty (Forcing it to update everything)
  71650. */
  71651. markAsDirty(): void;
  71652. /** @hidden */
  71653. _markAsDirtyAndCompose(): void;
  71654. private _markAsDirtyAndDecompose;
  71655. /**
  71656. * Translate the bone in local or world space
  71657. * @param vec The amount to translate the bone
  71658. * @param space The space that the translation is in
  71659. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71660. */
  71661. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71662. /**
  71663. * Set the postion of the bone in local or world space
  71664. * @param position The position to set the bone
  71665. * @param space The space that the position is in
  71666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71667. */
  71668. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71669. /**
  71670. * Set the absolute position of the bone (world space)
  71671. * @param position The position to set the bone
  71672. * @param mesh The mesh that this bone is attached to
  71673. */
  71674. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  71675. /**
  71676. * Scale the bone on the x, y and z axes (in local space)
  71677. * @param x The amount to scale the bone on the x axis
  71678. * @param y The amount to scale the bone on the y axis
  71679. * @param z The amount to scale the bone on the z axis
  71680. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  71681. */
  71682. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  71683. /**
  71684. * Set the bone scaling in local space
  71685. * @param scale defines the scaling vector
  71686. */
  71687. setScale(scale: Vector3): void;
  71688. /**
  71689. * Gets the current scaling in local space
  71690. * @returns the current scaling vector
  71691. */
  71692. getScale(): Vector3;
  71693. /**
  71694. * Gets the current scaling in local space and stores it in a target vector
  71695. * @param result defines the target vector
  71696. */
  71697. getScaleToRef(result: Vector3): void;
  71698. /**
  71699. * Set the yaw, pitch, and roll of the bone in local or world space
  71700. * @param yaw The rotation of the bone on the y axis
  71701. * @param pitch The rotation of the bone on the x axis
  71702. * @param roll The rotation of the bone on the z axis
  71703. * @param space The space that the axes of rotation are in
  71704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71705. */
  71706. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  71707. /**
  71708. * Add a rotation to the bone on an axis in local or world space
  71709. * @param axis The axis to rotate the bone on
  71710. * @param amount The amount to rotate the bone
  71711. * @param space The space that the axis is in
  71712. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71713. */
  71714. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  71715. /**
  71716. * Set the rotation of the bone to a particular axis angle in local or world space
  71717. * @param axis The axis to rotate the bone on
  71718. * @param angle The angle that the bone should be rotated to
  71719. * @param space The space that the axis is in
  71720. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71721. */
  71722. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  71723. /**
  71724. * Set the euler rotation of the bone in local of world space
  71725. * @param rotation The euler rotation that the bone should be set to
  71726. * @param space The space that the rotation is in
  71727. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71728. */
  71729. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71730. /**
  71731. * Set the quaternion rotation of the bone in local of world space
  71732. * @param quat The quaternion rotation that the bone should be set to
  71733. * @param space The space that the rotation is in
  71734. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71735. */
  71736. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  71737. /**
  71738. * Set the rotation matrix of the bone in local of world space
  71739. * @param rotMat The rotation matrix that the bone should be set to
  71740. * @param space The space that the rotation is in
  71741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71742. */
  71743. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  71744. private _rotateWithMatrix;
  71745. private _getNegativeRotationToRef;
  71746. /**
  71747. * Get the position of the bone in local or world space
  71748. * @param space The space that the returned position is in
  71749. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71750. * @returns The position of the bone
  71751. */
  71752. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71753. /**
  71754. * Copy the position of the bone to a vector3 in local or world space
  71755. * @param space The space that the returned position is in
  71756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71757. * @param result The vector3 to copy the position to
  71758. */
  71759. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  71760. /**
  71761. * Get the absolute position of the bone (world space)
  71762. * @param mesh The mesh that this bone is attached to
  71763. * @returns The absolute position of the bone
  71764. */
  71765. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  71766. /**
  71767. * Copy the absolute position of the bone (world space) to the result param
  71768. * @param mesh The mesh that this bone is attached to
  71769. * @param result The vector3 to copy the absolute position to
  71770. */
  71771. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  71772. /**
  71773. * Compute the absolute transforms of this bone and its children
  71774. */
  71775. computeAbsoluteTransforms(): void;
  71776. /**
  71777. * Get the world direction from an axis that is in the local space of the bone
  71778. * @param localAxis The local direction that is used to compute the world direction
  71779. * @param mesh The mesh that this bone is attached to
  71780. * @returns The world direction
  71781. */
  71782. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71783. /**
  71784. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  71785. * @param localAxis The local direction that is used to compute the world direction
  71786. * @param mesh The mesh that this bone is attached to
  71787. * @param result The vector3 that the world direction will be copied to
  71788. */
  71789. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71790. /**
  71791. * Get the euler rotation of the bone in local or world space
  71792. * @param space The space that the rotation should be in
  71793. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71794. * @returns The euler rotation
  71795. */
  71796. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71797. /**
  71798. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  71799. * @param space The space that the rotation should be in
  71800. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71801. * @param result The vector3 that the rotation should be copied to
  71802. */
  71803. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71804. /**
  71805. * Get the quaternion rotation of the bone in either local or world space
  71806. * @param space The space that the rotation should be in
  71807. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71808. * @returns The quaternion rotation
  71809. */
  71810. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  71811. /**
  71812. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  71813. * @param space The space that the rotation should be in
  71814. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71815. * @param result The quaternion that the rotation should be copied to
  71816. */
  71817. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  71818. /**
  71819. * Get the rotation matrix of the bone in local or world space
  71820. * @param space The space that the rotation should be in
  71821. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71822. * @returns The rotation matrix
  71823. */
  71824. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  71825. /**
  71826. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  71827. * @param space The space that the rotation should be in
  71828. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71829. * @param result The quaternion that the rotation should be copied to
  71830. */
  71831. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  71832. /**
  71833. * Get the world position of a point that is in the local space of the bone
  71834. * @param position The local position
  71835. * @param mesh The mesh that this bone is attached to
  71836. * @returns The world position
  71837. */
  71838. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71839. /**
  71840. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  71841. * @param position The local position
  71842. * @param mesh The mesh that this bone is attached to
  71843. * @param result The vector3 that the world position should be copied to
  71844. */
  71845. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71846. /**
  71847. * Get the local position of a point that is in world space
  71848. * @param position The world position
  71849. * @param mesh The mesh that this bone is attached to
  71850. * @returns The local position
  71851. */
  71852. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71853. /**
  71854. * Get the local position of a point that is in world space and copy it to the result param
  71855. * @param position The world position
  71856. * @param mesh The mesh that this bone is attached to
  71857. * @param result The vector3 that the local position should be copied to
  71858. */
  71859. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71860. }
  71861. }
  71862. declare module BABYLON {
  71863. interface Engine {
  71864. /**
  71865. * Creates a raw texture
  71866. * @param data defines the data to store in the texture
  71867. * @param width defines the width of the texture
  71868. * @param height defines the height of the texture
  71869. * @param format defines the format of the data
  71870. * @param generateMipMaps defines if the engine should generate the mip levels
  71871. * @param invertY defines if data must be stored with Y axis inverted
  71872. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71873. * @param compression defines the compression used (null by default)
  71874. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71875. * @returns the raw texture inside an InternalTexture
  71876. */
  71877. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  71878. /**
  71879. * Update a raw texture
  71880. * @param texture defines the texture to update
  71881. * @param data defines the data to store in the texture
  71882. * @param format defines the format of the data
  71883. * @param invertY defines if data must be stored with Y axis inverted
  71884. */
  71885. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  71886. /**
  71887. * Update a raw texture
  71888. * @param texture defines the texture to update
  71889. * @param data defines the data to store in the texture
  71890. * @param format defines the format of the data
  71891. * @param invertY defines if data must be stored with Y axis inverted
  71892. * @param compression defines the compression used (null by default)
  71893. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71894. */
  71895. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  71896. /**
  71897. * Creates a new raw cube texture
  71898. * @param data defines the array of data to use to create each face
  71899. * @param size defines the size of the textures
  71900. * @param format defines the format of the data
  71901. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71902. * @param generateMipMaps defines if the engine should generate the mip levels
  71903. * @param invertY defines if data must be stored with Y axis inverted
  71904. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71905. * @param compression defines the compression used (null by default)
  71906. * @returns the cube texture as an InternalTexture
  71907. */
  71908. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  71909. /**
  71910. * Update a raw cube texture
  71911. * @param texture defines the texture to udpdate
  71912. * @param data defines the data to store
  71913. * @param format defines the data format
  71914. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71915. * @param invertY defines if data must be stored with Y axis inverted
  71916. */
  71917. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  71918. /**
  71919. * Update a raw cube texture
  71920. * @param texture defines the texture to udpdate
  71921. * @param data defines the data to store
  71922. * @param format defines the data format
  71923. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71924. * @param invertY defines if data must be stored with Y axis inverted
  71925. * @param compression defines the compression used (null by default)
  71926. */
  71927. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  71928. /**
  71929. * Update a raw cube texture
  71930. * @param texture defines the texture to udpdate
  71931. * @param data defines the data to store
  71932. * @param format defines the data format
  71933. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71934. * @param invertY defines if data must be stored with Y axis inverted
  71935. * @param compression defines the compression used (null by default)
  71936. * @param level defines which level of the texture to update
  71937. */
  71938. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  71939. /**
  71940. * Creates a new raw cube texture from a specified url
  71941. * @param url defines the url where the data is located
  71942. * @param scene defines the current scene
  71943. * @param size defines the size of the textures
  71944. * @param format defines the format of the data
  71945. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71946. * @param noMipmap defines if the engine should avoid generating the mip levels
  71947. * @param callback defines a callback used to extract texture data from loaded data
  71948. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  71949. * @param onLoad defines a callback called when texture is loaded
  71950. * @param onError defines a callback called if there is an error
  71951. * @returns the cube texture as an InternalTexture
  71952. */
  71953. 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;
  71954. /**
  71955. * Creates a new raw cube texture from a specified url
  71956. * @param url defines the url where the data is located
  71957. * @param scene defines the current scene
  71958. * @param size defines the size of the textures
  71959. * @param format defines the format of the data
  71960. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71961. * @param noMipmap defines if the engine should avoid generating the mip levels
  71962. * @param callback defines a callback used to extract texture data from loaded data
  71963. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  71964. * @param onLoad defines a callback called when texture is loaded
  71965. * @param onError defines a callback called if there is an error
  71966. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71967. * @param invertY defines if data must be stored with Y axis inverted
  71968. * @returns the cube texture as an InternalTexture
  71969. */
  71970. 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;
  71971. /**
  71972. * Creates a new raw 3D texture
  71973. * @param data defines the data used to create the texture
  71974. * @param width defines the width of the texture
  71975. * @param height defines the height of the texture
  71976. * @param depth defines the depth of the texture
  71977. * @param format defines the format of the texture
  71978. * @param generateMipMaps defines if the engine must generate mip levels
  71979. * @param invertY defines if data must be stored with Y axis inverted
  71980. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71981. * @param compression defines the compressed used (can be null)
  71982. * @param textureType defines the compressed used (can be null)
  71983. * @returns a new raw 3D texture (stored in an InternalTexture)
  71984. */
  71985. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  71986. /**
  71987. * Update a raw 3D texture
  71988. * @param texture defines the texture to update
  71989. * @param data defines the data to store
  71990. * @param format defines the data format
  71991. * @param invertY defines if data must be stored with Y axis inverted
  71992. */
  71993. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  71994. /**
  71995. * Update a raw 3D texture
  71996. * @param texture defines the texture to update
  71997. * @param data defines the data to store
  71998. * @param format defines the data format
  71999. * @param invertY defines if data must be stored with Y axis inverted
  72000. * @param compression defines the used compression (can be null)
  72001. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  72002. */
  72003. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  72004. }
  72005. }
  72006. declare module BABYLON {
  72007. /**
  72008. * Raw texture can help creating a texture directly from an array of data.
  72009. * This can be super useful if you either get the data from an uncompressed source or
  72010. * if you wish to create your texture pixel by pixel.
  72011. */
  72012. export class RawTexture extends Texture {
  72013. /**
  72014. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72015. */
  72016. format: number;
  72017. private _engine;
  72018. /**
  72019. * Instantiates a new RawTexture.
  72020. * Raw texture can help creating a texture directly from an array of data.
  72021. * This can be super useful if you either get the data from an uncompressed source or
  72022. * if you wish to create your texture pixel by pixel.
  72023. * @param data define the array of data to use to create the texture
  72024. * @param width define the width of the texture
  72025. * @param height define the height of the texture
  72026. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72027. * @param scene define the scene the texture belongs to
  72028. * @param generateMipMaps define whether mip maps should be generated or not
  72029. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72030. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72031. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72032. */
  72033. constructor(data: ArrayBufferView, width: number, height: number,
  72034. /**
  72035. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72036. */
  72037. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  72038. /**
  72039. * Updates the texture underlying data.
  72040. * @param data Define the new data of the texture
  72041. */
  72042. update(data: ArrayBufferView): void;
  72043. /**
  72044. * Creates a luminance texture from some data.
  72045. * @param data Define the texture data
  72046. * @param width Define the width of the texture
  72047. * @param height Define the height of the texture
  72048. * @param scene Define the scene the texture belongs to
  72049. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72050. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72051. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72052. * @returns the luminance texture
  72053. */
  72054. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72055. /**
  72056. * Creates a luminance alpha texture from some data.
  72057. * @param data Define the texture data
  72058. * @param width Define the width of the texture
  72059. * @param height Define the height of the texture
  72060. * @param scene Define the scene the texture belongs to
  72061. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72062. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72063. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72064. * @returns the luminance alpha texture
  72065. */
  72066. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72067. /**
  72068. * Creates an alpha texture from some data.
  72069. * @param data Define the texture data
  72070. * @param width Define the width of the texture
  72071. * @param height Define the height of the texture
  72072. * @param scene Define the scene the texture belongs to
  72073. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72074. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72075. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72076. * @returns the alpha texture
  72077. */
  72078. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72079. /**
  72080. * Creates a RGB texture from some data.
  72081. * @param data Define the texture data
  72082. * @param width Define the width of the texture
  72083. * @param height Define the height of the texture
  72084. * @param scene Define the scene the texture belongs to
  72085. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72086. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72087. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72088. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72089. * @returns the RGB alpha texture
  72090. */
  72091. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72092. /**
  72093. * Creates a RGBA texture from some data.
  72094. * @param data Define the texture data
  72095. * @param width Define the width of the texture
  72096. * @param height Define the height of the texture
  72097. * @param scene Define the scene the texture belongs to
  72098. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72099. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72100. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72101. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72102. * @returns the RGBA texture
  72103. */
  72104. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72105. /**
  72106. * Creates a R texture from some data.
  72107. * @param data Define the texture data
  72108. * @param width Define the width of the texture
  72109. * @param height Define the height of the texture
  72110. * @param scene Define the scene the texture belongs to
  72111. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72112. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72113. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72114. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72115. * @returns the R texture
  72116. */
  72117. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72118. }
  72119. }
  72120. declare module BABYLON {
  72121. /**
  72122. * Defines a runtime animation
  72123. */
  72124. export class RuntimeAnimation {
  72125. private _events;
  72126. /**
  72127. * The current frame of the runtime animation
  72128. */
  72129. private _currentFrame;
  72130. /**
  72131. * The animation used by the runtime animation
  72132. */
  72133. private _animation;
  72134. /**
  72135. * The target of the runtime animation
  72136. */
  72137. private _target;
  72138. /**
  72139. * The initiating animatable
  72140. */
  72141. private _host;
  72142. /**
  72143. * The original value of the runtime animation
  72144. */
  72145. private _originalValue;
  72146. /**
  72147. * The original blend value of the runtime animation
  72148. */
  72149. private _originalBlendValue;
  72150. /**
  72151. * The offsets cache of the runtime animation
  72152. */
  72153. private _offsetsCache;
  72154. /**
  72155. * The high limits cache of the runtime animation
  72156. */
  72157. private _highLimitsCache;
  72158. /**
  72159. * Specifies if the runtime animation has been stopped
  72160. */
  72161. private _stopped;
  72162. /**
  72163. * The blending factor of the runtime animation
  72164. */
  72165. private _blendingFactor;
  72166. /**
  72167. * The BabylonJS scene
  72168. */
  72169. private _scene;
  72170. /**
  72171. * The current value of the runtime animation
  72172. */
  72173. private _currentValue;
  72174. /** @hidden */
  72175. _animationState: _IAnimationState;
  72176. /**
  72177. * The active target of the runtime animation
  72178. */
  72179. private _activeTargets;
  72180. private _currentActiveTarget;
  72181. private _directTarget;
  72182. /**
  72183. * The target path of the runtime animation
  72184. */
  72185. private _targetPath;
  72186. /**
  72187. * The weight of the runtime animation
  72188. */
  72189. private _weight;
  72190. /**
  72191. * The ratio offset of the runtime animation
  72192. */
  72193. private _ratioOffset;
  72194. /**
  72195. * The previous delay of the runtime animation
  72196. */
  72197. private _previousDelay;
  72198. /**
  72199. * The previous ratio of the runtime animation
  72200. */
  72201. private _previousRatio;
  72202. private _enableBlending;
  72203. private _keys;
  72204. private _minFrame;
  72205. private _maxFrame;
  72206. private _minValue;
  72207. private _maxValue;
  72208. private _targetIsArray;
  72209. /**
  72210. * Gets the current frame of the runtime animation
  72211. */
  72212. readonly currentFrame: number;
  72213. /**
  72214. * Gets the weight of the runtime animation
  72215. */
  72216. readonly weight: number;
  72217. /**
  72218. * Gets the current value of the runtime animation
  72219. */
  72220. readonly currentValue: any;
  72221. /**
  72222. * Gets the target path of the runtime animation
  72223. */
  72224. readonly targetPath: string;
  72225. /**
  72226. * Gets the actual target of the runtime animation
  72227. */
  72228. readonly target: any;
  72229. /** @hidden */
  72230. _onLoop: () => void;
  72231. /**
  72232. * Create a new RuntimeAnimation object
  72233. * @param target defines the target of the animation
  72234. * @param animation defines the source animation object
  72235. * @param scene defines the hosting scene
  72236. * @param host defines the initiating Animatable
  72237. */
  72238. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  72239. private _preparePath;
  72240. /**
  72241. * Gets the animation from the runtime animation
  72242. */
  72243. readonly animation: Animation;
  72244. /**
  72245. * Resets the runtime animation to the beginning
  72246. * @param restoreOriginal defines whether to restore the target property to the original value
  72247. */
  72248. reset(restoreOriginal?: boolean): void;
  72249. /**
  72250. * Specifies if the runtime animation is stopped
  72251. * @returns Boolean specifying if the runtime animation is stopped
  72252. */
  72253. isStopped(): boolean;
  72254. /**
  72255. * Disposes of the runtime animation
  72256. */
  72257. dispose(): void;
  72258. /**
  72259. * Apply the interpolated value to the target
  72260. * @param currentValue defines the value computed by the animation
  72261. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  72262. */
  72263. setValue(currentValue: any, weight: number): void;
  72264. private _getOriginalValues;
  72265. private _setValue;
  72266. /**
  72267. * Gets the loop pmode of the runtime animation
  72268. * @returns Loop Mode
  72269. */
  72270. private _getCorrectLoopMode;
  72271. /**
  72272. * Move the current animation to a given frame
  72273. * @param frame defines the frame to move to
  72274. */
  72275. goToFrame(frame: number): void;
  72276. /**
  72277. * @hidden Internal use only
  72278. */
  72279. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  72280. /**
  72281. * Execute the current animation
  72282. * @param delay defines the delay to add to the current frame
  72283. * @param from defines the lower bound of the animation range
  72284. * @param to defines the upper bound of the animation range
  72285. * @param loop defines if the current animation must loop
  72286. * @param speedRatio defines the current speed ratio
  72287. * @param weight defines the weight of the animation (default is -1 so no weight)
  72288. * @param onLoop optional callback called when animation loops
  72289. * @returns a boolean indicating if the animation is running
  72290. */
  72291. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  72292. }
  72293. }
  72294. declare module BABYLON {
  72295. /**
  72296. * Class used to store an actual running animation
  72297. */
  72298. export class Animatable {
  72299. /** defines the target object */
  72300. target: any;
  72301. /** defines the starting frame number (default is 0) */
  72302. fromFrame: number;
  72303. /** defines the ending frame number (default is 100) */
  72304. toFrame: number;
  72305. /** defines if the animation must loop (default is false) */
  72306. loopAnimation: boolean;
  72307. /** defines a callback to call when animation ends if it is not looping */
  72308. onAnimationEnd?: (() => void) | null | undefined;
  72309. /** defines a callback to call when animation loops */
  72310. onAnimationLoop?: (() => void) | null | undefined;
  72311. private _localDelayOffset;
  72312. private _pausedDelay;
  72313. private _runtimeAnimations;
  72314. private _paused;
  72315. private _scene;
  72316. private _speedRatio;
  72317. private _weight;
  72318. private _syncRoot;
  72319. /**
  72320. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  72321. * This will only apply for non looping animation (default is true)
  72322. */
  72323. disposeOnEnd: boolean;
  72324. /**
  72325. * Gets a boolean indicating if the animation has started
  72326. */
  72327. animationStarted: boolean;
  72328. /**
  72329. * Observer raised when the animation ends
  72330. */
  72331. onAnimationEndObservable: Observable<Animatable>;
  72332. /**
  72333. * Observer raised when the animation loops
  72334. */
  72335. onAnimationLoopObservable: Observable<Animatable>;
  72336. /**
  72337. * Gets the root Animatable used to synchronize and normalize animations
  72338. */
  72339. readonly syncRoot: Nullable<Animatable>;
  72340. /**
  72341. * Gets the current frame of the first RuntimeAnimation
  72342. * Used to synchronize Animatables
  72343. */
  72344. readonly masterFrame: number;
  72345. /**
  72346. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  72347. */
  72348. weight: number;
  72349. /**
  72350. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  72351. */
  72352. speedRatio: number;
  72353. /**
  72354. * Creates a new Animatable
  72355. * @param scene defines the hosting scene
  72356. * @param target defines the target object
  72357. * @param fromFrame defines the starting frame number (default is 0)
  72358. * @param toFrame defines the ending frame number (default is 100)
  72359. * @param loopAnimation defines if the animation must loop (default is false)
  72360. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  72361. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  72362. * @param animations defines a group of animation to add to the new Animatable
  72363. * @param onAnimationLoop defines a callback to call when animation loops
  72364. */
  72365. constructor(scene: Scene,
  72366. /** defines the target object */
  72367. target: any,
  72368. /** defines the starting frame number (default is 0) */
  72369. fromFrame?: number,
  72370. /** defines the ending frame number (default is 100) */
  72371. toFrame?: number,
  72372. /** defines if the animation must loop (default is false) */
  72373. loopAnimation?: boolean, speedRatio?: number,
  72374. /** defines a callback to call when animation ends if it is not looping */
  72375. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  72376. /** defines a callback to call when animation loops */
  72377. onAnimationLoop?: (() => void) | null | undefined);
  72378. /**
  72379. * Synchronize and normalize current Animatable with a source Animatable
  72380. * This is useful when using animation weights and when animations are not of the same length
  72381. * @param root defines the root Animatable to synchronize with
  72382. * @returns the current Animatable
  72383. */
  72384. syncWith(root: Animatable): Animatable;
  72385. /**
  72386. * Gets the list of runtime animations
  72387. * @returns an array of RuntimeAnimation
  72388. */
  72389. getAnimations(): RuntimeAnimation[];
  72390. /**
  72391. * Adds more animations to the current animatable
  72392. * @param target defines the target of the animations
  72393. * @param animations defines the new animations to add
  72394. */
  72395. appendAnimations(target: any, animations: Animation[]): void;
  72396. /**
  72397. * Gets the source animation for a specific property
  72398. * @param property defines the propertyu to look for
  72399. * @returns null or the source animation for the given property
  72400. */
  72401. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  72402. /**
  72403. * Gets the runtime animation for a specific property
  72404. * @param property defines the propertyu to look for
  72405. * @returns null or the runtime animation for the given property
  72406. */
  72407. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  72408. /**
  72409. * Resets the animatable to its original state
  72410. */
  72411. reset(): void;
  72412. /**
  72413. * Allows the animatable to blend with current running animations
  72414. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72415. * @param blendingSpeed defines the blending speed to use
  72416. */
  72417. enableBlending(blendingSpeed: number): void;
  72418. /**
  72419. * Disable animation blending
  72420. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72421. */
  72422. disableBlending(): void;
  72423. /**
  72424. * Jump directly to a given frame
  72425. * @param frame defines the frame to jump to
  72426. */
  72427. goToFrame(frame: number): void;
  72428. /**
  72429. * Pause the animation
  72430. */
  72431. pause(): void;
  72432. /**
  72433. * Restart the animation
  72434. */
  72435. restart(): void;
  72436. private _raiseOnAnimationEnd;
  72437. /**
  72438. * Stop and delete the current animation
  72439. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  72440. * @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)
  72441. */
  72442. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  72443. /**
  72444. * Wait asynchronously for the animation to end
  72445. * @returns a promise which will be fullfilled when the animation ends
  72446. */
  72447. waitAsync(): Promise<Animatable>;
  72448. /** @hidden */
  72449. _animate(delay: number): boolean;
  72450. }
  72451. interface Scene {
  72452. /** @hidden */
  72453. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  72454. /** @hidden */
  72455. _processLateAnimationBindingsForMatrices(holder: {
  72456. totalWeight: number;
  72457. animations: RuntimeAnimation[];
  72458. originalValue: Matrix;
  72459. }): any;
  72460. /** @hidden */
  72461. _processLateAnimationBindingsForQuaternions(holder: {
  72462. totalWeight: number;
  72463. animations: RuntimeAnimation[];
  72464. originalValue: Quaternion;
  72465. }, refQuaternion: Quaternion): Quaternion;
  72466. /** @hidden */
  72467. _processLateAnimationBindings(): void;
  72468. /**
  72469. * Will start the animation sequence of a given target
  72470. * @param target defines the target
  72471. * @param from defines from which frame should animation start
  72472. * @param to defines until which frame should animation run.
  72473. * @param weight defines the weight to apply to the animation (1.0 by default)
  72474. * @param loop defines if the animation loops
  72475. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72476. * @param onAnimationEnd defines the function to be executed when the animation ends
  72477. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72478. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72479. * @param onAnimationLoop defines the callback to call when an animation loops
  72480. * @returns the animatable object created for this animation
  72481. */
  72482. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72483. /**
  72484. * Will start the animation sequence of a given target
  72485. * @param target defines the target
  72486. * @param from defines from which frame should animation start
  72487. * @param to defines until which frame should animation run.
  72488. * @param loop defines if the animation loops
  72489. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72490. * @param onAnimationEnd defines the function to be executed when the animation ends
  72491. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72492. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72493. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  72494. * @param onAnimationLoop defines the callback to call when an animation loops
  72495. * @returns the animatable object created for this animation
  72496. */
  72497. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72498. /**
  72499. * Will start the animation sequence of a given target and its hierarchy
  72500. * @param target defines the target
  72501. * @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.
  72502. * @param from defines from which frame should animation start
  72503. * @param to defines until which frame should animation run.
  72504. * @param loop defines if the animation loops
  72505. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72506. * @param onAnimationEnd defines the function to be executed when the animation ends
  72507. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72508. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72509. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72510. * @param onAnimationLoop defines the callback to call when an animation loops
  72511. * @returns the list of created animatables
  72512. */
  72513. 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[];
  72514. /**
  72515. * Begin a new animation on a given node
  72516. * @param target defines the target where the animation will take place
  72517. * @param animations defines the list of animations to start
  72518. * @param from defines the initial value
  72519. * @param to defines the final value
  72520. * @param loop defines if you want animation to loop (off by default)
  72521. * @param speedRatio defines the speed ratio to apply to all animations
  72522. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72523. * @param onAnimationLoop defines the callback to call when an animation loops
  72524. * @returns the list of created animatables
  72525. */
  72526. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  72527. /**
  72528. * Begin a new animation on a given node and its hierarchy
  72529. * @param target defines the root node where the animation will take place
  72530. * @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.
  72531. * @param animations defines the list of animations to start
  72532. * @param from defines the initial value
  72533. * @param to defines the final value
  72534. * @param loop defines if you want animation to loop (off by default)
  72535. * @param speedRatio defines the speed ratio to apply to all animations
  72536. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72537. * @param onAnimationLoop defines the callback to call when an animation loops
  72538. * @returns the list of animatables created for all nodes
  72539. */
  72540. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  72541. /**
  72542. * Gets the animatable associated with a specific target
  72543. * @param target defines the target of the animatable
  72544. * @returns the required animatable if found
  72545. */
  72546. getAnimatableByTarget(target: any): Nullable<Animatable>;
  72547. /**
  72548. * Gets all animatables associated with a given target
  72549. * @param target defines the target to look animatables for
  72550. * @returns an array of Animatables
  72551. */
  72552. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  72553. /**
  72554. * Stops and removes all animations that have been applied to the scene
  72555. */
  72556. stopAllAnimations(): void;
  72557. }
  72558. interface Bone {
  72559. /**
  72560. * Copy an animation range from another bone
  72561. * @param source defines the source bone
  72562. * @param rangeName defines the range name to copy
  72563. * @param frameOffset defines the frame offset
  72564. * @param rescaleAsRequired defines if rescaling must be applied if required
  72565. * @param skelDimensionsRatio defines the scaling ratio
  72566. * @returns true if operation was successful
  72567. */
  72568. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  72569. }
  72570. }
  72571. declare module BABYLON {
  72572. /**
  72573. * Class used to handle skinning animations
  72574. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  72575. */
  72576. export class Skeleton implements IAnimatable {
  72577. /** defines the skeleton name */
  72578. name: string;
  72579. /** defines the skeleton Id */
  72580. id: string;
  72581. /**
  72582. * Defines the list of child bones
  72583. */
  72584. bones: Bone[];
  72585. /**
  72586. * Defines an estimate of the dimension of the skeleton at rest
  72587. */
  72588. dimensionsAtRest: Vector3;
  72589. /**
  72590. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  72591. */
  72592. needInitialSkinMatrix: boolean;
  72593. /**
  72594. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  72595. */
  72596. overrideMesh: Nullable<AbstractMesh>;
  72597. /**
  72598. * Gets the list of animations attached to this skeleton
  72599. */
  72600. animations: Array<Animation>;
  72601. private _scene;
  72602. private _isDirty;
  72603. private _transformMatrices;
  72604. private _transformMatrixTexture;
  72605. private _meshesWithPoseMatrix;
  72606. private _animatables;
  72607. private _identity;
  72608. private _synchronizedWithMesh;
  72609. private _ranges;
  72610. private _lastAbsoluteTransformsUpdateId;
  72611. private _canUseTextureForBones;
  72612. private _uniqueId;
  72613. /** @hidden */
  72614. _numBonesWithLinkedTransformNode: number;
  72615. /** @hidden */
  72616. _hasWaitingData: Nullable<boolean>;
  72617. /**
  72618. * Specifies if the skeleton should be serialized
  72619. */
  72620. doNotSerialize: boolean;
  72621. private _useTextureToStoreBoneMatrices;
  72622. /**
  72623. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  72624. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  72625. */
  72626. useTextureToStoreBoneMatrices: boolean;
  72627. private _animationPropertiesOverride;
  72628. /**
  72629. * Gets or sets the animation properties override
  72630. */
  72631. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72632. /**
  72633. * List of inspectable custom properties (used by the Inspector)
  72634. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72635. */
  72636. inspectableCustomProperties: IInspectable[];
  72637. /**
  72638. * An observable triggered before computing the skeleton's matrices
  72639. */
  72640. onBeforeComputeObservable: Observable<Skeleton>;
  72641. /**
  72642. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  72643. */
  72644. readonly isUsingTextureForMatrices: boolean;
  72645. /**
  72646. * Gets the unique ID of this skeleton
  72647. */
  72648. readonly uniqueId: number;
  72649. /**
  72650. * Creates a new skeleton
  72651. * @param name defines the skeleton name
  72652. * @param id defines the skeleton Id
  72653. * @param scene defines the hosting scene
  72654. */
  72655. constructor(
  72656. /** defines the skeleton name */
  72657. name: string,
  72658. /** defines the skeleton Id */
  72659. id: string, scene: Scene);
  72660. /**
  72661. * Gets the current object class name.
  72662. * @return the class name
  72663. */
  72664. getClassName(): string;
  72665. /**
  72666. * Returns an array containing the root bones
  72667. * @returns an array containing the root bones
  72668. */
  72669. getChildren(): Array<Bone>;
  72670. /**
  72671. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  72672. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72673. * @returns a Float32Array containing matrices data
  72674. */
  72675. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  72676. /**
  72677. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  72678. * @returns a raw texture containing the data
  72679. */
  72680. getTransformMatrixTexture(): Nullable<RawTexture>;
  72681. /**
  72682. * Gets the current hosting scene
  72683. * @returns a scene object
  72684. */
  72685. getScene(): Scene;
  72686. /**
  72687. * Gets a string representing the current skeleton data
  72688. * @param fullDetails defines a boolean indicating if we want a verbose version
  72689. * @returns a string representing the current skeleton data
  72690. */
  72691. toString(fullDetails?: boolean): string;
  72692. /**
  72693. * Get bone's index searching by name
  72694. * @param name defines bone's name to search for
  72695. * @return the indice of the bone. Returns -1 if not found
  72696. */
  72697. getBoneIndexByName(name: string): number;
  72698. /**
  72699. * Creater a new animation range
  72700. * @param name defines the name of the range
  72701. * @param from defines the start key
  72702. * @param to defines the end key
  72703. */
  72704. createAnimationRange(name: string, from: number, to: number): void;
  72705. /**
  72706. * Delete a specific animation range
  72707. * @param name defines the name of the range
  72708. * @param deleteFrames defines if frames must be removed as well
  72709. */
  72710. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  72711. /**
  72712. * Gets a specific animation range
  72713. * @param name defines the name of the range to look for
  72714. * @returns the requested animation range or null if not found
  72715. */
  72716. getAnimationRange(name: string): Nullable<AnimationRange>;
  72717. /**
  72718. * Gets the list of all animation ranges defined on this skeleton
  72719. * @returns an array
  72720. */
  72721. getAnimationRanges(): Nullable<AnimationRange>[];
  72722. /**
  72723. * Copy animation range from a source skeleton.
  72724. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  72725. * @param source defines the source skeleton
  72726. * @param name defines the name of the range to copy
  72727. * @param rescaleAsRequired defines if rescaling must be applied if required
  72728. * @returns true if operation was successful
  72729. */
  72730. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  72731. /**
  72732. * Forces the skeleton to go to rest pose
  72733. */
  72734. returnToRest(): void;
  72735. private _getHighestAnimationFrame;
  72736. /**
  72737. * Begin a specific animation range
  72738. * @param name defines the name of the range to start
  72739. * @param loop defines if looping must be turned on (false by default)
  72740. * @param speedRatio defines the speed ratio to apply (1 by default)
  72741. * @param onAnimationEnd defines a callback which will be called when animation will end
  72742. * @returns a new animatable
  72743. */
  72744. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  72745. /** @hidden */
  72746. _markAsDirty(): void;
  72747. /** @hidden */
  72748. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72749. /** @hidden */
  72750. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72751. private _computeTransformMatrices;
  72752. /**
  72753. * Build all resources required to render a skeleton
  72754. */
  72755. prepare(): void;
  72756. /**
  72757. * Gets the list of animatables currently running for this skeleton
  72758. * @returns an array of animatables
  72759. */
  72760. getAnimatables(): IAnimatable[];
  72761. /**
  72762. * Clone the current skeleton
  72763. * @param name defines the name of the new skeleton
  72764. * @param id defines the id of the new skeleton
  72765. * @returns the new skeleton
  72766. */
  72767. clone(name: string, id: string): Skeleton;
  72768. /**
  72769. * Enable animation blending for this skeleton
  72770. * @param blendingSpeed defines the blending speed to apply
  72771. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72772. */
  72773. enableBlending(blendingSpeed?: number): void;
  72774. /**
  72775. * Releases all resources associated with the current skeleton
  72776. */
  72777. dispose(): void;
  72778. /**
  72779. * Serialize the skeleton in a JSON object
  72780. * @returns a JSON object
  72781. */
  72782. serialize(): any;
  72783. /**
  72784. * Creates a new skeleton from serialized data
  72785. * @param parsedSkeleton defines the serialized data
  72786. * @param scene defines the hosting scene
  72787. * @returns a new skeleton
  72788. */
  72789. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  72790. /**
  72791. * Compute all node absolute transforms
  72792. * @param forceUpdate defines if computation must be done even if cache is up to date
  72793. */
  72794. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  72795. /**
  72796. * Gets the root pose matrix
  72797. * @returns a matrix
  72798. */
  72799. getPoseMatrix(): Nullable<Matrix>;
  72800. /**
  72801. * Sorts bones per internal index
  72802. */
  72803. sortBones(): void;
  72804. private _sortBones;
  72805. }
  72806. }
  72807. declare module BABYLON {
  72808. /**
  72809. * Defines a target to use with MorphTargetManager
  72810. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  72811. */
  72812. export class MorphTarget implements IAnimatable {
  72813. /** defines the name of the target */
  72814. name: string;
  72815. /**
  72816. * Gets or sets the list of animations
  72817. */
  72818. animations: Animation[];
  72819. private _scene;
  72820. private _positions;
  72821. private _normals;
  72822. private _tangents;
  72823. private _influence;
  72824. /**
  72825. * Observable raised when the influence changes
  72826. */
  72827. onInfluenceChanged: Observable<boolean>;
  72828. /** @hidden */
  72829. _onDataLayoutChanged: Observable<void>;
  72830. /**
  72831. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  72832. */
  72833. influence: number;
  72834. /**
  72835. * Gets or sets the id of the morph Target
  72836. */
  72837. id: string;
  72838. private _animationPropertiesOverride;
  72839. /**
  72840. * Gets or sets the animation properties override
  72841. */
  72842. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72843. /**
  72844. * Creates a new MorphTarget
  72845. * @param name defines the name of the target
  72846. * @param influence defines the influence to use
  72847. * @param scene defines the scene the morphtarget belongs to
  72848. */
  72849. constructor(
  72850. /** defines the name of the target */
  72851. name: string, influence?: number, scene?: Nullable<Scene>);
  72852. /**
  72853. * Gets a boolean defining if the target contains position data
  72854. */
  72855. readonly hasPositions: boolean;
  72856. /**
  72857. * Gets a boolean defining if the target contains normal data
  72858. */
  72859. readonly hasNormals: boolean;
  72860. /**
  72861. * Gets a boolean defining if the target contains tangent data
  72862. */
  72863. readonly hasTangents: boolean;
  72864. /**
  72865. * Affects position data to this target
  72866. * @param data defines the position data to use
  72867. */
  72868. setPositions(data: Nullable<FloatArray>): void;
  72869. /**
  72870. * Gets the position data stored in this target
  72871. * @returns a FloatArray containing the position data (or null if not present)
  72872. */
  72873. getPositions(): Nullable<FloatArray>;
  72874. /**
  72875. * Affects normal data to this target
  72876. * @param data defines the normal data to use
  72877. */
  72878. setNormals(data: Nullable<FloatArray>): void;
  72879. /**
  72880. * Gets the normal data stored in this target
  72881. * @returns a FloatArray containing the normal data (or null if not present)
  72882. */
  72883. getNormals(): Nullable<FloatArray>;
  72884. /**
  72885. * Affects tangent data to this target
  72886. * @param data defines the tangent data to use
  72887. */
  72888. setTangents(data: Nullable<FloatArray>): void;
  72889. /**
  72890. * Gets the tangent data stored in this target
  72891. * @returns a FloatArray containing the tangent data (or null if not present)
  72892. */
  72893. getTangents(): Nullable<FloatArray>;
  72894. /**
  72895. * Serializes the current target into a Serialization object
  72896. * @returns the serialized object
  72897. */
  72898. serialize(): any;
  72899. /**
  72900. * Returns the string "MorphTarget"
  72901. * @returns "MorphTarget"
  72902. */
  72903. getClassName(): string;
  72904. /**
  72905. * Creates a new target from serialized data
  72906. * @param serializationObject defines the serialized data to use
  72907. * @returns a new MorphTarget
  72908. */
  72909. static Parse(serializationObject: any): MorphTarget;
  72910. /**
  72911. * Creates a MorphTarget from mesh data
  72912. * @param mesh defines the source mesh
  72913. * @param name defines the name to use for the new target
  72914. * @param influence defines the influence to attach to the target
  72915. * @returns a new MorphTarget
  72916. */
  72917. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  72918. }
  72919. }
  72920. declare module BABYLON {
  72921. /**
  72922. * This class is used to deform meshes using morphing between different targets
  72923. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  72924. */
  72925. export class MorphTargetManager {
  72926. private _targets;
  72927. private _targetInfluenceChangedObservers;
  72928. private _targetDataLayoutChangedObservers;
  72929. private _activeTargets;
  72930. private _scene;
  72931. private _influences;
  72932. private _supportsNormals;
  72933. private _supportsTangents;
  72934. private _vertexCount;
  72935. private _uniqueId;
  72936. private _tempInfluences;
  72937. /**
  72938. * Creates a new MorphTargetManager
  72939. * @param scene defines the current scene
  72940. */
  72941. constructor(scene?: Nullable<Scene>);
  72942. /**
  72943. * Gets the unique ID of this manager
  72944. */
  72945. readonly uniqueId: number;
  72946. /**
  72947. * Gets the number of vertices handled by this manager
  72948. */
  72949. readonly vertexCount: number;
  72950. /**
  72951. * Gets a boolean indicating if this manager supports morphing of normals
  72952. */
  72953. readonly supportsNormals: boolean;
  72954. /**
  72955. * Gets a boolean indicating if this manager supports morphing of tangents
  72956. */
  72957. readonly supportsTangents: boolean;
  72958. /**
  72959. * Gets the number of targets stored in this manager
  72960. */
  72961. readonly numTargets: number;
  72962. /**
  72963. * Gets the number of influencers (ie. the number of targets with influences > 0)
  72964. */
  72965. readonly numInfluencers: number;
  72966. /**
  72967. * Gets the list of influences (one per target)
  72968. */
  72969. readonly influences: Float32Array;
  72970. /**
  72971. * Gets the active target at specified index. An active target is a target with an influence > 0
  72972. * @param index defines the index to check
  72973. * @returns the requested target
  72974. */
  72975. getActiveTarget(index: number): MorphTarget;
  72976. /**
  72977. * Gets the target at specified index
  72978. * @param index defines the index to check
  72979. * @returns the requested target
  72980. */
  72981. getTarget(index: number): MorphTarget;
  72982. /**
  72983. * Add a new target to this manager
  72984. * @param target defines the target to add
  72985. */
  72986. addTarget(target: MorphTarget): void;
  72987. /**
  72988. * Removes a target from the manager
  72989. * @param target defines the target to remove
  72990. */
  72991. removeTarget(target: MorphTarget): void;
  72992. /**
  72993. * Serializes the current manager into a Serialization object
  72994. * @returns the serialized object
  72995. */
  72996. serialize(): any;
  72997. private _syncActiveTargets;
  72998. /**
  72999. * Syncrhonize the targets with all the meshes using this morph target manager
  73000. */
  73001. synchronize(): void;
  73002. /**
  73003. * Creates a new MorphTargetManager from serialized data
  73004. * @param serializationObject defines the serialized data
  73005. * @param scene defines the hosting scene
  73006. * @returns the new MorphTargetManager
  73007. */
  73008. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  73009. }
  73010. }
  73011. declare module BABYLON {
  73012. /**
  73013. * Groups all the scene component constants in one place to ease maintenance.
  73014. * @hidden
  73015. */
  73016. export class SceneComponentConstants {
  73017. static readonly NAME_EFFECTLAYER: string;
  73018. static readonly NAME_LAYER: string;
  73019. static readonly NAME_LENSFLARESYSTEM: string;
  73020. static readonly NAME_BOUNDINGBOXRENDERER: string;
  73021. static readonly NAME_PARTICLESYSTEM: string;
  73022. static readonly NAME_GAMEPAD: string;
  73023. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  73024. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  73025. static readonly NAME_DEPTHRENDERER: string;
  73026. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  73027. static readonly NAME_SPRITE: string;
  73028. static readonly NAME_OUTLINERENDERER: string;
  73029. static readonly NAME_PROCEDURALTEXTURE: string;
  73030. static readonly NAME_SHADOWGENERATOR: string;
  73031. static readonly NAME_OCTREE: string;
  73032. static readonly NAME_PHYSICSENGINE: string;
  73033. static readonly NAME_AUDIO: string;
  73034. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  73035. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73036. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  73037. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73038. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  73039. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  73040. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  73041. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  73042. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  73043. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  73044. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  73045. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  73046. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  73047. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  73048. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  73049. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  73050. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  73051. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  73052. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  73053. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  73054. static readonly STEP_AFTERRENDER_AUDIO: number;
  73055. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  73056. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  73057. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  73058. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  73059. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  73060. static readonly STEP_POINTERMOVE_SPRITE: number;
  73061. static readonly STEP_POINTERDOWN_SPRITE: number;
  73062. static readonly STEP_POINTERUP_SPRITE: number;
  73063. }
  73064. /**
  73065. * This represents a scene component.
  73066. *
  73067. * This is used to decouple the dependency the scene is having on the different workloads like
  73068. * layers, post processes...
  73069. */
  73070. export interface ISceneComponent {
  73071. /**
  73072. * The name of the component. Each component must have a unique name.
  73073. */
  73074. name: string;
  73075. /**
  73076. * The scene the component belongs to.
  73077. */
  73078. scene: Scene;
  73079. /**
  73080. * Register the component to one instance of a scene.
  73081. */
  73082. register(): void;
  73083. /**
  73084. * Rebuilds the elements related to this component in case of
  73085. * context lost for instance.
  73086. */
  73087. rebuild(): void;
  73088. /**
  73089. * Disposes the component and the associated ressources.
  73090. */
  73091. dispose(): void;
  73092. }
  73093. /**
  73094. * This represents a SERIALIZABLE scene component.
  73095. *
  73096. * This extends Scene Component to add Serialization methods on top.
  73097. */
  73098. export interface ISceneSerializableComponent extends ISceneComponent {
  73099. /**
  73100. * Adds all the elements from the container to the scene
  73101. * @param container the container holding the elements
  73102. */
  73103. addFromContainer(container: AbstractScene): void;
  73104. /**
  73105. * Removes all the elements in the container from the scene
  73106. * @param container contains the elements to remove
  73107. * @param dispose if the removed element should be disposed (default: false)
  73108. */
  73109. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73110. /**
  73111. * Serializes the component data to the specified json object
  73112. * @param serializationObject The object to serialize to
  73113. */
  73114. serialize(serializationObject: any): void;
  73115. }
  73116. /**
  73117. * Strong typing of a Mesh related stage step action
  73118. */
  73119. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  73120. /**
  73121. * Strong typing of a Evaluate Sub Mesh related stage step action
  73122. */
  73123. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  73124. /**
  73125. * Strong typing of a Active Mesh related stage step action
  73126. */
  73127. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  73128. /**
  73129. * Strong typing of a Camera related stage step action
  73130. */
  73131. export type CameraStageAction = (camera: Camera) => void;
  73132. /**
  73133. * Strong typing of a Camera Frame buffer related stage step action
  73134. */
  73135. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  73136. /**
  73137. * Strong typing of a Render Target related stage step action
  73138. */
  73139. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  73140. /**
  73141. * Strong typing of a RenderingGroup related stage step action
  73142. */
  73143. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  73144. /**
  73145. * Strong typing of a Mesh Render related stage step action
  73146. */
  73147. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  73148. /**
  73149. * Strong typing of a simple stage step action
  73150. */
  73151. export type SimpleStageAction = () => void;
  73152. /**
  73153. * Strong typing of a render target action.
  73154. */
  73155. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  73156. /**
  73157. * Strong typing of a pointer move action.
  73158. */
  73159. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  73160. /**
  73161. * Strong typing of a pointer up/down action.
  73162. */
  73163. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  73164. /**
  73165. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  73166. * @hidden
  73167. */
  73168. export class Stage<T extends Function> extends Array<{
  73169. index: number;
  73170. component: ISceneComponent;
  73171. action: T;
  73172. }> {
  73173. /**
  73174. * Hide ctor from the rest of the world.
  73175. * @param items The items to add.
  73176. */
  73177. private constructor();
  73178. /**
  73179. * Creates a new Stage.
  73180. * @returns A new instance of a Stage
  73181. */
  73182. static Create<T extends Function>(): Stage<T>;
  73183. /**
  73184. * Registers a step in an ordered way in the targeted stage.
  73185. * @param index Defines the position to register the step in
  73186. * @param component Defines the component attached to the step
  73187. * @param action Defines the action to launch during the step
  73188. */
  73189. registerStep(index: number, component: ISceneComponent, action: T): void;
  73190. /**
  73191. * Clears all the steps from the stage.
  73192. */
  73193. clear(): void;
  73194. }
  73195. }
  73196. declare module BABYLON {
  73197. /**
  73198. * Class used to represent a specific level of detail of a mesh
  73199. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  73200. */
  73201. export class MeshLODLevel {
  73202. /** Defines the distance where this level should star being displayed */
  73203. distance: number;
  73204. /** Defines the mesh to use to render this level */
  73205. mesh: Nullable<Mesh>;
  73206. /**
  73207. * Creates a new LOD level
  73208. * @param distance defines the distance where this level should star being displayed
  73209. * @param mesh defines the mesh to use to render this level
  73210. */
  73211. constructor(
  73212. /** Defines the distance where this level should star being displayed */
  73213. distance: number,
  73214. /** Defines the mesh to use to render this level */
  73215. mesh: Nullable<Mesh>);
  73216. }
  73217. }
  73218. declare module BABYLON {
  73219. /**
  73220. * Interface describing all the common properties and methods a shadow light needs to implement.
  73221. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73222. * as well as binding the different shadow properties to the effects.
  73223. */
  73224. export interface IShadowLight extends Light {
  73225. /**
  73226. * The light id in the scene (used in scene.findLighById for instance)
  73227. */
  73228. id: string;
  73229. /**
  73230. * The position the shdow will be casted from.
  73231. */
  73232. position: Vector3;
  73233. /**
  73234. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73235. */
  73236. direction: Vector3;
  73237. /**
  73238. * The transformed position. Position of the light in world space taking parenting in account.
  73239. */
  73240. transformedPosition: Vector3;
  73241. /**
  73242. * The transformed direction. Direction of the light in world space taking parenting in account.
  73243. */
  73244. transformedDirection: Vector3;
  73245. /**
  73246. * The friendly name of the light in the scene.
  73247. */
  73248. name: string;
  73249. /**
  73250. * Defines the shadow projection clipping minimum z value.
  73251. */
  73252. shadowMinZ: number;
  73253. /**
  73254. * Defines the shadow projection clipping maximum z value.
  73255. */
  73256. shadowMaxZ: number;
  73257. /**
  73258. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73259. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73260. */
  73261. computeTransformedInformation(): boolean;
  73262. /**
  73263. * Gets the scene the light belongs to.
  73264. * @returns The scene
  73265. */
  73266. getScene(): Scene;
  73267. /**
  73268. * Callback defining a custom Projection Matrix Builder.
  73269. * This can be used to override the default projection matrix computation.
  73270. */
  73271. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73272. /**
  73273. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73274. * @param matrix The materix to updated with the projection information
  73275. * @param viewMatrix The transform matrix of the light
  73276. * @param renderList The list of mesh to render in the map
  73277. * @returns The current light
  73278. */
  73279. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73280. /**
  73281. * Gets the current depth scale used in ESM.
  73282. * @returns The scale
  73283. */
  73284. getDepthScale(): number;
  73285. /**
  73286. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73287. * @returns true if a cube texture needs to be use
  73288. */
  73289. needCube(): boolean;
  73290. /**
  73291. * Detects if the projection matrix requires to be recomputed this frame.
  73292. * @returns true if it requires to be recomputed otherwise, false.
  73293. */
  73294. needProjectionMatrixCompute(): boolean;
  73295. /**
  73296. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73297. */
  73298. forceProjectionMatrixCompute(): void;
  73299. /**
  73300. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73301. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73302. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73303. */
  73304. getShadowDirection(faceIndex?: number): Vector3;
  73305. /**
  73306. * Gets the minZ used for shadow according to both the scene and the light.
  73307. * @param activeCamera The camera we are returning the min for
  73308. * @returns the depth min z
  73309. */
  73310. getDepthMinZ(activeCamera: Camera): number;
  73311. /**
  73312. * Gets the maxZ used for shadow according to both the scene and the light.
  73313. * @param activeCamera The camera we are returning the max for
  73314. * @returns the depth max z
  73315. */
  73316. getDepthMaxZ(activeCamera: Camera): number;
  73317. }
  73318. /**
  73319. * Base implementation IShadowLight
  73320. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73321. */
  73322. export abstract class ShadowLight extends Light implements IShadowLight {
  73323. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73324. protected _position: Vector3;
  73325. protected _setPosition(value: Vector3): void;
  73326. /**
  73327. * Sets the position the shadow will be casted from. Also use as the light position for both
  73328. * point and spot lights.
  73329. */
  73330. /**
  73331. * Sets the position the shadow will be casted from. Also use as the light position for both
  73332. * point and spot lights.
  73333. */
  73334. position: Vector3;
  73335. protected _direction: Vector3;
  73336. protected _setDirection(value: Vector3): void;
  73337. /**
  73338. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73339. * Also use as the light direction on spot and directional lights.
  73340. */
  73341. /**
  73342. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73343. * Also use as the light direction on spot and directional lights.
  73344. */
  73345. direction: Vector3;
  73346. private _shadowMinZ;
  73347. /**
  73348. * Gets the shadow projection clipping minimum z value.
  73349. */
  73350. /**
  73351. * Sets the shadow projection clipping minimum z value.
  73352. */
  73353. shadowMinZ: number;
  73354. private _shadowMaxZ;
  73355. /**
  73356. * Sets the shadow projection clipping maximum z value.
  73357. */
  73358. /**
  73359. * Gets the shadow projection clipping maximum z value.
  73360. */
  73361. shadowMaxZ: number;
  73362. /**
  73363. * Callback defining a custom Projection Matrix Builder.
  73364. * This can be used to override the default projection matrix computation.
  73365. */
  73366. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73367. /**
  73368. * The transformed position. Position of the light in world space taking parenting in account.
  73369. */
  73370. transformedPosition: Vector3;
  73371. /**
  73372. * The transformed direction. Direction of the light in world space taking parenting in account.
  73373. */
  73374. transformedDirection: Vector3;
  73375. private _needProjectionMatrixCompute;
  73376. /**
  73377. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73378. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73379. */
  73380. computeTransformedInformation(): boolean;
  73381. /**
  73382. * Return the depth scale used for the shadow map.
  73383. * @returns the depth scale.
  73384. */
  73385. getDepthScale(): number;
  73386. /**
  73387. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73388. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73389. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73390. */
  73391. getShadowDirection(faceIndex?: number): Vector3;
  73392. /**
  73393. * Returns the ShadowLight absolute position in the World.
  73394. * @returns the position vector in world space
  73395. */
  73396. getAbsolutePosition(): Vector3;
  73397. /**
  73398. * Sets the ShadowLight direction toward the passed target.
  73399. * @param target The point to target in local space
  73400. * @returns the updated ShadowLight direction
  73401. */
  73402. setDirectionToTarget(target: Vector3): Vector3;
  73403. /**
  73404. * Returns the light rotation in euler definition.
  73405. * @returns the x y z rotation in local space.
  73406. */
  73407. getRotation(): Vector3;
  73408. /**
  73409. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73410. * @returns true if a cube texture needs to be use
  73411. */
  73412. needCube(): boolean;
  73413. /**
  73414. * Detects if the projection matrix requires to be recomputed this frame.
  73415. * @returns true if it requires to be recomputed otherwise, false.
  73416. */
  73417. needProjectionMatrixCompute(): boolean;
  73418. /**
  73419. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73420. */
  73421. forceProjectionMatrixCompute(): void;
  73422. /** @hidden */
  73423. _initCache(): void;
  73424. /** @hidden */
  73425. _isSynchronized(): boolean;
  73426. /**
  73427. * Computes the world matrix of the node
  73428. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73429. * @returns the world matrix
  73430. */
  73431. computeWorldMatrix(force?: boolean): Matrix;
  73432. /**
  73433. * Gets the minZ used for shadow according to both the scene and the light.
  73434. * @param activeCamera The camera we are returning the min for
  73435. * @returns the depth min z
  73436. */
  73437. getDepthMinZ(activeCamera: Camera): number;
  73438. /**
  73439. * Gets the maxZ used for shadow according to both the scene and the light.
  73440. * @param activeCamera The camera we are returning the max for
  73441. * @returns the depth max z
  73442. */
  73443. getDepthMaxZ(activeCamera: Camera): number;
  73444. /**
  73445. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73446. * @param matrix The materix to updated with the projection information
  73447. * @param viewMatrix The transform matrix of the light
  73448. * @param renderList The list of mesh to render in the map
  73449. * @returns The current light
  73450. */
  73451. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73452. }
  73453. }
  73454. declare module BABYLON {
  73455. /**
  73456. * "Static Class" containing the most commonly used helper while dealing with material for
  73457. * rendering purpose.
  73458. *
  73459. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73460. *
  73461. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73462. */
  73463. export class MaterialHelper {
  73464. /**
  73465. * Bind the current view position to an effect.
  73466. * @param effect The effect to be bound
  73467. * @param scene The scene the eyes position is used from
  73468. */
  73469. static BindEyePosition(effect: Effect, scene: Scene): void;
  73470. /**
  73471. * Helps preparing the defines values about the UVs in used in the effect.
  73472. * UVs are shared as much as we can accross channels in the shaders.
  73473. * @param texture The texture we are preparing the UVs for
  73474. * @param defines The defines to update
  73475. * @param key The channel key "diffuse", "specular"... used in the shader
  73476. */
  73477. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73478. /**
  73479. * Binds a texture matrix value to its corrsponding uniform
  73480. * @param texture The texture to bind the matrix for
  73481. * @param uniformBuffer The uniform buffer receivin the data
  73482. * @param key The channel key "diffuse", "specular"... used in the shader
  73483. */
  73484. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73485. /**
  73486. * Gets the current status of the fog (should it be enabled?)
  73487. * @param mesh defines the mesh to evaluate for fog support
  73488. * @param scene defines the hosting scene
  73489. * @returns true if fog must be enabled
  73490. */
  73491. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73492. /**
  73493. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73494. * @param mesh defines the current mesh
  73495. * @param scene defines the current scene
  73496. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73497. * @param pointsCloud defines if point cloud rendering has to be turned on
  73498. * @param fogEnabled defines if fog has to be turned on
  73499. * @param alphaTest defines if alpha testing has to be turned on
  73500. * @param defines defines the current list of defines
  73501. */
  73502. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73503. /**
  73504. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73505. * @param scene defines the current scene
  73506. * @param engine defines the current engine
  73507. * @param defines specifies the list of active defines
  73508. * @param useInstances defines if instances have to be turned on
  73509. * @param useClipPlane defines if clip plane have to be turned on
  73510. */
  73511. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73512. /**
  73513. * Prepares the defines for bones
  73514. * @param mesh The mesh containing the geometry data we will draw
  73515. * @param defines The defines to update
  73516. */
  73517. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73518. /**
  73519. * Prepares the defines for morph targets
  73520. * @param mesh The mesh containing the geometry data we will draw
  73521. * @param defines The defines to update
  73522. */
  73523. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73524. /**
  73525. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73526. * @param mesh The mesh containing the geometry data we will draw
  73527. * @param defines The defines to update
  73528. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73529. * @param useBones Precise whether bones should be used or not (override mesh info)
  73530. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73531. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73532. * @returns false if defines are considered not dirty and have not been checked
  73533. */
  73534. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73535. /**
  73536. * Prepares the defines related to multiview
  73537. * @param scene The scene we are intending to draw
  73538. * @param defines The defines to update
  73539. */
  73540. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73541. /**
  73542. * Prepares the defines related to the light information passed in parameter
  73543. * @param scene The scene we are intending to draw
  73544. * @param mesh The mesh the effect is compiling for
  73545. * @param defines The defines to update
  73546. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73547. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73548. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73549. * @returns true if normals will be required for the rest of the effect
  73550. */
  73551. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73552. /**
  73553. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  73554. * that won t be acctive due to defines being turned off.
  73555. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73556. * @param samplersList The samplers list
  73557. * @param defines The defines helping in the list generation
  73558. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73559. */
  73560. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73561. /**
  73562. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73563. * @param defines The defines to update while falling back
  73564. * @param fallbacks The authorized effect fallbacks
  73565. * @param maxSimultaneousLights The maximum number of lights allowed
  73566. * @param rank the current rank of the Effect
  73567. * @returns The newly affected rank
  73568. */
  73569. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73570. /**
  73571. * Prepares the list of attributes required for morph targets according to the effect defines.
  73572. * @param attribs The current list of supported attribs
  73573. * @param mesh The mesh to prepare the morph targets attributes for
  73574. * @param defines The current Defines of the effect
  73575. */
  73576. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73577. /**
  73578. * Prepares the list of attributes required for bones according to the effect defines.
  73579. * @param attribs The current list of supported attribs
  73580. * @param mesh The mesh to prepare the bones attributes for
  73581. * @param defines The current Defines of the effect
  73582. * @param fallbacks The current efffect fallback strategy
  73583. */
  73584. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73585. /**
  73586. * Check and prepare the list of attributes required for instances according to the effect defines.
  73587. * @param attribs The current list of supported attribs
  73588. * @param defines The current MaterialDefines of the effect
  73589. */
  73590. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73591. /**
  73592. * Add the list of attributes required for instances to the attribs array.
  73593. * @param attribs The current list of supported attribs
  73594. */
  73595. static PushAttributesForInstances(attribs: string[]): void;
  73596. /**
  73597. * Binds the light shadow information to the effect for the given mesh.
  73598. * @param light The light containing the generator
  73599. * @param scene The scene the lights belongs to
  73600. * @param mesh The mesh we are binding the information to render
  73601. * @param lightIndex The light index in the effect used to render the mesh
  73602. * @param effect The effect we are binding the data to
  73603. */
  73604. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73605. /**
  73606. * Binds the light information to the effect.
  73607. * @param light The light containing the generator
  73608. * @param effect The effect we are binding the data to
  73609. * @param lightIndex The light index in the effect used to render
  73610. */
  73611. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73612. /**
  73613. * Binds the lights information from the scene to the effect for the given mesh.
  73614. * @param scene The scene the lights belongs to
  73615. * @param mesh The mesh we are binding the information to render
  73616. * @param effect The effect we are binding the data to
  73617. * @param defines The generated defines for the effect
  73618. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73619. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73620. */
  73621. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73622. private static _tempFogColor;
  73623. /**
  73624. * Binds the fog information from the scene to the effect for the given mesh.
  73625. * @param scene The scene the lights belongs to
  73626. * @param mesh The mesh we are binding the information to render
  73627. * @param effect The effect we are binding the data to
  73628. * @param linearSpace Defines if the fog effect is applied in linear space
  73629. */
  73630. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73631. /**
  73632. * Binds the bones information from the mesh to the effect.
  73633. * @param mesh The mesh we are binding the information to render
  73634. * @param effect The effect we are binding the data to
  73635. */
  73636. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73637. /**
  73638. * Binds the morph targets information from the mesh to the effect.
  73639. * @param abstractMesh The mesh we are binding the information to render
  73640. * @param effect The effect we are binding the data to
  73641. */
  73642. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73643. /**
  73644. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73645. * @param defines The generated defines used in the effect
  73646. * @param effect The effect we are binding the data to
  73647. * @param scene The scene we are willing to render with logarithmic scale for
  73648. */
  73649. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73650. /**
  73651. * Binds the clip plane information from the scene to the effect.
  73652. * @param scene The scene the clip plane information are extracted from
  73653. * @param effect The effect we are binding the data to
  73654. */
  73655. static BindClipPlane(effect: Effect, scene: Scene): void;
  73656. }
  73657. }
  73658. declare module BABYLON {
  73659. /** @hidden */
  73660. export var shadowMapPixelShader: {
  73661. name: string;
  73662. shader: string;
  73663. };
  73664. }
  73665. declare module BABYLON {
  73666. /** @hidden */
  73667. export var bonesDeclaration: {
  73668. name: string;
  73669. shader: string;
  73670. };
  73671. }
  73672. declare module BABYLON {
  73673. /** @hidden */
  73674. export var morphTargetsVertexGlobalDeclaration: {
  73675. name: string;
  73676. shader: string;
  73677. };
  73678. }
  73679. declare module BABYLON {
  73680. /** @hidden */
  73681. export var morphTargetsVertexDeclaration: {
  73682. name: string;
  73683. shader: string;
  73684. };
  73685. }
  73686. declare module BABYLON {
  73687. /** @hidden */
  73688. export var instancesDeclaration: {
  73689. name: string;
  73690. shader: string;
  73691. };
  73692. }
  73693. declare module BABYLON {
  73694. /** @hidden */
  73695. export var helperFunctions: {
  73696. name: string;
  73697. shader: string;
  73698. };
  73699. }
  73700. declare module BABYLON {
  73701. /** @hidden */
  73702. export var morphTargetsVertex: {
  73703. name: string;
  73704. shader: string;
  73705. };
  73706. }
  73707. declare module BABYLON {
  73708. /** @hidden */
  73709. export var instancesVertex: {
  73710. name: string;
  73711. shader: string;
  73712. };
  73713. }
  73714. declare module BABYLON {
  73715. /** @hidden */
  73716. export var bonesVertex: {
  73717. name: string;
  73718. shader: string;
  73719. };
  73720. }
  73721. declare module BABYLON {
  73722. /** @hidden */
  73723. export var shadowMapVertexShader: {
  73724. name: string;
  73725. shader: string;
  73726. };
  73727. }
  73728. declare module BABYLON {
  73729. /** @hidden */
  73730. export var depthBoxBlurPixelShader: {
  73731. name: string;
  73732. shader: string;
  73733. };
  73734. }
  73735. declare module BABYLON {
  73736. /**
  73737. * Defines the options associated with the creation of a custom shader for a shadow generator.
  73738. */
  73739. export interface ICustomShaderOptions {
  73740. /**
  73741. * Gets or sets the custom shader name to use
  73742. */
  73743. shaderName: string;
  73744. /**
  73745. * The list of attribute names used in the shader
  73746. */
  73747. attributes?: string[];
  73748. /**
  73749. * The list of unifrom names used in the shader
  73750. */
  73751. uniforms?: string[];
  73752. /**
  73753. * The list of sampler names used in the shader
  73754. */
  73755. samplers?: string[];
  73756. /**
  73757. * The list of defines used in the shader
  73758. */
  73759. defines?: string[];
  73760. }
  73761. /**
  73762. * Interface to implement to create a shadow generator compatible with BJS.
  73763. */
  73764. export interface IShadowGenerator {
  73765. /**
  73766. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73767. * @returns The render target texture if present otherwise, null
  73768. */
  73769. getShadowMap(): Nullable<RenderTargetTexture>;
  73770. /**
  73771. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73772. * @returns The render target texture if the shadow map is present otherwise, null
  73773. */
  73774. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73775. /**
  73776. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73777. * @param subMesh The submesh we want to render in the shadow map
  73778. * @param useInstances Defines wether will draw in the map using instances
  73779. * @returns true if ready otherwise, false
  73780. */
  73781. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73782. /**
  73783. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73784. * @param defines Defines of the material we want to update
  73785. * @param lightIndex Index of the light in the enabled light list of the material
  73786. */
  73787. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73788. /**
  73789. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73790. * defined in the generator but impacting the effect).
  73791. * It implies the unifroms available on the materials are the standard BJS ones.
  73792. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73793. * @param effect The effect we are binfing the information for
  73794. */
  73795. bindShadowLight(lightIndex: string, effect: Effect): void;
  73796. /**
  73797. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73798. * (eq to shadow prjection matrix * light transform matrix)
  73799. * @returns The transform matrix used to create the shadow map
  73800. */
  73801. getTransformMatrix(): Matrix;
  73802. /**
  73803. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73804. * Cube and 2D textures for instance.
  73805. */
  73806. recreateShadowMap(): void;
  73807. /**
  73808. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73809. * @param onCompiled Callback triggered at the and of the effects compilation
  73810. * @param options Sets of optional options forcing the compilation with different modes
  73811. */
  73812. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73813. useInstances: boolean;
  73814. }>): void;
  73815. /**
  73816. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73817. * @param options Sets of optional options forcing the compilation with different modes
  73818. * @returns A promise that resolves when the compilation completes
  73819. */
  73820. forceCompilationAsync(options?: Partial<{
  73821. useInstances: boolean;
  73822. }>): Promise<void>;
  73823. /**
  73824. * Serializes the shadow generator setup to a json object.
  73825. * @returns The serialized JSON object
  73826. */
  73827. serialize(): any;
  73828. /**
  73829. * Disposes the Shadow map and related Textures and effects.
  73830. */
  73831. dispose(): void;
  73832. }
  73833. /**
  73834. * Default implementation IShadowGenerator.
  73835. * This is the main object responsible of generating shadows in the framework.
  73836. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73837. */
  73838. export class ShadowGenerator implements IShadowGenerator {
  73839. /**
  73840. * Shadow generator mode None: no filtering applied.
  73841. */
  73842. static readonly FILTER_NONE: number;
  73843. /**
  73844. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73845. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73846. */
  73847. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73848. /**
  73849. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73850. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73851. */
  73852. static readonly FILTER_POISSONSAMPLING: number;
  73853. /**
  73854. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  73855. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73856. */
  73857. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  73858. /**
  73859. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  73860. * edge artifacts on steep falloff.
  73861. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73862. */
  73863. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  73864. /**
  73865. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  73866. * edge artifacts on steep falloff.
  73867. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73868. */
  73869. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  73870. /**
  73871. * Shadow generator mode PCF: Percentage Closer Filtering
  73872. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73873. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  73874. */
  73875. static readonly FILTER_PCF: number;
  73876. /**
  73877. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73878. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73879. * Contact Hardening
  73880. */
  73881. static readonly FILTER_PCSS: number;
  73882. /**
  73883. * Reserved for PCF and PCSS
  73884. * Highest Quality.
  73885. *
  73886. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73887. *
  73888. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73889. */
  73890. static readonly QUALITY_HIGH: number;
  73891. /**
  73892. * Reserved for PCF and PCSS
  73893. * Good tradeoff for quality/perf cross devices
  73894. *
  73895. * Execute PCF on a 3*3 kernel.
  73896. *
  73897. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73898. */
  73899. static readonly QUALITY_MEDIUM: number;
  73900. /**
  73901. * Reserved for PCF and PCSS
  73902. * The lowest quality but the fastest.
  73903. *
  73904. * Execute PCF on a 1*1 kernel.
  73905. *
  73906. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73907. */
  73908. static readonly QUALITY_LOW: number;
  73909. /** Gets or sets the custom shader name to use */
  73910. customShaderOptions: ICustomShaderOptions;
  73911. /**
  73912. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73913. */
  73914. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73915. /**
  73916. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73917. */
  73918. onAfterShadowMapRenderObservable: Observable<Effect>;
  73919. /**
  73920. * Observable triggered before a mesh is rendered in the shadow map.
  73921. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73922. */
  73923. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73924. /**
  73925. * Observable triggered after a mesh is rendered in the shadow map.
  73926. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73927. */
  73928. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73929. private _bias;
  73930. /**
  73931. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73932. */
  73933. /**
  73934. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73935. */
  73936. bias: number;
  73937. private _normalBias;
  73938. /**
  73939. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73940. */
  73941. /**
  73942. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73943. */
  73944. normalBias: number;
  73945. private _blurBoxOffset;
  73946. /**
  73947. * Gets the blur box offset: offset applied during the blur pass.
  73948. * Only useful if useKernelBlur = false
  73949. */
  73950. /**
  73951. * Sets the blur box offset: offset applied during the blur pass.
  73952. * Only useful if useKernelBlur = false
  73953. */
  73954. blurBoxOffset: number;
  73955. private _blurScale;
  73956. /**
  73957. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  73958. * 2 means half of the size.
  73959. */
  73960. /**
  73961. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  73962. * 2 means half of the size.
  73963. */
  73964. blurScale: number;
  73965. private _blurKernel;
  73966. /**
  73967. * Gets the blur kernel: kernel size of the blur pass.
  73968. * Only useful if useKernelBlur = true
  73969. */
  73970. /**
  73971. * Sets the blur kernel: kernel size of the blur pass.
  73972. * Only useful if useKernelBlur = true
  73973. */
  73974. blurKernel: number;
  73975. private _useKernelBlur;
  73976. /**
  73977. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  73978. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73979. */
  73980. /**
  73981. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  73982. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73983. */
  73984. useKernelBlur: boolean;
  73985. private _depthScale;
  73986. /**
  73987. * Gets the depth scale used in ESM mode.
  73988. */
  73989. /**
  73990. * Sets the depth scale used in ESM mode.
  73991. * This can override the scale stored on the light.
  73992. */
  73993. depthScale: number;
  73994. private _filter;
  73995. /**
  73996. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  73997. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73998. */
  73999. /**
  74000. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74001. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74002. */
  74003. filter: number;
  74004. /**
  74005. * Gets if the current filter is set to Poisson Sampling.
  74006. */
  74007. /**
  74008. * Sets the current filter to Poisson Sampling.
  74009. */
  74010. usePoissonSampling: boolean;
  74011. /**
  74012. * Gets if the current filter is set to ESM.
  74013. */
  74014. /**
  74015. * Sets the current filter is to ESM.
  74016. */
  74017. useExponentialShadowMap: boolean;
  74018. /**
  74019. * Gets if the current filter is set to filtered ESM.
  74020. */
  74021. /**
  74022. * Gets if the current filter is set to filtered ESM.
  74023. */
  74024. useBlurExponentialShadowMap: boolean;
  74025. /**
  74026. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74027. * exponential to prevent steep falloff artifacts).
  74028. */
  74029. /**
  74030. * Sets the current filter to "close ESM" (using the inverse of the
  74031. * exponential to prevent steep falloff artifacts).
  74032. */
  74033. useCloseExponentialShadowMap: boolean;
  74034. /**
  74035. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74036. * exponential to prevent steep falloff artifacts).
  74037. */
  74038. /**
  74039. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74040. * exponential to prevent steep falloff artifacts).
  74041. */
  74042. useBlurCloseExponentialShadowMap: boolean;
  74043. /**
  74044. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74045. */
  74046. /**
  74047. * Sets the current filter to "PCF" (percentage closer filtering).
  74048. */
  74049. usePercentageCloserFiltering: boolean;
  74050. private _filteringQuality;
  74051. /**
  74052. * Gets the PCF or PCSS Quality.
  74053. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74054. */
  74055. /**
  74056. * Sets the PCF or PCSS Quality.
  74057. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74058. */
  74059. filteringQuality: number;
  74060. /**
  74061. * Gets if the current filter is set to "PCSS" (contact hardening).
  74062. */
  74063. /**
  74064. * Sets the current filter to "PCSS" (contact hardening).
  74065. */
  74066. useContactHardeningShadow: boolean;
  74067. private _contactHardeningLightSizeUVRatio;
  74068. /**
  74069. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74070. * Using a ratio helps keeping shape stability independently of the map size.
  74071. *
  74072. * It does not account for the light projection as it was having too much
  74073. * instability during the light setup or during light position changes.
  74074. *
  74075. * Only valid if useContactHardeningShadow is true.
  74076. */
  74077. /**
  74078. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74079. * Using a ratio helps keeping shape stability independently of the map size.
  74080. *
  74081. * It does not account for the light projection as it was having too much
  74082. * instability during the light setup or during light position changes.
  74083. *
  74084. * Only valid if useContactHardeningShadow is true.
  74085. */
  74086. contactHardeningLightSizeUVRatio: number;
  74087. private _darkness;
  74088. /** Gets or sets the actual darkness of a shadow */
  74089. darkness: number;
  74090. /**
  74091. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74092. * 0 means strongest and 1 would means no shadow.
  74093. * @returns the darkness.
  74094. */
  74095. getDarkness(): number;
  74096. /**
  74097. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74098. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74099. * @returns the shadow generator allowing fluent coding.
  74100. */
  74101. setDarkness(darkness: number): ShadowGenerator;
  74102. private _transparencyShadow;
  74103. /** Gets or sets the ability to have transparent shadow */
  74104. transparencyShadow: boolean;
  74105. /**
  74106. * Sets the ability to have transparent shadow (boolean).
  74107. * @param transparent True if transparent else False
  74108. * @returns the shadow generator allowing fluent coding
  74109. */
  74110. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74111. private _shadowMap;
  74112. private _shadowMap2;
  74113. /**
  74114. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74115. * @returns The render target texture if present otherwise, null
  74116. */
  74117. getShadowMap(): Nullable<RenderTargetTexture>;
  74118. /**
  74119. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74120. * @returns The render target texture if the shadow map is present otherwise, null
  74121. */
  74122. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74123. /**
  74124. * Gets the class name of that object
  74125. * @returns "ShadowGenerator"
  74126. */
  74127. getClassName(): string;
  74128. /**
  74129. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74130. * @param mesh Mesh to add
  74131. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74132. * @returns the Shadow Generator itself
  74133. */
  74134. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74135. /**
  74136. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74137. * @param mesh Mesh to remove
  74138. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74139. * @returns the Shadow Generator itself
  74140. */
  74141. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74142. /**
  74143. * Controls the extent to which the shadows fade out at the edge of the frustum
  74144. * Used only by directionals and spots
  74145. */
  74146. frustumEdgeFalloff: number;
  74147. private _light;
  74148. /**
  74149. * Returns the associated light object.
  74150. * @returns the light generating the shadow
  74151. */
  74152. getLight(): IShadowLight;
  74153. /**
  74154. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74155. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74156. * It might on the other hand introduce peter panning.
  74157. */
  74158. forceBackFacesOnly: boolean;
  74159. private _scene;
  74160. private _lightDirection;
  74161. private _effect;
  74162. private _viewMatrix;
  74163. private _projectionMatrix;
  74164. private _transformMatrix;
  74165. private _cachedPosition;
  74166. private _cachedDirection;
  74167. private _cachedDefines;
  74168. private _currentRenderID;
  74169. private _boxBlurPostprocess;
  74170. private _kernelBlurXPostprocess;
  74171. private _kernelBlurYPostprocess;
  74172. private _blurPostProcesses;
  74173. private _mapSize;
  74174. private _currentFaceIndex;
  74175. private _currentFaceIndexCache;
  74176. private _textureType;
  74177. private _defaultTextureMatrix;
  74178. /** @hidden */
  74179. static _SceneComponentInitialization: (scene: Scene) => void;
  74180. /**
  74181. * Creates a ShadowGenerator object.
  74182. * A ShadowGenerator is the required tool to use the shadows.
  74183. * Each light casting shadows needs to use its own ShadowGenerator.
  74184. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74185. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74186. * @param light The light object generating the shadows.
  74187. * @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.
  74188. */
  74189. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74190. private _initializeGenerator;
  74191. private _initializeShadowMap;
  74192. private _initializeBlurRTTAndPostProcesses;
  74193. private _renderForShadowMap;
  74194. private _renderSubMeshForShadowMap;
  74195. private _applyFilterValues;
  74196. /**
  74197. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74198. * @param onCompiled Callback triggered at the and of the effects compilation
  74199. * @param options Sets of optional options forcing the compilation with different modes
  74200. */
  74201. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74202. useInstances: boolean;
  74203. }>): void;
  74204. /**
  74205. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74206. * @param options Sets of optional options forcing the compilation with different modes
  74207. * @returns A promise that resolves when the compilation completes
  74208. */
  74209. forceCompilationAsync(options?: Partial<{
  74210. useInstances: boolean;
  74211. }>): Promise<void>;
  74212. /**
  74213. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74214. * @param subMesh The submesh we want to render in the shadow map
  74215. * @param useInstances Defines wether will draw in the map using instances
  74216. * @returns true if ready otherwise, false
  74217. */
  74218. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74219. /**
  74220. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74221. * @param defines Defines of the material we want to update
  74222. * @param lightIndex Index of the light in the enabled light list of the material
  74223. */
  74224. prepareDefines(defines: any, lightIndex: number): void;
  74225. /**
  74226. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74227. * defined in the generator but impacting the effect).
  74228. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74229. * @param effect The effect we are binfing the information for
  74230. */
  74231. bindShadowLight(lightIndex: string, effect: Effect): void;
  74232. /**
  74233. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74234. * (eq to shadow prjection matrix * light transform matrix)
  74235. * @returns The transform matrix used to create the shadow map
  74236. */
  74237. getTransformMatrix(): Matrix;
  74238. /**
  74239. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74240. * Cube and 2D textures for instance.
  74241. */
  74242. recreateShadowMap(): void;
  74243. private _disposeBlurPostProcesses;
  74244. private _disposeRTTandPostProcesses;
  74245. /**
  74246. * Disposes the ShadowGenerator.
  74247. * Returns nothing.
  74248. */
  74249. dispose(): void;
  74250. /**
  74251. * Serializes the shadow generator setup to a json object.
  74252. * @returns The serialized JSON object
  74253. */
  74254. serialize(): any;
  74255. /**
  74256. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74257. * @param parsedShadowGenerator The JSON object to parse
  74258. * @param scene The scene to create the shadow map for
  74259. * @returns The parsed shadow generator
  74260. */
  74261. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74262. }
  74263. }
  74264. declare module BABYLON {
  74265. /**
  74266. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74267. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74268. * 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.
  74269. */
  74270. export abstract class Light extends Node {
  74271. /**
  74272. * Falloff Default: light is falling off following the material specification:
  74273. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74274. */
  74275. static readonly FALLOFF_DEFAULT: number;
  74276. /**
  74277. * Falloff Physical: light is falling off following the inverse squared distance law.
  74278. */
  74279. static readonly FALLOFF_PHYSICAL: number;
  74280. /**
  74281. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74282. * to enhance interoperability with other engines.
  74283. */
  74284. static readonly FALLOFF_GLTF: number;
  74285. /**
  74286. * Falloff Standard: light is falling off like in the standard material
  74287. * to enhance interoperability with other materials.
  74288. */
  74289. static readonly FALLOFF_STANDARD: number;
  74290. /**
  74291. * If every light affecting the material is in this lightmapMode,
  74292. * material.lightmapTexture adds or multiplies
  74293. * (depends on material.useLightmapAsShadowmap)
  74294. * after every other light calculations.
  74295. */
  74296. static readonly LIGHTMAP_DEFAULT: number;
  74297. /**
  74298. * material.lightmapTexture as only diffuse lighting from this light
  74299. * adds only specular lighting from this light
  74300. * adds dynamic shadows
  74301. */
  74302. static readonly LIGHTMAP_SPECULAR: number;
  74303. /**
  74304. * material.lightmapTexture as only lighting
  74305. * no light calculation from this light
  74306. * only adds dynamic shadows from this light
  74307. */
  74308. static readonly LIGHTMAP_SHADOWSONLY: number;
  74309. /**
  74310. * Each light type uses the default quantity according to its type:
  74311. * point/spot lights use luminous intensity
  74312. * directional lights use illuminance
  74313. */
  74314. static readonly INTENSITYMODE_AUTOMATIC: number;
  74315. /**
  74316. * lumen (lm)
  74317. */
  74318. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74319. /**
  74320. * candela (lm/sr)
  74321. */
  74322. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74323. /**
  74324. * lux (lm/m^2)
  74325. */
  74326. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74327. /**
  74328. * nit (cd/m^2)
  74329. */
  74330. static readonly INTENSITYMODE_LUMINANCE: number;
  74331. /**
  74332. * Light type const id of the point light.
  74333. */
  74334. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74335. /**
  74336. * Light type const id of the directional light.
  74337. */
  74338. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74339. /**
  74340. * Light type const id of the spot light.
  74341. */
  74342. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74343. /**
  74344. * Light type const id of the hemispheric light.
  74345. */
  74346. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74347. /**
  74348. * Diffuse gives the basic color to an object.
  74349. */
  74350. diffuse: Color3;
  74351. /**
  74352. * Specular produces a highlight color on an object.
  74353. * Note: This is note affecting PBR materials.
  74354. */
  74355. specular: Color3;
  74356. /**
  74357. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74358. * falling off base on range or angle.
  74359. * This can be set to any values in Light.FALLOFF_x.
  74360. *
  74361. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74362. * other types of materials.
  74363. */
  74364. falloffType: number;
  74365. /**
  74366. * Strength of the light.
  74367. * Note: By default it is define in the framework own unit.
  74368. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74369. */
  74370. intensity: number;
  74371. private _range;
  74372. protected _inverseSquaredRange: number;
  74373. /**
  74374. * Defines how far from the source the light is impacting in scene units.
  74375. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74376. */
  74377. /**
  74378. * Defines how far from the source the light is impacting in scene units.
  74379. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74380. */
  74381. range: number;
  74382. /**
  74383. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74384. * of light.
  74385. */
  74386. private _photometricScale;
  74387. private _intensityMode;
  74388. /**
  74389. * Gets the photometric scale used to interpret the intensity.
  74390. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74391. */
  74392. /**
  74393. * Sets the photometric scale used to interpret the intensity.
  74394. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74395. */
  74396. intensityMode: number;
  74397. private _radius;
  74398. /**
  74399. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74400. */
  74401. /**
  74402. * sets the light radius used by PBR Materials to simulate soft area lights.
  74403. */
  74404. radius: number;
  74405. private _renderPriority;
  74406. /**
  74407. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74408. * exceeding the number allowed of the materials.
  74409. */
  74410. renderPriority: number;
  74411. private _shadowEnabled;
  74412. /**
  74413. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74414. * the current shadow generator.
  74415. */
  74416. /**
  74417. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74418. * the current shadow generator.
  74419. */
  74420. shadowEnabled: boolean;
  74421. private _includedOnlyMeshes;
  74422. /**
  74423. * Gets the only meshes impacted by this light.
  74424. */
  74425. /**
  74426. * Sets the only meshes impacted by this light.
  74427. */
  74428. includedOnlyMeshes: AbstractMesh[];
  74429. private _excludedMeshes;
  74430. /**
  74431. * Gets the meshes not impacted by this light.
  74432. */
  74433. /**
  74434. * Sets the meshes not impacted by this light.
  74435. */
  74436. excludedMeshes: AbstractMesh[];
  74437. private _excludeWithLayerMask;
  74438. /**
  74439. * Gets the layer id use to find what meshes are not impacted by the light.
  74440. * Inactive if 0
  74441. */
  74442. /**
  74443. * Sets the layer id use to find what meshes are not impacted by the light.
  74444. * Inactive if 0
  74445. */
  74446. excludeWithLayerMask: number;
  74447. private _includeOnlyWithLayerMask;
  74448. /**
  74449. * Gets the layer id use to find what meshes are impacted by the light.
  74450. * Inactive if 0
  74451. */
  74452. /**
  74453. * Sets the layer id use to find what meshes are impacted by the light.
  74454. * Inactive if 0
  74455. */
  74456. includeOnlyWithLayerMask: number;
  74457. private _lightmapMode;
  74458. /**
  74459. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74460. */
  74461. /**
  74462. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74463. */
  74464. lightmapMode: number;
  74465. /**
  74466. * Shadow generator associted to the light.
  74467. * @hidden Internal use only.
  74468. */
  74469. _shadowGenerator: Nullable<IShadowGenerator>;
  74470. /**
  74471. * @hidden Internal use only.
  74472. */
  74473. _excludedMeshesIds: string[];
  74474. /**
  74475. * @hidden Internal use only.
  74476. */
  74477. _includedOnlyMeshesIds: string[];
  74478. /**
  74479. * The current light unifom buffer.
  74480. * @hidden Internal use only.
  74481. */
  74482. _uniformBuffer: UniformBuffer;
  74483. /**
  74484. * Creates a Light object in the scene.
  74485. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74486. * @param name The firendly name of the light
  74487. * @param scene The scene the light belongs too
  74488. */
  74489. constructor(name: string, scene: Scene);
  74490. protected abstract _buildUniformLayout(): void;
  74491. /**
  74492. * Sets the passed Effect "effect" with the Light information.
  74493. * @param effect The effect to update
  74494. * @param lightIndex The index of the light in the effect to update
  74495. * @returns The light
  74496. */
  74497. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74498. /**
  74499. * Returns the string "Light".
  74500. * @returns the class name
  74501. */
  74502. getClassName(): string;
  74503. /** @hidden */
  74504. readonly _isLight: boolean;
  74505. /**
  74506. * Converts the light information to a readable string for debug purpose.
  74507. * @param fullDetails Supports for multiple levels of logging within scene loading
  74508. * @returns the human readable light info
  74509. */
  74510. toString(fullDetails?: boolean): string;
  74511. /** @hidden */
  74512. protected _syncParentEnabledState(): void;
  74513. /**
  74514. * Set the enabled state of this node.
  74515. * @param value - the new enabled state
  74516. */
  74517. setEnabled(value: boolean): void;
  74518. /**
  74519. * Returns the Light associated shadow generator if any.
  74520. * @return the associated shadow generator.
  74521. */
  74522. getShadowGenerator(): Nullable<IShadowGenerator>;
  74523. /**
  74524. * Returns a Vector3, the absolute light position in the World.
  74525. * @returns the world space position of the light
  74526. */
  74527. getAbsolutePosition(): Vector3;
  74528. /**
  74529. * Specifies if the light will affect the passed mesh.
  74530. * @param mesh The mesh to test against the light
  74531. * @return true the mesh is affected otherwise, false.
  74532. */
  74533. canAffectMesh(mesh: AbstractMesh): boolean;
  74534. /**
  74535. * Sort function to order lights for rendering.
  74536. * @param a First Light object to compare to second.
  74537. * @param b Second Light object to compare first.
  74538. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74539. */
  74540. static CompareLightsPriority(a: Light, b: Light): number;
  74541. /**
  74542. * Releases resources associated with this node.
  74543. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74544. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74545. */
  74546. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74547. /**
  74548. * Returns the light type ID (integer).
  74549. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74550. */
  74551. getTypeID(): number;
  74552. /**
  74553. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74554. * @returns the scaled intensity in intensity mode unit
  74555. */
  74556. getScaledIntensity(): number;
  74557. /**
  74558. * Returns a new Light object, named "name", from the current one.
  74559. * @param name The name of the cloned light
  74560. * @returns the new created light
  74561. */
  74562. clone(name: string): Nullable<Light>;
  74563. /**
  74564. * Serializes the current light into a Serialization object.
  74565. * @returns the serialized object.
  74566. */
  74567. serialize(): any;
  74568. /**
  74569. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74570. * This new light is named "name" and added to the passed scene.
  74571. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74572. * @param name The friendly name of the light
  74573. * @param scene The scene the new light will belong to
  74574. * @returns the constructor function
  74575. */
  74576. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74577. /**
  74578. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74579. * @param parsedLight The JSON representation of the light
  74580. * @param scene The scene to create the parsed light in
  74581. * @returns the created light after parsing
  74582. */
  74583. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74584. private _hookArrayForExcluded;
  74585. private _hookArrayForIncludedOnly;
  74586. private _resyncMeshes;
  74587. /**
  74588. * Forces the meshes to update their light related information in their rendering used effects
  74589. * @hidden Internal Use Only
  74590. */
  74591. _markMeshesAsLightDirty(): void;
  74592. /**
  74593. * Recomputes the cached photometric scale if needed.
  74594. */
  74595. private _computePhotometricScale;
  74596. /**
  74597. * Returns the Photometric Scale according to the light type and intensity mode.
  74598. */
  74599. private _getPhotometricScale;
  74600. /**
  74601. * Reorder the light in the scene according to their defined priority.
  74602. * @hidden Internal Use Only
  74603. */
  74604. _reorderLightsInScene(): void;
  74605. /**
  74606. * Prepares the list of defines specific to the light type.
  74607. * @param defines the list of defines
  74608. * @param lightIndex defines the index of the light for the effect
  74609. */
  74610. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74611. }
  74612. }
  74613. declare module BABYLON {
  74614. /**
  74615. * Creates an instance based on a source mesh.
  74616. */
  74617. export class InstancedMesh extends AbstractMesh {
  74618. private _sourceMesh;
  74619. private _currentLOD;
  74620. /** @hidden */
  74621. _indexInSourceMeshInstanceArray: number;
  74622. constructor(name: string, source: Mesh);
  74623. /**
  74624. * Returns the string "InstancedMesh".
  74625. */
  74626. getClassName(): string;
  74627. /** Gets the list of lights affecting that mesh */
  74628. readonly lightSources: Light[];
  74629. _resyncLightSources(): void;
  74630. _resyncLighSource(light: Light): void;
  74631. _removeLightSource(light: Light): void;
  74632. /**
  74633. * If the source mesh receives shadows
  74634. */
  74635. readonly receiveShadows: boolean;
  74636. /**
  74637. * The material of the source mesh
  74638. */
  74639. readonly material: Nullable<Material>;
  74640. /**
  74641. * Visibility of the source mesh
  74642. */
  74643. readonly visibility: number;
  74644. /**
  74645. * Skeleton of the source mesh
  74646. */
  74647. readonly skeleton: Nullable<Skeleton>;
  74648. /**
  74649. * Rendering ground id of the source mesh
  74650. */
  74651. renderingGroupId: number;
  74652. /**
  74653. * Returns the total number of vertices (integer).
  74654. */
  74655. getTotalVertices(): number;
  74656. /**
  74657. * Returns a positive integer : the total number of indices in this mesh geometry.
  74658. * @returns the numner of indices or zero if the mesh has no geometry.
  74659. */
  74660. getTotalIndices(): number;
  74661. /**
  74662. * The source mesh of the instance
  74663. */
  74664. readonly sourceMesh: Mesh;
  74665. /**
  74666. * Is this node ready to be used/rendered
  74667. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74668. * @return {boolean} is it ready
  74669. */
  74670. isReady(completeCheck?: boolean): boolean;
  74671. /**
  74672. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74673. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74674. * @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.
  74675. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74676. */
  74677. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74678. /**
  74679. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74680. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74681. * The `data` are either a numeric array either a Float32Array.
  74682. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74683. * 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).
  74684. * Note that a new underlying VertexBuffer object is created each call.
  74685. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74686. *
  74687. * Possible `kind` values :
  74688. * - VertexBuffer.PositionKind
  74689. * - VertexBuffer.UVKind
  74690. * - VertexBuffer.UV2Kind
  74691. * - VertexBuffer.UV3Kind
  74692. * - VertexBuffer.UV4Kind
  74693. * - VertexBuffer.UV5Kind
  74694. * - VertexBuffer.UV6Kind
  74695. * - VertexBuffer.ColorKind
  74696. * - VertexBuffer.MatricesIndicesKind
  74697. * - VertexBuffer.MatricesIndicesExtraKind
  74698. * - VertexBuffer.MatricesWeightsKind
  74699. * - VertexBuffer.MatricesWeightsExtraKind
  74700. *
  74701. * Returns the Mesh.
  74702. */
  74703. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74704. /**
  74705. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74706. * If the mesh has no geometry, it is simply returned as it is.
  74707. * The `data` are either a numeric array either a Float32Array.
  74708. * No new underlying VertexBuffer object is created.
  74709. * 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.
  74710. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74711. *
  74712. * Possible `kind` values :
  74713. * - VertexBuffer.PositionKind
  74714. * - VertexBuffer.UVKind
  74715. * - VertexBuffer.UV2Kind
  74716. * - VertexBuffer.UV3Kind
  74717. * - VertexBuffer.UV4Kind
  74718. * - VertexBuffer.UV5Kind
  74719. * - VertexBuffer.UV6Kind
  74720. * - VertexBuffer.ColorKind
  74721. * - VertexBuffer.MatricesIndicesKind
  74722. * - VertexBuffer.MatricesIndicesExtraKind
  74723. * - VertexBuffer.MatricesWeightsKind
  74724. * - VertexBuffer.MatricesWeightsExtraKind
  74725. *
  74726. * Returns the Mesh.
  74727. */
  74728. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74729. /**
  74730. * Sets the mesh indices.
  74731. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74732. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74733. * This method creates a new index buffer each call.
  74734. * Returns the Mesh.
  74735. */
  74736. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74737. /**
  74738. * Boolean : True if the mesh owns the requested kind of data.
  74739. */
  74740. isVerticesDataPresent(kind: string): boolean;
  74741. /**
  74742. * Returns an array of indices (IndicesArray).
  74743. */
  74744. getIndices(): Nullable<IndicesArray>;
  74745. readonly _positions: Nullable<Vector3[]>;
  74746. /**
  74747. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74748. * This means the mesh underlying bounding box and sphere are recomputed.
  74749. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74750. * @returns the current mesh
  74751. */
  74752. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74753. /** @hidden */
  74754. _preActivate(): InstancedMesh;
  74755. /** @hidden */
  74756. _activate(renderId: number, intermediateRendering: boolean): boolean;
  74757. /** @hidden */
  74758. _postActivate(): void;
  74759. getWorldMatrix(): Matrix;
  74760. readonly isAnInstance: boolean;
  74761. /**
  74762. * Returns the current associated LOD AbstractMesh.
  74763. */
  74764. getLOD(camera: Camera): AbstractMesh;
  74765. /** @hidden */
  74766. _syncSubMeshes(): InstancedMesh;
  74767. /** @hidden */
  74768. _generatePointsArray(): boolean;
  74769. /**
  74770. * Creates a new InstancedMesh from the current mesh.
  74771. * - name (string) : the cloned mesh name
  74772. * - newParent (optional Node) : the optional Node to parent the clone to.
  74773. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74774. *
  74775. * Returns the clone.
  74776. */
  74777. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74778. /**
  74779. * Disposes the InstancedMesh.
  74780. * Returns nothing.
  74781. */
  74782. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74783. }
  74784. }
  74785. declare module BABYLON {
  74786. /**
  74787. * Defines the options associated with the creation of a shader material.
  74788. */
  74789. export interface IShaderMaterialOptions {
  74790. /**
  74791. * Does the material work in alpha blend mode
  74792. */
  74793. needAlphaBlending: boolean;
  74794. /**
  74795. * Does the material work in alpha test mode
  74796. */
  74797. needAlphaTesting: boolean;
  74798. /**
  74799. * The list of attribute names used in the shader
  74800. */
  74801. attributes: string[];
  74802. /**
  74803. * The list of unifrom names used in the shader
  74804. */
  74805. uniforms: string[];
  74806. /**
  74807. * The list of UBO names used in the shader
  74808. */
  74809. uniformBuffers: string[];
  74810. /**
  74811. * The list of sampler names used in the shader
  74812. */
  74813. samplers: string[];
  74814. /**
  74815. * The list of defines used in the shader
  74816. */
  74817. defines: string[];
  74818. }
  74819. /**
  74820. * 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.
  74821. *
  74822. * This returned material effects how the mesh will look based on the code in the shaders.
  74823. *
  74824. * @see http://doc.babylonjs.com/how_to/shader_material
  74825. */
  74826. export class ShaderMaterial extends Material {
  74827. private _shaderPath;
  74828. private _options;
  74829. private _textures;
  74830. private _textureArrays;
  74831. private _floats;
  74832. private _ints;
  74833. private _floatsArrays;
  74834. private _colors3;
  74835. private _colors3Arrays;
  74836. private _colors4;
  74837. private _vectors2;
  74838. private _vectors3;
  74839. private _vectors4;
  74840. private _matrices;
  74841. private _matrices3x3;
  74842. private _matrices2x2;
  74843. private _vectors2Arrays;
  74844. private _vectors3Arrays;
  74845. private _cachedWorldViewMatrix;
  74846. private _cachedWorldViewProjectionMatrix;
  74847. private _renderId;
  74848. /**
  74849. * Instantiate a new shader material.
  74850. * 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.
  74851. * This returned material effects how the mesh will look based on the code in the shaders.
  74852. * @see http://doc.babylonjs.com/how_to/shader_material
  74853. * @param name Define the name of the material in the scene
  74854. * @param scene Define the scene the material belongs to
  74855. * @param shaderPath Defines the route to the shader code in one of three ways:
  74856. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74857. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74858. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74859. * @param options Define the options used to create the shader
  74860. */
  74861. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74862. /**
  74863. * Gets the options used to compile the shader.
  74864. * They can be modified to trigger a new compilation
  74865. */
  74866. readonly options: IShaderMaterialOptions;
  74867. /**
  74868. * Gets the current class name of the material e.g. "ShaderMaterial"
  74869. * Mainly use in serialization.
  74870. * @returns the class name
  74871. */
  74872. getClassName(): string;
  74873. /**
  74874. * Specifies if the material will require alpha blending
  74875. * @returns a boolean specifying if alpha blending is needed
  74876. */
  74877. needAlphaBlending(): boolean;
  74878. /**
  74879. * Specifies if this material should be rendered in alpha test mode
  74880. * @returns a boolean specifying if an alpha test is needed.
  74881. */
  74882. needAlphaTesting(): boolean;
  74883. private _checkUniform;
  74884. /**
  74885. * Set a texture in the shader.
  74886. * @param name Define the name of the uniform samplers as defined in the shader
  74887. * @param texture Define the texture to bind to this sampler
  74888. * @return the material itself allowing "fluent" like uniform updates
  74889. */
  74890. setTexture(name: string, texture: Texture): ShaderMaterial;
  74891. /**
  74892. * Set a texture array in the shader.
  74893. * @param name Define the name of the uniform sampler array as defined in the shader
  74894. * @param textures Define the list of textures to bind to this sampler
  74895. * @return the material itself allowing "fluent" like uniform updates
  74896. */
  74897. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74898. /**
  74899. * Set a float in the shader.
  74900. * @param name Define the name of the uniform as defined in the shader
  74901. * @param value Define the value to give to the uniform
  74902. * @return the material itself allowing "fluent" like uniform updates
  74903. */
  74904. setFloat(name: string, value: number): ShaderMaterial;
  74905. /**
  74906. * Set a int in the shader.
  74907. * @param name Define the name of the uniform as defined in the shader
  74908. * @param value Define the value to give to the uniform
  74909. * @return the material itself allowing "fluent" like uniform updates
  74910. */
  74911. setInt(name: string, value: number): ShaderMaterial;
  74912. /**
  74913. * Set an array of floats in the shader.
  74914. * @param name Define the name of the uniform as defined in the shader
  74915. * @param value Define the value to give to the uniform
  74916. * @return the material itself allowing "fluent" like uniform updates
  74917. */
  74918. setFloats(name: string, value: number[]): ShaderMaterial;
  74919. /**
  74920. * Set a vec3 in the shader from a Color3.
  74921. * @param name Define the name of the uniform as defined in the shader
  74922. * @param value Define the value to give to the uniform
  74923. * @return the material itself allowing "fluent" like uniform updates
  74924. */
  74925. setColor3(name: string, value: Color3): ShaderMaterial;
  74926. /**
  74927. * Set a vec3 array in the shader from a Color3 array.
  74928. * @param name Define the name of the uniform as defined in the shader
  74929. * @param value Define the value to give to the uniform
  74930. * @return the material itself allowing "fluent" like uniform updates
  74931. */
  74932. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74933. /**
  74934. * Set a vec4 in the shader from a Color4.
  74935. * @param name Define the name of the uniform as defined in the shader
  74936. * @param value Define the value to give to the uniform
  74937. * @return the material itself allowing "fluent" like uniform updates
  74938. */
  74939. setColor4(name: string, value: Color4): ShaderMaterial;
  74940. /**
  74941. * Set a vec2 in the shader from a Vector2.
  74942. * @param name Define the name of the uniform as defined in the shader
  74943. * @param value Define the value to give to the uniform
  74944. * @return the material itself allowing "fluent" like uniform updates
  74945. */
  74946. setVector2(name: string, value: Vector2): ShaderMaterial;
  74947. /**
  74948. * Set a vec3 in the shader from a Vector3.
  74949. * @param name Define the name of the uniform as defined in the shader
  74950. * @param value Define the value to give to the uniform
  74951. * @return the material itself allowing "fluent" like uniform updates
  74952. */
  74953. setVector3(name: string, value: Vector3): ShaderMaterial;
  74954. /**
  74955. * Set a vec4 in the shader from a Vector4.
  74956. * @param name Define the name of the uniform as defined in the shader
  74957. * @param value Define the value to give to the uniform
  74958. * @return the material itself allowing "fluent" like uniform updates
  74959. */
  74960. setVector4(name: string, value: Vector4): ShaderMaterial;
  74961. /**
  74962. * Set a mat4 in the shader from a Matrix.
  74963. * @param name Define the name of the uniform as defined in the shader
  74964. * @param value Define the value to give to the uniform
  74965. * @return the material itself allowing "fluent" like uniform updates
  74966. */
  74967. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74968. /**
  74969. * Set a mat3 in the shader from a Float32Array.
  74970. * @param name Define the name of the uniform as defined in the shader
  74971. * @param value Define the value to give to the uniform
  74972. * @return the material itself allowing "fluent" like uniform updates
  74973. */
  74974. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74975. /**
  74976. * Set a mat2 in the shader from a Float32Array.
  74977. * @param name Define the name of the uniform as defined in the shader
  74978. * @param value Define the value to give to the uniform
  74979. * @return the material itself allowing "fluent" like uniform updates
  74980. */
  74981. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74982. /**
  74983. * Set a vec2 array in the shader from a number array.
  74984. * @param name Define the name of the uniform as defined in the shader
  74985. * @param value Define the value to give to the uniform
  74986. * @return the material itself allowing "fluent" like uniform updates
  74987. */
  74988. setArray2(name: string, value: number[]): ShaderMaterial;
  74989. /**
  74990. * Set a vec3 array in the shader from a number array.
  74991. * @param name Define the name of the uniform as defined in the shader
  74992. * @param value Define the value to give to the uniform
  74993. * @return the material itself allowing "fluent" like uniform updates
  74994. */
  74995. setArray3(name: string, value: number[]): ShaderMaterial;
  74996. private _checkCache;
  74997. /**
  74998. * Specifies that the submesh is ready to be used
  74999. * @param mesh defines the mesh to check
  75000. * @param subMesh defines which submesh to check
  75001. * @param useInstances specifies that instances should be used
  75002. * @returns a boolean indicating that the submesh is ready or not
  75003. */
  75004. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75005. /**
  75006. * Checks if the material is ready to render the requested mesh
  75007. * @param mesh Define the mesh to render
  75008. * @param useInstances Define whether or not the material is used with instances
  75009. * @returns true if ready, otherwise false
  75010. */
  75011. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75012. /**
  75013. * Binds the world matrix to the material
  75014. * @param world defines the world transformation matrix
  75015. */
  75016. bindOnlyWorldMatrix(world: Matrix): void;
  75017. /**
  75018. * Binds the material to the mesh
  75019. * @param world defines the world transformation matrix
  75020. * @param mesh defines the mesh to bind the material to
  75021. */
  75022. bind(world: Matrix, mesh?: Mesh): void;
  75023. /**
  75024. * Gets the active textures from the material
  75025. * @returns an array of textures
  75026. */
  75027. getActiveTextures(): BaseTexture[];
  75028. /**
  75029. * Specifies if the material uses a texture
  75030. * @param texture defines the texture to check against the material
  75031. * @returns a boolean specifying if the material uses the texture
  75032. */
  75033. hasTexture(texture: BaseTexture): boolean;
  75034. /**
  75035. * Makes a duplicate of the material, and gives it a new name
  75036. * @param name defines the new name for the duplicated material
  75037. * @returns the cloned material
  75038. */
  75039. clone(name: string): ShaderMaterial;
  75040. /**
  75041. * Disposes the material
  75042. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75043. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75044. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75045. */
  75046. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75047. /**
  75048. * Serializes this material in a JSON representation
  75049. * @returns the serialized material object
  75050. */
  75051. serialize(): any;
  75052. /**
  75053. * Creates a shader material from parsed shader material data
  75054. * @param source defines the JSON represnetation of the material
  75055. * @param scene defines the hosting scene
  75056. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75057. * @returns a new material
  75058. */
  75059. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75060. }
  75061. }
  75062. declare module BABYLON {
  75063. /** @hidden */
  75064. export var clipPlaneFragmentDeclaration: {
  75065. name: string;
  75066. shader: string;
  75067. };
  75068. }
  75069. declare module BABYLON {
  75070. /** @hidden */
  75071. export var clipPlaneFragment: {
  75072. name: string;
  75073. shader: string;
  75074. };
  75075. }
  75076. declare module BABYLON {
  75077. /** @hidden */
  75078. export var colorPixelShader: {
  75079. name: string;
  75080. shader: string;
  75081. };
  75082. }
  75083. declare module BABYLON {
  75084. /** @hidden */
  75085. export var clipPlaneVertexDeclaration: {
  75086. name: string;
  75087. shader: string;
  75088. };
  75089. }
  75090. declare module BABYLON {
  75091. /** @hidden */
  75092. export var clipPlaneVertex: {
  75093. name: string;
  75094. shader: string;
  75095. };
  75096. }
  75097. declare module BABYLON {
  75098. /** @hidden */
  75099. export var colorVertexShader: {
  75100. name: string;
  75101. shader: string;
  75102. };
  75103. }
  75104. declare module BABYLON {
  75105. /**
  75106. * Line mesh
  75107. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75108. */
  75109. export class LinesMesh extends Mesh {
  75110. /**
  75111. * If vertex color should be applied to the mesh
  75112. */
  75113. readonly useVertexColor?: boolean | undefined;
  75114. /**
  75115. * If vertex alpha should be applied to the mesh
  75116. */
  75117. readonly useVertexAlpha?: boolean | undefined;
  75118. /**
  75119. * Color of the line (Default: White)
  75120. */
  75121. color: Color3;
  75122. /**
  75123. * Alpha of the line (Default: 1)
  75124. */
  75125. alpha: number;
  75126. /**
  75127. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75128. * This margin is expressed in world space coordinates, so its value may vary.
  75129. * Default value is 0.1
  75130. */
  75131. intersectionThreshold: number;
  75132. private _colorShader;
  75133. private color4;
  75134. /**
  75135. * Creates a new LinesMesh
  75136. * @param name defines the name
  75137. * @param scene defines the hosting scene
  75138. * @param parent defines the parent mesh if any
  75139. * @param source defines the optional source LinesMesh used to clone data from
  75140. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75141. * When false, achieved by calling a clone(), also passing False.
  75142. * This will make creation of children, recursive.
  75143. * @param useVertexColor defines if this LinesMesh supports vertex color
  75144. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75145. */
  75146. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75147. /**
  75148. * If vertex color should be applied to the mesh
  75149. */
  75150. useVertexColor?: boolean | undefined,
  75151. /**
  75152. * If vertex alpha should be applied to the mesh
  75153. */
  75154. useVertexAlpha?: boolean | undefined);
  75155. private _addClipPlaneDefine;
  75156. private _removeClipPlaneDefine;
  75157. isReady(): boolean;
  75158. /**
  75159. * Returns the string "LineMesh"
  75160. */
  75161. getClassName(): string;
  75162. /**
  75163. * @hidden
  75164. */
  75165. /**
  75166. * @hidden
  75167. */
  75168. material: Material;
  75169. /**
  75170. * @hidden
  75171. */
  75172. readonly checkCollisions: boolean;
  75173. /** @hidden */
  75174. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75175. /** @hidden */
  75176. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75177. /**
  75178. * Disposes of the line mesh
  75179. * @param doNotRecurse If children should be disposed
  75180. */
  75181. dispose(doNotRecurse?: boolean): void;
  75182. /**
  75183. * Returns a new LineMesh object cloned from the current one.
  75184. */
  75185. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75186. /**
  75187. * Creates a new InstancedLinesMesh object from the mesh model.
  75188. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75189. * @param name defines the name of the new instance
  75190. * @returns a new InstancedLinesMesh
  75191. */
  75192. createInstance(name: string): InstancedLinesMesh;
  75193. }
  75194. /**
  75195. * Creates an instance based on a source LinesMesh
  75196. */
  75197. export class InstancedLinesMesh extends InstancedMesh {
  75198. /**
  75199. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75200. * This margin is expressed in world space coordinates, so its value may vary.
  75201. * Initilized with the intersectionThreshold value of the source LinesMesh
  75202. */
  75203. intersectionThreshold: number;
  75204. constructor(name: string, source: LinesMesh);
  75205. /**
  75206. * Returns the string "InstancedLinesMesh".
  75207. */
  75208. getClassName(): string;
  75209. }
  75210. }
  75211. declare module BABYLON {
  75212. /**
  75213. * Mesh representing the gorund
  75214. */
  75215. export class GroundMesh extends Mesh {
  75216. /** If octree should be generated */
  75217. generateOctree: boolean;
  75218. private _heightQuads;
  75219. /** @hidden */
  75220. _subdivisionsX: number;
  75221. /** @hidden */
  75222. _subdivisionsY: number;
  75223. /** @hidden */
  75224. _width: number;
  75225. /** @hidden */
  75226. _height: number;
  75227. /** @hidden */
  75228. _minX: number;
  75229. /** @hidden */
  75230. _maxX: number;
  75231. /** @hidden */
  75232. _minZ: number;
  75233. /** @hidden */
  75234. _maxZ: number;
  75235. constructor(name: string, scene: Scene);
  75236. /**
  75237. * "GroundMesh"
  75238. * @returns "GroundMesh"
  75239. */
  75240. getClassName(): string;
  75241. /**
  75242. * The minimum of x and y subdivisions
  75243. */
  75244. readonly subdivisions: number;
  75245. /**
  75246. * X subdivisions
  75247. */
  75248. readonly subdivisionsX: number;
  75249. /**
  75250. * Y subdivisions
  75251. */
  75252. readonly subdivisionsY: number;
  75253. /**
  75254. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75255. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75256. * @param chunksCount the number of subdivisions for x and y
  75257. * @param octreeBlocksSize (Default: 32)
  75258. */
  75259. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75260. /**
  75261. * Returns a height (y) value in the Worl system :
  75262. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75263. * @param x x coordinate
  75264. * @param z z coordinate
  75265. * @returns the ground y position if (x, z) are outside the ground surface.
  75266. */
  75267. getHeightAtCoordinates(x: number, z: number): number;
  75268. /**
  75269. * Returns a normalized vector (Vector3) orthogonal to the ground
  75270. * at the ground coordinates (x, z) expressed in the World system.
  75271. * @param x x coordinate
  75272. * @param z z coordinate
  75273. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75274. */
  75275. getNormalAtCoordinates(x: number, z: number): Vector3;
  75276. /**
  75277. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75278. * at the ground coordinates (x, z) expressed in the World system.
  75279. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75280. * @param x x coordinate
  75281. * @param z z coordinate
  75282. * @param ref vector to store the result
  75283. * @returns the GroundMesh.
  75284. */
  75285. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75286. /**
  75287. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75288. * if the ground has been updated.
  75289. * This can be used in the render loop.
  75290. * @returns the GroundMesh.
  75291. */
  75292. updateCoordinateHeights(): GroundMesh;
  75293. private _getFacetAt;
  75294. private _initHeightQuads;
  75295. private _computeHeightQuads;
  75296. /**
  75297. * Serializes this ground mesh
  75298. * @param serializationObject object to write serialization to
  75299. */
  75300. serialize(serializationObject: any): void;
  75301. /**
  75302. * Parses a serialized ground mesh
  75303. * @param parsedMesh the serialized mesh
  75304. * @param scene the scene to create the ground mesh in
  75305. * @returns the created ground mesh
  75306. */
  75307. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75308. }
  75309. }
  75310. declare module BABYLON {
  75311. /**
  75312. * Interface for Physics-Joint data
  75313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75314. */
  75315. export interface PhysicsJointData {
  75316. /**
  75317. * The main pivot of the joint
  75318. */
  75319. mainPivot?: Vector3;
  75320. /**
  75321. * The connected pivot of the joint
  75322. */
  75323. connectedPivot?: Vector3;
  75324. /**
  75325. * The main axis of the joint
  75326. */
  75327. mainAxis?: Vector3;
  75328. /**
  75329. * The connected axis of the joint
  75330. */
  75331. connectedAxis?: Vector3;
  75332. /**
  75333. * The collision of the joint
  75334. */
  75335. collision?: boolean;
  75336. /**
  75337. * Native Oimo/Cannon/Energy data
  75338. */
  75339. nativeParams?: any;
  75340. }
  75341. /**
  75342. * This is a holder class for the physics joint created by the physics plugin
  75343. * It holds a set of functions to control the underlying joint
  75344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75345. */
  75346. export class PhysicsJoint {
  75347. /**
  75348. * The type of the physics joint
  75349. */
  75350. type: number;
  75351. /**
  75352. * The data for the physics joint
  75353. */
  75354. jointData: PhysicsJointData;
  75355. private _physicsJoint;
  75356. protected _physicsPlugin: IPhysicsEnginePlugin;
  75357. /**
  75358. * Initializes the physics joint
  75359. * @param type The type of the physics joint
  75360. * @param jointData The data for the physics joint
  75361. */
  75362. constructor(
  75363. /**
  75364. * The type of the physics joint
  75365. */
  75366. type: number,
  75367. /**
  75368. * The data for the physics joint
  75369. */
  75370. jointData: PhysicsJointData);
  75371. /**
  75372. * Gets the physics joint
  75373. */
  75374. /**
  75375. * Sets the physics joint
  75376. */
  75377. physicsJoint: any;
  75378. /**
  75379. * Sets the physics plugin
  75380. */
  75381. physicsPlugin: IPhysicsEnginePlugin;
  75382. /**
  75383. * Execute a function that is physics-plugin specific.
  75384. * @param {Function} func the function that will be executed.
  75385. * It accepts two parameters: the physics world and the physics joint
  75386. */
  75387. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75388. /**
  75389. * Distance-Joint type
  75390. */
  75391. static DistanceJoint: number;
  75392. /**
  75393. * Hinge-Joint type
  75394. */
  75395. static HingeJoint: number;
  75396. /**
  75397. * Ball-and-Socket joint type
  75398. */
  75399. static BallAndSocketJoint: number;
  75400. /**
  75401. * Wheel-Joint type
  75402. */
  75403. static WheelJoint: number;
  75404. /**
  75405. * Slider-Joint type
  75406. */
  75407. static SliderJoint: number;
  75408. /**
  75409. * Prismatic-Joint type
  75410. */
  75411. static PrismaticJoint: number;
  75412. /**
  75413. * Universal-Joint type
  75414. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75415. */
  75416. static UniversalJoint: number;
  75417. /**
  75418. * Hinge-Joint 2 type
  75419. */
  75420. static Hinge2Joint: number;
  75421. /**
  75422. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75423. */
  75424. static PointToPointJoint: number;
  75425. /**
  75426. * Spring-Joint type
  75427. */
  75428. static SpringJoint: number;
  75429. /**
  75430. * Lock-Joint type
  75431. */
  75432. static LockJoint: number;
  75433. }
  75434. /**
  75435. * A class representing a physics distance joint
  75436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75437. */
  75438. export class DistanceJoint extends PhysicsJoint {
  75439. /**
  75440. *
  75441. * @param jointData The data for the Distance-Joint
  75442. */
  75443. constructor(jointData: DistanceJointData);
  75444. /**
  75445. * Update the predefined distance.
  75446. * @param maxDistance The maximum preferred distance
  75447. * @param minDistance The minimum preferred distance
  75448. */
  75449. updateDistance(maxDistance: number, minDistance?: number): void;
  75450. }
  75451. /**
  75452. * Represents a Motor-Enabled Joint
  75453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75454. */
  75455. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75456. /**
  75457. * Initializes the Motor-Enabled Joint
  75458. * @param type The type of the joint
  75459. * @param jointData The physica joint data for the joint
  75460. */
  75461. constructor(type: number, jointData: PhysicsJointData);
  75462. /**
  75463. * Set the motor values.
  75464. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75465. * @param force the force to apply
  75466. * @param maxForce max force for this motor.
  75467. */
  75468. setMotor(force?: number, maxForce?: number): void;
  75469. /**
  75470. * Set the motor's limits.
  75471. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75472. * @param upperLimit The upper limit of the motor
  75473. * @param lowerLimit The lower limit of the motor
  75474. */
  75475. setLimit(upperLimit: number, lowerLimit?: number): void;
  75476. }
  75477. /**
  75478. * This class represents a single physics Hinge-Joint
  75479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75480. */
  75481. export class HingeJoint extends MotorEnabledJoint {
  75482. /**
  75483. * Initializes the Hinge-Joint
  75484. * @param jointData The joint data for the Hinge-Joint
  75485. */
  75486. constructor(jointData: PhysicsJointData);
  75487. /**
  75488. * Set the motor values.
  75489. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75490. * @param {number} force the force to apply
  75491. * @param {number} maxForce max force for this motor.
  75492. */
  75493. setMotor(force?: number, maxForce?: number): void;
  75494. /**
  75495. * Set the motor's limits.
  75496. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75497. * @param upperLimit The upper limit of the motor
  75498. * @param lowerLimit The lower limit of the motor
  75499. */
  75500. setLimit(upperLimit: number, lowerLimit?: number): void;
  75501. }
  75502. /**
  75503. * This class represents a dual hinge physics joint (same as wheel joint)
  75504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75505. */
  75506. export class Hinge2Joint extends MotorEnabledJoint {
  75507. /**
  75508. * Initializes the Hinge2-Joint
  75509. * @param jointData The joint data for the Hinge2-Joint
  75510. */
  75511. constructor(jointData: PhysicsJointData);
  75512. /**
  75513. * Set the motor values.
  75514. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75515. * @param {number} targetSpeed the speed the motor is to reach
  75516. * @param {number} maxForce max force for this motor.
  75517. * @param {motorIndex} the motor's index, 0 or 1.
  75518. */
  75519. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  75520. /**
  75521. * Set the motor limits.
  75522. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75523. * @param {number} upperLimit the upper limit
  75524. * @param {number} lowerLimit lower limit
  75525. * @param {motorIndex} the motor's index, 0 or 1.
  75526. */
  75527. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75528. }
  75529. /**
  75530. * Interface for a motor enabled joint
  75531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75532. */
  75533. export interface IMotorEnabledJoint {
  75534. /**
  75535. * Physics joint
  75536. */
  75537. physicsJoint: any;
  75538. /**
  75539. * Sets the motor of the motor-enabled joint
  75540. * @param force The force of the motor
  75541. * @param maxForce The maximum force of the motor
  75542. * @param motorIndex The index of the motor
  75543. */
  75544. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  75545. /**
  75546. * Sets the limit of the motor
  75547. * @param upperLimit The upper limit of the motor
  75548. * @param lowerLimit The lower limit of the motor
  75549. * @param motorIndex The index of the motor
  75550. */
  75551. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75552. }
  75553. /**
  75554. * Joint data for a Distance-Joint
  75555. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75556. */
  75557. export interface DistanceJointData extends PhysicsJointData {
  75558. /**
  75559. * Max distance the 2 joint objects can be apart
  75560. */
  75561. maxDistance: number;
  75562. }
  75563. /**
  75564. * Joint data from a spring joint
  75565. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75566. */
  75567. export interface SpringJointData extends PhysicsJointData {
  75568. /**
  75569. * Length of the spring
  75570. */
  75571. length: number;
  75572. /**
  75573. * Stiffness of the spring
  75574. */
  75575. stiffness: number;
  75576. /**
  75577. * Damping of the spring
  75578. */
  75579. damping: number;
  75580. /** this callback will be called when applying the force to the impostors. */
  75581. forceApplicationCallback: () => void;
  75582. }
  75583. }
  75584. declare module BABYLON {
  75585. /**
  75586. * Holds the data for the raycast result
  75587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75588. */
  75589. export class PhysicsRaycastResult {
  75590. private _hasHit;
  75591. private _hitDistance;
  75592. private _hitNormalWorld;
  75593. private _hitPointWorld;
  75594. private _rayFromWorld;
  75595. private _rayToWorld;
  75596. /**
  75597. * Gets if there was a hit
  75598. */
  75599. readonly hasHit: boolean;
  75600. /**
  75601. * Gets the distance from the hit
  75602. */
  75603. readonly hitDistance: number;
  75604. /**
  75605. * Gets the hit normal/direction in the world
  75606. */
  75607. readonly hitNormalWorld: Vector3;
  75608. /**
  75609. * Gets the hit point in the world
  75610. */
  75611. readonly hitPointWorld: Vector3;
  75612. /**
  75613. * Gets the ray "start point" of the ray in the world
  75614. */
  75615. readonly rayFromWorld: Vector3;
  75616. /**
  75617. * Gets the ray "end point" of the ray in the world
  75618. */
  75619. readonly rayToWorld: Vector3;
  75620. /**
  75621. * Sets the hit data (normal & point in world space)
  75622. * @param hitNormalWorld defines the normal in world space
  75623. * @param hitPointWorld defines the point in world space
  75624. */
  75625. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  75626. /**
  75627. * Sets the distance from the start point to the hit point
  75628. * @param distance
  75629. */
  75630. setHitDistance(distance: number): void;
  75631. /**
  75632. * Calculates the distance manually
  75633. */
  75634. calculateHitDistance(): void;
  75635. /**
  75636. * Resets all the values to default
  75637. * @param from The from point on world space
  75638. * @param to The to point on world space
  75639. */
  75640. reset(from?: Vector3, to?: Vector3): void;
  75641. }
  75642. /**
  75643. * Interface for the size containing width and height
  75644. */
  75645. interface IXYZ {
  75646. /**
  75647. * X
  75648. */
  75649. x: number;
  75650. /**
  75651. * Y
  75652. */
  75653. y: number;
  75654. /**
  75655. * Z
  75656. */
  75657. z: number;
  75658. }
  75659. }
  75660. declare module BABYLON {
  75661. /**
  75662. * Interface used to describe a physics joint
  75663. */
  75664. export interface PhysicsImpostorJoint {
  75665. /** Defines the main impostor to which the joint is linked */
  75666. mainImpostor: PhysicsImpostor;
  75667. /** Defines the impostor that is connected to the main impostor using this joint */
  75668. connectedImpostor: PhysicsImpostor;
  75669. /** Defines the joint itself */
  75670. joint: PhysicsJoint;
  75671. }
  75672. /** @hidden */
  75673. export interface IPhysicsEnginePlugin {
  75674. world: any;
  75675. name: string;
  75676. setGravity(gravity: Vector3): void;
  75677. setTimeStep(timeStep: number): void;
  75678. getTimeStep(): number;
  75679. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  75680. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75681. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75682. generatePhysicsBody(impostor: PhysicsImpostor): void;
  75683. removePhysicsBody(impostor: PhysicsImpostor): void;
  75684. generateJoint(joint: PhysicsImpostorJoint): void;
  75685. removeJoint(joint: PhysicsImpostorJoint): void;
  75686. isSupported(): boolean;
  75687. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  75688. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  75689. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75690. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75691. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75692. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75693. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  75694. getBodyMass(impostor: PhysicsImpostor): number;
  75695. getBodyFriction(impostor: PhysicsImpostor): number;
  75696. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  75697. getBodyRestitution(impostor: PhysicsImpostor): number;
  75698. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  75699. getBodyPressure?(impostor: PhysicsImpostor): number;
  75700. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  75701. getBodyStiffness?(impostor: PhysicsImpostor): number;
  75702. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  75703. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  75704. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  75705. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  75706. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  75707. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  75708. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  75709. sleepBody(impostor: PhysicsImpostor): void;
  75710. wakeUpBody(impostor: PhysicsImpostor): void;
  75711. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  75712. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  75713. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  75714. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75715. getRadius(impostor: PhysicsImpostor): number;
  75716. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  75717. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  75718. dispose(): void;
  75719. }
  75720. /**
  75721. * Interface used to define a physics engine
  75722. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  75723. */
  75724. export interface IPhysicsEngine {
  75725. /**
  75726. * Gets the gravity vector used by the simulation
  75727. */
  75728. gravity: Vector3;
  75729. /**
  75730. * Sets the gravity vector used by the simulation
  75731. * @param gravity defines the gravity vector to use
  75732. */
  75733. setGravity(gravity: Vector3): void;
  75734. /**
  75735. * Set the time step of the physics engine.
  75736. * Default is 1/60.
  75737. * To slow it down, enter 1/600 for example.
  75738. * To speed it up, 1/30
  75739. * @param newTimeStep the new timestep to apply to this world.
  75740. */
  75741. setTimeStep(newTimeStep: number): void;
  75742. /**
  75743. * Get the time step of the physics engine.
  75744. * @returns the current time step
  75745. */
  75746. getTimeStep(): number;
  75747. /**
  75748. * Release all resources
  75749. */
  75750. dispose(): void;
  75751. /**
  75752. * Gets the name of the current physics plugin
  75753. * @returns the name of the plugin
  75754. */
  75755. getPhysicsPluginName(): string;
  75756. /**
  75757. * Adding a new impostor for the impostor tracking.
  75758. * This will be done by the impostor itself.
  75759. * @param impostor the impostor to add
  75760. */
  75761. addImpostor(impostor: PhysicsImpostor): void;
  75762. /**
  75763. * Remove an impostor from the engine.
  75764. * This impostor and its mesh will not longer be updated by the physics engine.
  75765. * @param impostor the impostor to remove
  75766. */
  75767. removeImpostor(impostor: PhysicsImpostor): void;
  75768. /**
  75769. * Add a joint to the physics engine
  75770. * @param mainImpostor defines the main impostor to which the joint is added.
  75771. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  75772. * @param joint defines the joint that will connect both impostors.
  75773. */
  75774. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75775. /**
  75776. * Removes a joint from the simulation
  75777. * @param mainImpostor defines the impostor used with the joint
  75778. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  75779. * @param joint defines the joint to remove
  75780. */
  75781. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75782. /**
  75783. * Gets the current plugin used to run the simulation
  75784. * @returns current plugin
  75785. */
  75786. getPhysicsPlugin(): IPhysicsEnginePlugin;
  75787. /**
  75788. * Gets the list of physic impostors
  75789. * @returns an array of PhysicsImpostor
  75790. */
  75791. getImpostors(): Array<PhysicsImpostor>;
  75792. /**
  75793. * Gets the impostor for a physics enabled object
  75794. * @param object defines the object impersonated by the impostor
  75795. * @returns the PhysicsImpostor or null if not found
  75796. */
  75797. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  75798. /**
  75799. * Gets the impostor for a physics body object
  75800. * @param body defines physics body used by the impostor
  75801. * @returns the PhysicsImpostor or null if not found
  75802. */
  75803. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  75804. /**
  75805. * Does a raycast in the physics world
  75806. * @param from when should the ray start?
  75807. * @param to when should the ray end?
  75808. * @returns PhysicsRaycastResult
  75809. */
  75810. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  75811. /**
  75812. * Called by the scene. No need to call it.
  75813. * @param delta defines the timespam between frames
  75814. */
  75815. _step(delta: number): void;
  75816. }
  75817. }
  75818. declare module BABYLON {
  75819. /**
  75820. * The interface for the physics imposter parameters
  75821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75822. */
  75823. export interface PhysicsImpostorParameters {
  75824. /**
  75825. * The mass of the physics imposter
  75826. */
  75827. mass: number;
  75828. /**
  75829. * The friction of the physics imposter
  75830. */
  75831. friction?: number;
  75832. /**
  75833. * The coefficient of restitution of the physics imposter
  75834. */
  75835. restitution?: number;
  75836. /**
  75837. * The native options of the physics imposter
  75838. */
  75839. nativeOptions?: any;
  75840. /**
  75841. * Specifies if the parent should be ignored
  75842. */
  75843. ignoreParent?: boolean;
  75844. /**
  75845. * Specifies if bi-directional transformations should be disabled
  75846. */
  75847. disableBidirectionalTransformation?: boolean;
  75848. /**
  75849. * The pressure inside the physics imposter, soft object only
  75850. */
  75851. pressure?: number;
  75852. /**
  75853. * The stiffness the physics imposter, soft object only
  75854. */
  75855. stiffness?: number;
  75856. /**
  75857. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  75858. */
  75859. velocityIterations?: number;
  75860. /**
  75861. * The number of iterations used in maintaining consistent vertex positions, soft object only
  75862. */
  75863. positionIterations?: number;
  75864. /**
  75865. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  75866. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  75867. * Add to fix multiple points
  75868. */
  75869. fixedPoints?: number;
  75870. /**
  75871. * The collision margin around a soft object
  75872. */
  75873. margin?: number;
  75874. /**
  75875. * The collision margin around a soft object
  75876. */
  75877. damping?: number;
  75878. /**
  75879. * The path for a rope based on an extrusion
  75880. */
  75881. path?: any;
  75882. /**
  75883. * The shape of an extrusion used for a rope based on an extrusion
  75884. */
  75885. shape?: any;
  75886. }
  75887. /**
  75888. * Interface for a physics-enabled object
  75889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75890. */
  75891. export interface IPhysicsEnabledObject {
  75892. /**
  75893. * The position of the physics-enabled object
  75894. */
  75895. position: Vector3;
  75896. /**
  75897. * The rotation of the physics-enabled object
  75898. */
  75899. rotationQuaternion: Nullable<Quaternion>;
  75900. /**
  75901. * The scale of the physics-enabled object
  75902. */
  75903. scaling: Vector3;
  75904. /**
  75905. * The rotation of the physics-enabled object
  75906. */
  75907. rotation?: Vector3;
  75908. /**
  75909. * The parent of the physics-enabled object
  75910. */
  75911. parent?: any;
  75912. /**
  75913. * The bounding info of the physics-enabled object
  75914. * @returns The bounding info of the physics-enabled object
  75915. */
  75916. getBoundingInfo(): BoundingInfo;
  75917. /**
  75918. * Computes the world matrix
  75919. * @param force Specifies if the world matrix should be computed by force
  75920. * @returns A world matrix
  75921. */
  75922. computeWorldMatrix(force: boolean): Matrix;
  75923. /**
  75924. * Gets the world matrix
  75925. * @returns A world matrix
  75926. */
  75927. getWorldMatrix?(): Matrix;
  75928. /**
  75929. * Gets the child meshes
  75930. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  75931. * @returns An array of abstract meshes
  75932. */
  75933. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  75934. /**
  75935. * Gets the vertex data
  75936. * @param kind The type of vertex data
  75937. * @returns A nullable array of numbers, or a float32 array
  75938. */
  75939. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  75940. /**
  75941. * Gets the indices from the mesh
  75942. * @returns A nullable array of index arrays
  75943. */
  75944. getIndices?(): Nullable<IndicesArray>;
  75945. /**
  75946. * Gets the scene from the mesh
  75947. * @returns the indices array or null
  75948. */
  75949. getScene?(): Scene;
  75950. /**
  75951. * Gets the absolute position from the mesh
  75952. * @returns the absolute position
  75953. */
  75954. getAbsolutePosition(): Vector3;
  75955. /**
  75956. * Gets the absolute pivot point from the mesh
  75957. * @returns the absolute pivot point
  75958. */
  75959. getAbsolutePivotPoint(): Vector3;
  75960. /**
  75961. * Rotates the mesh
  75962. * @param axis The axis of rotation
  75963. * @param amount The amount of rotation
  75964. * @param space The space of the rotation
  75965. * @returns The rotation transform node
  75966. */
  75967. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  75968. /**
  75969. * Translates the mesh
  75970. * @param axis The axis of translation
  75971. * @param distance The distance of translation
  75972. * @param space The space of the translation
  75973. * @returns The transform node
  75974. */
  75975. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  75976. /**
  75977. * Sets the absolute position of the mesh
  75978. * @param absolutePosition The absolute position of the mesh
  75979. * @returns The transform node
  75980. */
  75981. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  75982. /**
  75983. * Gets the class name of the mesh
  75984. * @returns The class name
  75985. */
  75986. getClassName(): string;
  75987. }
  75988. /**
  75989. * Represents a physics imposter
  75990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75991. */
  75992. export class PhysicsImpostor {
  75993. /**
  75994. * The physics-enabled object used as the physics imposter
  75995. */
  75996. object: IPhysicsEnabledObject;
  75997. /**
  75998. * The type of the physics imposter
  75999. */
  76000. type: number;
  76001. private _options;
  76002. private _scene?;
  76003. /**
  76004. * The default object size of the imposter
  76005. */
  76006. static DEFAULT_OBJECT_SIZE: Vector3;
  76007. /**
  76008. * The identity quaternion of the imposter
  76009. */
  76010. static IDENTITY_QUATERNION: Quaternion;
  76011. /** @hidden */
  76012. _pluginData: any;
  76013. private _physicsEngine;
  76014. private _physicsBody;
  76015. private _bodyUpdateRequired;
  76016. private _onBeforePhysicsStepCallbacks;
  76017. private _onAfterPhysicsStepCallbacks;
  76018. /** @hidden */
  76019. _onPhysicsCollideCallbacks: Array<{
  76020. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76021. otherImpostors: Array<PhysicsImpostor>;
  76022. }>;
  76023. private _deltaPosition;
  76024. private _deltaRotation;
  76025. private _deltaRotationConjugated;
  76026. /** @hidden */
  76027. _isFromLine: boolean;
  76028. private _parent;
  76029. private _isDisposed;
  76030. private static _tmpVecs;
  76031. private static _tmpQuat;
  76032. /**
  76033. * Specifies if the physics imposter is disposed
  76034. */
  76035. readonly isDisposed: boolean;
  76036. /**
  76037. * Gets the mass of the physics imposter
  76038. */
  76039. mass: number;
  76040. /**
  76041. * Gets the coefficient of friction
  76042. */
  76043. /**
  76044. * Sets the coefficient of friction
  76045. */
  76046. friction: number;
  76047. /**
  76048. * Gets the coefficient of restitution
  76049. */
  76050. /**
  76051. * Sets the coefficient of restitution
  76052. */
  76053. restitution: number;
  76054. /**
  76055. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  76056. */
  76057. /**
  76058. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  76059. */
  76060. pressure: number;
  76061. /**
  76062. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76063. */
  76064. /**
  76065. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76066. */
  76067. stiffness: number;
  76068. /**
  76069. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76070. */
  76071. /**
  76072. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76073. */
  76074. velocityIterations: number;
  76075. /**
  76076. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76077. */
  76078. /**
  76079. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76080. */
  76081. positionIterations: number;
  76082. /**
  76083. * The unique id of the physics imposter
  76084. * set by the physics engine when adding this impostor to the array
  76085. */
  76086. uniqueId: number;
  76087. /**
  76088. * @hidden
  76089. */
  76090. soft: boolean;
  76091. /**
  76092. * @hidden
  76093. */
  76094. segments: number;
  76095. private _joints;
  76096. /**
  76097. * Initializes the physics imposter
  76098. * @param object The physics-enabled object used as the physics imposter
  76099. * @param type The type of the physics imposter
  76100. * @param _options The options for the physics imposter
  76101. * @param _scene The Babylon scene
  76102. */
  76103. constructor(
  76104. /**
  76105. * The physics-enabled object used as the physics imposter
  76106. */
  76107. object: IPhysicsEnabledObject,
  76108. /**
  76109. * The type of the physics imposter
  76110. */
  76111. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76112. /**
  76113. * This function will completly initialize this impostor.
  76114. * It will create a new body - but only if this mesh has no parent.
  76115. * If it has, this impostor will not be used other than to define the impostor
  76116. * of the child mesh.
  76117. * @hidden
  76118. */
  76119. _init(): void;
  76120. private _getPhysicsParent;
  76121. /**
  76122. * Should a new body be generated.
  76123. * @returns boolean specifying if body initialization is required
  76124. */
  76125. isBodyInitRequired(): boolean;
  76126. /**
  76127. * Sets the updated scaling
  76128. * @param updated Specifies if the scaling is updated
  76129. */
  76130. setScalingUpdated(): void;
  76131. /**
  76132. * Force a regeneration of this or the parent's impostor's body.
  76133. * Use under cautious - This will remove all joints already implemented.
  76134. */
  76135. forceUpdate(): void;
  76136. /**
  76137. * Gets the body that holds this impostor. Either its own, or its parent.
  76138. */
  76139. /**
  76140. * Set the physics body. Used mainly by the physics engine/plugin
  76141. */
  76142. physicsBody: any;
  76143. /**
  76144. * Get the parent of the physics imposter
  76145. * @returns Physics imposter or null
  76146. */
  76147. /**
  76148. * Sets the parent of the physics imposter
  76149. */
  76150. parent: Nullable<PhysicsImpostor>;
  76151. /**
  76152. * Resets the update flags
  76153. */
  76154. resetUpdateFlags(): void;
  76155. /**
  76156. * Gets the object extend size
  76157. * @returns the object extend size
  76158. */
  76159. getObjectExtendSize(): Vector3;
  76160. /**
  76161. * Gets the object center
  76162. * @returns The object center
  76163. */
  76164. getObjectCenter(): Vector3;
  76165. /**
  76166. * Get a specific parametes from the options parameter
  76167. * @param paramName The object parameter name
  76168. * @returns The object parameter
  76169. */
  76170. getParam(paramName: string): any;
  76171. /**
  76172. * Sets a specific parameter in the options given to the physics plugin
  76173. * @param paramName The parameter name
  76174. * @param value The value of the parameter
  76175. */
  76176. setParam(paramName: string, value: number): void;
  76177. /**
  76178. * Specifically change the body's mass option. Won't recreate the physics body object
  76179. * @param mass The mass of the physics imposter
  76180. */
  76181. setMass(mass: number): void;
  76182. /**
  76183. * Gets the linear velocity
  76184. * @returns linear velocity or null
  76185. */
  76186. getLinearVelocity(): Nullable<Vector3>;
  76187. /**
  76188. * Sets the linear velocity
  76189. * @param velocity linear velocity or null
  76190. */
  76191. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76192. /**
  76193. * Gets the angular velocity
  76194. * @returns angular velocity or null
  76195. */
  76196. getAngularVelocity(): Nullable<Vector3>;
  76197. /**
  76198. * Sets the angular velocity
  76199. * @param velocity The velocity or null
  76200. */
  76201. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76202. /**
  76203. * Execute a function with the physics plugin native code
  76204. * Provide a function the will have two variables - the world object and the physics body object
  76205. * @param func The function to execute with the physics plugin native code
  76206. */
  76207. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76208. /**
  76209. * Register a function that will be executed before the physics world is stepping forward
  76210. * @param func The function to execute before the physics world is stepped forward
  76211. */
  76212. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76213. /**
  76214. * Unregister a function that will be executed before the physics world is stepping forward
  76215. * @param func The function to execute before the physics world is stepped forward
  76216. */
  76217. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76218. /**
  76219. * Register a function that will be executed after the physics step
  76220. * @param func The function to execute after physics step
  76221. */
  76222. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76223. /**
  76224. * Unregisters a function that will be executed after the physics step
  76225. * @param func The function to execute after physics step
  76226. */
  76227. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76228. /**
  76229. * register a function that will be executed when this impostor collides against a different body
  76230. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76231. * @param func Callback that is executed on collision
  76232. */
  76233. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76234. /**
  76235. * Unregisters the physics imposter on contact
  76236. * @param collideAgainst The physics object to collide against
  76237. * @param func Callback to execute on collision
  76238. */
  76239. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76240. private _tmpQuat;
  76241. private _tmpQuat2;
  76242. /**
  76243. * Get the parent rotation
  76244. * @returns The parent rotation
  76245. */
  76246. getParentsRotation(): Quaternion;
  76247. /**
  76248. * this function is executed by the physics engine.
  76249. */
  76250. beforeStep: () => void;
  76251. /**
  76252. * this function is executed by the physics engine
  76253. */
  76254. afterStep: () => void;
  76255. /**
  76256. * Legacy collision detection event support
  76257. */
  76258. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76259. /**
  76260. * event and body object due to cannon's event-based architecture.
  76261. */
  76262. onCollide: (e: {
  76263. body: any;
  76264. }) => void;
  76265. /**
  76266. * Apply a force
  76267. * @param force The force to apply
  76268. * @param contactPoint The contact point for the force
  76269. * @returns The physics imposter
  76270. */
  76271. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76272. /**
  76273. * Apply an impulse
  76274. * @param force The impulse force
  76275. * @param contactPoint The contact point for the impulse force
  76276. * @returns The physics imposter
  76277. */
  76278. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76279. /**
  76280. * A help function to create a joint
  76281. * @param otherImpostor A physics imposter used to create a joint
  76282. * @param jointType The type of joint
  76283. * @param jointData The data for the joint
  76284. * @returns The physics imposter
  76285. */
  76286. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76287. /**
  76288. * Add a joint to this impostor with a different impostor
  76289. * @param otherImpostor A physics imposter used to add a joint
  76290. * @param joint The joint to add
  76291. * @returns The physics imposter
  76292. */
  76293. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76294. /**
  76295. * Add an anchor to a cloth impostor
  76296. * @param otherImpostor rigid impostor to anchor to
  76297. * @param width ratio across width from 0 to 1
  76298. * @param height ratio up height from 0 to 1
  76299. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  76300. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  76301. * @returns impostor the soft imposter
  76302. */
  76303. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76304. /**
  76305. * Add a hook to a rope impostor
  76306. * @param otherImpostor rigid impostor to anchor to
  76307. * @param length ratio across rope from 0 to 1
  76308. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  76309. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  76310. * @returns impostor the rope imposter
  76311. */
  76312. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76313. /**
  76314. * Will keep this body still, in a sleep mode.
  76315. * @returns the physics imposter
  76316. */
  76317. sleep(): PhysicsImpostor;
  76318. /**
  76319. * Wake the body up.
  76320. * @returns The physics imposter
  76321. */
  76322. wakeUp(): PhysicsImpostor;
  76323. /**
  76324. * Clones the physics imposter
  76325. * @param newObject The physics imposter clones to this physics-enabled object
  76326. * @returns A nullable physics imposter
  76327. */
  76328. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76329. /**
  76330. * Disposes the physics imposter
  76331. */
  76332. dispose(): void;
  76333. /**
  76334. * Sets the delta position
  76335. * @param position The delta position amount
  76336. */
  76337. setDeltaPosition(position: Vector3): void;
  76338. /**
  76339. * Sets the delta rotation
  76340. * @param rotation The delta rotation amount
  76341. */
  76342. setDeltaRotation(rotation: Quaternion): void;
  76343. /**
  76344. * Gets the box size of the physics imposter and stores the result in the input parameter
  76345. * @param result Stores the box size
  76346. * @returns The physics imposter
  76347. */
  76348. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76349. /**
  76350. * Gets the radius of the physics imposter
  76351. * @returns Radius of the physics imposter
  76352. */
  76353. getRadius(): number;
  76354. /**
  76355. * Sync a bone with this impostor
  76356. * @param bone The bone to sync to the impostor.
  76357. * @param boneMesh The mesh that the bone is influencing.
  76358. * @param jointPivot The pivot of the joint / bone in local space.
  76359. * @param distToJoint Optional distance from the impostor to the joint.
  76360. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76361. */
  76362. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76363. /**
  76364. * Sync impostor to a bone
  76365. * @param bone The bone that the impostor will be synced to.
  76366. * @param boneMesh The mesh that the bone is influencing.
  76367. * @param jointPivot The pivot of the joint / bone in local space.
  76368. * @param distToJoint Optional distance from the impostor to the joint.
  76369. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76370. * @param boneAxis Optional vector3 axis the bone is aligned with
  76371. */
  76372. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76373. /**
  76374. * No-Imposter type
  76375. */
  76376. static NoImpostor: number;
  76377. /**
  76378. * Sphere-Imposter type
  76379. */
  76380. static SphereImpostor: number;
  76381. /**
  76382. * Box-Imposter type
  76383. */
  76384. static BoxImpostor: number;
  76385. /**
  76386. * Plane-Imposter type
  76387. */
  76388. static PlaneImpostor: number;
  76389. /**
  76390. * Mesh-imposter type
  76391. */
  76392. static MeshImpostor: number;
  76393. /**
  76394. * Cylinder-Imposter type
  76395. */
  76396. static CylinderImpostor: number;
  76397. /**
  76398. * Particle-Imposter type
  76399. */
  76400. static ParticleImpostor: number;
  76401. /**
  76402. * Heightmap-Imposter type
  76403. */
  76404. static HeightmapImpostor: number;
  76405. /**
  76406. * ConvexHull-Impostor type (Ammo.js plugin only)
  76407. */
  76408. static ConvexHullImpostor: number;
  76409. /**
  76410. * Rope-Imposter type
  76411. */
  76412. static RopeImpostor: number;
  76413. /**
  76414. * Cloth-Imposter type
  76415. */
  76416. static ClothImpostor: number;
  76417. /**
  76418. * Softbody-Imposter type
  76419. */
  76420. static SoftbodyImpostor: number;
  76421. }
  76422. }
  76423. declare module BABYLON {
  76424. /**
  76425. * @hidden
  76426. **/
  76427. export class _CreationDataStorage {
  76428. closePath?: boolean;
  76429. closeArray?: boolean;
  76430. idx: number[];
  76431. dashSize: number;
  76432. gapSize: number;
  76433. path3D: Path3D;
  76434. pathArray: Vector3[][];
  76435. arc: number;
  76436. radius: number;
  76437. cap: number;
  76438. tessellation: number;
  76439. }
  76440. /**
  76441. * @hidden
  76442. **/
  76443. class _InstanceDataStorage {
  76444. visibleInstances: any;
  76445. batchCache: _InstancesBatch;
  76446. instancesBufferSize: number;
  76447. instancesBuffer: Nullable<Buffer>;
  76448. instancesData: Float32Array;
  76449. overridenInstanceCount: number;
  76450. isFrozen: boolean;
  76451. previousBatch: Nullable<_InstancesBatch>;
  76452. hardwareInstancedRendering: boolean;
  76453. sideOrientation: number;
  76454. }
  76455. /**
  76456. * @hidden
  76457. **/
  76458. export class _InstancesBatch {
  76459. mustReturn: boolean;
  76460. visibleInstances: Nullable<InstancedMesh[]>[];
  76461. renderSelf: boolean[];
  76462. hardwareInstancedRendering: boolean[];
  76463. }
  76464. /**
  76465. * Class used to represent renderable models
  76466. */
  76467. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76468. /**
  76469. * Mesh side orientation : usually the external or front surface
  76470. */
  76471. static readonly FRONTSIDE: number;
  76472. /**
  76473. * Mesh side orientation : usually the internal or back surface
  76474. */
  76475. static readonly BACKSIDE: number;
  76476. /**
  76477. * Mesh side orientation : both internal and external or front and back surfaces
  76478. */
  76479. static readonly DOUBLESIDE: number;
  76480. /**
  76481. * Mesh side orientation : by default, `FRONTSIDE`
  76482. */
  76483. static readonly DEFAULTSIDE: number;
  76484. /**
  76485. * Mesh cap setting : no cap
  76486. */
  76487. static readonly NO_CAP: number;
  76488. /**
  76489. * Mesh cap setting : one cap at the beginning of the mesh
  76490. */
  76491. static readonly CAP_START: number;
  76492. /**
  76493. * Mesh cap setting : one cap at the end of the mesh
  76494. */
  76495. static readonly CAP_END: number;
  76496. /**
  76497. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76498. */
  76499. static readonly CAP_ALL: number;
  76500. /**
  76501. * Mesh pattern setting : no flip or rotate
  76502. */
  76503. static readonly NO_FLIP: number;
  76504. /**
  76505. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  76506. */
  76507. static readonly FLIP_TILE: number;
  76508. /**
  76509. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  76510. */
  76511. static readonly ROTATE_TILE: number;
  76512. /**
  76513. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  76514. */
  76515. static readonly FLIP_ROW: number;
  76516. /**
  76517. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  76518. */
  76519. static readonly ROTATE_ROW: number;
  76520. /**
  76521. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  76522. */
  76523. static readonly FLIP_N_ROTATE_TILE: number;
  76524. /**
  76525. * Mesh pattern setting : rotate pattern and rotate
  76526. */
  76527. static readonly FLIP_N_ROTATE_ROW: number;
  76528. /**
  76529. * Mesh tile positioning : part tiles same on left/right or top/bottom
  76530. */
  76531. static readonly CENTER: number;
  76532. /**
  76533. * Mesh tile positioning : part tiles on left
  76534. */
  76535. static readonly LEFT: number;
  76536. /**
  76537. * Mesh tile positioning : part tiles on right
  76538. */
  76539. static readonly RIGHT: number;
  76540. /**
  76541. * Mesh tile positioning : part tiles on top
  76542. */
  76543. static readonly TOP: number;
  76544. /**
  76545. * Mesh tile positioning : part tiles on bottom
  76546. */
  76547. static readonly BOTTOM: number;
  76548. /**
  76549. * Gets the default side orientation.
  76550. * @param orientation the orientation to value to attempt to get
  76551. * @returns the default orientation
  76552. * @hidden
  76553. */
  76554. static _GetDefaultSideOrientation(orientation?: number): number;
  76555. private _internalMeshDataInfo;
  76556. /**
  76557. * An event triggered before rendering the mesh
  76558. */
  76559. readonly onBeforeRenderObservable: Observable<Mesh>;
  76560. /**
  76561. * An event triggered before binding the mesh
  76562. */
  76563. readonly onBeforeBindObservable: Observable<Mesh>;
  76564. /**
  76565. * An event triggered after rendering the mesh
  76566. */
  76567. readonly onAfterRenderObservable: Observable<Mesh>;
  76568. /**
  76569. * An event triggered before drawing the mesh
  76570. */
  76571. readonly onBeforeDrawObservable: Observable<Mesh>;
  76572. private _onBeforeDrawObserver;
  76573. /**
  76574. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  76575. */
  76576. onBeforeDraw: () => void;
  76577. /**
  76578. * Gets the delay loading state of the mesh (when delay loading is turned on)
  76579. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  76580. */
  76581. delayLoadState: number;
  76582. /**
  76583. * Gets the list of instances created from this mesh
  76584. * it is not supposed to be modified manually.
  76585. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  76586. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76587. */
  76588. instances: InstancedMesh[];
  76589. /**
  76590. * Gets the file containing delay loading data for this mesh
  76591. */
  76592. delayLoadingFile: string;
  76593. /** @hidden */
  76594. _binaryInfo: any;
  76595. /**
  76596. * User defined function used to change how LOD level selection is done
  76597. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76598. */
  76599. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  76600. /**
  76601. * Gets or sets the morph target manager
  76602. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76603. */
  76604. morphTargetManager: Nullable<MorphTargetManager>;
  76605. /** @hidden */
  76606. _creationDataStorage: Nullable<_CreationDataStorage>;
  76607. /** @hidden */
  76608. _geometry: Nullable<Geometry>;
  76609. /** @hidden */
  76610. _delayInfo: Array<string>;
  76611. /** @hidden */
  76612. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  76613. /** @hidden */
  76614. _instanceDataStorage: _InstanceDataStorage;
  76615. private _effectiveMaterial;
  76616. /** @hidden */
  76617. _shouldGenerateFlatShading: boolean;
  76618. /** @hidden */
  76619. _originalBuilderSideOrientation: number;
  76620. /**
  76621. * Use this property to change the original side orientation defined at construction time
  76622. */
  76623. overrideMaterialSideOrientation: Nullable<number>;
  76624. /**
  76625. * Gets the source mesh (the one used to clone this one from)
  76626. */
  76627. readonly source: Nullable<Mesh>;
  76628. /**
  76629. * Gets or sets a boolean indicating that this mesh does not use index buffer
  76630. */
  76631. isUnIndexed: boolean;
  76632. /**
  76633. * @constructor
  76634. * @param name The value used by scene.getMeshByName() to do a lookup.
  76635. * @param scene The scene to add this mesh to.
  76636. * @param parent The parent of this mesh, if it has one
  76637. * @param source An optional Mesh from which geometry is shared, cloned.
  76638. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76639. * When false, achieved by calling a clone(), also passing False.
  76640. * This will make creation of children, recursive.
  76641. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  76642. */
  76643. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  76644. /**
  76645. * Gets the class name
  76646. * @returns the string "Mesh".
  76647. */
  76648. getClassName(): string;
  76649. /** @hidden */
  76650. readonly _isMesh: boolean;
  76651. /**
  76652. * Returns a description of this mesh
  76653. * @param fullDetails define if full details about this mesh must be used
  76654. * @returns a descriptive string representing this mesh
  76655. */
  76656. toString(fullDetails?: boolean): string;
  76657. /** @hidden */
  76658. _unBindEffect(): void;
  76659. /**
  76660. * Gets a boolean indicating if this mesh has LOD
  76661. */
  76662. readonly hasLODLevels: boolean;
  76663. /**
  76664. * Gets the list of MeshLODLevel associated with the current mesh
  76665. * @returns an array of MeshLODLevel
  76666. */
  76667. getLODLevels(): MeshLODLevel[];
  76668. private _sortLODLevels;
  76669. /**
  76670. * Add a mesh as LOD level triggered at the given distance.
  76671. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76672. * @param distance The distance from the center of the object to show this level
  76673. * @param mesh The mesh to be added as LOD level (can be null)
  76674. * @return This mesh (for chaining)
  76675. */
  76676. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  76677. /**
  76678. * Returns the LOD level mesh at the passed distance or null if not found.
  76679. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76680. * @param distance The distance from the center of the object to show this level
  76681. * @returns a Mesh or `null`
  76682. */
  76683. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  76684. /**
  76685. * Remove a mesh from the LOD array
  76686. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76687. * @param mesh defines the mesh to be removed
  76688. * @return This mesh (for chaining)
  76689. */
  76690. removeLODLevel(mesh: Mesh): Mesh;
  76691. /**
  76692. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  76693. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76694. * @param camera defines the camera to use to compute distance
  76695. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  76696. * @return This mesh (for chaining)
  76697. */
  76698. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  76699. /**
  76700. * Gets the mesh internal Geometry object
  76701. */
  76702. readonly geometry: Nullable<Geometry>;
  76703. /**
  76704. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  76705. * @returns the total number of vertices
  76706. */
  76707. getTotalVertices(): number;
  76708. /**
  76709. * Returns the content of an associated vertex buffer
  76710. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76711. * - VertexBuffer.PositionKind
  76712. * - VertexBuffer.UVKind
  76713. * - VertexBuffer.UV2Kind
  76714. * - VertexBuffer.UV3Kind
  76715. * - VertexBuffer.UV4Kind
  76716. * - VertexBuffer.UV5Kind
  76717. * - VertexBuffer.UV6Kind
  76718. * - VertexBuffer.ColorKind
  76719. * - VertexBuffer.MatricesIndicesKind
  76720. * - VertexBuffer.MatricesIndicesExtraKind
  76721. * - VertexBuffer.MatricesWeightsKind
  76722. * - VertexBuffer.MatricesWeightsExtraKind
  76723. * @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
  76724. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  76725. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  76726. */
  76727. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  76728. /**
  76729. * Returns the mesh VertexBuffer object from the requested `kind`
  76730. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76731. * - VertexBuffer.PositionKind
  76732. * - VertexBuffer.NormalKind
  76733. * - VertexBuffer.UVKind
  76734. * - VertexBuffer.UV2Kind
  76735. * - VertexBuffer.UV3Kind
  76736. * - VertexBuffer.UV4Kind
  76737. * - VertexBuffer.UV5Kind
  76738. * - VertexBuffer.UV6Kind
  76739. * - VertexBuffer.ColorKind
  76740. * - VertexBuffer.MatricesIndicesKind
  76741. * - VertexBuffer.MatricesIndicesExtraKind
  76742. * - VertexBuffer.MatricesWeightsKind
  76743. * - VertexBuffer.MatricesWeightsExtraKind
  76744. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  76745. */
  76746. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  76747. /**
  76748. * Tests if a specific vertex buffer is associated with this mesh
  76749. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76750. * - VertexBuffer.PositionKind
  76751. * - VertexBuffer.NormalKind
  76752. * - VertexBuffer.UVKind
  76753. * - VertexBuffer.UV2Kind
  76754. * - VertexBuffer.UV3Kind
  76755. * - VertexBuffer.UV4Kind
  76756. * - VertexBuffer.UV5Kind
  76757. * - VertexBuffer.UV6Kind
  76758. * - VertexBuffer.ColorKind
  76759. * - VertexBuffer.MatricesIndicesKind
  76760. * - VertexBuffer.MatricesIndicesExtraKind
  76761. * - VertexBuffer.MatricesWeightsKind
  76762. * - VertexBuffer.MatricesWeightsExtraKind
  76763. * @returns a boolean
  76764. */
  76765. isVerticesDataPresent(kind: string): boolean;
  76766. /**
  76767. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  76768. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76769. * - VertexBuffer.PositionKind
  76770. * - VertexBuffer.UVKind
  76771. * - VertexBuffer.UV2Kind
  76772. * - VertexBuffer.UV3Kind
  76773. * - VertexBuffer.UV4Kind
  76774. * - VertexBuffer.UV5Kind
  76775. * - VertexBuffer.UV6Kind
  76776. * - VertexBuffer.ColorKind
  76777. * - VertexBuffer.MatricesIndicesKind
  76778. * - VertexBuffer.MatricesIndicesExtraKind
  76779. * - VertexBuffer.MatricesWeightsKind
  76780. * - VertexBuffer.MatricesWeightsExtraKind
  76781. * @returns a boolean
  76782. */
  76783. isVertexBufferUpdatable(kind: string): boolean;
  76784. /**
  76785. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  76786. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76787. * - VertexBuffer.PositionKind
  76788. * - VertexBuffer.NormalKind
  76789. * - VertexBuffer.UVKind
  76790. * - VertexBuffer.UV2Kind
  76791. * - VertexBuffer.UV3Kind
  76792. * - VertexBuffer.UV4Kind
  76793. * - VertexBuffer.UV5Kind
  76794. * - VertexBuffer.UV6Kind
  76795. * - VertexBuffer.ColorKind
  76796. * - VertexBuffer.MatricesIndicesKind
  76797. * - VertexBuffer.MatricesIndicesExtraKind
  76798. * - VertexBuffer.MatricesWeightsKind
  76799. * - VertexBuffer.MatricesWeightsExtraKind
  76800. * @returns an array of strings
  76801. */
  76802. getVerticesDataKinds(): string[];
  76803. /**
  76804. * Returns a positive integer : the total number of indices in this mesh geometry.
  76805. * @returns the numner of indices or zero if the mesh has no geometry.
  76806. */
  76807. getTotalIndices(): number;
  76808. /**
  76809. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76810. * @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.
  76811. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  76812. * @returns the indices array or an empty array if the mesh has no geometry
  76813. */
  76814. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  76815. readonly isBlocked: boolean;
  76816. /**
  76817. * Determine if the current mesh is ready to be rendered
  76818. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76819. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  76820. * @returns true if all associated assets are ready (material, textures, shaders)
  76821. */
  76822. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  76823. /**
  76824. * 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.
  76825. */
  76826. readonly areNormalsFrozen: boolean;
  76827. /**
  76828. * 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.
  76829. * @returns the current mesh
  76830. */
  76831. freezeNormals(): Mesh;
  76832. /**
  76833. * 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
  76834. * @returns the current mesh
  76835. */
  76836. unfreezeNormals(): Mesh;
  76837. /**
  76838. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  76839. */
  76840. overridenInstanceCount: number;
  76841. /** @hidden */
  76842. _preActivate(): Mesh;
  76843. /** @hidden */
  76844. _preActivateForIntermediateRendering(renderId: number): Mesh;
  76845. /** @hidden */
  76846. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  76847. /**
  76848. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76849. * This means the mesh underlying bounding box and sphere are recomputed.
  76850. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76851. * @returns the current mesh
  76852. */
  76853. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  76854. /** @hidden */
  76855. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  76856. /**
  76857. * This function will subdivide the mesh into multiple submeshes
  76858. * @param count defines the expected number of submeshes
  76859. */
  76860. subdivide(count: number): void;
  76861. /**
  76862. * Copy a FloatArray into a specific associated vertex buffer
  76863. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76864. * - VertexBuffer.PositionKind
  76865. * - VertexBuffer.UVKind
  76866. * - VertexBuffer.UV2Kind
  76867. * - VertexBuffer.UV3Kind
  76868. * - VertexBuffer.UV4Kind
  76869. * - VertexBuffer.UV5Kind
  76870. * - VertexBuffer.UV6Kind
  76871. * - VertexBuffer.ColorKind
  76872. * - VertexBuffer.MatricesIndicesKind
  76873. * - VertexBuffer.MatricesIndicesExtraKind
  76874. * - VertexBuffer.MatricesWeightsKind
  76875. * - VertexBuffer.MatricesWeightsExtraKind
  76876. * @param data defines the data source
  76877. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76878. * @param stride defines the data stride size (can be null)
  76879. * @returns the current mesh
  76880. */
  76881. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76882. /**
  76883. * Flags an associated vertex buffer as updatable
  76884. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  76885. * - VertexBuffer.PositionKind
  76886. * - VertexBuffer.UVKind
  76887. * - VertexBuffer.UV2Kind
  76888. * - VertexBuffer.UV3Kind
  76889. * - VertexBuffer.UV4Kind
  76890. * - VertexBuffer.UV5Kind
  76891. * - VertexBuffer.UV6Kind
  76892. * - VertexBuffer.ColorKind
  76893. * - VertexBuffer.MatricesIndicesKind
  76894. * - VertexBuffer.MatricesIndicesExtraKind
  76895. * - VertexBuffer.MatricesWeightsKind
  76896. * - VertexBuffer.MatricesWeightsExtraKind
  76897. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76898. */
  76899. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  76900. /**
  76901. * Sets the mesh global Vertex Buffer
  76902. * @param buffer defines the buffer to use
  76903. * @returns the current mesh
  76904. */
  76905. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  76906. /**
  76907. * Update a specific associated vertex buffer
  76908. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76909. * - VertexBuffer.PositionKind
  76910. * - VertexBuffer.UVKind
  76911. * - VertexBuffer.UV2Kind
  76912. * - VertexBuffer.UV3Kind
  76913. * - VertexBuffer.UV4Kind
  76914. * - VertexBuffer.UV5Kind
  76915. * - VertexBuffer.UV6Kind
  76916. * - VertexBuffer.ColorKind
  76917. * - VertexBuffer.MatricesIndicesKind
  76918. * - VertexBuffer.MatricesIndicesExtraKind
  76919. * - VertexBuffer.MatricesWeightsKind
  76920. * - VertexBuffer.MatricesWeightsExtraKind
  76921. * @param data defines the data source
  76922. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  76923. * @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)
  76924. * @returns the current mesh
  76925. */
  76926. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76927. /**
  76928. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  76929. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  76930. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  76931. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  76932. * @returns the current mesh
  76933. */
  76934. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  76935. /**
  76936. * Creates a un-shared specific occurence of the geometry for the mesh.
  76937. * @returns the current mesh
  76938. */
  76939. makeGeometryUnique(): Mesh;
  76940. /**
  76941. * Set the index buffer of this mesh
  76942. * @param indices defines the source data
  76943. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  76944. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  76945. * @returns the current mesh
  76946. */
  76947. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  76948. /**
  76949. * Update the current index buffer
  76950. * @param indices defines the source data
  76951. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  76952. * @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)
  76953. * @returns the current mesh
  76954. */
  76955. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  76956. /**
  76957. * Invert the geometry to move from a right handed system to a left handed one.
  76958. * @returns the current mesh
  76959. */
  76960. toLeftHanded(): Mesh;
  76961. /** @hidden */
  76962. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  76963. /** @hidden */
  76964. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  76965. /**
  76966. * Registers for this mesh a javascript function called just before the rendering process
  76967. * @param func defines the function to call before rendering this mesh
  76968. * @returns the current mesh
  76969. */
  76970. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  76971. /**
  76972. * Disposes a previously registered javascript function called before the rendering
  76973. * @param func defines the function to remove
  76974. * @returns the current mesh
  76975. */
  76976. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  76977. /**
  76978. * Registers for this mesh a javascript function called just after the rendering is complete
  76979. * @param func defines the function to call after rendering this mesh
  76980. * @returns the current mesh
  76981. */
  76982. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  76983. /**
  76984. * Disposes a previously registered javascript function called after the rendering.
  76985. * @param func defines the function to remove
  76986. * @returns the current mesh
  76987. */
  76988. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  76989. /** @hidden */
  76990. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  76991. /** @hidden */
  76992. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  76993. /** @hidden */
  76994. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  76995. /** @hidden */
  76996. _rebuild(): void;
  76997. /** @hidden */
  76998. _freeze(): void;
  76999. /** @hidden */
  77000. _unFreeze(): void;
  77001. /**
  77002. * 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
  77003. * @param subMesh defines the subMesh to render
  77004. * @param enableAlphaMode defines if alpha mode can be changed
  77005. * @returns the current mesh
  77006. */
  77007. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77008. private _onBeforeDraw;
  77009. /**
  77010. * Renormalize the mesh and patch it up if there are no weights
  77011. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77012. * However in the case of zero weights then we set just a single influence to 1.
  77013. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77014. */
  77015. cleanMatrixWeights(): void;
  77016. private normalizeSkinFourWeights;
  77017. private normalizeSkinWeightsAndExtra;
  77018. /**
  77019. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77020. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77021. * the user know there was an issue with importing the mesh
  77022. * @returns a validation object with skinned, valid and report string
  77023. */
  77024. validateSkinning(): {
  77025. skinned: boolean;
  77026. valid: boolean;
  77027. report: string;
  77028. };
  77029. /** @hidden */
  77030. _checkDelayState(): Mesh;
  77031. private _queueLoad;
  77032. /**
  77033. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77034. * A mesh is in the frustum if its bounding box intersects the frustum
  77035. * @param frustumPlanes defines the frustum to test
  77036. * @returns true if the mesh is in the frustum planes
  77037. */
  77038. isInFrustum(frustumPlanes: Plane[]): boolean;
  77039. /**
  77040. * Sets the mesh material by the material or multiMaterial `id` property
  77041. * @param id is a string identifying the material or the multiMaterial
  77042. * @returns the current mesh
  77043. */
  77044. setMaterialByID(id: string): Mesh;
  77045. /**
  77046. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77047. * @returns an array of IAnimatable
  77048. */
  77049. getAnimatables(): IAnimatable[];
  77050. /**
  77051. * Modifies the mesh geometry according to the passed transformation matrix.
  77052. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77053. * The mesh normals are modified using the same transformation.
  77054. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77055. * @param transform defines the transform matrix to use
  77056. * @see http://doc.babylonjs.com/resources/baking_transformations
  77057. * @returns the current mesh
  77058. */
  77059. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77060. /**
  77061. * Modifies the mesh geometry according to its own current World Matrix.
  77062. * The mesh World Matrix is then reset.
  77063. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77064. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77065. * @see http://doc.babylonjs.com/resources/baking_transformations
  77066. * @returns the current mesh
  77067. */
  77068. bakeCurrentTransformIntoVertices(): Mesh;
  77069. /** @hidden */
  77070. readonly _positions: Nullable<Vector3[]>;
  77071. /** @hidden */
  77072. _resetPointsArrayCache(): Mesh;
  77073. /** @hidden */
  77074. _generatePointsArray(): boolean;
  77075. /**
  77076. * Returns a new Mesh object generated from the current mesh properties.
  77077. * This method must not get confused with createInstance()
  77078. * @param name is a string, the name given to the new mesh
  77079. * @param newParent can be any Node object (default `null`)
  77080. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77081. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77082. * @returns a new mesh
  77083. */
  77084. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77085. /**
  77086. * Releases resources associated with this mesh.
  77087. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77088. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77089. */
  77090. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77091. /**
  77092. * Modifies the mesh geometry according to a displacement map.
  77093. * 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.
  77094. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77095. * @param url is a string, the URL from the image file is to be downloaded.
  77096. * @param minHeight is the lower limit of the displacement.
  77097. * @param maxHeight is the upper limit of the displacement.
  77098. * @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.
  77099. * @param uvOffset is an optional vector2 used to offset UV.
  77100. * @param uvScale is an optional vector2 used to scale UV.
  77101. * @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.
  77102. * @returns the Mesh.
  77103. */
  77104. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77105. /**
  77106. * Modifies the mesh geometry according to a displacementMap buffer.
  77107. * 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.
  77108. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77109. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77110. * @param heightMapWidth is the width of the buffer image.
  77111. * @param heightMapHeight is the height of the buffer image.
  77112. * @param minHeight is the lower limit of the displacement.
  77113. * @param maxHeight is the upper limit of the displacement.
  77114. * @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.
  77115. * @param uvOffset is an optional vector2 used to offset UV.
  77116. * @param uvScale is an optional vector2 used to scale UV.
  77117. * @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.
  77118. * @returns the Mesh.
  77119. */
  77120. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77121. /**
  77122. * Modify the mesh to get a flat shading rendering.
  77123. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77124. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77125. * @returns current mesh
  77126. */
  77127. convertToFlatShadedMesh(): Mesh;
  77128. /**
  77129. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77130. * In other words, more vertices, no more indices and a single bigger VBO.
  77131. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77132. * @returns current mesh
  77133. */
  77134. convertToUnIndexedMesh(): Mesh;
  77135. /**
  77136. * Inverses facet orientations.
  77137. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77138. * @param flipNormals will also inverts the normals
  77139. * @returns current mesh
  77140. */
  77141. flipFaces(flipNormals?: boolean): Mesh;
  77142. /**
  77143. * Increase the number of facets and hence vertices in a mesh
  77144. * Vertex normals are interpolated from existing vertex normals
  77145. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77146. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  77147. */
  77148. increaseVertices(numberPerEdge: number): void;
  77149. /**
  77150. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  77151. * This will undo any application of covertToFlatShadedMesh
  77152. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77153. */
  77154. forceSharedVertices(): void;
  77155. /** @hidden */
  77156. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77157. /** @hidden */
  77158. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77159. /**
  77160. * Creates a new InstancedMesh object from the mesh model.
  77161. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77162. * @param name defines the name of the new instance
  77163. * @returns a new InstancedMesh
  77164. */
  77165. createInstance(name: string): InstancedMesh;
  77166. /**
  77167. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77168. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77169. * @returns the current mesh
  77170. */
  77171. synchronizeInstances(): Mesh;
  77172. /**
  77173. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77174. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77175. * This should be used together with the simplification to avoid disappearing triangles.
  77176. * @param successCallback an optional success callback to be called after the optimization finished.
  77177. * @returns the current mesh
  77178. */
  77179. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77180. /**
  77181. * Serialize current mesh
  77182. * @param serializationObject defines the object which will receive the serialization data
  77183. */
  77184. serialize(serializationObject: any): void;
  77185. /** @hidden */
  77186. _syncGeometryWithMorphTargetManager(): void;
  77187. /** @hidden */
  77188. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77189. /**
  77190. * Returns a new Mesh object parsed from the source provided.
  77191. * @param parsedMesh is the source
  77192. * @param scene defines the hosting scene
  77193. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77194. * @returns a new Mesh
  77195. */
  77196. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77197. /**
  77198. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77199. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77200. * @param name defines the name of the mesh to create
  77201. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77202. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77203. * @param closePath creates a seam between the first and the last points of each path of the path array
  77204. * @param offset is taken in account only if the `pathArray` is containing a single path
  77205. * @param scene defines the hosting scene
  77206. * @param updatable defines if the mesh must be flagged as updatable
  77207. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77208. * @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)
  77209. * @returns a new Mesh
  77210. */
  77211. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77212. /**
  77213. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77214. * @param name defines the name of the mesh to create
  77215. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77216. * @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
  77217. * @param scene defines the hosting scene
  77218. * @param updatable defines if the mesh must be flagged as updatable
  77219. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77220. * @returns a new Mesh
  77221. */
  77222. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77223. /**
  77224. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77225. * @param name defines the name of the mesh to create
  77226. * @param size sets the size (float) of each box side (default 1)
  77227. * @param scene defines the hosting scene
  77228. * @param updatable defines if the mesh must be flagged as updatable
  77229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77230. * @returns a new Mesh
  77231. */
  77232. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77233. /**
  77234. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77235. * @param name defines the name of the mesh to create
  77236. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77237. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77238. * @param scene defines the hosting scene
  77239. * @param updatable defines if the mesh must be flagged as updatable
  77240. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77241. * @returns a new Mesh
  77242. */
  77243. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77244. /**
  77245. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  77246. * @param name defines the name of the mesh to create
  77247. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77248. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77249. * @param scene defines the hosting scene
  77250. * @returns a new Mesh
  77251. */
  77252. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  77253. /**
  77254. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77255. * @param name defines the name of the mesh to create
  77256. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77257. * @param diameterTop set the top cap diameter (floats, default 1)
  77258. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77259. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77260. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77261. * @param scene defines the hosting scene
  77262. * @param updatable defines if the mesh must be flagged as updatable
  77263. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77264. * @returns a new Mesh
  77265. */
  77266. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77267. /**
  77268. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77269. * @param name defines the name of the mesh to create
  77270. * @param diameter sets the diameter size (float) of the torus (default 1)
  77271. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77272. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77273. * @param scene defines the hosting scene
  77274. * @param updatable defines if the mesh must be flagged as updatable
  77275. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77276. * @returns a new Mesh
  77277. */
  77278. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77279. /**
  77280. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77281. * @param name defines the name of the mesh to create
  77282. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77283. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77284. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77285. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77286. * @param p the number of windings on X axis (positive integers, default 2)
  77287. * @param q the number of windings on Y axis (positive integers, default 3)
  77288. * @param scene defines the hosting scene
  77289. * @param updatable defines if the mesh must be flagged as updatable
  77290. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77291. * @returns a new Mesh
  77292. */
  77293. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77294. /**
  77295. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77296. * @param name defines the name of the mesh to create
  77297. * @param points is an array successive Vector3
  77298. * @param scene defines the hosting scene
  77299. * @param updatable defines if the mesh must be flagged as updatable
  77300. * @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).
  77301. * @returns a new Mesh
  77302. */
  77303. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77304. /**
  77305. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77306. * @param name defines the name of the mesh to create
  77307. * @param points is an array successive Vector3
  77308. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77309. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77310. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77311. * @param scene defines the hosting scene
  77312. * @param updatable defines if the mesh must be flagged as updatable
  77313. * @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)
  77314. * @returns a new Mesh
  77315. */
  77316. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77317. /**
  77318. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77319. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77320. * 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.
  77321. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77322. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77323. * Remember you can only change the shape positions, not their number when updating a polygon.
  77324. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77325. * @param name defines the name of the mesh to create
  77326. * @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
  77327. * @param scene defines the hosting scene
  77328. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77329. * @param updatable defines if the mesh must be flagged as updatable
  77330. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77331. * @param earcutInjection can be used to inject your own earcut reference
  77332. * @returns a new Mesh
  77333. */
  77334. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77335. /**
  77336. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77337. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77338. * @param name defines the name of the mesh to create
  77339. * @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
  77340. * @param depth defines the height of extrusion
  77341. * @param scene defines the hosting scene
  77342. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77343. * @param updatable defines if the mesh must be flagged as updatable
  77344. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77345. * @param earcutInjection can be used to inject your own earcut reference
  77346. * @returns a new Mesh
  77347. */
  77348. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77349. /**
  77350. * Creates an extruded shape mesh.
  77351. * 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
  77352. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77353. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77354. * @param name defines the name of the mesh to create
  77355. * @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
  77356. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77357. * @param scale is the value to scale the shape
  77358. * @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
  77359. * @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
  77360. * @param scene defines the hosting scene
  77361. * @param updatable defines if the mesh must be flagged as updatable
  77362. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77363. * @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)
  77364. * @returns a new Mesh
  77365. */
  77366. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77367. /**
  77368. * Creates an custom extruded shape mesh.
  77369. * The custom extrusion is a parametric shape.
  77370. * It has no predefined shape. Its final shape will depend on the input parameters.
  77371. * Please consider using the same method from the MeshBuilder class instead
  77372. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77373. * @param name defines the name of the mesh to create
  77374. * @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
  77375. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77376. * @param scaleFunction is a custom Javascript function called on each path point
  77377. * @param rotationFunction is a custom Javascript function called on each path point
  77378. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77379. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77380. * @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
  77381. * @param scene defines the hosting scene
  77382. * @param updatable defines if the mesh must be flagged as updatable
  77383. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77384. * @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)
  77385. * @returns a new Mesh
  77386. */
  77387. 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;
  77388. /**
  77389. * Creates lathe mesh.
  77390. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77391. * Please consider using the same method from the MeshBuilder class instead
  77392. * @param name defines the name of the mesh to create
  77393. * @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
  77394. * @param radius is the radius value of the lathe
  77395. * @param tessellation is the side number of the lathe.
  77396. * @param scene defines the hosting scene
  77397. * @param updatable defines if the mesh must be flagged as updatable
  77398. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77399. * @returns a new Mesh
  77400. */
  77401. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77402. /**
  77403. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77404. * @param name defines the name of the mesh to create
  77405. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77406. * @param scene defines the hosting scene
  77407. * @param updatable defines if the mesh must be flagged as updatable
  77408. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77409. * @returns a new Mesh
  77410. */
  77411. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77412. /**
  77413. * Creates a ground mesh.
  77414. * Please consider using the same method from the MeshBuilder class instead
  77415. * @param name defines the name of the mesh to create
  77416. * @param width set the width of the ground
  77417. * @param height set the height of the ground
  77418. * @param subdivisions sets the number of subdivisions per side
  77419. * @param scene defines the hosting scene
  77420. * @param updatable defines if the mesh must be flagged as updatable
  77421. * @returns a new Mesh
  77422. */
  77423. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77424. /**
  77425. * Creates a tiled ground mesh.
  77426. * Please consider using the same method from the MeshBuilder class instead
  77427. * @param name defines the name of the mesh to create
  77428. * @param xmin set the ground minimum X coordinate
  77429. * @param zmin set the ground minimum Y coordinate
  77430. * @param xmax set the ground maximum X coordinate
  77431. * @param zmax set the ground maximum Z coordinate
  77432. * @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
  77433. * @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
  77434. * @param scene defines the hosting scene
  77435. * @param updatable defines if the mesh must be flagged as updatable
  77436. * @returns a new Mesh
  77437. */
  77438. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77439. w: number;
  77440. h: number;
  77441. }, precision: {
  77442. w: number;
  77443. h: number;
  77444. }, scene: Scene, updatable?: boolean): Mesh;
  77445. /**
  77446. * Creates a ground mesh from a height map.
  77447. * Please consider using the same method from the MeshBuilder class instead
  77448. * @see http://doc.babylonjs.com/babylon101/height_map
  77449. * @param name defines the name of the mesh to create
  77450. * @param url sets the URL of the height map image resource
  77451. * @param width set the ground width size
  77452. * @param height set the ground height size
  77453. * @param subdivisions sets the number of subdivision per side
  77454. * @param minHeight is the minimum altitude on the ground
  77455. * @param maxHeight is the maximum altitude on the ground
  77456. * @param scene defines the hosting scene
  77457. * @param updatable defines if the mesh must be flagged as updatable
  77458. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77459. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77460. * @returns a new Mesh
  77461. */
  77462. 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;
  77463. /**
  77464. * Creates a tube mesh.
  77465. * The tube is a parametric shape.
  77466. * It has no predefined shape. Its final shape will depend on the input parameters.
  77467. * Please consider using the same method from the MeshBuilder class instead
  77468. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77469. * @param name defines the name of the mesh to create
  77470. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77471. * @param radius sets the tube radius size
  77472. * @param tessellation is the number of sides on the tubular surface
  77473. * @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
  77474. * @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
  77475. * @param scene defines the hosting scene
  77476. * @param updatable defines if the mesh must be flagged as updatable
  77477. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77478. * @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)
  77479. * @returns a new Mesh
  77480. */
  77481. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77482. (i: number, distance: number): number;
  77483. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77484. /**
  77485. * Creates a polyhedron mesh.
  77486. * Please consider using the same method from the MeshBuilder class instead.
  77487. * * 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
  77488. * * The parameter `size` (positive float, default 1) sets the polygon size
  77489. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77490. * * 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`
  77491. * * 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
  77492. * * 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)`)
  77493. * * 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
  77494. * * 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
  77495. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77496. * * If you create a double-sided mesh, you can choose what parts of 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
  77497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77498. * @param name defines the name of the mesh to create
  77499. * @param options defines the options used to create the mesh
  77500. * @param scene defines the hosting scene
  77501. * @returns a new Mesh
  77502. */
  77503. static CreatePolyhedron(name: string, options: {
  77504. type?: number;
  77505. size?: number;
  77506. sizeX?: number;
  77507. sizeY?: number;
  77508. sizeZ?: number;
  77509. custom?: any;
  77510. faceUV?: Vector4[];
  77511. faceColors?: Color4[];
  77512. updatable?: boolean;
  77513. sideOrientation?: number;
  77514. }, scene: Scene): Mesh;
  77515. /**
  77516. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77517. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77518. * * 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`)
  77519. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77520. * * 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
  77521. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77522. * * If you create a double-sided mesh, you can choose what parts of 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
  77523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77524. * @param name defines the name of the mesh
  77525. * @param options defines the options used to create the mesh
  77526. * @param scene defines the hosting scene
  77527. * @returns a new Mesh
  77528. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77529. */
  77530. static CreateIcoSphere(name: string, options: {
  77531. radius?: number;
  77532. flat?: boolean;
  77533. subdivisions?: number;
  77534. sideOrientation?: number;
  77535. updatable?: boolean;
  77536. }, scene: Scene): Mesh;
  77537. /**
  77538. * Creates a decal mesh.
  77539. * Please consider using the same method from the MeshBuilder class instead.
  77540. * A decal is a mesh usually applied as a model onto the surface of another mesh
  77541. * @param name defines the name of the mesh
  77542. * @param sourceMesh defines the mesh receiving the decal
  77543. * @param position sets the position of the decal in world coordinates
  77544. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  77545. * @param size sets the decal scaling
  77546. * @param angle sets the angle to rotate the decal
  77547. * @returns a new Mesh
  77548. */
  77549. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  77550. /**
  77551. * Prepare internal position array for software CPU skinning
  77552. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  77553. */
  77554. setPositionsForCPUSkinning(): Float32Array;
  77555. /**
  77556. * Prepare internal normal array for software CPU skinning
  77557. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  77558. */
  77559. setNormalsForCPUSkinning(): Float32Array;
  77560. /**
  77561. * Updates the vertex buffer by applying transformation from the bones
  77562. * @param skeleton defines the skeleton to apply to current mesh
  77563. * @returns the current mesh
  77564. */
  77565. applySkeleton(skeleton: Skeleton): Mesh;
  77566. /**
  77567. * 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
  77568. * @param meshes defines the list of meshes to scan
  77569. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  77570. */
  77571. static MinMax(meshes: AbstractMesh[]): {
  77572. min: Vector3;
  77573. max: Vector3;
  77574. };
  77575. /**
  77576. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  77577. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  77578. * @returns a vector3
  77579. */
  77580. static Center(meshesOrMinMaxVector: {
  77581. min: Vector3;
  77582. max: Vector3;
  77583. } | AbstractMesh[]): Vector3;
  77584. /**
  77585. * Merge the array of meshes into a single mesh for performance reasons.
  77586. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  77587. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  77588. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  77589. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  77590. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  77591. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  77592. * @returns a new mesh
  77593. */
  77594. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  77595. /** @hidden */
  77596. addInstance(instance: InstancedMesh): void;
  77597. /** @hidden */
  77598. removeInstance(instance: InstancedMesh): void;
  77599. }
  77600. }
  77601. declare module BABYLON {
  77602. /**
  77603. * Interface used to define Action
  77604. */
  77605. export interface IAction {
  77606. /**
  77607. * Trigger for the action
  77608. */
  77609. trigger: number;
  77610. /** Options of the trigger */
  77611. triggerOptions: any;
  77612. /**
  77613. * Gets the trigger parameters
  77614. * @returns the trigger parameters
  77615. */
  77616. getTriggerParameter(): any;
  77617. /**
  77618. * Internal only - executes current action event
  77619. * @hidden
  77620. */
  77621. _executeCurrent(evt?: ActionEvent): void;
  77622. /**
  77623. * Serialize placeholder for child classes
  77624. * @param parent of child
  77625. * @returns the serialized object
  77626. */
  77627. serialize(parent: any): any;
  77628. /**
  77629. * Internal only
  77630. * @hidden
  77631. */
  77632. _prepare(): void;
  77633. /**
  77634. * Internal only - manager for action
  77635. * @hidden
  77636. */
  77637. _actionManager: AbstractActionManager;
  77638. /**
  77639. * Adds action to chain of actions, may be a DoNothingAction
  77640. * @param action defines the next action to execute
  77641. * @returns The action passed in
  77642. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77643. */
  77644. then(action: IAction): IAction;
  77645. }
  77646. /**
  77647. * The action to be carried out following a trigger
  77648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77649. */
  77650. export class Action implements IAction {
  77651. /** the trigger, with or without parameters, for the action */
  77652. triggerOptions: any;
  77653. /**
  77654. * Trigger for the action
  77655. */
  77656. trigger: number;
  77657. /**
  77658. * Internal only - manager for action
  77659. * @hidden
  77660. */
  77661. _actionManager: ActionManager;
  77662. private _nextActiveAction;
  77663. private _child;
  77664. private _condition?;
  77665. private _triggerParameter;
  77666. /**
  77667. * An event triggered prior to action being executed.
  77668. */
  77669. onBeforeExecuteObservable: Observable<Action>;
  77670. /**
  77671. * Creates a new Action
  77672. * @param triggerOptions the trigger, with or without parameters, for the action
  77673. * @param condition an optional determinant of action
  77674. */
  77675. constructor(
  77676. /** the trigger, with or without parameters, for the action */
  77677. triggerOptions: any, condition?: Condition);
  77678. /**
  77679. * Internal only
  77680. * @hidden
  77681. */
  77682. _prepare(): void;
  77683. /**
  77684. * Gets the trigger parameters
  77685. * @returns the trigger parameters
  77686. */
  77687. getTriggerParameter(): any;
  77688. /**
  77689. * Internal only - executes current action event
  77690. * @hidden
  77691. */
  77692. _executeCurrent(evt?: ActionEvent): void;
  77693. /**
  77694. * Execute placeholder for child classes
  77695. * @param evt optional action event
  77696. */
  77697. execute(evt?: ActionEvent): void;
  77698. /**
  77699. * Skips to next active action
  77700. */
  77701. skipToNextActiveAction(): void;
  77702. /**
  77703. * Adds action to chain of actions, may be a DoNothingAction
  77704. * @param action defines the next action to execute
  77705. * @returns The action passed in
  77706. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77707. */
  77708. then(action: Action): Action;
  77709. /**
  77710. * Internal only
  77711. * @hidden
  77712. */
  77713. _getProperty(propertyPath: string): string;
  77714. /**
  77715. * Internal only
  77716. * @hidden
  77717. */
  77718. _getEffectiveTarget(target: any, propertyPath: string): any;
  77719. /**
  77720. * Serialize placeholder for child classes
  77721. * @param parent of child
  77722. * @returns the serialized object
  77723. */
  77724. serialize(parent: any): any;
  77725. /**
  77726. * Internal only called by serialize
  77727. * @hidden
  77728. */
  77729. protected _serialize(serializedAction: any, parent?: any): any;
  77730. /**
  77731. * Internal only
  77732. * @hidden
  77733. */
  77734. static _SerializeValueAsString: (value: any) => string;
  77735. /**
  77736. * Internal only
  77737. * @hidden
  77738. */
  77739. static _GetTargetProperty: (target: Scene | Node) => {
  77740. name: string;
  77741. targetType: string;
  77742. value: string;
  77743. };
  77744. }
  77745. }
  77746. declare module BABYLON {
  77747. /**
  77748. * A Condition applied to an Action
  77749. */
  77750. export class Condition {
  77751. /**
  77752. * Internal only - manager for action
  77753. * @hidden
  77754. */
  77755. _actionManager: ActionManager;
  77756. /**
  77757. * Internal only
  77758. * @hidden
  77759. */
  77760. _evaluationId: number;
  77761. /**
  77762. * Internal only
  77763. * @hidden
  77764. */
  77765. _currentResult: boolean;
  77766. /**
  77767. * Creates a new Condition
  77768. * @param actionManager the manager of the action the condition is applied to
  77769. */
  77770. constructor(actionManager: ActionManager);
  77771. /**
  77772. * Check if the current condition is valid
  77773. * @returns a boolean
  77774. */
  77775. isValid(): boolean;
  77776. /**
  77777. * Internal only
  77778. * @hidden
  77779. */
  77780. _getProperty(propertyPath: string): string;
  77781. /**
  77782. * Internal only
  77783. * @hidden
  77784. */
  77785. _getEffectiveTarget(target: any, propertyPath: string): any;
  77786. /**
  77787. * Serialize placeholder for child classes
  77788. * @returns the serialized object
  77789. */
  77790. serialize(): any;
  77791. /**
  77792. * Internal only
  77793. * @hidden
  77794. */
  77795. protected _serialize(serializedCondition: any): any;
  77796. }
  77797. /**
  77798. * Defines specific conditional operators as extensions of Condition
  77799. */
  77800. export class ValueCondition extends Condition {
  77801. /** path to specify the property of the target the conditional operator uses */
  77802. propertyPath: string;
  77803. /** the value compared by the conditional operator against the current value of the property */
  77804. value: any;
  77805. /** the conditional operator, default ValueCondition.IsEqual */
  77806. operator: number;
  77807. /**
  77808. * Internal only
  77809. * @hidden
  77810. */
  77811. private static _IsEqual;
  77812. /**
  77813. * Internal only
  77814. * @hidden
  77815. */
  77816. private static _IsDifferent;
  77817. /**
  77818. * Internal only
  77819. * @hidden
  77820. */
  77821. private static _IsGreater;
  77822. /**
  77823. * Internal only
  77824. * @hidden
  77825. */
  77826. private static _IsLesser;
  77827. /**
  77828. * returns the number for IsEqual
  77829. */
  77830. static readonly IsEqual: number;
  77831. /**
  77832. * Returns the number for IsDifferent
  77833. */
  77834. static readonly IsDifferent: number;
  77835. /**
  77836. * Returns the number for IsGreater
  77837. */
  77838. static readonly IsGreater: number;
  77839. /**
  77840. * Returns the number for IsLesser
  77841. */
  77842. static readonly IsLesser: number;
  77843. /**
  77844. * Internal only The action manager for the condition
  77845. * @hidden
  77846. */
  77847. _actionManager: ActionManager;
  77848. /**
  77849. * Internal only
  77850. * @hidden
  77851. */
  77852. private _target;
  77853. /**
  77854. * Internal only
  77855. * @hidden
  77856. */
  77857. private _effectiveTarget;
  77858. /**
  77859. * Internal only
  77860. * @hidden
  77861. */
  77862. private _property;
  77863. /**
  77864. * Creates a new ValueCondition
  77865. * @param actionManager manager for the action the condition applies to
  77866. * @param target for the action
  77867. * @param propertyPath path to specify the property of the target the conditional operator uses
  77868. * @param value the value compared by the conditional operator against the current value of the property
  77869. * @param operator the conditional operator, default ValueCondition.IsEqual
  77870. */
  77871. constructor(actionManager: ActionManager, target: any,
  77872. /** path to specify the property of the target the conditional operator uses */
  77873. propertyPath: string,
  77874. /** the value compared by the conditional operator against the current value of the property */
  77875. value: any,
  77876. /** the conditional operator, default ValueCondition.IsEqual */
  77877. operator?: number);
  77878. /**
  77879. * Compares the given value with the property value for the specified conditional operator
  77880. * @returns the result of the comparison
  77881. */
  77882. isValid(): boolean;
  77883. /**
  77884. * Serialize the ValueCondition into a JSON compatible object
  77885. * @returns serialization object
  77886. */
  77887. serialize(): any;
  77888. /**
  77889. * Gets the name of the conditional operator for the ValueCondition
  77890. * @param operator the conditional operator
  77891. * @returns the name
  77892. */
  77893. static GetOperatorName(operator: number): string;
  77894. }
  77895. /**
  77896. * Defines a predicate condition as an extension of Condition
  77897. */
  77898. export class PredicateCondition extends Condition {
  77899. /** defines the predicate function used to validate the condition */
  77900. predicate: () => boolean;
  77901. /**
  77902. * Internal only - manager for action
  77903. * @hidden
  77904. */
  77905. _actionManager: ActionManager;
  77906. /**
  77907. * Creates a new PredicateCondition
  77908. * @param actionManager manager for the action the condition applies to
  77909. * @param predicate defines the predicate function used to validate the condition
  77910. */
  77911. constructor(actionManager: ActionManager,
  77912. /** defines the predicate function used to validate the condition */
  77913. predicate: () => boolean);
  77914. /**
  77915. * @returns the validity of the predicate condition
  77916. */
  77917. isValid(): boolean;
  77918. }
  77919. /**
  77920. * Defines a state condition as an extension of Condition
  77921. */
  77922. export class StateCondition extends Condition {
  77923. /** Value to compare with target state */
  77924. value: string;
  77925. /**
  77926. * Internal only - manager for action
  77927. * @hidden
  77928. */
  77929. _actionManager: ActionManager;
  77930. /**
  77931. * Internal only
  77932. * @hidden
  77933. */
  77934. private _target;
  77935. /**
  77936. * Creates a new StateCondition
  77937. * @param actionManager manager for the action the condition applies to
  77938. * @param target of the condition
  77939. * @param value to compare with target state
  77940. */
  77941. constructor(actionManager: ActionManager, target: any,
  77942. /** Value to compare with target state */
  77943. value: string);
  77944. /**
  77945. * Gets a boolean indicating if the current condition is met
  77946. * @returns the validity of the state
  77947. */
  77948. isValid(): boolean;
  77949. /**
  77950. * Serialize the StateCondition into a JSON compatible object
  77951. * @returns serialization object
  77952. */
  77953. serialize(): any;
  77954. }
  77955. }
  77956. declare module BABYLON {
  77957. /**
  77958. * This defines an action responsible to toggle a boolean once triggered.
  77959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77960. */
  77961. export class SwitchBooleanAction extends Action {
  77962. /**
  77963. * The path to the boolean property in the target object
  77964. */
  77965. propertyPath: string;
  77966. private _target;
  77967. private _effectiveTarget;
  77968. private _property;
  77969. /**
  77970. * Instantiate the action
  77971. * @param triggerOptions defines the trigger options
  77972. * @param target defines the object containing the boolean
  77973. * @param propertyPath defines the path to the boolean property in the target object
  77974. * @param condition defines the trigger related conditions
  77975. */
  77976. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77977. /** @hidden */
  77978. _prepare(): void;
  77979. /**
  77980. * Execute the action toggle the boolean value.
  77981. */
  77982. execute(): void;
  77983. /**
  77984. * Serializes the actions and its related information.
  77985. * @param parent defines the object to serialize in
  77986. * @returns the serialized object
  77987. */
  77988. serialize(parent: any): any;
  77989. }
  77990. /**
  77991. * This defines an action responsible to set a the state field of the target
  77992. * to a desired value once triggered.
  77993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77994. */
  77995. export class SetStateAction extends Action {
  77996. /**
  77997. * The value to store in the state field.
  77998. */
  77999. value: string;
  78000. private _target;
  78001. /**
  78002. * Instantiate the action
  78003. * @param triggerOptions defines the trigger options
  78004. * @param target defines the object containing the state property
  78005. * @param value defines the value to store in the state field
  78006. * @param condition defines the trigger related conditions
  78007. */
  78008. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78009. /**
  78010. * Execute the action and store the value on the target state property.
  78011. */
  78012. execute(): void;
  78013. /**
  78014. * Serializes the actions and its related information.
  78015. * @param parent defines the object to serialize in
  78016. * @returns the serialized object
  78017. */
  78018. serialize(parent: any): any;
  78019. }
  78020. /**
  78021. * This defines an action responsible to set a property of the target
  78022. * to a desired value once triggered.
  78023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78024. */
  78025. export class SetValueAction extends Action {
  78026. /**
  78027. * The path of the property to set in the target.
  78028. */
  78029. propertyPath: string;
  78030. /**
  78031. * The value to set in the property
  78032. */
  78033. value: any;
  78034. private _target;
  78035. private _effectiveTarget;
  78036. private _property;
  78037. /**
  78038. * Instantiate the action
  78039. * @param triggerOptions defines the trigger options
  78040. * @param target defines the object containing the property
  78041. * @param propertyPath defines the path of the property to set in the target
  78042. * @param value defines the value to set in the property
  78043. * @param condition defines the trigger related conditions
  78044. */
  78045. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78046. /** @hidden */
  78047. _prepare(): void;
  78048. /**
  78049. * Execute the action and set the targetted property to the desired value.
  78050. */
  78051. execute(): void;
  78052. /**
  78053. * Serializes the actions and its related information.
  78054. * @param parent defines the object to serialize in
  78055. * @returns the serialized object
  78056. */
  78057. serialize(parent: any): any;
  78058. }
  78059. /**
  78060. * This defines an action responsible to increment the target value
  78061. * to a desired value once triggered.
  78062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78063. */
  78064. export class IncrementValueAction extends Action {
  78065. /**
  78066. * The path of the property to increment in the target.
  78067. */
  78068. propertyPath: string;
  78069. /**
  78070. * The value we should increment the property by.
  78071. */
  78072. value: any;
  78073. private _target;
  78074. private _effectiveTarget;
  78075. private _property;
  78076. /**
  78077. * Instantiate the action
  78078. * @param triggerOptions defines the trigger options
  78079. * @param target defines the object containing the property
  78080. * @param propertyPath defines the path of the property to increment in the target
  78081. * @param value defines the value value we should increment the property by
  78082. * @param condition defines the trigger related conditions
  78083. */
  78084. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78085. /** @hidden */
  78086. _prepare(): void;
  78087. /**
  78088. * Execute the action and increment the target of the value amount.
  78089. */
  78090. execute(): void;
  78091. /**
  78092. * Serializes the actions and its related information.
  78093. * @param parent defines the object to serialize in
  78094. * @returns the serialized object
  78095. */
  78096. serialize(parent: any): any;
  78097. }
  78098. /**
  78099. * This defines an action responsible to start an animation once triggered.
  78100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78101. */
  78102. export class PlayAnimationAction extends Action {
  78103. /**
  78104. * Where the animation should start (animation frame)
  78105. */
  78106. from: number;
  78107. /**
  78108. * Where the animation should stop (animation frame)
  78109. */
  78110. to: number;
  78111. /**
  78112. * Define if the animation should loop or stop after the first play.
  78113. */
  78114. loop?: boolean;
  78115. private _target;
  78116. /**
  78117. * Instantiate the action
  78118. * @param triggerOptions defines the trigger options
  78119. * @param target defines the target animation or animation name
  78120. * @param from defines from where the animation should start (animation frame)
  78121. * @param end defines where the animation should stop (animation frame)
  78122. * @param loop defines if the animation should loop or stop after the first play
  78123. * @param condition defines the trigger related conditions
  78124. */
  78125. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78126. /** @hidden */
  78127. _prepare(): void;
  78128. /**
  78129. * Execute the action and play the animation.
  78130. */
  78131. execute(): void;
  78132. /**
  78133. * Serializes the actions and its related information.
  78134. * @param parent defines the object to serialize in
  78135. * @returns the serialized object
  78136. */
  78137. serialize(parent: any): any;
  78138. }
  78139. /**
  78140. * This defines an action responsible to stop an animation once triggered.
  78141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78142. */
  78143. export class StopAnimationAction extends Action {
  78144. private _target;
  78145. /**
  78146. * Instantiate the action
  78147. * @param triggerOptions defines the trigger options
  78148. * @param target defines the target animation or animation name
  78149. * @param condition defines the trigger related conditions
  78150. */
  78151. constructor(triggerOptions: any, target: any, condition?: Condition);
  78152. /** @hidden */
  78153. _prepare(): void;
  78154. /**
  78155. * Execute the action and stop the animation.
  78156. */
  78157. execute(): void;
  78158. /**
  78159. * Serializes the actions and its related information.
  78160. * @param parent defines the object to serialize in
  78161. * @returns the serialized object
  78162. */
  78163. serialize(parent: any): any;
  78164. }
  78165. /**
  78166. * This defines an action responsible that does nothing once triggered.
  78167. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78168. */
  78169. export class DoNothingAction extends Action {
  78170. /**
  78171. * Instantiate the action
  78172. * @param triggerOptions defines the trigger options
  78173. * @param condition defines the trigger related conditions
  78174. */
  78175. constructor(triggerOptions?: any, condition?: Condition);
  78176. /**
  78177. * Execute the action and do nothing.
  78178. */
  78179. execute(): void;
  78180. /**
  78181. * Serializes the actions and its related information.
  78182. * @param parent defines the object to serialize in
  78183. * @returns the serialized object
  78184. */
  78185. serialize(parent: any): any;
  78186. }
  78187. /**
  78188. * This defines an action responsible to trigger several actions once triggered.
  78189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78190. */
  78191. export class CombineAction extends Action {
  78192. /**
  78193. * The list of aggregated animations to run.
  78194. */
  78195. children: Action[];
  78196. /**
  78197. * Instantiate the action
  78198. * @param triggerOptions defines the trigger options
  78199. * @param children defines the list of aggregated animations to run
  78200. * @param condition defines the trigger related conditions
  78201. */
  78202. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78203. /** @hidden */
  78204. _prepare(): void;
  78205. /**
  78206. * Execute the action and executes all the aggregated actions.
  78207. */
  78208. execute(evt: ActionEvent): void;
  78209. /**
  78210. * Serializes the actions and its related information.
  78211. * @param parent defines the object to serialize in
  78212. * @returns the serialized object
  78213. */
  78214. serialize(parent: any): any;
  78215. }
  78216. /**
  78217. * This defines an action responsible to run code (external event) once triggered.
  78218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78219. */
  78220. export class ExecuteCodeAction extends Action {
  78221. /**
  78222. * The callback function to run.
  78223. */
  78224. func: (evt: ActionEvent) => void;
  78225. /**
  78226. * Instantiate the action
  78227. * @param triggerOptions defines the trigger options
  78228. * @param func defines the callback function to run
  78229. * @param condition defines the trigger related conditions
  78230. */
  78231. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78232. /**
  78233. * Execute the action and run the attached code.
  78234. */
  78235. execute(evt: ActionEvent): void;
  78236. }
  78237. /**
  78238. * This defines an action responsible to set the parent property of the target once triggered.
  78239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78240. */
  78241. export class SetParentAction extends Action {
  78242. private _parent;
  78243. private _target;
  78244. /**
  78245. * Instantiate the action
  78246. * @param triggerOptions defines the trigger options
  78247. * @param target defines the target containing the parent property
  78248. * @param parent defines from where the animation should start (animation frame)
  78249. * @param condition defines the trigger related conditions
  78250. */
  78251. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78252. /** @hidden */
  78253. _prepare(): void;
  78254. /**
  78255. * Execute the action and set the parent property.
  78256. */
  78257. execute(): void;
  78258. /**
  78259. * Serializes the actions and its related information.
  78260. * @param parent defines the object to serialize in
  78261. * @returns the serialized object
  78262. */
  78263. serialize(parent: any): any;
  78264. }
  78265. }
  78266. declare module BABYLON {
  78267. /**
  78268. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78269. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78271. */
  78272. export class ActionManager extends AbstractActionManager {
  78273. /**
  78274. * Nothing
  78275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78276. */
  78277. static readonly NothingTrigger: number;
  78278. /**
  78279. * On pick
  78280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78281. */
  78282. static readonly OnPickTrigger: number;
  78283. /**
  78284. * On left pick
  78285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78286. */
  78287. static readonly OnLeftPickTrigger: number;
  78288. /**
  78289. * On right pick
  78290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78291. */
  78292. static readonly OnRightPickTrigger: number;
  78293. /**
  78294. * On center pick
  78295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78296. */
  78297. static readonly OnCenterPickTrigger: number;
  78298. /**
  78299. * On pick down
  78300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78301. */
  78302. static readonly OnPickDownTrigger: number;
  78303. /**
  78304. * On double pick
  78305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78306. */
  78307. static readonly OnDoublePickTrigger: number;
  78308. /**
  78309. * On pick up
  78310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78311. */
  78312. static readonly OnPickUpTrigger: number;
  78313. /**
  78314. * On pick out.
  78315. * This trigger will only be raised if you also declared a OnPickDown
  78316. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78317. */
  78318. static readonly OnPickOutTrigger: number;
  78319. /**
  78320. * On long press
  78321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78322. */
  78323. static readonly OnLongPressTrigger: number;
  78324. /**
  78325. * On pointer over
  78326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78327. */
  78328. static readonly OnPointerOverTrigger: number;
  78329. /**
  78330. * On pointer out
  78331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78332. */
  78333. static readonly OnPointerOutTrigger: number;
  78334. /**
  78335. * On every frame
  78336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78337. */
  78338. static readonly OnEveryFrameTrigger: number;
  78339. /**
  78340. * On intersection enter
  78341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78342. */
  78343. static readonly OnIntersectionEnterTrigger: number;
  78344. /**
  78345. * On intersection exit
  78346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78347. */
  78348. static readonly OnIntersectionExitTrigger: number;
  78349. /**
  78350. * On key down
  78351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78352. */
  78353. static readonly OnKeyDownTrigger: number;
  78354. /**
  78355. * On key up
  78356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78357. */
  78358. static readonly OnKeyUpTrigger: number;
  78359. private _scene;
  78360. /**
  78361. * Creates a new action manager
  78362. * @param scene defines the hosting scene
  78363. */
  78364. constructor(scene: Scene);
  78365. /**
  78366. * Releases all associated resources
  78367. */
  78368. dispose(): void;
  78369. /**
  78370. * Gets hosting scene
  78371. * @returns the hosting scene
  78372. */
  78373. getScene(): Scene;
  78374. /**
  78375. * Does this action manager handles actions of any of the given triggers
  78376. * @param triggers defines the triggers to be tested
  78377. * @return a boolean indicating whether one (or more) of the triggers is handled
  78378. */
  78379. hasSpecificTriggers(triggers: number[]): boolean;
  78380. /**
  78381. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78382. * speed.
  78383. * @param triggerA defines the trigger to be tested
  78384. * @param triggerB defines the trigger to be tested
  78385. * @return a boolean indicating whether one (or more) of the triggers is handled
  78386. */
  78387. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78388. /**
  78389. * Does this action manager handles actions of a given trigger
  78390. * @param trigger defines the trigger to be tested
  78391. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78392. * @return whether the trigger is handled
  78393. */
  78394. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78395. /**
  78396. * Does this action manager has pointer triggers
  78397. */
  78398. readonly hasPointerTriggers: boolean;
  78399. /**
  78400. * Does this action manager has pick triggers
  78401. */
  78402. readonly hasPickTriggers: boolean;
  78403. /**
  78404. * Registers an action to this action manager
  78405. * @param action defines the action to be registered
  78406. * @return the action amended (prepared) after registration
  78407. */
  78408. registerAction(action: IAction): Nullable<IAction>;
  78409. /**
  78410. * Unregisters an action to this action manager
  78411. * @param action defines the action to be unregistered
  78412. * @return a boolean indicating whether the action has been unregistered
  78413. */
  78414. unregisterAction(action: IAction): Boolean;
  78415. /**
  78416. * Process a specific trigger
  78417. * @param trigger defines the trigger to process
  78418. * @param evt defines the event details to be processed
  78419. */
  78420. processTrigger(trigger: number, evt?: IActionEvent): void;
  78421. /** @hidden */
  78422. _getEffectiveTarget(target: any, propertyPath: string): any;
  78423. /** @hidden */
  78424. _getProperty(propertyPath: string): string;
  78425. /**
  78426. * Serialize this manager to a JSON object
  78427. * @param name defines the property name to store this manager
  78428. * @returns a JSON representation of this manager
  78429. */
  78430. serialize(name: string): any;
  78431. /**
  78432. * Creates a new ActionManager from a JSON data
  78433. * @param parsedActions defines the JSON data to read from
  78434. * @param object defines the hosting mesh
  78435. * @param scene defines the hosting scene
  78436. */
  78437. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78438. /**
  78439. * Get a trigger name by index
  78440. * @param trigger defines the trigger index
  78441. * @returns a trigger name
  78442. */
  78443. static GetTriggerName(trigger: number): string;
  78444. }
  78445. }
  78446. declare module BABYLON {
  78447. /**
  78448. * Class representing a ray with position and direction
  78449. */
  78450. export class Ray {
  78451. /** origin point */
  78452. origin: Vector3;
  78453. /** direction */
  78454. direction: Vector3;
  78455. /** length of the ray */
  78456. length: number;
  78457. private static readonly TmpVector3;
  78458. private _tmpRay;
  78459. /**
  78460. * Creates a new ray
  78461. * @param origin origin point
  78462. * @param direction direction
  78463. * @param length length of the ray
  78464. */
  78465. constructor(
  78466. /** origin point */
  78467. origin: Vector3,
  78468. /** direction */
  78469. direction: Vector3,
  78470. /** length of the ray */
  78471. length?: number);
  78472. /**
  78473. * Checks if the ray intersects a box
  78474. * @param minimum bound of the box
  78475. * @param maximum bound of the box
  78476. * @param intersectionTreshold extra extend to be added to the box in all direction
  78477. * @returns if the box was hit
  78478. */
  78479. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78480. /**
  78481. * Checks if the ray intersects a box
  78482. * @param box the bounding box to check
  78483. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78484. * @returns if the box was hit
  78485. */
  78486. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78487. /**
  78488. * If the ray hits a sphere
  78489. * @param sphere the bounding sphere to check
  78490. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78491. * @returns true if it hits the sphere
  78492. */
  78493. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78494. /**
  78495. * If the ray hits a triange
  78496. * @param vertex0 triangle vertex
  78497. * @param vertex1 triangle vertex
  78498. * @param vertex2 triangle vertex
  78499. * @returns intersection information if hit
  78500. */
  78501. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78502. /**
  78503. * Checks if ray intersects a plane
  78504. * @param plane the plane to check
  78505. * @returns the distance away it was hit
  78506. */
  78507. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78508. /**
  78509. * Checks if ray intersects a mesh
  78510. * @param mesh the mesh to check
  78511. * @param fastCheck if only the bounding box should checked
  78512. * @returns picking info of the intersecton
  78513. */
  78514. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78515. /**
  78516. * Checks if ray intersects a mesh
  78517. * @param meshes the meshes to check
  78518. * @param fastCheck if only the bounding box should checked
  78519. * @param results array to store result in
  78520. * @returns Array of picking infos
  78521. */
  78522. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78523. private _comparePickingInfo;
  78524. private static smallnum;
  78525. private static rayl;
  78526. /**
  78527. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78528. * @param sega the first point of the segment to test the intersection against
  78529. * @param segb the second point of the segment to test the intersection against
  78530. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78531. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78532. */
  78533. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78534. /**
  78535. * Update the ray from viewport position
  78536. * @param x position
  78537. * @param y y position
  78538. * @param viewportWidth viewport width
  78539. * @param viewportHeight viewport height
  78540. * @param world world matrix
  78541. * @param view view matrix
  78542. * @param projection projection matrix
  78543. * @returns this ray updated
  78544. */
  78545. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78546. /**
  78547. * Creates a ray with origin and direction of 0,0,0
  78548. * @returns the new ray
  78549. */
  78550. static Zero(): Ray;
  78551. /**
  78552. * Creates a new ray from screen space and viewport
  78553. * @param x position
  78554. * @param y y position
  78555. * @param viewportWidth viewport width
  78556. * @param viewportHeight viewport height
  78557. * @param world world matrix
  78558. * @param view view matrix
  78559. * @param projection projection matrix
  78560. * @returns new ray
  78561. */
  78562. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78563. /**
  78564. * 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
  78565. * transformed to the given world matrix.
  78566. * @param origin The origin point
  78567. * @param end The end point
  78568. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78569. * @returns the new ray
  78570. */
  78571. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78572. /**
  78573. * Transforms a ray by a matrix
  78574. * @param ray ray to transform
  78575. * @param matrix matrix to apply
  78576. * @returns the resulting new ray
  78577. */
  78578. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78579. /**
  78580. * Transforms a ray by a matrix
  78581. * @param ray ray to transform
  78582. * @param matrix matrix to apply
  78583. * @param result ray to store result in
  78584. */
  78585. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78586. /**
  78587. * Unproject a ray from screen space to object space
  78588. * @param sourceX defines the screen space x coordinate to use
  78589. * @param sourceY defines the screen space y coordinate to use
  78590. * @param viewportWidth defines the current width of the viewport
  78591. * @param viewportHeight defines the current height of the viewport
  78592. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78593. * @param view defines the view matrix to use
  78594. * @param projection defines the projection matrix to use
  78595. */
  78596. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78597. }
  78598. /**
  78599. * Type used to define predicate used to select faces when a mesh intersection is detected
  78600. */
  78601. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78602. interface Scene {
  78603. /** @hidden */
  78604. _tempPickingRay: Nullable<Ray>;
  78605. /** @hidden */
  78606. _cachedRayForTransform: Ray;
  78607. /** @hidden */
  78608. _pickWithRayInverseMatrix: Matrix;
  78609. /** @hidden */
  78610. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78611. /** @hidden */
  78612. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78613. }
  78614. }
  78615. declare module BABYLON {
  78616. interface Scene {
  78617. /** @hidden */
  78618. _pointerOverSprite: Nullable<Sprite>;
  78619. /** @hidden */
  78620. _pickedDownSprite: Nullable<Sprite>;
  78621. /** @hidden */
  78622. _tempSpritePickingRay: Nullable<Ray>;
  78623. /**
  78624. * All of the sprite managers added to this scene
  78625. * @see http://doc.babylonjs.com/babylon101/sprites
  78626. */
  78627. spriteManagers: Array<ISpriteManager>;
  78628. /**
  78629. * An event triggered when sprites rendering is about to start
  78630. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78631. */
  78632. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78633. /**
  78634. * An event triggered when sprites rendering is done
  78635. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78636. */
  78637. onAfterSpritesRenderingObservable: Observable<Scene>;
  78638. /** @hidden */
  78639. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78640. /** Launch a ray to try to pick a sprite in the scene
  78641. * @param x position on screen
  78642. * @param y position on screen
  78643. * @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
  78644. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78645. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78646. * @returns a PickingInfo
  78647. */
  78648. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78649. /** Use the given ray to pick a sprite in the scene
  78650. * @param ray The ray (in world space) to use to pick meshes
  78651. * @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
  78652. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78653. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78654. * @returns a PickingInfo
  78655. */
  78656. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78657. /**
  78658. * Force the sprite under the pointer
  78659. * @param sprite defines the sprite to use
  78660. */
  78661. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78662. /**
  78663. * Gets the sprite under the pointer
  78664. * @returns a Sprite or null if no sprite is under the pointer
  78665. */
  78666. getPointerOverSprite(): Nullable<Sprite>;
  78667. }
  78668. /**
  78669. * Defines the sprite scene component responsible to manage sprites
  78670. * in a given scene.
  78671. */
  78672. export class SpriteSceneComponent implements ISceneComponent {
  78673. /**
  78674. * The component name helpfull to identify the component in the list of scene components.
  78675. */
  78676. readonly name: string;
  78677. /**
  78678. * The scene the component belongs to.
  78679. */
  78680. scene: Scene;
  78681. /** @hidden */
  78682. private _spritePredicate;
  78683. /**
  78684. * Creates a new instance of the component for the given scene
  78685. * @param scene Defines the scene to register the component in
  78686. */
  78687. constructor(scene: Scene);
  78688. /**
  78689. * Registers the component in a given scene
  78690. */
  78691. register(): void;
  78692. /**
  78693. * Rebuilds the elements related to this component in case of
  78694. * context lost for instance.
  78695. */
  78696. rebuild(): void;
  78697. /**
  78698. * Disposes the component and the associated ressources.
  78699. */
  78700. dispose(): void;
  78701. private _pickSpriteButKeepRay;
  78702. private _pointerMove;
  78703. private _pointerDown;
  78704. private _pointerUp;
  78705. }
  78706. }
  78707. declare module BABYLON {
  78708. /** @hidden */
  78709. export var fogFragmentDeclaration: {
  78710. name: string;
  78711. shader: string;
  78712. };
  78713. }
  78714. declare module BABYLON {
  78715. /** @hidden */
  78716. export var fogFragment: {
  78717. name: string;
  78718. shader: string;
  78719. };
  78720. }
  78721. declare module BABYLON {
  78722. /** @hidden */
  78723. export var spritesPixelShader: {
  78724. name: string;
  78725. shader: string;
  78726. };
  78727. }
  78728. declare module BABYLON {
  78729. /** @hidden */
  78730. export var fogVertexDeclaration: {
  78731. name: string;
  78732. shader: string;
  78733. };
  78734. }
  78735. declare module BABYLON {
  78736. /** @hidden */
  78737. export var spritesVertexShader: {
  78738. name: string;
  78739. shader: string;
  78740. };
  78741. }
  78742. declare module BABYLON {
  78743. /**
  78744. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78745. */
  78746. export interface ISpriteManager extends IDisposable {
  78747. /**
  78748. * Restricts the camera to viewing objects with the same layerMask.
  78749. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78750. */
  78751. layerMask: number;
  78752. /**
  78753. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78754. */
  78755. isPickable: boolean;
  78756. /**
  78757. * Specifies the rendering group id for this mesh (0 by default)
  78758. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78759. */
  78760. renderingGroupId: number;
  78761. /**
  78762. * Defines the list of sprites managed by the manager.
  78763. */
  78764. sprites: Array<Sprite>;
  78765. /**
  78766. * Tests the intersection of a sprite with a specific ray.
  78767. * @param ray The ray we are sending to test the collision
  78768. * @param camera The camera space we are sending rays in
  78769. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78770. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78771. * @returns picking info or null.
  78772. */
  78773. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78774. /**
  78775. * Renders the list of sprites on screen.
  78776. */
  78777. render(): void;
  78778. }
  78779. /**
  78780. * Class used to manage multiple sprites on the same spritesheet
  78781. * @see http://doc.babylonjs.com/babylon101/sprites
  78782. */
  78783. export class SpriteManager implements ISpriteManager {
  78784. /** defines the manager's name */
  78785. name: string;
  78786. /** Gets the list of sprites */
  78787. sprites: Sprite[];
  78788. /** Gets or sets the rendering group id (0 by default) */
  78789. renderingGroupId: number;
  78790. /** Gets or sets camera layer mask */
  78791. layerMask: number;
  78792. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78793. fogEnabled: boolean;
  78794. /** Gets or sets a boolean indicating if the sprites are pickable */
  78795. isPickable: boolean;
  78796. /** Defines the default width of a cell in the spritesheet */
  78797. cellWidth: number;
  78798. /** Defines the default height of a cell in the spritesheet */
  78799. cellHeight: number;
  78800. /**
  78801. * An event triggered when the manager is disposed.
  78802. */
  78803. onDisposeObservable: Observable<SpriteManager>;
  78804. private _onDisposeObserver;
  78805. /**
  78806. * Callback called when the manager is disposed
  78807. */
  78808. onDispose: () => void;
  78809. private _capacity;
  78810. private _spriteTexture;
  78811. private _epsilon;
  78812. private _scene;
  78813. private _vertexData;
  78814. private _buffer;
  78815. private _vertexBuffers;
  78816. private _indexBuffer;
  78817. private _effectBase;
  78818. private _effectFog;
  78819. /**
  78820. * Gets or sets the spritesheet texture
  78821. */
  78822. texture: Texture;
  78823. /**
  78824. * Creates a new sprite manager
  78825. * @param name defines the manager's name
  78826. * @param imgUrl defines the sprite sheet url
  78827. * @param capacity defines the maximum allowed number of sprites
  78828. * @param cellSize defines the size of a sprite cell
  78829. * @param scene defines the hosting scene
  78830. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78831. * @param samplingMode defines the smapling mode to use with spritesheet
  78832. */
  78833. constructor(
  78834. /** defines the manager's name */
  78835. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  78836. private _appendSpriteVertex;
  78837. /**
  78838. * Intersects the sprites with a ray
  78839. * @param ray defines the ray to intersect with
  78840. * @param camera defines the current active camera
  78841. * @param predicate defines a predicate used to select candidate sprites
  78842. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78843. * @returns null if no hit or a PickingInfo
  78844. */
  78845. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78846. /**
  78847. * Render all child sprites
  78848. */
  78849. render(): void;
  78850. /**
  78851. * Release associated resources
  78852. */
  78853. dispose(): void;
  78854. }
  78855. }
  78856. declare module BABYLON {
  78857. /**
  78858. * Class used to represent a sprite
  78859. * @see http://doc.babylonjs.com/babylon101/sprites
  78860. */
  78861. export class Sprite {
  78862. /** defines the name */
  78863. name: string;
  78864. /** Gets or sets the current world position */
  78865. position: Vector3;
  78866. /** Gets or sets the main color */
  78867. color: Color4;
  78868. /** Gets or sets the width */
  78869. width: number;
  78870. /** Gets or sets the height */
  78871. height: number;
  78872. /** Gets or sets rotation angle */
  78873. angle: number;
  78874. /** Gets or sets the cell index in the sprite sheet */
  78875. cellIndex: number;
  78876. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78877. invertU: number;
  78878. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78879. invertV: number;
  78880. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78881. disposeWhenFinishedAnimating: boolean;
  78882. /** Gets the list of attached animations */
  78883. animations: Animation[];
  78884. /** Gets or sets a boolean indicating if the sprite can be picked */
  78885. isPickable: boolean;
  78886. /**
  78887. * Gets or sets the associated action manager
  78888. */
  78889. actionManager: Nullable<ActionManager>;
  78890. private _animationStarted;
  78891. private _loopAnimation;
  78892. private _fromIndex;
  78893. private _toIndex;
  78894. private _delay;
  78895. private _direction;
  78896. private _manager;
  78897. private _time;
  78898. private _onAnimationEnd;
  78899. /**
  78900. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78901. */
  78902. isVisible: boolean;
  78903. /**
  78904. * Gets or sets the sprite size
  78905. */
  78906. size: number;
  78907. /**
  78908. * Creates a new Sprite
  78909. * @param name defines the name
  78910. * @param manager defines the manager
  78911. */
  78912. constructor(
  78913. /** defines the name */
  78914. name: string, manager: ISpriteManager);
  78915. /**
  78916. * Starts an animation
  78917. * @param from defines the initial key
  78918. * @param to defines the end key
  78919. * @param loop defines if the animation must loop
  78920. * @param delay defines the start delay (in ms)
  78921. * @param onAnimationEnd defines a callback to call when animation ends
  78922. */
  78923. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78924. /** Stops current animation (if any) */
  78925. stopAnimation(): void;
  78926. /** @hidden */
  78927. _animate(deltaTime: number): void;
  78928. /** Release associated resources */
  78929. dispose(): void;
  78930. }
  78931. }
  78932. declare module BABYLON {
  78933. /**
  78934. * Information about the result of picking within a scene
  78935. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78936. */
  78937. export class PickingInfo {
  78938. /** @hidden */
  78939. _pickingUnavailable: boolean;
  78940. /**
  78941. * If the pick collided with an object
  78942. */
  78943. hit: boolean;
  78944. /**
  78945. * Distance away where the pick collided
  78946. */
  78947. distance: number;
  78948. /**
  78949. * The location of pick collision
  78950. */
  78951. pickedPoint: Nullable<Vector3>;
  78952. /**
  78953. * The mesh corresponding the the pick collision
  78954. */
  78955. pickedMesh: Nullable<AbstractMesh>;
  78956. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78957. bu: number;
  78958. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78959. bv: number;
  78960. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78961. faceId: number;
  78962. /** Id of the the submesh that was picked */
  78963. subMeshId: number;
  78964. /** If a sprite was picked, this will be the sprite the pick collided with */
  78965. pickedSprite: Nullable<Sprite>;
  78966. /**
  78967. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78968. */
  78969. originMesh: Nullable<AbstractMesh>;
  78970. /**
  78971. * The ray that was used to perform the picking.
  78972. */
  78973. ray: Nullable<Ray>;
  78974. /**
  78975. * Gets the normal correspodning to the face the pick collided with
  78976. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78977. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78978. * @returns The normal correspodning to the face the pick collided with
  78979. */
  78980. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78981. /**
  78982. * Gets the texture coordinates of where the pick occured
  78983. * @returns the vector containing the coordnates of the texture
  78984. */
  78985. getTextureCoordinates(): Nullable<Vector2>;
  78986. }
  78987. }
  78988. declare module BABYLON {
  78989. /**
  78990. * Gather the list of pointer event types as constants.
  78991. */
  78992. export class PointerEventTypes {
  78993. /**
  78994. * 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.
  78995. */
  78996. static readonly POINTERDOWN: number;
  78997. /**
  78998. * The pointerup event is fired when a pointer is no longer active.
  78999. */
  79000. static readonly POINTERUP: number;
  79001. /**
  79002. * The pointermove event is fired when a pointer changes coordinates.
  79003. */
  79004. static readonly POINTERMOVE: number;
  79005. /**
  79006. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79007. */
  79008. static readonly POINTERWHEEL: number;
  79009. /**
  79010. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79011. */
  79012. static readonly POINTERPICK: number;
  79013. /**
  79014. * The pointertap event is fired when a the object has been touched and released without drag.
  79015. */
  79016. static readonly POINTERTAP: number;
  79017. /**
  79018. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79019. */
  79020. static readonly POINTERDOUBLETAP: number;
  79021. }
  79022. /**
  79023. * Base class of pointer info types.
  79024. */
  79025. export class PointerInfoBase {
  79026. /**
  79027. * Defines the type of event (PointerEventTypes)
  79028. */
  79029. type: number;
  79030. /**
  79031. * Defines the related dom event
  79032. */
  79033. event: PointerEvent | MouseWheelEvent;
  79034. /**
  79035. * Instantiates the base class of pointers info.
  79036. * @param type Defines the type of event (PointerEventTypes)
  79037. * @param event Defines the related dom event
  79038. */
  79039. constructor(
  79040. /**
  79041. * Defines the type of event (PointerEventTypes)
  79042. */
  79043. type: number,
  79044. /**
  79045. * Defines the related dom event
  79046. */
  79047. event: PointerEvent | MouseWheelEvent);
  79048. }
  79049. /**
  79050. * This class is used to store pointer related info for the onPrePointerObservable event.
  79051. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79052. */
  79053. export class PointerInfoPre extends PointerInfoBase {
  79054. /**
  79055. * Ray from a pointer if availible (eg. 6dof controller)
  79056. */
  79057. ray: Nullable<Ray>;
  79058. /**
  79059. * Defines the local position of the pointer on the canvas.
  79060. */
  79061. localPosition: Vector2;
  79062. /**
  79063. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79064. */
  79065. skipOnPointerObservable: boolean;
  79066. /**
  79067. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79068. * @param type Defines the type of event (PointerEventTypes)
  79069. * @param event Defines the related dom event
  79070. * @param localX Defines the local x coordinates of the pointer when the event occured
  79071. * @param localY Defines the local y coordinates of the pointer when the event occured
  79072. */
  79073. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79074. }
  79075. /**
  79076. * This type contains all the data related to a pointer event in Babylon.js.
  79077. * 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.
  79078. */
  79079. export class PointerInfo extends PointerInfoBase {
  79080. /**
  79081. * Defines the picking info associated to the info (if any)\
  79082. */
  79083. pickInfo: Nullable<PickingInfo>;
  79084. /**
  79085. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79086. * @param type Defines the type of event (PointerEventTypes)
  79087. * @param event Defines the related dom event
  79088. * @param pickInfo Defines the picking info associated to the info (if any)\
  79089. */
  79090. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79091. /**
  79092. * Defines the picking info associated to the info (if any)\
  79093. */
  79094. pickInfo: Nullable<PickingInfo>);
  79095. }
  79096. /**
  79097. * Data relating to a touch event on the screen.
  79098. */
  79099. export interface PointerTouch {
  79100. /**
  79101. * X coordinate of touch.
  79102. */
  79103. x: number;
  79104. /**
  79105. * Y coordinate of touch.
  79106. */
  79107. y: number;
  79108. /**
  79109. * Id of touch. Unique for each finger.
  79110. */
  79111. pointerId: number;
  79112. /**
  79113. * Event type passed from DOM.
  79114. */
  79115. type: any;
  79116. }
  79117. }
  79118. declare module BABYLON {
  79119. /**
  79120. * Manage the mouse inputs to control the movement of a free camera.
  79121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79122. */
  79123. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79124. /**
  79125. * Define if touch is enabled in the mouse input
  79126. */
  79127. touchEnabled: boolean;
  79128. /**
  79129. * Defines the camera the input is attached to.
  79130. */
  79131. camera: FreeCamera;
  79132. /**
  79133. * Defines the buttons associated with the input to handle camera move.
  79134. */
  79135. buttons: number[];
  79136. /**
  79137. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79138. */
  79139. angularSensibility: number;
  79140. private _pointerInput;
  79141. private _onMouseMove;
  79142. private _observer;
  79143. private previousPosition;
  79144. /**
  79145. * Observable for when a pointer move event occurs containing the move offset
  79146. */
  79147. onPointerMovedObservable: Observable<{
  79148. offsetX: number;
  79149. offsetY: number;
  79150. }>;
  79151. /**
  79152. * @hidden
  79153. * If the camera should be rotated automatically based on pointer movement
  79154. */
  79155. _allowCameraRotation: boolean;
  79156. /**
  79157. * Manage the mouse inputs to control the movement of a free camera.
  79158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79159. * @param touchEnabled Defines if touch is enabled or not
  79160. */
  79161. constructor(
  79162. /**
  79163. * Define if touch is enabled in the mouse input
  79164. */
  79165. touchEnabled?: boolean);
  79166. /**
  79167. * Attach the input controls to a specific dom element to get the input from.
  79168. * @param element Defines the element the controls should be listened from
  79169. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79170. */
  79171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79172. /**
  79173. * Called on JS contextmenu event.
  79174. * Override this method to provide functionality.
  79175. */
  79176. protected onContextMenu(evt: PointerEvent): void;
  79177. /**
  79178. * Detach the current controls from the specified dom element.
  79179. * @param element Defines the element to stop listening the inputs from
  79180. */
  79181. detachControl(element: Nullable<HTMLElement>): void;
  79182. /**
  79183. * Gets the class name of the current intput.
  79184. * @returns the class name
  79185. */
  79186. getClassName(): string;
  79187. /**
  79188. * Get the friendly name associated with the input class.
  79189. * @returns the input friendly name
  79190. */
  79191. getSimpleName(): string;
  79192. }
  79193. }
  79194. declare module BABYLON {
  79195. /**
  79196. * Manage the touch inputs to control the movement of a free camera.
  79197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79198. */
  79199. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79200. /**
  79201. * Defines the camera the input is attached to.
  79202. */
  79203. camera: FreeCamera;
  79204. /**
  79205. * Defines the touch sensibility for rotation.
  79206. * The higher the faster.
  79207. */
  79208. touchAngularSensibility: number;
  79209. /**
  79210. * Defines the touch sensibility for move.
  79211. * The higher the faster.
  79212. */
  79213. touchMoveSensibility: number;
  79214. private _offsetX;
  79215. private _offsetY;
  79216. private _pointerPressed;
  79217. private _pointerInput;
  79218. private _observer;
  79219. private _onLostFocus;
  79220. /**
  79221. * Attach the input controls to a specific dom element to get the input from.
  79222. * @param element Defines the element the controls should be listened from
  79223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79224. */
  79225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79226. /**
  79227. * Detach the current controls from the specified dom element.
  79228. * @param element Defines the element to stop listening the inputs from
  79229. */
  79230. detachControl(element: Nullable<HTMLElement>): void;
  79231. /**
  79232. * Update the current camera state depending on the inputs that have been used this frame.
  79233. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79234. */
  79235. checkInputs(): void;
  79236. /**
  79237. * Gets the class name of the current intput.
  79238. * @returns the class name
  79239. */
  79240. getClassName(): string;
  79241. /**
  79242. * Get the friendly name associated with the input class.
  79243. * @returns the input friendly name
  79244. */
  79245. getSimpleName(): string;
  79246. }
  79247. }
  79248. declare module BABYLON {
  79249. /**
  79250. * Default Inputs manager for the FreeCamera.
  79251. * It groups all the default supported inputs for ease of use.
  79252. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79253. */
  79254. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79255. /**
  79256. * @hidden
  79257. */
  79258. _mouseInput: Nullable<FreeCameraMouseInput>;
  79259. /**
  79260. * Instantiates a new FreeCameraInputsManager.
  79261. * @param camera Defines the camera the inputs belong to
  79262. */
  79263. constructor(camera: FreeCamera);
  79264. /**
  79265. * Add keyboard input support to the input manager.
  79266. * @returns the current input manager
  79267. */
  79268. addKeyboard(): FreeCameraInputsManager;
  79269. /**
  79270. * Add mouse input support to the input manager.
  79271. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79272. * @returns the current input manager
  79273. */
  79274. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79275. /**
  79276. * Removes the mouse input support from the manager
  79277. * @returns the current input manager
  79278. */
  79279. removeMouse(): FreeCameraInputsManager;
  79280. /**
  79281. * Add touch input support to the input manager.
  79282. * @returns the current input manager
  79283. */
  79284. addTouch(): FreeCameraInputsManager;
  79285. /**
  79286. * Remove all attached input methods from a camera
  79287. */
  79288. clear(): void;
  79289. }
  79290. }
  79291. declare module BABYLON {
  79292. /**
  79293. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79294. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79295. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79296. */
  79297. export class FreeCamera extends TargetCamera {
  79298. /**
  79299. * Define the collision ellipsoid of the camera.
  79300. * This is helpful to simulate a camera body like the player body around the camera
  79301. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79302. */
  79303. ellipsoid: Vector3;
  79304. /**
  79305. * Define an offset for the position of the ellipsoid around the camera.
  79306. * This can be helpful to determine the center of the body near the gravity center of the body
  79307. * instead of its head.
  79308. */
  79309. ellipsoidOffset: Vector3;
  79310. /**
  79311. * Enable or disable collisions of the camera with the rest of the scene objects.
  79312. */
  79313. checkCollisions: boolean;
  79314. /**
  79315. * Enable or disable gravity on the camera.
  79316. */
  79317. applyGravity: boolean;
  79318. /**
  79319. * Define the input manager associated to the camera.
  79320. */
  79321. inputs: FreeCameraInputsManager;
  79322. /**
  79323. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79324. * Higher values reduce sensitivity.
  79325. */
  79326. /**
  79327. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79328. * Higher values reduce sensitivity.
  79329. */
  79330. angularSensibility: number;
  79331. /**
  79332. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79333. */
  79334. keysUp: number[];
  79335. /**
  79336. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79337. */
  79338. keysDown: number[];
  79339. /**
  79340. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79341. */
  79342. keysLeft: number[];
  79343. /**
  79344. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79345. */
  79346. keysRight: number[];
  79347. /**
  79348. * Event raised when the camera collide with a mesh in the scene.
  79349. */
  79350. onCollide: (collidedMesh: AbstractMesh) => void;
  79351. private _collider;
  79352. private _needMoveForGravity;
  79353. private _oldPosition;
  79354. private _diffPosition;
  79355. private _newPosition;
  79356. /** @hidden */
  79357. _localDirection: Vector3;
  79358. /** @hidden */
  79359. _transformedDirection: Vector3;
  79360. /**
  79361. * Instantiates a Free Camera.
  79362. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79363. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79364. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79365. * @param name Define the name of the camera in the scene
  79366. * @param position Define the start position of the camera in the scene
  79367. * @param scene Define the scene the camera belongs to
  79368. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79369. */
  79370. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79371. /**
  79372. * Attached controls to the current camera.
  79373. * @param element Defines the element the controls should be listened from
  79374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79375. */
  79376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79377. /**
  79378. * Detach the current controls from the camera.
  79379. * The camera will stop reacting to inputs.
  79380. * @param element Defines the element to stop listening the inputs from
  79381. */
  79382. detachControl(element: HTMLElement): void;
  79383. private _collisionMask;
  79384. /**
  79385. * Define a collision mask to limit the list of object the camera can collide with
  79386. */
  79387. collisionMask: number;
  79388. /** @hidden */
  79389. _collideWithWorld(displacement: Vector3): void;
  79390. private _onCollisionPositionChange;
  79391. /** @hidden */
  79392. _checkInputs(): void;
  79393. /** @hidden */
  79394. _decideIfNeedsToMove(): boolean;
  79395. /** @hidden */
  79396. _updatePosition(): void;
  79397. /**
  79398. * Destroy the camera and release the current resources hold by it.
  79399. */
  79400. dispose(): void;
  79401. /**
  79402. * Gets the current object class name.
  79403. * @return the class name
  79404. */
  79405. getClassName(): string;
  79406. }
  79407. }
  79408. declare module BABYLON {
  79409. /**
  79410. * Represents a gamepad control stick position
  79411. */
  79412. export class StickValues {
  79413. /**
  79414. * The x component of the control stick
  79415. */
  79416. x: number;
  79417. /**
  79418. * The y component of the control stick
  79419. */
  79420. y: number;
  79421. /**
  79422. * Initializes the gamepad x and y control stick values
  79423. * @param x The x component of the gamepad control stick value
  79424. * @param y The y component of the gamepad control stick value
  79425. */
  79426. constructor(
  79427. /**
  79428. * The x component of the control stick
  79429. */
  79430. x: number,
  79431. /**
  79432. * The y component of the control stick
  79433. */
  79434. y: number);
  79435. }
  79436. /**
  79437. * An interface which manages callbacks for gamepad button changes
  79438. */
  79439. export interface GamepadButtonChanges {
  79440. /**
  79441. * Called when a gamepad has been changed
  79442. */
  79443. changed: boolean;
  79444. /**
  79445. * Called when a gamepad press event has been triggered
  79446. */
  79447. pressChanged: boolean;
  79448. /**
  79449. * Called when a touch event has been triggered
  79450. */
  79451. touchChanged: boolean;
  79452. /**
  79453. * Called when a value has changed
  79454. */
  79455. valueChanged: boolean;
  79456. }
  79457. /**
  79458. * Represents a gamepad
  79459. */
  79460. export class Gamepad {
  79461. /**
  79462. * The id of the gamepad
  79463. */
  79464. id: string;
  79465. /**
  79466. * The index of the gamepad
  79467. */
  79468. index: number;
  79469. /**
  79470. * The browser gamepad
  79471. */
  79472. browserGamepad: any;
  79473. /**
  79474. * Specifies what type of gamepad this represents
  79475. */
  79476. type: number;
  79477. private _leftStick;
  79478. private _rightStick;
  79479. /** @hidden */
  79480. _isConnected: boolean;
  79481. private _leftStickAxisX;
  79482. private _leftStickAxisY;
  79483. private _rightStickAxisX;
  79484. private _rightStickAxisY;
  79485. /**
  79486. * Triggered when the left control stick has been changed
  79487. */
  79488. private _onleftstickchanged;
  79489. /**
  79490. * Triggered when the right control stick has been changed
  79491. */
  79492. private _onrightstickchanged;
  79493. /**
  79494. * Represents a gamepad controller
  79495. */
  79496. static GAMEPAD: number;
  79497. /**
  79498. * Represents a generic controller
  79499. */
  79500. static GENERIC: number;
  79501. /**
  79502. * Represents an XBox controller
  79503. */
  79504. static XBOX: number;
  79505. /**
  79506. * Represents a pose-enabled controller
  79507. */
  79508. static POSE_ENABLED: number;
  79509. /**
  79510. * Specifies whether the left control stick should be Y-inverted
  79511. */
  79512. protected _invertLeftStickY: boolean;
  79513. /**
  79514. * Specifies if the gamepad has been connected
  79515. */
  79516. readonly isConnected: boolean;
  79517. /**
  79518. * Initializes the gamepad
  79519. * @param id The id of the gamepad
  79520. * @param index The index of the gamepad
  79521. * @param browserGamepad The browser gamepad
  79522. * @param leftStickX The x component of the left joystick
  79523. * @param leftStickY The y component of the left joystick
  79524. * @param rightStickX The x component of the right joystick
  79525. * @param rightStickY The y component of the right joystick
  79526. */
  79527. constructor(
  79528. /**
  79529. * The id of the gamepad
  79530. */
  79531. id: string,
  79532. /**
  79533. * The index of the gamepad
  79534. */
  79535. index: number,
  79536. /**
  79537. * The browser gamepad
  79538. */
  79539. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79540. /**
  79541. * Callback triggered when the left joystick has changed
  79542. * @param callback
  79543. */
  79544. onleftstickchanged(callback: (values: StickValues) => void): void;
  79545. /**
  79546. * Callback triggered when the right joystick has changed
  79547. * @param callback
  79548. */
  79549. onrightstickchanged(callback: (values: StickValues) => void): void;
  79550. /**
  79551. * Gets the left joystick
  79552. */
  79553. /**
  79554. * Sets the left joystick values
  79555. */
  79556. leftStick: StickValues;
  79557. /**
  79558. * Gets the right joystick
  79559. */
  79560. /**
  79561. * Sets the right joystick value
  79562. */
  79563. rightStick: StickValues;
  79564. /**
  79565. * Updates the gamepad joystick positions
  79566. */
  79567. update(): void;
  79568. /**
  79569. * Disposes the gamepad
  79570. */
  79571. dispose(): void;
  79572. }
  79573. /**
  79574. * Represents a generic gamepad
  79575. */
  79576. export class GenericPad extends Gamepad {
  79577. private _buttons;
  79578. private _onbuttondown;
  79579. private _onbuttonup;
  79580. /**
  79581. * Observable triggered when a button has been pressed
  79582. */
  79583. onButtonDownObservable: Observable<number>;
  79584. /**
  79585. * Observable triggered when a button has been released
  79586. */
  79587. onButtonUpObservable: Observable<number>;
  79588. /**
  79589. * Callback triggered when a button has been pressed
  79590. * @param callback Called when a button has been pressed
  79591. */
  79592. onbuttondown(callback: (buttonPressed: number) => void): void;
  79593. /**
  79594. * Callback triggered when a button has been released
  79595. * @param callback Called when a button has been released
  79596. */
  79597. onbuttonup(callback: (buttonReleased: number) => void): void;
  79598. /**
  79599. * Initializes the generic gamepad
  79600. * @param id The id of the generic gamepad
  79601. * @param index The index of the generic gamepad
  79602. * @param browserGamepad The browser gamepad
  79603. */
  79604. constructor(id: string, index: number, browserGamepad: any);
  79605. private _setButtonValue;
  79606. /**
  79607. * Updates the generic gamepad
  79608. */
  79609. update(): void;
  79610. /**
  79611. * Disposes the generic gamepad
  79612. */
  79613. dispose(): void;
  79614. }
  79615. }
  79616. declare module BABYLON {
  79617. /**
  79618. * Defines the types of pose enabled controllers that are supported
  79619. */
  79620. export enum PoseEnabledControllerType {
  79621. /**
  79622. * HTC Vive
  79623. */
  79624. VIVE = 0,
  79625. /**
  79626. * Oculus Rift
  79627. */
  79628. OCULUS = 1,
  79629. /**
  79630. * Windows mixed reality
  79631. */
  79632. WINDOWS = 2,
  79633. /**
  79634. * Samsung gear VR
  79635. */
  79636. GEAR_VR = 3,
  79637. /**
  79638. * Google Daydream
  79639. */
  79640. DAYDREAM = 4,
  79641. /**
  79642. * Generic
  79643. */
  79644. GENERIC = 5
  79645. }
  79646. /**
  79647. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79648. */
  79649. export interface MutableGamepadButton {
  79650. /**
  79651. * Value of the button/trigger
  79652. */
  79653. value: number;
  79654. /**
  79655. * If the button/trigger is currently touched
  79656. */
  79657. touched: boolean;
  79658. /**
  79659. * If the button/trigger is currently pressed
  79660. */
  79661. pressed: boolean;
  79662. }
  79663. /**
  79664. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79665. * @hidden
  79666. */
  79667. export interface ExtendedGamepadButton extends GamepadButton {
  79668. /**
  79669. * If the button/trigger is currently pressed
  79670. */
  79671. readonly pressed: boolean;
  79672. /**
  79673. * If the button/trigger is currently touched
  79674. */
  79675. readonly touched: boolean;
  79676. /**
  79677. * Value of the button/trigger
  79678. */
  79679. readonly value: number;
  79680. }
  79681. /** @hidden */
  79682. export interface _GamePadFactory {
  79683. /**
  79684. * Returns wether or not the current gamepad can be created for this type of controller.
  79685. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79686. * @returns true if it can be created, otherwise false
  79687. */
  79688. canCreate(gamepadInfo: any): boolean;
  79689. /**
  79690. * Creates a new instance of the Gamepad.
  79691. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79692. * @returns the new gamepad instance
  79693. */
  79694. create(gamepadInfo: any): Gamepad;
  79695. }
  79696. /**
  79697. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79698. */
  79699. export class PoseEnabledControllerHelper {
  79700. /** @hidden */
  79701. static _ControllerFactories: _GamePadFactory[];
  79702. /** @hidden */
  79703. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  79704. /**
  79705. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79706. * @param vrGamepad the gamepad to initialized
  79707. * @returns a vr controller of the type the gamepad identified as
  79708. */
  79709. static InitiateController(vrGamepad: any): Gamepad;
  79710. }
  79711. /**
  79712. * Defines the PoseEnabledController object that contains state of a vr capable controller
  79713. */
  79714. export class PoseEnabledController extends Gamepad implements PoseControlled {
  79715. private _deviceRoomPosition;
  79716. private _deviceRoomRotationQuaternion;
  79717. /**
  79718. * The device position in babylon space
  79719. */
  79720. devicePosition: Vector3;
  79721. /**
  79722. * The device rotation in babylon space
  79723. */
  79724. deviceRotationQuaternion: Quaternion;
  79725. /**
  79726. * The scale factor of the device in babylon space
  79727. */
  79728. deviceScaleFactor: number;
  79729. /**
  79730. * (Likely devicePosition should be used instead) The device position in its room space
  79731. */
  79732. position: Vector3;
  79733. /**
  79734. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  79735. */
  79736. rotationQuaternion: Quaternion;
  79737. /**
  79738. * The type of controller (Eg. Windows mixed reality)
  79739. */
  79740. controllerType: PoseEnabledControllerType;
  79741. protected _calculatedPosition: Vector3;
  79742. private _calculatedRotation;
  79743. /**
  79744. * The raw pose from the device
  79745. */
  79746. rawPose: DevicePose;
  79747. private _trackPosition;
  79748. private _maxRotationDistFromHeadset;
  79749. private _draggedRoomRotation;
  79750. /**
  79751. * @hidden
  79752. */
  79753. _disableTrackPosition(fixedPosition: Vector3): void;
  79754. /**
  79755. * Internal, the mesh attached to the controller
  79756. * @hidden
  79757. */
  79758. _mesh: Nullable<AbstractMesh>;
  79759. private _poseControlledCamera;
  79760. private _leftHandSystemQuaternion;
  79761. /**
  79762. * Internal, matrix used to convert room space to babylon space
  79763. * @hidden
  79764. */
  79765. _deviceToWorld: Matrix;
  79766. /**
  79767. * Node to be used when casting a ray from the controller
  79768. * @hidden
  79769. */
  79770. _pointingPoseNode: Nullable<TransformNode>;
  79771. /**
  79772. * Name of the child mesh that can be used to cast a ray from the controller
  79773. */
  79774. static readonly POINTING_POSE: string;
  79775. /**
  79776. * Creates a new PoseEnabledController from a gamepad
  79777. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  79778. */
  79779. constructor(browserGamepad: any);
  79780. private _workingMatrix;
  79781. /**
  79782. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  79783. */
  79784. update(): void;
  79785. /**
  79786. * Updates only the pose device and mesh without doing any button event checking
  79787. */
  79788. protected _updatePoseAndMesh(): void;
  79789. /**
  79790. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  79791. * @param poseData raw pose fromthe device
  79792. */
  79793. updateFromDevice(poseData: DevicePose): void;
  79794. /**
  79795. * @hidden
  79796. */
  79797. _meshAttachedObservable: Observable<AbstractMesh>;
  79798. /**
  79799. * Attaches a mesh to the controller
  79800. * @param mesh the mesh to be attached
  79801. */
  79802. attachToMesh(mesh: AbstractMesh): void;
  79803. /**
  79804. * Attaches the controllers mesh to a camera
  79805. * @param camera the camera the mesh should be attached to
  79806. */
  79807. attachToPoseControlledCamera(camera: TargetCamera): void;
  79808. /**
  79809. * Disposes of the controller
  79810. */
  79811. dispose(): void;
  79812. /**
  79813. * The mesh that is attached to the controller
  79814. */
  79815. readonly mesh: Nullable<AbstractMesh>;
  79816. /**
  79817. * Gets the ray of the controller in the direction the controller is pointing
  79818. * @param length the length the resulting ray should be
  79819. * @returns a ray in the direction the controller is pointing
  79820. */
  79821. getForwardRay(length?: number): Ray;
  79822. }
  79823. }
  79824. declare module BABYLON {
  79825. /**
  79826. * Defines the WebVRController object that represents controllers tracked in 3D space
  79827. */
  79828. export abstract class WebVRController extends PoseEnabledController {
  79829. /**
  79830. * Internal, the default controller model for the controller
  79831. */
  79832. protected _defaultModel: AbstractMesh;
  79833. /**
  79834. * Fired when the trigger state has changed
  79835. */
  79836. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  79837. /**
  79838. * Fired when the main button state has changed
  79839. */
  79840. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79841. /**
  79842. * Fired when the secondary button state has changed
  79843. */
  79844. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79845. /**
  79846. * Fired when the pad state has changed
  79847. */
  79848. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  79849. /**
  79850. * Fired when controllers stick values have changed
  79851. */
  79852. onPadValuesChangedObservable: Observable<StickValues>;
  79853. /**
  79854. * Array of button availible on the controller
  79855. */
  79856. protected _buttons: Array<MutableGamepadButton>;
  79857. private _onButtonStateChange;
  79858. /**
  79859. * Fired when a controller button's state has changed
  79860. * @param callback the callback containing the button that was modified
  79861. */
  79862. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  79863. /**
  79864. * X and Y axis corresponding to the controllers joystick
  79865. */
  79866. pad: StickValues;
  79867. /**
  79868. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  79869. */
  79870. hand: string;
  79871. /**
  79872. * The default controller model for the controller
  79873. */
  79874. readonly defaultModel: AbstractMesh;
  79875. /**
  79876. * Creates a new WebVRController from a gamepad
  79877. * @param vrGamepad the gamepad that the WebVRController should be created from
  79878. */
  79879. constructor(vrGamepad: any);
  79880. /**
  79881. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  79882. */
  79883. update(): void;
  79884. /**
  79885. * Function to be called when a button is modified
  79886. */
  79887. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  79888. /**
  79889. * Loads a mesh and attaches it to the controller
  79890. * @param scene the scene the mesh should be added to
  79891. * @param meshLoaded callback for when the mesh has been loaded
  79892. */
  79893. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  79894. private _setButtonValue;
  79895. private _changes;
  79896. private _checkChanges;
  79897. /**
  79898. * Disposes of th webVRCOntroller
  79899. */
  79900. dispose(): void;
  79901. }
  79902. }
  79903. declare module BABYLON {
  79904. /**
  79905. * The HemisphericLight simulates the ambient environment light,
  79906. * so the passed direction is the light reflection direction, not the incoming direction.
  79907. */
  79908. export class HemisphericLight extends Light {
  79909. /**
  79910. * The groundColor is the light in the opposite direction to the one specified during creation.
  79911. * 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.
  79912. */
  79913. groundColor: Color3;
  79914. /**
  79915. * The light reflection direction, not the incoming direction.
  79916. */
  79917. direction: Vector3;
  79918. /**
  79919. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  79920. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  79921. * The HemisphericLight can't cast shadows.
  79922. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79923. * @param name The friendly name of the light
  79924. * @param direction The direction of the light reflection
  79925. * @param scene The scene the light belongs to
  79926. */
  79927. constructor(name: string, direction: Vector3, scene: Scene);
  79928. protected _buildUniformLayout(): void;
  79929. /**
  79930. * Returns the string "HemisphericLight".
  79931. * @return The class name
  79932. */
  79933. getClassName(): string;
  79934. /**
  79935. * Sets the HemisphericLight direction towards the passed target (Vector3).
  79936. * Returns the updated direction.
  79937. * @param target The target the direction should point to
  79938. * @return The computed direction
  79939. */
  79940. setDirectionToTarget(target: Vector3): Vector3;
  79941. /**
  79942. * Returns the shadow generator associated to the light.
  79943. * @returns Always null for hemispheric lights because it does not support shadows.
  79944. */
  79945. getShadowGenerator(): Nullable<IShadowGenerator>;
  79946. /**
  79947. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  79948. * @param effect The effect to update
  79949. * @param lightIndex The index of the light in the effect to update
  79950. * @returns The hemispheric light
  79951. */
  79952. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  79953. /**
  79954. * Computes the world matrix of the node
  79955. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79956. * @param useWasUpdatedFlag defines a reserved property
  79957. * @returns the world matrix
  79958. */
  79959. computeWorldMatrix(): Matrix;
  79960. /**
  79961. * Returns the integer 3.
  79962. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79963. */
  79964. getTypeID(): number;
  79965. /**
  79966. * Prepares the list of defines specific to the light type.
  79967. * @param defines the list of defines
  79968. * @param lightIndex defines the index of the light for the effect
  79969. */
  79970. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79971. }
  79972. }
  79973. declare module BABYLON {
  79974. /** @hidden */
  79975. export var vrMultiviewToSingleviewPixelShader: {
  79976. name: string;
  79977. shader: string;
  79978. };
  79979. }
  79980. declare module BABYLON {
  79981. /**
  79982. * Renders to multiple views with a single draw call
  79983. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  79984. */
  79985. export class MultiviewRenderTarget extends RenderTargetTexture {
  79986. /**
  79987. * Creates a multiview render target
  79988. * @param scene scene used with the render target
  79989. * @param size the size of the render target (used for each view)
  79990. */
  79991. constructor(scene: Scene, size?: number | {
  79992. width: number;
  79993. height: number;
  79994. } | {
  79995. ratio: number;
  79996. });
  79997. /**
  79998. * @hidden
  79999. * @param faceIndex the face index, if its a cube texture
  80000. */
  80001. _bindFrameBuffer(faceIndex?: number): void;
  80002. /**
  80003. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80004. * @returns the view count
  80005. */
  80006. getViewCount(): number;
  80007. }
  80008. }
  80009. declare module BABYLON {
  80010. interface Engine {
  80011. /**
  80012. * Creates a new multiview render target
  80013. * @param width defines the width of the texture
  80014. * @param height defines the height of the texture
  80015. * @returns the created multiview texture
  80016. */
  80017. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80018. /**
  80019. * Binds a multiview framebuffer to be drawn to
  80020. * @param multiviewTexture texture to bind
  80021. */
  80022. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80023. }
  80024. interface Camera {
  80025. /**
  80026. * @hidden
  80027. * 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)
  80028. */
  80029. _useMultiviewToSingleView: boolean;
  80030. /**
  80031. * @hidden
  80032. * 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)
  80033. */
  80034. _multiviewTexture: Nullable<RenderTargetTexture>;
  80035. /**
  80036. * @hidden
  80037. * ensures the multiview texture of the camera exists and has the specified width/height
  80038. * @param width height to set on the multiview texture
  80039. * @param height width to set on the multiview texture
  80040. */
  80041. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80042. }
  80043. interface Scene {
  80044. /** @hidden */
  80045. _transformMatrixR: Matrix;
  80046. /** @hidden */
  80047. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80048. /** @hidden */
  80049. _createMultiviewUbo(): void;
  80050. /** @hidden */
  80051. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80052. /** @hidden */
  80053. _renderMultiviewToSingleView(camera: Camera): void;
  80054. }
  80055. }
  80056. declare module BABYLON {
  80057. /**
  80058. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80059. * This will not be used for webXR as it supports displaying texture arrays directly
  80060. */
  80061. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80062. /**
  80063. * Initializes a VRMultiviewToSingleview
  80064. * @param name name of the post process
  80065. * @param camera camera to be applied to
  80066. * @param scaleFactor scaling factor to the size of the output texture
  80067. */
  80068. constructor(name: string, camera: Camera, scaleFactor: number);
  80069. }
  80070. }
  80071. declare module BABYLON {
  80072. interface Engine {
  80073. /** @hidden */
  80074. _vrDisplay: any;
  80075. /** @hidden */
  80076. _vrSupported: boolean;
  80077. /** @hidden */
  80078. _oldSize: Size;
  80079. /** @hidden */
  80080. _oldHardwareScaleFactor: number;
  80081. /** @hidden */
  80082. _vrExclusivePointerMode: boolean;
  80083. /** @hidden */
  80084. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80085. /** @hidden */
  80086. _onVRDisplayPointerRestricted: () => void;
  80087. /** @hidden */
  80088. _onVRDisplayPointerUnrestricted: () => void;
  80089. /** @hidden */
  80090. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80091. /** @hidden */
  80092. _onVrDisplayDisconnect: Nullable<() => void>;
  80093. /** @hidden */
  80094. _onVrDisplayPresentChange: Nullable<() => void>;
  80095. /**
  80096. * Observable signaled when VR display mode changes
  80097. */
  80098. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80099. /**
  80100. * Observable signaled when VR request present is complete
  80101. */
  80102. onVRRequestPresentComplete: Observable<boolean>;
  80103. /**
  80104. * Observable signaled when VR request present starts
  80105. */
  80106. onVRRequestPresentStart: Observable<Engine>;
  80107. /**
  80108. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80109. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80110. */
  80111. isInVRExclusivePointerMode: boolean;
  80112. /**
  80113. * Gets a boolean indicating if a webVR device was detected
  80114. * @returns true if a webVR device was detected
  80115. */
  80116. isVRDevicePresent(): boolean;
  80117. /**
  80118. * Gets the current webVR device
  80119. * @returns the current webVR device (or null)
  80120. */
  80121. getVRDevice(): any;
  80122. /**
  80123. * Initializes a webVR display and starts listening to display change events
  80124. * The onVRDisplayChangedObservable will be notified upon these changes
  80125. * @returns A promise containing a VRDisplay and if vr is supported
  80126. */
  80127. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80128. /** @hidden */
  80129. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80130. /**
  80131. * Call this function to switch to webVR mode
  80132. * Will do nothing if webVR is not supported or if there is no webVR device
  80133. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80134. */
  80135. enableVR(): void;
  80136. /** @hidden */
  80137. _onVRFullScreenTriggered(): void;
  80138. }
  80139. }
  80140. declare module BABYLON {
  80141. /**
  80142. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80143. * IMPORTANT!! The data is right-hand data.
  80144. * @export
  80145. * @interface DevicePose
  80146. */
  80147. export interface DevicePose {
  80148. /**
  80149. * The position of the device, values in array are [x,y,z].
  80150. */
  80151. readonly position: Nullable<Float32Array>;
  80152. /**
  80153. * The linearVelocity of the device, values in array are [x,y,z].
  80154. */
  80155. readonly linearVelocity: Nullable<Float32Array>;
  80156. /**
  80157. * The linearAcceleration of the device, values in array are [x,y,z].
  80158. */
  80159. readonly linearAcceleration: Nullable<Float32Array>;
  80160. /**
  80161. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80162. */
  80163. readonly orientation: Nullable<Float32Array>;
  80164. /**
  80165. * The angularVelocity of the device, values in array are [x,y,z].
  80166. */
  80167. readonly angularVelocity: Nullable<Float32Array>;
  80168. /**
  80169. * The angularAcceleration of the device, values in array are [x,y,z].
  80170. */
  80171. readonly angularAcceleration: Nullable<Float32Array>;
  80172. }
  80173. /**
  80174. * Interface representing a pose controlled object in Babylon.
  80175. * A pose controlled object has both regular pose values as well as pose values
  80176. * from an external device such as a VR head mounted display
  80177. */
  80178. export interface PoseControlled {
  80179. /**
  80180. * The position of the object in babylon space.
  80181. */
  80182. position: Vector3;
  80183. /**
  80184. * The rotation quaternion of the object in babylon space.
  80185. */
  80186. rotationQuaternion: Quaternion;
  80187. /**
  80188. * The position of the device in babylon space.
  80189. */
  80190. devicePosition?: Vector3;
  80191. /**
  80192. * The rotation quaternion of the device in babylon space.
  80193. */
  80194. deviceRotationQuaternion: Quaternion;
  80195. /**
  80196. * The raw pose coming from the device.
  80197. */
  80198. rawPose: Nullable<DevicePose>;
  80199. /**
  80200. * The scale of the device to be used when translating from device space to babylon space.
  80201. */
  80202. deviceScaleFactor: number;
  80203. /**
  80204. * Updates the poseControlled values based on the input device pose.
  80205. * @param poseData the pose data to update the object with
  80206. */
  80207. updateFromDevice(poseData: DevicePose): void;
  80208. }
  80209. /**
  80210. * Set of options to customize the webVRCamera
  80211. */
  80212. export interface WebVROptions {
  80213. /**
  80214. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80215. */
  80216. trackPosition?: boolean;
  80217. /**
  80218. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80219. */
  80220. positionScale?: number;
  80221. /**
  80222. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80223. */
  80224. displayName?: string;
  80225. /**
  80226. * Should the native controller meshes be initialized. (default: true)
  80227. */
  80228. controllerMeshes?: boolean;
  80229. /**
  80230. * Creating a default HemiLight only on controllers. (default: true)
  80231. */
  80232. defaultLightingOnControllers?: boolean;
  80233. /**
  80234. * If you don't want to use the default VR button of the helper. (default: false)
  80235. */
  80236. useCustomVRButton?: boolean;
  80237. /**
  80238. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80239. */
  80240. customVRButton?: HTMLButtonElement;
  80241. /**
  80242. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80243. */
  80244. rayLength?: number;
  80245. /**
  80246. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80247. */
  80248. defaultHeight?: number;
  80249. /**
  80250. * If multiview should be used if availible (default: false)
  80251. */
  80252. useMultiview?: boolean;
  80253. }
  80254. /**
  80255. * This represents a WebVR camera.
  80256. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80257. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80258. */
  80259. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80260. private webVROptions;
  80261. /**
  80262. * @hidden
  80263. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80264. */
  80265. _vrDevice: any;
  80266. /**
  80267. * The rawPose of the vrDevice.
  80268. */
  80269. rawPose: Nullable<DevicePose>;
  80270. private _onVREnabled;
  80271. private _specsVersion;
  80272. private _attached;
  80273. private _frameData;
  80274. protected _descendants: Array<Node>;
  80275. private _deviceRoomPosition;
  80276. /** @hidden */
  80277. _deviceRoomRotationQuaternion: Quaternion;
  80278. private _standingMatrix;
  80279. /**
  80280. * Represents device position in babylon space.
  80281. */
  80282. devicePosition: Vector3;
  80283. /**
  80284. * Represents device rotation in babylon space.
  80285. */
  80286. deviceRotationQuaternion: Quaternion;
  80287. /**
  80288. * The scale of the device to be used when translating from device space to babylon space.
  80289. */
  80290. deviceScaleFactor: number;
  80291. private _deviceToWorld;
  80292. private _worldToDevice;
  80293. /**
  80294. * References to the webVR controllers for the vrDevice.
  80295. */
  80296. controllers: Array<WebVRController>;
  80297. /**
  80298. * Emits an event when a controller is attached.
  80299. */
  80300. onControllersAttachedObservable: Observable<WebVRController[]>;
  80301. /**
  80302. * Emits an event when a controller's mesh has been loaded;
  80303. */
  80304. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80305. /**
  80306. * Emits an event when the HMD's pose has been updated.
  80307. */
  80308. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80309. private _poseSet;
  80310. /**
  80311. * If the rig cameras be used as parent instead of this camera.
  80312. */
  80313. rigParenting: boolean;
  80314. private _lightOnControllers;
  80315. private _defaultHeight?;
  80316. /**
  80317. * Instantiates a WebVRFreeCamera.
  80318. * @param name The name of the WebVRFreeCamera
  80319. * @param position The starting anchor position for the camera
  80320. * @param scene The scene the camera belongs to
  80321. * @param webVROptions a set of customizable options for the webVRCamera
  80322. */
  80323. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80324. /**
  80325. * Gets the device distance from the ground in meters.
  80326. * @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.
  80327. */
  80328. deviceDistanceToRoomGround(): number;
  80329. /**
  80330. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80331. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80332. */
  80333. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80334. /**
  80335. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80336. * @returns A promise with a boolean set to if the standing matrix is supported.
  80337. */
  80338. useStandingMatrixAsync(): Promise<boolean>;
  80339. /**
  80340. * Disposes the camera
  80341. */
  80342. dispose(): void;
  80343. /**
  80344. * Gets a vrController by name.
  80345. * @param name The name of the controller to retreive
  80346. * @returns the controller matching the name specified or null if not found
  80347. */
  80348. getControllerByName(name: string): Nullable<WebVRController>;
  80349. private _leftController;
  80350. /**
  80351. * The controller corresponding to the users left hand.
  80352. */
  80353. readonly leftController: Nullable<WebVRController>;
  80354. private _rightController;
  80355. /**
  80356. * The controller corresponding to the users right hand.
  80357. */
  80358. readonly rightController: Nullable<WebVRController>;
  80359. /**
  80360. * Casts a ray forward from the vrCamera's gaze.
  80361. * @param length Length of the ray (default: 100)
  80362. * @returns the ray corresponding to the gaze
  80363. */
  80364. getForwardRay(length?: number): Ray;
  80365. /**
  80366. * @hidden
  80367. * Updates the camera based on device's frame data
  80368. */
  80369. _checkInputs(): void;
  80370. /**
  80371. * Updates the poseControlled values based on the input device pose.
  80372. * @param poseData Pose coming from the device
  80373. */
  80374. updateFromDevice(poseData: DevicePose): void;
  80375. private _htmlElementAttached;
  80376. private _detachIfAttached;
  80377. /**
  80378. * WebVR's attach control will start broadcasting frames to the device.
  80379. * Note that in certain browsers (chrome for example) this function must be called
  80380. * within a user-interaction callback. Example:
  80381. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80382. *
  80383. * @param element html element to attach the vrDevice to
  80384. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80385. */
  80386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80387. /**
  80388. * Detaches the camera from the html element and disables VR
  80389. *
  80390. * @param element html element to detach from
  80391. */
  80392. detachControl(element: HTMLElement): void;
  80393. /**
  80394. * @returns the name of this class
  80395. */
  80396. getClassName(): string;
  80397. /**
  80398. * Calls resetPose on the vrDisplay
  80399. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80400. */
  80401. resetToCurrentRotation(): void;
  80402. /**
  80403. * @hidden
  80404. * Updates the rig cameras (left and right eye)
  80405. */
  80406. _updateRigCameras(): void;
  80407. private _workingVector;
  80408. private _oneVector;
  80409. private _workingMatrix;
  80410. private updateCacheCalled;
  80411. private _correctPositionIfNotTrackPosition;
  80412. /**
  80413. * @hidden
  80414. * Updates the cached values of the camera
  80415. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80416. */
  80417. _updateCache(ignoreParentClass?: boolean): void;
  80418. /**
  80419. * @hidden
  80420. * Get current device position in babylon world
  80421. */
  80422. _computeDevicePosition(): void;
  80423. /**
  80424. * Updates the current device position and rotation in the babylon world
  80425. */
  80426. update(): void;
  80427. /**
  80428. * @hidden
  80429. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80430. * @returns an identity matrix
  80431. */
  80432. _getViewMatrix(): Matrix;
  80433. private _tmpMatrix;
  80434. /**
  80435. * This function is called by the two RIG cameras.
  80436. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80437. * @hidden
  80438. */
  80439. _getWebVRViewMatrix(): Matrix;
  80440. /** @hidden */
  80441. _getWebVRProjectionMatrix(): Matrix;
  80442. private _onGamepadConnectedObserver;
  80443. private _onGamepadDisconnectedObserver;
  80444. private _updateCacheWhenTrackingDisabledObserver;
  80445. /**
  80446. * Initializes the controllers and their meshes
  80447. */
  80448. initControllers(): void;
  80449. }
  80450. }
  80451. declare module BABYLON {
  80452. /**
  80453. * Size options for a post process
  80454. */
  80455. export type PostProcessOptions = {
  80456. width: number;
  80457. height: number;
  80458. };
  80459. /**
  80460. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80461. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80462. */
  80463. export class PostProcess {
  80464. /** Name of the PostProcess. */
  80465. name: string;
  80466. /**
  80467. * Gets or sets the unique id of the post process
  80468. */
  80469. uniqueId: number;
  80470. /**
  80471. * Width of the texture to apply the post process on
  80472. */
  80473. width: number;
  80474. /**
  80475. * Height of the texture to apply the post process on
  80476. */
  80477. height: number;
  80478. /**
  80479. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80480. * @hidden
  80481. */
  80482. _outputTexture: Nullable<InternalTexture>;
  80483. /**
  80484. * Sampling mode used by the shader
  80485. * See https://doc.babylonjs.com/classes/3.1/texture
  80486. */
  80487. renderTargetSamplingMode: number;
  80488. /**
  80489. * Clear color to use when screen clearing
  80490. */
  80491. clearColor: Color4;
  80492. /**
  80493. * If the buffer needs to be cleared before applying the post process. (default: true)
  80494. * Should be set to false if shader will overwrite all previous pixels.
  80495. */
  80496. autoClear: boolean;
  80497. /**
  80498. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80499. */
  80500. alphaMode: number;
  80501. /**
  80502. * Sets the setAlphaBlendConstants of the babylon engine
  80503. */
  80504. alphaConstants: Color4;
  80505. /**
  80506. * Animations to be used for the post processing
  80507. */
  80508. animations: Animation[];
  80509. /**
  80510. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80511. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80512. */
  80513. enablePixelPerfectMode: boolean;
  80514. /**
  80515. * Force the postprocess to be applied without taking in account viewport
  80516. */
  80517. forceFullscreenViewport: boolean;
  80518. /**
  80519. * List of inspectable custom properties (used by the Inspector)
  80520. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80521. */
  80522. inspectableCustomProperties: IInspectable[];
  80523. /**
  80524. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80525. *
  80526. * | Value | Type | Description |
  80527. * | ----- | ----------------------------------- | ----------- |
  80528. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80529. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80530. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80531. *
  80532. */
  80533. scaleMode: number;
  80534. /**
  80535. * Force textures to be a power of two (default: false)
  80536. */
  80537. alwaysForcePOT: boolean;
  80538. private _samples;
  80539. /**
  80540. * Number of sample textures (default: 1)
  80541. */
  80542. samples: number;
  80543. /**
  80544. * Modify the scale of the post process to be the same as the viewport (default: false)
  80545. */
  80546. adaptScaleToCurrentViewport: boolean;
  80547. private _camera;
  80548. private _scene;
  80549. private _engine;
  80550. private _options;
  80551. private _reusable;
  80552. private _textureType;
  80553. /**
  80554. * Smart array of input and output textures for the post process.
  80555. * @hidden
  80556. */
  80557. _textures: SmartArray<InternalTexture>;
  80558. /**
  80559. * The index in _textures that corresponds to the output texture.
  80560. * @hidden
  80561. */
  80562. _currentRenderTextureInd: number;
  80563. private _effect;
  80564. private _samplers;
  80565. private _fragmentUrl;
  80566. private _vertexUrl;
  80567. private _parameters;
  80568. private _scaleRatio;
  80569. protected _indexParameters: any;
  80570. private _shareOutputWithPostProcess;
  80571. private _texelSize;
  80572. private _forcedOutputTexture;
  80573. /**
  80574. * Returns the fragment url or shader name used in the post process.
  80575. * @returns the fragment url or name in the shader store.
  80576. */
  80577. getEffectName(): string;
  80578. /**
  80579. * An event triggered when the postprocess is activated.
  80580. */
  80581. onActivateObservable: Observable<Camera>;
  80582. private _onActivateObserver;
  80583. /**
  80584. * A function that is added to the onActivateObservable
  80585. */
  80586. onActivate: Nullable<(camera: Camera) => void>;
  80587. /**
  80588. * An event triggered when the postprocess changes its size.
  80589. */
  80590. onSizeChangedObservable: Observable<PostProcess>;
  80591. private _onSizeChangedObserver;
  80592. /**
  80593. * A function that is added to the onSizeChangedObservable
  80594. */
  80595. onSizeChanged: (postProcess: PostProcess) => void;
  80596. /**
  80597. * An event triggered when the postprocess applies its effect.
  80598. */
  80599. onApplyObservable: Observable<Effect>;
  80600. private _onApplyObserver;
  80601. /**
  80602. * A function that is added to the onApplyObservable
  80603. */
  80604. onApply: (effect: Effect) => void;
  80605. /**
  80606. * An event triggered before rendering the postprocess
  80607. */
  80608. onBeforeRenderObservable: Observable<Effect>;
  80609. private _onBeforeRenderObserver;
  80610. /**
  80611. * A function that is added to the onBeforeRenderObservable
  80612. */
  80613. onBeforeRender: (effect: Effect) => void;
  80614. /**
  80615. * An event triggered after rendering the postprocess
  80616. */
  80617. onAfterRenderObservable: Observable<Effect>;
  80618. private _onAfterRenderObserver;
  80619. /**
  80620. * A function that is added to the onAfterRenderObservable
  80621. */
  80622. onAfterRender: (efect: Effect) => void;
  80623. /**
  80624. * 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
  80625. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80626. */
  80627. inputTexture: InternalTexture;
  80628. /**
  80629. * Gets the camera which post process is applied to.
  80630. * @returns The camera the post process is applied to.
  80631. */
  80632. getCamera(): Camera;
  80633. /**
  80634. * Gets the texel size of the postprocess.
  80635. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80636. */
  80637. readonly texelSize: Vector2;
  80638. /**
  80639. * Creates a new instance PostProcess
  80640. * @param name The name of the PostProcess.
  80641. * @param fragmentUrl The url of the fragment shader to be used.
  80642. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80643. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80644. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80645. * @param camera The camera to apply the render pass to.
  80646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80647. * @param engine The engine which the post process will be applied. (default: current engine)
  80648. * @param reusable If the post process can be reused on the same frame. (default: false)
  80649. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80650. * @param textureType Type of textures used when performing the post process. (default: 0)
  80651. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80652. * @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
  80653. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80654. */
  80655. constructor(
  80656. /** Name of the PostProcess. */
  80657. 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);
  80658. /**
  80659. * Gets a string idenfifying the name of the class
  80660. * @returns "PostProcess" string
  80661. */
  80662. getClassName(): string;
  80663. /**
  80664. * Gets the engine which this post process belongs to.
  80665. * @returns The engine the post process was enabled with.
  80666. */
  80667. getEngine(): Engine;
  80668. /**
  80669. * The effect that is created when initializing the post process.
  80670. * @returns The created effect corresponding the the postprocess.
  80671. */
  80672. getEffect(): Effect;
  80673. /**
  80674. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  80675. * @param postProcess The post process to share the output with.
  80676. * @returns This post process.
  80677. */
  80678. shareOutputWith(postProcess: PostProcess): PostProcess;
  80679. /**
  80680. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  80681. * This should be called if the post process that shares output with this post process is disabled/disposed.
  80682. */
  80683. useOwnOutput(): void;
  80684. /**
  80685. * Updates the effect with the current post process compile time values and recompiles the shader.
  80686. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80687. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80688. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80689. * @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
  80690. * @param onCompiled Called when the shader has been compiled.
  80691. * @param onError Called if there is an error when compiling a shader.
  80692. */
  80693. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80694. /**
  80695. * The post process is reusable if it can be used multiple times within one frame.
  80696. * @returns If the post process is reusable
  80697. */
  80698. isReusable(): boolean;
  80699. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  80700. markTextureDirty(): void;
  80701. /**
  80702. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  80703. * 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.
  80704. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  80705. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  80706. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  80707. * @returns The target texture that was bound to be written to.
  80708. */
  80709. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  80710. /**
  80711. * If the post process is supported.
  80712. */
  80713. readonly isSupported: boolean;
  80714. /**
  80715. * The aspect ratio of the output texture.
  80716. */
  80717. readonly aspectRatio: number;
  80718. /**
  80719. * Get a value indicating if the post-process is ready to be used
  80720. * @returns true if the post-process is ready (shader is compiled)
  80721. */
  80722. isReady(): boolean;
  80723. /**
  80724. * Binds all textures and uniforms to the shader, this will be run on every pass.
  80725. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  80726. */
  80727. apply(): Nullable<Effect>;
  80728. private _disposeTextures;
  80729. /**
  80730. * Disposes the post process.
  80731. * @param camera The camera to dispose the post process on.
  80732. */
  80733. dispose(camera?: Camera): void;
  80734. }
  80735. }
  80736. declare module BABYLON {
  80737. /** @hidden */
  80738. export var kernelBlurVaryingDeclaration: {
  80739. name: string;
  80740. shader: string;
  80741. };
  80742. }
  80743. declare module BABYLON {
  80744. /** @hidden */
  80745. export var kernelBlurFragment: {
  80746. name: string;
  80747. shader: string;
  80748. };
  80749. }
  80750. declare module BABYLON {
  80751. /** @hidden */
  80752. export var kernelBlurFragment2: {
  80753. name: string;
  80754. shader: string;
  80755. };
  80756. }
  80757. declare module BABYLON {
  80758. /** @hidden */
  80759. export var kernelBlurPixelShader: {
  80760. name: string;
  80761. shader: string;
  80762. };
  80763. }
  80764. declare module BABYLON {
  80765. /** @hidden */
  80766. export var kernelBlurVertex: {
  80767. name: string;
  80768. shader: string;
  80769. };
  80770. }
  80771. declare module BABYLON {
  80772. /** @hidden */
  80773. export var kernelBlurVertexShader: {
  80774. name: string;
  80775. shader: string;
  80776. };
  80777. }
  80778. declare module BABYLON {
  80779. /**
  80780. * The Blur Post Process which blurs an image based on a kernel and direction.
  80781. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  80782. */
  80783. export class BlurPostProcess extends PostProcess {
  80784. /** The direction in which to blur the image. */
  80785. direction: Vector2;
  80786. private blockCompilation;
  80787. protected _kernel: number;
  80788. protected _idealKernel: number;
  80789. protected _packedFloat: boolean;
  80790. private _staticDefines;
  80791. /**
  80792. * Sets the length in pixels of the blur sample region
  80793. */
  80794. /**
  80795. * Gets the length in pixels of the blur sample region
  80796. */
  80797. kernel: number;
  80798. /**
  80799. * Sets wether or not the blur needs to unpack/repack floats
  80800. */
  80801. /**
  80802. * Gets wether or not the blur is unpacking/repacking floats
  80803. */
  80804. packedFloat: boolean;
  80805. /**
  80806. * Creates a new instance BlurPostProcess
  80807. * @param name The name of the effect.
  80808. * @param direction The direction in which to blur the image.
  80809. * @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.
  80810. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80811. * @param camera The camera to apply the render pass to.
  80812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80813. * @param engine The engine which the post process will be applied. (default: current engine)
  80814. * @param reusable If the post process can be reused on the same frame. (default: false)
  80815. * @param textureType Type of textures used when performing the post process. (default: 0)
  80816. * @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)
  80817. */
  80818. constructor(name: string,
  80819. /** The direction in which to blur the image. */
  80820. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  80821. /**
  80822. * Updates the effect with the current post process compile time values and recompiles the shader.
  80823. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80824. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80825. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80826. * @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
  80827. * @param onCompiled Called when the shader has been compiled.
  80828. * @param onError Called if there is an error when compiling a shader.
  80829. */
  80830. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80831. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80832. /**
  80833. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  80834. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  80835. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  80836. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  80837. * The gaps between physical kernels are compensated for in the weighting of the samples
  80838. * @param idealKernel Ideal blur kernel.
  80839. * @return Nearest best kernel.
  80840. */
  80841. protected _nearestBestKernel(idealKernel: number): number;
  80842. /**
  80843. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  80844. * @param x The point on the Gaussian distribution to sample.
  80845. * @return the value of the Gaussian function at x.
  80846. */
  80847. protected _gaussianWeight(x: number): number;
  80848. /**
  80849. * Generates a string that can be used as a floating point number in GLSL.
  80850. * @param x Value to print.
  80851. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  80852. * @return GLSL float string.
  80853. */
  80854. protected _glslFloat(x: number, decimalFigures?: number): string;
  80855. }
  80856. }
  80857. declare module BABYLON {
  80858. /**
  80859. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80860. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80861. * You can then easily use it as a reflectionTexture on a flat surface.
  80862. * In case the surface is not a plane, please consider relying on reflection probes.
  80863. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80864. */
  80865. export class MirrorTexture extends RenderTargetTexture {
  80866. private scene;
  80867. /**
  80868. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80869. * 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.
  80870. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80871. */
  80872. mirrorPlane: Plane;
  80873. /**
  80874. * Define the blur ratio used to blur the reflection if needed.
  80875. */
  80876. blurRatio: number;
  80877. /**
  80878. * Define the adaptive blur kernel used to blur the reflection if needed.
  80879. * This will autocompute the closest best match for the `blurKernel`
  80880. */
  80881. adaptiveBlurKernel: number;
  80882. /**
  80883. * Define the blur kernel used to blur the reflection if needed.
  80884. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80885. */
  80886. blurKernel: number;
  80887. /**
  80888. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80889. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80890. */
  80891. blurKernelX: number;
  80892. /**
  80893. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80894. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80895. */
  80896. blurKernelY: number;
  80897. private _autoComputeBlurKernel;
  80898. protected _onRatioRescale(): void;
  80899. private _updateGammaSpace;
  80900. private _imageProcessingConfigChangeObserver;
  80901. private _transformMatrix;
  80902. private _mirrorMatrix;
  80903. private _savedViewMatrix;
  80904. private _blurX;
  80905. private _blurY;
  80906. private _adaptiveBlurKernel;
  80907. private _blurKernelX;
  80908. private _blurKernelY;
  80909. private _blurRatio;
  80910. /**
  80911. * Instantiates a Mirror Texture.
  80912. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80913. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80914. * You can then easily use it as a reflectionTexture on a flat surface.
  80915. * In case the surface is not a plane, please consider relying on reflection probes.
  80916. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80917. * @param name
  80918. * @param size
  80919. * @param scene
  80920. * @param generateMipMaps
  80921. * @param type
  80922. * @param samplingMode
  80923. * @param generateDepthBuffer
  80924. */
  80925. constructor(name: string, size: number | {
  80926. width: number;
  80927. height: number;
  80928. } | {
  80929. ratio: number;
  80930. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80931. private _preparePostProcesses;
  80932. /**
  80933. * Clone the mirror texture.
  80934. * @returns the cloned texture
  80935. */
  80936. clone(): MirrorTexture;
  80937. /**
  80938. * Serialize the texture to a JSON representation you could use in Parse later on
  80939. * @returns the serialized JSON representation
  80940. */
  80941. serialize(): any;
  80942. /**
  80943. * Dispose the texture and release its associated resources.
  80944. */
  80945. dispose(): void;
  80946. }
  80947. }
  80948. declare module BABYLON {
  80949. /**
  80950. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80951. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80952. */
  80953. export class Texture extends BaseTexture {
  80954. /** @hidden */
  80955. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80956. /** @hidden */
  80957. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80958. /** @hidden */
  80959. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80960. /** nearest is mag = nearest and min = nearest and mip = linear */
  80961. static readonly NEAREST_SAMPLINGMODE: number;
  80962. /** nearest is mag = nearest and min = nearest and mip = linear */
  80963. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80964. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80965. static readonly BILINEAR_SAMPLINGMODE: number;
  80966. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80967. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80968. /** Trilinear is mag = linear and min = linear and mip = linear */
  80969. static readonly TRILINEAR_SAMPLINGMODE: number;
  80970. /** Trilinear is mag = linear and min = linear and mip = linear */
  80971. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  80972. /** mag = nearest and min = nearest and mip = nearest */
  80973. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  80974. /** mag = nearest and min = linear and mip = nearest */
  80975. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  80976. /** mag = nearest and min = linear and mip = linear */
  80977. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  80978. /** mag = nearest and min = linear and mip = none */
  80979. static readonly NEAREST_LINEAR: number;
  80980. /** mag = nearest and min = nearest and mip = none */
  80981. static readonly NEAREST_NEAREST: number;
  80982. /** mag = linear and min = nearest and mip = nearest */
  80983. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  80984. /** mag = linear and min = nearest and mip = linear */
  80985. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  80986. /** mag = linear and min = linear and mip = none */
  80987. static readonly LINEAR_LINEAR: number;
  80988. /** mag = linear and min = nearest and mip = none */
  80989. static readonly LINEAR_NEAREST: number;
  80990. /** Explicit coordinates mode */
  80991. static readonly EXPLICIT_MODE: number;
  80992. /** Spherical coordinates mode */
  80993. static readonly SPHERICAL_MODE: number;
  80994. /** Planar coordinates mode */
  80995. static readonly PLANAR_MODE: number;
  80996. /** Cubic coordinates mode */
  80997. static readonly CUBIC_MODE: number;
  80998. /** Projection coordinates mode */
  80999. static readonly PROJECTION_MODE: number;
  81000. /** Inverse Cubic coordinates mode */
  81001. static readonly SKYBOX_MODE: number;
  81002. /** Inverse Cubic coordinates mode */
  81003. static readonly INVCUBIC_MODE: number;
  81004. /** Equirectangular coordinates mode */
  81005. static readonly EQUIRECTANGULAR_MODE: number;
  81006. /** Equirectangular Fixed coordinates mode */
  81007. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81008. /** Equirectangular Fixed Mirrored coordinates mode */
  81009. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81010. /** Texture is not repeating outside of 0..1 UVs */
  81011. static readonly CLAMP_ADDRESSMODE: number;
  81012. /** Texture is repeating outside of 0..1 UVs */
  81013. static readonly WRAP_ADDRESSMODE: number;
  81014. /** Texture is repeating and mirrored */
  81015. static readonly MIRROR_ADDRESSMODE: number;
  81016. /**
  81017. * 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
  81018. */
  81019. static UseSerializedUrlIfAny: boolean;
  81020. /**
  81021. * Define the url of the texture.
  81022. */
  81023. url: Nullable<string>;
  81024. /**
  81025. * Define an offset on the texture to offset the u coordinates of the UVs
  81026. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81027. */
  81028. uOffset: number;
  81029. /**
  81030. * Define an offset on the texture to offset the v coordinates of the UVs
  81031. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81032. */
  81033. vOffset: number;
  81034. /**
  81035. * Define an offset on the texture to scale the u coordinates of the UVs
  81036. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81037. */
  81038. uScale: number;
  81039. /**
  81040. * Define an offset on the texture to scale the v coordinates of the UVs
  81041. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81042. */
  81043. vScale: number;
  81044. /**
  81045. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81046. * @see http://doc.babylonjs.com/how_to/more_materials
  81047. */
  81048. uAng: number;
  81049. /**
  81050. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81051. * @see http://doc.babylonjs.com/how_to/more_materials
  81052. */
  81053. vAng: number;
  81054. /**
  81055. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81056. * @see http://doc.babylonjs.com/how_to/more_materials
  81057. */
  81058. wAng: number;
  81059. /**
  81060. * Defines the center of rotation (U)
  81061. */
  81062. uRotationCenter: number;
  81063. /**
  81064. * Defines the center of rotation (V)
  81065. */
  81066. vRotationCenter: number;
  81067. /**
  81068. * Defines the center of rotation (W)
  81069. */
  81070. wRotationCenter: number;
  81071. /**
  81072. * Are mip maps generated for this texture or not.
  81073. */
  81074. readonly noMipmap: boolean;
  81075. /**
  81076. * List of inspectable custom properties (used by the Inspector)
  81077. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81078. */
  81079. inspectableCustomProperties: Nullable<IInspectable[]>;
  81080. private _noMipmap;
  81081. /** @hidden */
  81082. _invertY: boolean;
  81083. private _rowGenerationMatrix;
  81084. private _cachedTextureMatrix;
  81085. private _projectionModeMatrix;
  81086. private _t0;
  81087. private _t1;
  81088. private _t2;
  81089. private _cachedUOffset;
  81090. private _cachedVOffset;
  81091. private _cachedUScale;
  81092. private _cachedVScale;
  81093. private _cachedUAng;
  81094. private _cachedVAng;
  81095. private _cachedWAng;
  81096. private _cachedProjectionMatrixId;
  81097. private _cachedCoordinatesMode;
  81098. /** @hidden */
  81099. protected _initialSamplingMode: number;
  81100. /** @hidden */
  81101. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  81102. private _deleteBuffer;
  81103. protected _format: Nullable<number>;
  81104. private _delayedOnLoad;
  81105. private _delayedOnError;
  81106. /**
  81107. * Observable triggered once the texture has been loaded.
  81108. */
  81109. onLoadObservable: Observable<Texture>;
  81110. protected _isBlocking: boolean;
  81111. /**
  81112. * Is the texture preventing material to render while loading.
  81113. * If false, a default texture will be used instead of the loading one during the preparation step.
  81114. */
  81115. isBlocking: boolean;
  81116. /**
  81117. * Get the current sampling mode associated with the texture.
  81118. */
  81119. readonly samplingMode: number;
  81120. /**
  81121. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81122. */
  81123. readonly invertY: boolean;
  81124. /**
  81125. * Instantiates a new texture.
  81126. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81127. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81128. * @param url define the url of the picture to load as a texture
  81129. * @param scene define the scene the texture will belong to
  81130. * @param noMipmap define if the texture will require mip maps or not
  81131. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81132. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81133. * @param onLoad define a callback triggered when the texture has been loaded
  81134. * @param onError define a callback triggered when an error occurred during the loading session
  81135. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81136. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81137. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81138. */
  81139. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  81140. /**
  81141. * Update the url (and optional buffer) of this texture if url was null during construction.
  81142. * @param url the url of the texture
  81143. * @param buffer the buffer of the texture (defaults to null)
  81144. * @param onLoad callback called when the texture is loaded (defaults to null)
  81145. */
  81146. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81147. /**
  81148. * Finish the loading sequence of a texture flagged as delayed load.
  81149. * @hidden
  81150. */
  81151. delayLoad(): void;
  81152. private _prepareRowForTextureGeneration;
  81153. /**
  81154. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81155. * @returns the transform matrix of the texture.
  81156. */
  81157. getTextureMatrix(): Matrix;
  81158. /**
  81159. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81160. * @returns The reflection texture transform
  81161. */
  81162. getReflectionTextureMatrix(): Matrix;
  81163. /**
  81164. * Clones the texture.
  81165. * @returns the cloned texture
  81166. */
  81167. clone(): Texture;
  81168. /**
  81169. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81170. * @returns The JSON representation of the texture
  81171. */
  81172. serialize(): any;
  81173. /**
  81174. * Get the current class name of the texture useful for serialization or dynamic coding.
  81175. * @returns "Texture"
  81176. */
  81177. getClassName(): string;
  81178. /**
  81179. * Dispose the texture and release its associated resources.
  81180. */
  81181. dispose(): void;
  81182. /**
  81183. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81184. * @param parsedTexture Define the JSON representation of the texture
  81185. * @param scene Define the scene the parsed texture should be instantiated in
  81186. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81187. * @returns The parsed texture if successful
  81188. */
  81189. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81190. /**
  81191. * Creates a texture from its base 64 representation.
  81192. * @param data Define the base64 payload without the data: prefix
  81193. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81194. * @param scene Define the scene the texture should belong to
  81195. * @param noMipmap Forces the texture to not create mip map information if true
  81196. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81197. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81198. * @param onLoad define a callback triggered when the texture has been loaded
  81199. * @param onError define a callback triggered when an error occurred during the loading session
  81200. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81201. * @returns the created texture
  81202. */
  81203. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81204. /**
  81205. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81206. * @param data Define the base64 payload without the data: prefix
  81207. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81208. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81209. * @param scene Define the scene the texture should belong to
  81210. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81211. * @param noMipmap Forces the texture to not create mip map information if true
  81212. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81213. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81214. * @param onLoad define a callback triggered when the texture has been loaded
  81215. * @param onError define a callback triggered when an error occurred during the loading session
  81216. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81217. * @returns the created texture
  81218. */
  81219. 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;
  81220. }
  81221. }
  81222. declare module BABYLON {
  81223. /**
  81224. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81225. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81226. */
  81227. export class PostProcessManager {
  81228. private _scene;
  81229. private _indexBuffer;
  81230. private _vertexBuffers;
  81231. /**
  81232. * Creates a new instance PostProcess
  81233. * @param scene The scene that the post process is associated with.
  81234. */
  81235. constructor(scene: Scene);
  81236. private _prepareBuffers;
  81237. private _buildIndexBuffer;
  81238. /**
  81239. * Rebuilds the vertex buffers of the manager.
  81240. * @hidden
  81241. */
  81242. _rebuild(): void;
  81243. /**
  81244. * Prepares a frame to be run through a post process.
  81245. * @param sourceTexture The input texture to the post procesess. (default: null)
  81246. * @param postProcesses An array of post processes to be run. (default: null)
  81247. * @returns True if the post processes were able to be run.
  81248. * @hidden
  81249. */
  81250. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81251. /**
  81252. * Manually render a set of post processes to a texture.
  81253. * @param postProcesses An array of post processes to be run.
  81254. * @param targetTexture The target texture to render to.
  81255. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81256. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81257. * @param lodLevel defines which lod of the texture to render to
  81258. */
  81259. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81260. /**
  81261. * Finalize the result of the output of the postprocesses.
  81262. * @param doNotPresent If true the result will not be displayed to the screen.
  81263. * @param targetTexture The target texture to render to.
  81264. * @param faceIndex The index of the face to bind the target texture to.
  81265. * @param postProcesses The array of post processes to render.
  81266. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81267. * @hidden
  81268. */
  81269. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81270. /**
  81271. * Disposes of the post process manager.
  81272. */
  81273. dispose(): void;
  81274. }
  81275. }
  81276. declare module BABYLON {
  81277. interface AbstractScene {
  81278. /**
  81279. * The list of procedural textures added to the scene
  81280. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81281. */
  81282. proceduralTextures: Array<ProceduralTexture>;
  81283. }
  81284. /**
  81285. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81286. * in a given scene.
  81287. */
  81288. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81289. /**
  81290. * The component name helpfull to identify the component in the list of scene components.
  81291. */
  81292. readonly name: string;
  81293. /**
  81294. * The scene the component belongs to.
  81295. */
  81296. scene: Scene;
  81297. /**
  81298. * Creates a new instance of the component for the given scene
  81299. * @param scene Defines the scene to register the component in
  81300. */
  81301. constructor(scene: Scene);
  81302. /**
  81303. * Registers the component in a given scene
  81304. */
  81305. register(): void;
  81306. /**
  81307. * Rebuilds the elements related to this component in case of
  81308. * context lost for instance.
  81309. */
  81310. rebuild(): void;
  81311. /**
  81312. * Disposes the component and the associated ressources.
  81313. */
  81314. dispose(): void;
  81315. private _beforeClear;
  81316. }
  81317. }
  81318. declare module BABYLON {
  81319. interface Engine {
  81320. /**
  81321. * Creates a new render target cube texture
  81322. * @param size defines the size of the texture
  81323. * @param options defines the options used to create the texture
  81324. * @returns a new render target cube texture stored in an InternalTexture
  81325. */
  81326. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81327. }
  81328. }
  81329. declare module BABYLON {
  81330. /** @hidden */
  81331. export var proceduralVertexShader: {
  81332. name: string;
  81333. shader: string;
  81334. };
  81335. }
  81336. declare module BABYLON {
  81337. /**
  81338. * 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.
  81339. * This is the base class of any Procedural texture and contains most of the shareable code.
  81340. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81341. */
  81342. export class ProceduralTexture extends Texture {
  81343. isCube: boolean;
  81344. /**
  81345. * Define if the texture is enabled or not (disabled texture will not render)
  81346. */
  81347. isEnabled: boolean;
  81348. /**
  81349. * Define if the texture must be cleared before rendering (default is true)
  81350. */
  81351. autoClear: boolean;
  81352. /**
  81353. * Callback called when the texture is generated
  81354. */
  81355. onGenerated: () => void;
  81356. /**
  81357. * Event raised when the texture is generated
  81358. */
  81359. onGeneratedObservable: Observable<ProceduralTexture>;
  81360. /** @hidden */
  81361. _generateMipMaps: boolean;
  81362. /** @hidden **/
  81363. _effect: Effect;
  81364. /** @hidden */
  81365. _textures: {
  81366. [key: string]: Texture;
  81367. };
  81368. private _size;
  81369. private _currentRefreshId;
  81370. private _refreshRate;
  81371. private _vertexBuffers;
  81372. private _indexBuffer;
  81373. private _uniforms;
  81374. private _samplers;
  81375. private _fragment;
  81376. private _floats;
  81377. private _ints;
  81378. private _floatsArrays;
  81379. private _colors3;
  81380. private _colors4;
  81381. private _vectors2;
  81382. private _vectors3;
  81383. private _matrices;
  81384. private _fallbackTexture;
  81385. private _fallbackTextureUsed;
  81386. private _engine;
  81387. private _cachedDefines;
  81388. private _contentUpdateId;
  81389. private _contentData;
  81390. /**
  81391. * Instantiates a new procedural texture.
  81392. * 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.
  81393. * This is the base class of any Procedural texture and contains most of the shareable code.
  81394. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81395. * @param name Define the name of the texture
  81396. * @param size Define the size of the texture to create
  81397. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81398. * @param scene Define the scene the texture belongs to
  81399. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81400. * @param generateMipMaps Define if the texture should creates mip maps or not
  81401. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81402. */
  81403. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81404. /**
  81405. * The effect that is created when initializing the post process.
  81406. * @returns The created effect corresponding the the postprocess.
  81407. */
  81408. getEffect(): Effect;
  81409. /**
  81410. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81411. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81412. */
  81413. getContent(): Nullable<ArrayBufferView>;
  81414. private _createIndexBuffer;
  81415. /** @hidden */
  81416. _rebuild(): void;
  81417. /**
  81418. * Resets the texture in order to recreate its associated resources.
  81419. * This can be called in case of context loss
  81420. */
  81421. reset(): void;
  81422. protected _getDefines(): string;
  81423. /**
  81424. * Is the texture ready to be used ? (rendered at least once)
  81425. * @returns true if ready, otherwise, false.
  81426. */
  81427. isReady(): boolean;
  81428. /**
  81429. * Resets the refresh counter of the texture and start bak from scratch.
  81430. * Could be useful to regenerate the texture if it is setup to render only once.
  81431. */
  81432. resetRefreshCounter(): void;
  81433. /**
  81434. * Set the fragment shader to use in order to render the texture.
  81435. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81436. */
  81437. setFragment(fragment: any): void;
  81438. /**
  81439. * Define the refresh rate of the texture or the rendering frequency.
  81440. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81441. */
  81442. refreshRate: number;
  81443. /** @hidden */
  81444. _shouldRender(): boolean;
  81445. /**
  81446. * Get the size the texture is rendering at.
  81447. * @returns the size (texture is always squared)
  81448. */
  81449. getRenderSize(): number;
  81450. /**
  81451. * Resize the texture to new value.
  81452. * @param size Define the new size the texture should have
  81453. * @param generateMipMaps Define whether the new texture should create mip maps
  81454. */
  81455. resize(size: number, generateMipMaps: boolean): void;
  81456. private _checkUniform;
  81457. /**
  81458. * Set a texture in the shader program used to render.
  81459. * @param name Define the name of the uniform samplers as defined in the shader
  81460. * @param texture Define the texture to bind to this sampler
  81461. * @return the texture itself allowing "fluent" like uniform updates
  81462. */
  81463. setTexture(name: string, texture: Texture): ProceduralTexture;
  81464. /**
  81465. * Set a float in the shader.
  81466. * @param name Define the name of the uniform as defined in the shader
  81467. * @param value Define the value to give to the uniform
  81468. * @return the texture itself allowing "fluent" like uniform updates
  81469. */
  81470. setFloat(name: string, value: number): ProceduralTexture;
  81471. /**
  81472. * Set a int in the shader.
  81473. * @param name Define the name of the uniform as defined in the shader
  81474. * @param value Define the value to give to the uniform
  81475. * @return the texture itself allowing "fluent" like uniform updates
  81476. */
  81477. setInt(name: string, value: number): ProceduralTexture;
  81478. /**
  81479. * Set an array of floats in the shader.
  81480. * @param name Define the name of the uniform as defined in the shader
  81481. * @param value Define the value to give to the uniform
  81482. * @return the texture itself allowing "fluent" like uniform updates
  81483. */
  81484. setFloats(name: string, value: number[]): ProceduralTexture;
  81485. /**
  81486. * Set a vec3 in the shader from a Color3.
  81487. * @param name Define the name of the uniform as defined in the shader
  81488. * @param value Define the value to give to the uniform
  81489. * @return the texture itself allowing "fluent" like uniform updates
  81490. */
  81491. setColor3(name: string, value: Color3): ProceduralTexture;
  81492. /**
  81493. * Set a vec4 in the shader from a Color4.
  81494. * @param name Define the name of the uniform as defined in the shader
  81495. * @param value Define the value to give to the uniform
  81496. * @return the texture itself allowing "fluent" like uniform updates
  81497. */
  81498. setColor4(name: string, value: Color4): ProceduralTexture;
  81499. /**
  81500. * Set a vec2 in the shader from a Vector2.
  81501. * @param name Define the name of the uniform as defined in the shader
  81502. * @param value Define the value to give to the uniform
  81503. * @return the texture itself allowing "fluent" like uniform updates
  81504. */
  81505. setVector2(name: string, value: Vector2): ProceduralTexture;
  81506. /**
  81507. * Set a vec3 in the shader from a Vector3.
  81508. * @param name Define the name of the uniform as defined in the shader
  81509. * @param value Define the value to give to the uniform
  81510. * @return the texture itself allowing "fluent" like uniform updates
  81511. */
  81512. setVector3(name: string, value: Vector3): ProceduralTexture;
  81513. /**
  81514. * Set a mat4 in the shader from a MAtrix.
  81515. * @param name Define the name of the uniform as defined in the shader
  81516. * @param value Define the value to give to the uniform
  81517. * @return the texture itself allowing "fluent" like uniform updates
  81518. */
  81519. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81520. /**
  81521. * Render the texture to its associated render target.
  81522. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81523. */
  81524. render(useCameraPostProcess?: boolean): void;
  81525. /**
  81526. * Clone the texture.
  81527. * @returns the cloned texture
  81528. */
  81529. clone(): ProceduralTexture;
  81530. /**
  81531. * Dispose the texture and release its asoociated resources.
  81532. */
  81533. dispose(): void;
  81534. }
  81535. }
  81536. declare module BABYLON {
  81537. /**
  81538. * This represents the base class for particle system in Babylon.
  81539. * 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.
  81540. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81541. * @example https://doc.babylonjs.com/babylon101/particles
  81542. */
  81543. export class BaseParticleSystem {
  81544. /**
  81545. * Source color is added to the destination color without alpha affecting the result
  81546. */
  81547. static BLENDMODE_ONEONE: number;
  81548. /**
  81549. * Blend current color and particle color using particle’s alpha
  81550. */
  81551. static BLENDMODE_STANDARD: number;
  81552. /**
  81553. * Add current color and particle color multiplied by particle’s alpha
  81554. */
  81555. static BLENDMODE_ADD: number;
  81556. /**
  81557. * Multiply current color with particle color
  81558. */
  81559. static BLENDMODE_MULTIPLY: number;
  81560. /**
  81561. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81562. */
  81563. static BLENDMODE_MULTIPLYADD: number;
  81564. /**
  81565. * List of animations used by the particle system.
  81566. */
  81567. animations: Animation[];
  81568. /**
  81569. * The id of the Particle system.
  81570. */
  81571. id: string;
  81572. /**
  81573. * The friendly name of the Particle system.
  81574. */
  81575. name: string;
  81576. /**
  81577. * The rendering group used by the Particle system to chose when to render.
  81578. */
  81579. renderingGroupId: number;
  81580. /**
  81581. * The emitter represents the Mesh or position we are attaching the particle system to.
  81582. */
  81583. emitter: Nullable<AbstractMesh | Vector3>;
  81584. /**
  81585. * The maximum number of particles to emit per frame
  81586. */
  81587. emitRate: number;
  81588. /**
  81589. * If you want to launch only a few particles at once, that can be done, as well.
  81590. */
  81591. manualEmitCount: number;
  81592. /**
  81593. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81594. */
  81595. updateSpeed: number;
  81596. /**
  81597. * The amount of time the particle system is running (depends of the overall update speed).
  81598. */
  81599. targetStopDuration: number;
  81600. /**
  81601. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81602. */
  81603. disposeOnStop: boolean;
  81604. /**
  81605. * Minimum power of emitting particles.
  81606. */
  81607. minEmitPower: number;
  81608. /**
  81609. * Maximum power of emitting particles.
  81610. */
  81611. maxEmitPower: number;
  81612. /**
  81613. * Minimum life time of emitting particles.
  81614. */
  81615. minLifeTime: number;
  81616. /**
  81617. * Maximum life time of emitting particles.
  81618. */
  81619. maxLifeTime: number;
  81620. /**
  81621. * Minimum Size of emitting particles.
  81622. */
  81623. minSize: number;
  81624. /**
  81625. * Maximum Size of emitting particles.
  81626. */
  81627. maxSize: number;
  81628. /**
  81629. * Minimum scale of emitting particles on X axis.
  81630. */
  81631. minScaleX: number;
  81632. /**
  81633. * Maximum scale of emitting particles on X axis.
  81634. */
  81635. maxScaleX: number;
  81636. /**
  81637. * Minimum scale of emitting particles on Y axis.
  81638. */
  81639. minScaleY: number;
  81640. /**
  81641. * Maximum scale of emitting particles on Y axis.
  81642. */
  81643. maxScaleY: number;
  81644. /**
  81645. * Gets or sets the minimal initial rotation in radians.
  81646. */
  81647. minInitialRotation: number;
  81648. /**
  81649. * Gets or sets the maximal initial rotation in radians.
  81650. */
  81651. maxInitialRotation: number;
  81652. /**
  81653. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81654. */
  81655. minAngularSpeed: number;
  81656. /**
  81657. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81658. */
  81659. maxAngularSpeed: number;
  81660. /**
  81661. * The texture used to render each particle. (this can be a spritesheet)
  81662. */
  81663. particleTexture: Nullable<Texture>;
  81664. /**
  81665. * The layer mask we are rendering the particles through.
  81666. */
  81667. layerMask: number;
  81668. /**
  81669. * This can help using your own shader to render the particle system.
  81670. * The according effect will be created
  81671. */
  81672. customShader: any;
  81673. /**
  81674. * By default particle system starts as soon as they are created. This prevents the
  81675. * automatic start to happen and let you decide when to start emitting particles.
  81676. */
  81677. preventAutoStart: boolean;
  81678. private _noiseTexture;
  81679. /**
  81680. * Gets or sets a texture used to add random noise to particle positions
  81681. */
  81682. noiseTexture: Nullable<ProceduralTexture>;
  81683. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81684. noiseStrength: Vector3;
  81685. /**
  81686. * Callback triggered when the particle animation is ending.
  81687. */
  81688. onAnimationEnd: Nullable<() => void>;
  81689. /**
  81690. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  81691. */
  81692. blendMode: number;
  81693. /**
  81694. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  81695. * to override the particles.
  81696. */
  81697. forceDepthWrite: boolean;
  81698. /** 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 */
  81699. preWarmCycles: number;
  81700. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  81701. preWarmStepOffset: number;
  81702. /**
  81703. * 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)
  81704. */
  81705. spriteCellChangeSpeed: number;
  81706. /**
  81707. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81708. */
  81709. startSpriteCellID: number;
  81710. /**
  81711. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81712. */
  81713. endSpriteCellID: number;
  81714. /**
  81715. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81716. */
  81717. spriteCellWidth: number;
  81718. /**
  81719. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81720. */
  81721. spriteCellHeight: number;
  81722. /**
  81723. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81724. */
  81725. spriteRandomStartCell: boolean;
  81726. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81727. translationPivot: Vector2;
  81728. /** @hidden */
  81729. protected _isAnimationSheetEnabled: boolean;
  81730. /**
  81731. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81732. */
  81733. beginAnimationOnStart: boolean;
  81734. /**
  81735. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81736. */
  81737. beginAnimationFrom: number;
  81738. /**
  81739. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81740. */
  81741. beginAnimationTo: number;
  81742. /**
  81743. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81744. */
  81745. beginAnimationLoop: boolean;
  81746. /**
  81747. * Gets or sets a world offset applied to all particles
  81748. */
  81749. worldOffset: Vector3;
  81750. /**
  81751. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  81752. */
  81753. isAnimationSheetEnabled: boolean;
  81754. /**
  81755. * Get hosting scene
  81756. * @returns the scene
  81757. */
  81758. getScene(): Scene;
  81759. /**
  81760. * You can use gravity if you want to give an orientation to your particles.
  81761. */
  81762. gravity: Vector3;
  81763. protected _colorGradients: Nullable<Array<ColorGradient>>;
  81764. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  81765. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  81766. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  81767. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  81768. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  81769. protected _dragGradients: Nullable<Array<FactorGradient>>;
  81770. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  81771. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  81772. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  81773. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  81774. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  81775. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  81776. /**
  81777. * Defines the delay in milliseconds before starting the system (0 by default)
  81778. */
  81779. startDelay: number;
  81780. /**
  81781. * Gets the current list of drag gradients.
  81782. * You must use addDragGradient and removeDragGradient to udpate this list
  81783. * @returns the list of drag gradients
  81784. */
  81785. getDragGradients(): Nullable<Array<FactorGradient>>;
  81786. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81787. limitVelocityDamping: number;
  81788. /**
  81789. * Gets the current list of limit velocity gradients.
  81790. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81791. * @returns the list of limit velocity gradients
  81792. */
  81793. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81794. /**
  81795. * Gets the current list of color gradients.
  81796. * You must use addColorGradient and removeColorGradient to udpate this list
  81797. * @returns the list of color gradients
  81798. */
  81799. getColorGradients(): Nullable<Array<ColorGradient>>;
  81800. /**
  81801. * Gets the current list of size gradients.
  81802. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81803. * @returns the list of size gradients
  81804. */
  81805. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81806. /**
  81807. * Gets the current list of color remap gradients.
  81808. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  81809. * @returns the list of color remap gradients
  81810. */
  81811. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  81812. /**
  81813. * Gets the current list of alpha remap gradients.
  81814. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  81815. * @returns the list of alpha remap gradients
  81816. */
  81817. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  81818. /**
  81819. * Gets the current list of life time gradients.
  81820. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  81821. * @returns the list of life time gradients
  81822. */
  81823. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  81824. /**
  81825. * Gets the current list of angular speed gradients.
  81826. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81827. * @returns the list of angular speed gradients
  81828. */
  81829. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81830. /**
  81831. * Gets the current list of velocity gradients.
  81832. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  81833. * @returns the list of velocity gradients
  81834. */
  81835. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  81836. /**
  81837. * Gets the current list of start size gradients.
  81838. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  81839. * @returns the list of start size gradients
  81840. */
  81841. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  81842. /**
  81843. * Gets the current list of emit rate gradients.
  81844. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  81845. * @returns the list of emit rate gradients
  81846. */
  81847. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  81848. /**
  81849. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81850. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81851. */
  81852. direction1: Vector3;
  81853. /**
  81854. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81855. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81856. */
  81857. direction2: Vector3;
  81858. /**
  81859. * 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.
  81860. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81861. */
  81862. minEmitBox: Vector3;
  81863. /**
  81864. * 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.
  81865. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81866. */
  81867. maxEmitBox: Vector3;
  81868. /**
  81869. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81870. */
  81871. color1: Color4;
  81872. /**
  81873. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81874. */
  81875. color2: Color4;
  81876. /**
  81877. * Color the particle will have at the end of its lifetime
  81878. */
  81879. colorDead: Color4;
  81880. /**
  81881. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  81882. */
  81883. textureMask: Color4;
  81884. /**
  81885. * The particle emitter type defines the emitter used by the particle system.
  81886. * It can be for example box, sphere, or cone...
  81887. */
  81888. particleEmitterType: IParticleEmitterType;
  81889. /** @hidden */
  81890. _isSubEmitter: boolean;
  81891. /**
  81892. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81893. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81894. */
  81895. billboardMode: number;
  81896. protected _isBillboardBased: boolean;
  81897. /**
  81898. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81899. */
  81900. isBillboardBased: boolean;
  81901. /**
  81902. * The scene the particle system belongs to.
  81903. */
  81904. protected _scene: Scene;
  81905. /**
  81906. * Local cache of defines for image processing.
  81907. */
  81908. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  81909. /**
  81910. * Default configuration related to image processing available in the standard Material.
  81911. */
  81912. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  81913. /**
  81914. * Gets the image processing configuration used either in this material.
  81915. */
  81916. /**
  81917. * Sets the Default image processing configuration used either in the this material.
  81918. *
  81919. * If sets to null, the scene one is in use.
  81920. */
  81921. imageProcessingConfiguration: ImageProcessingConfiguration;
  81922. /**
  81923. * Attaches a new image processing configuration to the Standard Material.
  81924. * @param configuration
  81925. */
  81926. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  81927. /** @hidden */
  81928. protected _reset(): void;
  81929. /** @hidden */
  81930. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  81931. /**
  81932. * Instantiates a particle system.
  81933. * 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.
  81934. * @param name The name of the particle system
  81935. */
  81936. constructor(name: string);
  81937. /**
  81938. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  81939. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81940. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81941. * @returns the emitter
  81942. */
  81943. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  81944. /**
  81945. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  81946. * @param radius The radius of the hemisphere to emit from
  81947. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81948. * @returns the emitter
  81949. */
  81950. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  81951. /**
  81952. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  81953. * @param radius The radius of the sphere to emit from
  81954. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81955. * @returns the emitter
  81956. */
  81957. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  81958. /**
  81959. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  81960. * @param radius The radius of the sphere to emit from
  81961. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  81962. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  81963. * @returns the emitter
  81964. */
  81965. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  81966. /**
  81967. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  81968. * @param radius The radius of the emission cylinder
  81969. * @param height The height of the emission cylinder
  81970. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  81971. * @param directionRandomizer How much to randomize the particle direction [0-1]
  81972. * @returns the emitter
  81973. */
  81974. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  81975. /**
  81976. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  81977. * @param radius The radius of the cylinder to emit from
  81978. * @param height The height of the emission cylinder
  81979. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81980. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  81981. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  81982. * @returns the emitter
  81983. */
  81984. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  81985. /**
  81986. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  81987. * @param radius The radius of the cone to emit from
  81988. * @param angle The base angle of the cone
  81989. * @returns the emitter
  81990. */
  81991. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  81992. /**
  81993. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  81994. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81995. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81996. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81997. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81998. * @returns the emitter
  81999. */
  82000. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82001. }
  82002. }
  82003. declare module BABYLON {
  82004. /**
  82005. * Type of sub emitter
  82006. */
  82007. export enum SubEmitterType {
  82008. /**
  82009. * Attached to the particle over it's lifetime
  82010. */
  82011. ATTACHED = 0,
  82012. /**
  82013. * Created when the particle dies
  82014. */
  82015. END = 1
  82016. }
  82017. /**
  82018. * Sub emitter class used to emit particles from an existing particle
  82019. */
  82020. export class SubEmitter {
  82021. /**
  82022. * the particle system to be used by the sub emitter
  82023. */
  82024. particleSystem: ParticleSystem;
  82025. /**
  82026. * Type of the submitter (Default: END)
  82027. */
  82028. type: SubEmitterType;
  82029. /**
  82030. * 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)
  82031. * Note: This only is supported when using an emitter of type Mesh
  82032. */
  82033. inheritDirection: boolean;
  82034. /**
  82035. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82036. */
  82037. inheritedVelocityAmount: number;
  82038. /**
  82039. * Creates a sub emitter
  82040. * @param particleSystem the particle system to be used by the sub emitter
  82041. */
  82042. constructor(
  82043. /**
  82044. * the particle system to be used by the sub emitter
  82045. */
  82046. particleSystem: ParticleSystem);
  82047. /**
  82048. * Clones the sub emitter
  82049. * @returns the cloned sub emitter
  82050. */
  82051. clone(): SubEmitter;
  82052. /**
  82053. * Serialize current object to a JSON object
  82054. * @returns the serialized object
  82055. */
  82056. serialize(): any;
  82057. /** @hidden */
  82058. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82059. /**
  82060. * Creates a new SubEmitter from a serialized JSON version
  82061. * @param serializationObject defines the JSON object to read from
  82062. * @param scene defines the hosting scene
  82063. * @param rootUrl defines the rootUrl for data loading
  82064. * @returns a new SubEmitter
  82065. */
  82066. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82067. /** Release associated resources */
  82068. dispose(): void;
  82069. }
  82070. }
  82071. declare module BABYLON {
  82072. /** @hidden */
  82073. export var imageProcessingDeclaration: {
  82074. name: string;
  82075. shader: string;
  82076. };
  82077. }
  82078. declare module BABYLON {
  82079. /** @hidden */
  82080. export var imageProcessingFunctions: {
  82081. name: string;
  82082. shader: string;
  82083. };
  82084. }
  82085. declare module BABYLON {
  82086. /** @hidden */
  82087. export var particlesPixelShader: {
  82088. name: string;
  82089. shader: string;
  82090. };
  82091. }
  82092. declare module BABYLON {
  82093. /** @hidden */
  82094. export var particlesVertexShader: {
  82095. name: string;
  82096. shader: string;
  82097. };
  82098. }
  82099. declare module BABYLON {
  82100. /**
  82101. * This represents a particle system in Babylon.
  82102. * 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.
  82103. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82104. * @example https://doc.babylonjs.com/babylon101/particles
  82105. */
  82106. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82107. /**
  82108. * Billboard mode will only apply to Y axis
  82109. */
  82110. static readonly BILLBOARDMODE_Y: number;
  82111. /**
  82112. * Billboard mode will apply to all axes
  82113. */
  82114. static readonly BILLBOARDMODE_ALL: number;
  82115. /**
  82116. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82117. */
  82118. static readonly BILLBOARDMODE_STRETCHED: number;
  82119. /**
  82120. * This function can be defined to provide custom update for active particles.
  82121. * This function will be called instead of regular update (age, position, color, etc.).
  82122. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82123. */
  82124. updateFunction: (particles: Particle[]) => void;
  82125. private _emitterWorldMatrix;
  82126. /**
  82127. * This function can be defined to specify initial direction for every new particle.
  82128. * It by default use the emitterType defined function
  82129. */
  82130. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82131. /**
  82132. * This function can be defined to specify initial position for every new particle.
  82133. * It by default use the emitterType defined function
  82134. */
  82135. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82136. /**
  82137. * @hidden
  82138. */
  82139. _inheritedVelocityOffset: Vector3;
  82140. /**
  82141. * An event triggered when the system is disposed
  82142. */
  82143. onDisposeObservable: Observable<ParticleSystem>;
  82144. private _onDisposeObserver;
  82145. /**
  82146. * Sets a callback that will be triggered when the system is disposed
  82147. */
  82148. onDispose: () => void;
  82149. private _particles;
  82150. private _epsilon;
  82151. private _capacity;
  82152. private _stockParticles;
  82153. private _newPartsExcess;
  82154. private _vertexData;
  82155. private _vertexBuffer;
  82156. private _vertexBuffers;
  82157. private _spriteBuffer;
  82158. private _indexBuffer;
  82159. private _effect;
  82160. private _customEffect;
  82161. private _cachedDefines;
  82162. private _scaledColorStep;
  82163. private _colorDiff;
  82164. private _scaledDirection;
  82165. private _scaledGravity;
  82166. private _currentRenderId;
  82167. private _alive;
  82168. private _useInstancing;
  82169. private _started;
  82170. private _stopped;
  82171. private _actualFrame;
  82172. private _scaledUpdateSpeed;
  82173. private _vertexBufferSize;
  82174. /** @hidden */
  82175. _currentEmitRateGradient: Nullable<FactorGradient>;
  82176. /** @hidden */
  82177. _currentEmitRate1: number;
  82178. /** @hidden */
  82179. _currentEmitRate2: number;
  82180. /** @hidden */
  82181. _currentStartSizeGradient: Nullable<FactorGradient>;
  82182. /** @hidden */
  82183. _currentStartSize1: number;
  82184. /** @hidden */
  82185. _currentStartSize2: number;
  82186. private readonly _rawTextureWidth;
  82187. private _rampGradientsTexture;
  82188. private _useRampGradients;
  82189. /** Gets or sets a boolean indicating that ramp gradients must be used
  82190. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82191. */
  82192. useRampGradients: boolean;
  82193. /**
  82194. * 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.
  82195. * 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: [])
  82196. */
  82197. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82198. private _subEmitters;
  82199. /**
  82200. * @hidden
  82201. * If the particle systems emitter should be disposed when the particle system is disposed
  82202. */
  82203. _disposeEmitterOnDispose: boolean;
  82204. /**
  82205. * The current active Sub-systems, this property is used by the root particle system only.
  82206. */
  82207. activeSubSystems: Array<ParticleSystem>;
  82208. private _rootParticleSystem;
  82209. /**
  82210. * Gets the current list of active particles
  82211. */
  82212. readonly particles: Particle[];
  82213. /**
  82214. * Returns the string "ParticleSystem"
  82215. * @returns a string containing the class name
  82216. */
  82217. getClassName(): string;
  82218. /**
  82219. * Instantiates a particle system.
  82220. * 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.
  82221. * @param name The name of the particle system
  82222. * @param capacity The max number of particles alive at the same time
  82223. * @param scene The scene the particle system belongs to
  82224. * @param customEffect a custom effect used to change the way particles are rendered by default
  82225. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82226. * @param epsilon Offset used to render the particles
  82227. */
  82228. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82229. private _addFactorGradient;
  82230. private _removeFactorGradient;
  82231. /**
  82232. * Adds a new life time gradient
  82233. * @param gradient defines the gradient to use (between 0 and 1)
  82234. * @param factor defines the life time factor to affect to the specified gradient
  82235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82236. * @returns the current particle system
  82237. */
  82238. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82239. /**
  82240. * Remove a specific life time gradient
  82241. * @param gradient defines the gradient to remove
  82242. * @returns the current particle system
  82243. */
  82244. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82245. /**
  82246. * Adds a new size gradient
  82247. * @param gradient defines the gradient to use (between 0 and 1)
  82248. * @param factor defines the size factor to affect to the specified gradient
  82249. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82250. * @returns the current particle system
  82251. */
  82252. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82253. /**
  82254. * Remove a specific size gradient
  82255. * @param gradient defines the gradient to remove
  82256. * @returns the current particle system
  82257. */
  82258. removeSizeGradient(gradient: number): IParticleSystem;
  82259. /**
  82260. * Adds a new color remap gradient
  82261. * @param gradient defines the gradient to use (between 0 and 1)
  82262. * @param min defines the color remap minimal range
  82263. * @param max defines the color remap maximal range
  82264. * @returns the current particle system
  82265. */
  82266. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82267. /**
  82268. * Remove a specific color remap gradient
  82269. * @param gradient defines the gradient to remove
  82270. * @returns the current particle system
  82271. */
  82272. removeColorRemapGradient(gradient: number): IParticleSystem;
  82273. /**
  82274. * Adds a new alpha remap gradient
  82275. * @param gradient defines the gradient to use (between 0 and 1)
  82276. * @param min defines the alpha remap minimal range
  82277. * @param max defines the alpha remap maximal range
  82278. * @returns the current particle system
  82279. */
  82280. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82281. /**
  82282. * Remove a specific alpha remap gradient
  82283. * @param gradient defines the gradient to remove
  82284. * @returns the current particle system
  82285. */
  82286. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82287. /**
  82288. * Adds a new angular speed gradient
  82289. * @param gradient defines the gradient to use (between 0 and 1)
  82290. * @param factor defines the angular speed to affect to the specified gradient
  82291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82292. * @returns the current particle system
  82293. */
  82294. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82295. /**
  82296. * Remove a specific angular speed gradient
  82297. * @param gradient defines the gradient to remove
  82298. * @returns the current particle system
  82299. */
  82300. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82301. /**
  82302. * Adds a new velocity gradient
  82303. * @param gradient defines the gradient to use (between 0 and 1)
  82304. * @param factor defines the velocity to affect to the specified gradient
  82305. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82306. * @returns the current particle system
  82307. */
  82308. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82309. /**
  82310. * Remove a specific velocity gradient
  82311. * @param gradient defines the gradient to remove
  82312. * @returns the current particle system
  82313. */
  82314. removeVelocityGradient(gradient: number): IParticleSystem;
  82315. /**
  82316. * Adds a new limit velocity gradient
  82317. * @param gradient defines the gradient to use (between 0 and 1)
  82318. * @param factor defines the limit velocity value to affect to the specified gradient
  82319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82320. * @returns the current particle system
  82321. */
  82322. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82323. /**
  82324. * Remove a specific limit velocity gradient
  82325. * @param gradient defines the gradient to remove
  82326. * @returns the current particle system
  82327. */
  82328. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82329. /**
  82330. * Adds a new drag gradient
  82331. * @param gradient defines the gradient to use (between 0 and 1)
  82332. * @param factor defines the drag value to affect to the specified gradient
  82333. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82334. * @returns the current particle system
  82335. */
  82336. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82337. /**
  82338. * Remove a specific drag gradient
  82339. * @param gradient defines the gradient to remove
  82340. * @returns the current particle system
  82341. */
  82342. removeDragGradient(gradient: number): IParticleSystem;
  82343. /**
  82344. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82345. * @param gradient defines the gradient to use (between 0 and 1)
  82346. * @param factor defines the emit rate value to affect to the specified gradient
  82347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82348. * @returns the current particle system
  82349. */
  82350. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82351. /**
  82352. * Remove a specific emit rate gradient
  82353. * @param gradient defines the gradient to remove
  82354. * @returns the current particle system
  82355. */
  82356. removeEmitRateGradient(gradient: number): IParticleSystem;
  82357. /**
  82358. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82359. * @param gradient defines the gradient to use (between 0 and 1)
  82360. * @param factor defines the start size value to affect to the specified gradient
  82361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82362. * @returns the current particle system
  82363. */
  82364. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82365. /**
  82366. * Remove a specific start size gradient
  82367. * @param gradient defines the gradient to remove
  82368. * @returns the current particle system
  82369. */
  82370. removeStartSizeGradient(gradient: number): IParticleSystem;
  82371. private _createRampGradientTexture;
  82372. /**
  82373. * Gets the current list of ramp gradients.
  82374. * You must use addRampGradient and removeRampGradient to udpate this list
  82375. * @returns the list of ramp gradients
  82376. */
  82377. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82378. /**
  82379. * Adds a new ramp gradient used to remap particle colors
  82380. * @param gradient defines the gradient to use (between 0 and 1)
  82381. * @param color defines the color to affect to the specified gradient
  82382. * @returns the current particle system
  82383. */
  82384. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82385. /**
  82386. * Remove a specific ramp gradient
  82387. * @param gradient defines the gradient to remove
  82388. * @returns the current particle system
  82389. */
  82390. removeRampGradient(gradient: number): ParticleSystem;
  82391. /**
  82392. * Adds a new color gradient
  82393. * @param gradient defines the gradient to use (between 0 and 1)
  82394. * @param color1 defines the color to affect to the specified gradient
  82395. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82396. * @returns this particle system
  82397. */
  82398. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82399. /**
  82400. * Remove a specific color gradient
  82401. * @param gradient defines the gradient to remove
  82402. * @returns this particle system
  82403. */
  82404. removeColorGradient(gradient: number): IParticleSystem;
  82405. private _fetchR;
  82406. protected _reset(): void;
  82407. private _resetEffect;
  82408. private _createVertexBuffers;
  82409. private _createIndexBuffer;
  82410. /**
  82411. * Gets the maximum number of particles active at the same time.
  82412. * @returns The max number of active particles.
  82413. */
  82414. getCapacity(): number;
  82415. /**
  82416. * Gets whether there are still active particles in the system.
  82417. * @returns True if it is alive, otherwise false.
  82418. */
  82419. isAlive(): boolean;
  82420. /**
  82421. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82422. * @returns True if it has been started, otherwise false.
  82423. */
  82424. isStarted(): boolean;
  82425. private _prepareSubEmitterInternalArray;
  82426. /**
  82427. * Starts the particle system and begins to emit
  82428. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82429. */
  82430. start(delay?: number): void;
  82431. /**
  82432. * Stops the particle system.
  82433. * @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.
  82434. */
  82435. stop(stopSubEmitters?: boolean): void;
  82436. /**
  82437. * Remove all active particles
  82438. */
  82439. reset(): void;
  82440. /**
  82441. * @hidden (for internal use only)
  82442. */
  82443. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82444. /**
  82445. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82446. * Its lifetime will start back at 0.
  82447. */
  82448. recycleParticle: (particle: Particle) => void;
  82449. private _stopSubEmitters;
  82450. private _createParticle;
  82451. private _removeFromRoot;
  82452. private _emitFromParticle;
  82453. private _update;
  82454. /** @hidden */
  82455. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82456. /** @hidden */
  82457. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82458. /** @hidden */
  82459. private _getEffect;
  82460. /**
  82461. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82462. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82463. */
  82464. animate(preWarmOnly?: boolean): void;
  82465. private _appendParticleVertices;
  82466. /**
  82467. * Rebuilds the particle system.
  82468. */
  82469. rebuild(): void;
  82470. /**
  82471. * Is this system ready to be used/rendered
  82472. * @return true if the system is ready
  82473. */
  82474. isReady(): boolean;
  82475. private _render;
  82476. /**
  82477. * Renders the particle system in its current state.
  82478. * @returns the current number of particles
  82479. */
  82480. render(): number;
  82481. /**
  82482. * Disposes the particle system and free the associated resources
  82483. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82484. */
  82485. dispose(disposeTexture?: boolean): void;
  82486. /**
  82487. * Clones the particle system.
  82488. * @param name The name of the cloned object
  82489. * @param newEmitter The new emitter to use
  82490. * @returns the cloned particle system
  82491. */
  82492. clone(name: string, newEmitter: any): ParticleSystem;
  82493. /**
  82494. * Serializes the particle system to a JSON object.
  82495. * @returns the JSON object
  82496. */
  82497. serialize(): any;
  82498. /** @hidden */
  82499. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82500. /** @hidden */
  82501. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82502. /**
  82503. * Parses a JSON object to create a particle system.
  82504. * @param parsedParticleSystem The JSON object to parse
  82505. * @param scene The scene to create the particle system in
  82506. * @param rootUrl The root url to use to load external dependencies like texture
  82507. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82508. * @returns the Parsed particle system
  82509. */
  82510. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82511. }
  82512. }
  82513. declare module BABYLON {
  82514. /**
  82515. * A particle represents one of the element emitted by a particle system.
  82516. * This is mainly define by its coordinates, direction, velocity and age.
  82517. */
  82518. export class Particle {
  82519. /**
  82520. * The particle system the particle belongs to.
  82521. */
  82522. particleSystem: ParticleSystem;
  82523. private static _Count;
  82524. /**
  82525. * Unique ID of the particle
  82526. */
  82527. id: number;
  82528. /**
  82529. * The world position of the particle in the scene.
  82530. */
  82531. position: Vector3;
  82532. /**
  82533. * The world direction of the particle in the scene.
  82534. */
  82535. direction: Vector3;
  82536. /**
  82537. * The color of the particle.
  82538. */
  82539. color: Color4;
  82540. /**
  82541. * The color change of the particle per step.
  82542. */
  82543. colorStep: Color4;
  82544. /**
  82545. * Defines how long will the life of the particle be.
  82546. */
  82547. lifeTime: number;
  82548. /**
  82549. * The current age of the particle.
  82550. */
  82551. age: number;
  82552. /**
  82553. * The current size of the particle.
  82554. */
  82555. size: number;
  82556. /**
  82557. * The current scale of the particle.
  82558. */
  82559. scale: Vector2;
  82560. /**
  82561. * The current angle of the particle.
  82562. */
  82563. angle: number;
  82564. /**
  82565. * Defines how fast is the angle changing.
  82566. */
  82567. angularSpeed: number;
  82568. /**
  82569. * Defines the cell index used by the particle to be rendered from a sprite.
  82570. */
  82571. cellIndex: number;
  82572. /**
  82573. * The information required to support color remapping
  82574. */
  82575. remapData: Vector4;
  82576. /** @hidden */
  82577. _randomCellOffset?: number;
  82578. /** @hidden */
  82579. _initialDirection: Nullable<Vector3>;
  82580. /** @hidden */
  82581. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82582. /** @hidden */
  82583. _initialStartSpriteCellID: number;
  82584. /** @hidden */
  82585. _initialEndSpriteCellID: number;
  82586. /** @hidden */
  82587. _currentColorGradient: Nullable<ColorGradient>;
  82588. /** @hidden */
  82589. _currentColor1: Color4;
  82590. /** @hidden */
  82591. _currentColor2: Color4;
  82592. /** @hidden */
  82593. _currentSizeGradient: Nullable<FactorGradient>;
  82594. /** @hidden */
  82595. _currentSize1: number;
  82596. /** @hidden */
  82597. _currentSize2: number;
  82598. /** @hidden */
  82599. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82600. /** @hidden */
  82601. _currentAngularSpeed1: number;
  82602. /** @hidden */
  82603. _currentAngularSpeed2: number;
  82604. /** @hidden */
  82605. _currentVelocityGradient: Nullable<FactorGradient>;
  82606. /** @hidden */
  82607. _currentVelocity1: number;
  82608. /** @hidden */
  82609. _currentVelocity2: number;
  82610. /** @hidden */
  82611. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  82612. /** @hidden */
  82613. _currentLimitVelocity1: number;
  82614. /** @hidden */
  82615. _currentLimitVelocity2: number;
  82616. /** @hidden */
  82617. _currentDragGradient: Nullable<FactorGradient>;
  82618. /** @hidden */
  82619. _currentDrag1: number;
  82620. /** @hidden */
  82621. _currentDrag2: number;
  82622. /** @hidden */
  82623. _randomNoiseCoordinates1: Vector3;
  82624. /** @hidden */
  82625. _randomNoiseCoordinates2: Vector3;
  82626. /**
  82627. * Creates a new instance Particle
  82628. * @param particleSystem the particle system the particle belongs to
  82629. */
  82630. constructor(
  82631. /**
  82632. * The particle system the particle belongs to.
  82633. */
  82634. particleSystem: ParticleSystem);
  82635. private updateCellInfoFromSystem;
  82636. /**
  82637. * Defines how the sprite cell index is updated for the particle
  82638. */
  82639. updateCellIndex(): void;
  82640. /** @hidden */
  82641. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  82642. /** @hidden */
  82643. _inheritParticleInfoToSubEmitters(): void;
  82644. /** @hidden */
  82645. _reset(): void;
  82646. /**
  82647. * Copy the properties of particle to another one.
  82648. * @param other the particle to copy the information to.
  82649. */
  82650. copyTo(other: Particle): void;
  82651. }
  82652. }
  82653. declare module BABYLON {
  82654. /**
  82655. * Particle emitter represents a volume emitting particles.
  82656. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  82657. */
  82658. export interface IParticleEmitterType {
  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(): IParticleEmitterType;
  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 the effect defines string
  82686. */
  82687. getEffectDefines(): string;
  82688. /**
  82689. * Returns a string representing the class name
  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 the inside of a box.
  82708. * It emits the particles randomly between 2 given directions.
  82709. */
  82710. export class BoxParticleEmitter 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. * 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.
  82721. */
  82722. minEmitBox: Vector3;
  82723. /**
  82724. * 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.
  82725. */
  82726. maxEmitBox: Vector3;
  82727. /**
  82728. * Creates a new instance BoxParticleEmitter
  82729. */
  82730. constructor();
  82731. /**
  82732. * Called by the particle System when the direction is computed for the created particle.
  82733. * @param worldMatrix is the world matrix of the particle system
  82734. * @param directionToUpdate is the direction vector to update with the result
  82735. * @param particle is the particle we are computed the direction for
  82736. */
  82737. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82738. /**
  82739. * Called by the particle System when the position is computed for the created particle.
  82740. * @param worldMatrix is the world matrix of the particle system
  82741. * @param positionToUpdate is the position vector to update with the result
  82742. * @param particle is the particle we are computed the position for
  82743. */
  82744. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82745. /**
  82746. * Clones the current emitter and returns a copy of it
  82747. * @returns the new emitter
  82748. */
  82749. clone(): BoxParticleEmitter;
  82750. /**
  82751. * Called by the GPUParticleSystem to setup the update shader
  82752. * @param effect defines the update shader
  82753. */
  82754. applyToShader(effect: Effect): void;
  82755. /**
  82756. * Returns a string to use to update the GPU particles update shader
  82757. * @returns a string containng the defines string
  82758. */
  82759. getEffectDefines(): string;
  82760. /**
  82761. * Returns the string "BoxParticleEmitter"
  82762. * @returns a string containing the class name
  82763. */
  82764. getClassName(): string;
  82765. /**
  82766. * Serializes the particle system to a JSON object.
  82767. * @returns the JSON object
  82768. */
  82769. serialize(): any;
  82770. /**
  82771. * Parse properties from a JSON object
  82772. * @param serializationObject defines the JSON object
  82773. */
  82774. parse(serializationObject: any): void;
  82775. }
  82776. }
  82777. declare module BABYLON {
  82778. /**
  82779. * Particle emitter emitting particles from the inside of a cone.
  82780. * It emits the particles alongside the cone volume from the base to the particle.
  82781. * The emission direction might be randomized.
  82782. */
  82783. export class ConeParticleEmitter implements IParticleEmitterType {
  82784. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82785. directionRandomizer: number;
  82786. private _radius;
  82787. private _angle;
  82788. private _height;
  82789. /**
  82790. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  82791. */
  82792. radiusRange: number;
  82793. /**
  82794. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  82795. */
  82796. heightRange: number;
  82797. /**
  82798. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  82799. */
  82800. emitFromSpawnPointOnly: boolean;
  82801. /**
  82802. * Gets or sets the radius of the emission cone
  82803. */
  82804. radius: number;
  82805. /**
  82806. * Gets or sets the angle of the emission cone
  82807. */
  82808. angle: number;
  82809. private _buildHeight;
  82810. /**
  82811. * Creates a new instance ConeParticleEmitter
  82812. * @param radius the radius of the emission cone (1 by default)
  82813. * @param angle the cone base angle (PI by default)
  82814. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  82815. */
  82816. constructor(radius?: number, angle?: number,
  82817. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82818. directionRandomizer?: number);
  82819. /**
  82820. * Called by the particle System when the direction is computed for the created particle.
  82821. * @param worldMatrix is the world matrix of the particle system
  82822. * @param directionToUpdate is the direction vector to update with the result
  82823. * @param particle is the particle we are computed the direction for
  82824. */
  82825. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82826. /**
  82827. * Called by the particle System when the position is computed for the created particle.
  82828. * @param worldMatrix is the world matrix of the particle system
  82829. * @param positionToUpdate is the position vector to update with the result
  82830. * @param particle is the particle we are computed the position for
  82831. */
  82832. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82833. /**
  82834. * Clones the current emitter and returns a copy of it
  82835. * @returns the new emitter
  82836. */
  82837. clone(): ConeParticleEmitter;
  82838. /**
  82839. * Called by the GPUParticleSystem to setup the update shader
  82840. * @param effect defines the update shader
  82841. */
  82842. applyToShader(effect: Effect): void;
  82843. /**
  82844. * Returns a string to use to update the GPU particles update shader
  82845. * @returns a string containng the defines string
  82846. */
  82847. getEffectDefines(): string;
  82848. /**
  82849. * Returns the string "ConeParticleEmitter"
  82850. * @returns a string containing the class name
  82851. */
  82852. getClassName(): string;
  82853. /**
  82854. * Serializes the particle system to a JSON object.
  82855. * @returns the JSON object
  82856. */
  82857. serialize(): any;
  82858. /**
  82859. * Parse properties from a JSON object
  82860. * @param serializationObject defines the JSON object
  82861. */
  82862. parse(serializationObject: any): void;
  82863. }
  82864. }
  82865. declare module BABYLON {
  82866. /**
  82867. * Particle emitter emitting particles from the inside of a cylinder.
  82868. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  82869. */
  82870. export class CylinderParticleEmitter implements IParticleEmitterType {
  82871. /**
  82872. * The radius of the emission cylinder.
  82873. */
  82874. radius: number;
  82875. /**
  82876. * The height of the emission cylinder.
  82877. */
  82878. height: number;
  82879. /**
  82880. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82881. */
  82882. radiusRange: number;
  82883. /**
  82884. * How much to randomize the particle direction [0-1].
  82885. */
  82886. directionRandomizer: number;
  82887. /**
  82888. * Creates a new instance CylinderParticleEmitter
  82889. * @param radius the radius of the emission cylinder (1 by default)
  82890. * @param height the height of the emission cylinder (1 by default)
  82891. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82892. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82893. */
  82894. constructor(
  82895. /**
  82896. * The radius of the emission cylinder.
  82897. */
  82898. radius?: number,
  82899. /**
  82900. * The height of the emission cylinder.
  82901. */
  82902. height?: number,
  82903. /**
  82904. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82905. */
  82906. radiusRange?: number,
  82907. /**
  82908. * How much to randomize the particle direction [0-1].
  82909. */
  82910. directionRandomizer?: number);
  82911. /**
  82912. * Called by the particle System when the direction is computed for the created particle.
  82913. * @param worldMatrix is the world matrix of the particle system
  82914. * @param directionToUpdate is the direction vector to update with the result
  82915. * @param particle is the particle we are computed the direction for
  82916. */
  82917. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82918. /**
  82919. * Called by the particle System when the position is computed for the created particle.
  82920. * @param worldMatrix is the world matrix of the particle system
  82921. * @param positionToUpdate is the position vector to update with the result
  82922. * @param particle is the particle we are computed the position for
  82923. */
  82924. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82925. /**
  82926. * Clones the current emitter and returns a copy of it
  82927. * @returns the new emitter
  82928. */
  82929. clone(): CylinderParticleEmitter;
  82930. /**
  82931. * Called by the GPUParticleSystem to setup the update shader
  82932. * @param effect defines the update shader
  82933. */
  82934. applyToShader(effect: Effect): void;
  82935. /**
  82936. * Returns a string to use to update the GPU particles update shader
  82937. * @returns a string containng the defines string
  82938. */
  82939. getEffectDefines(): string;
  82940. /**
  82941. * Returns the string "CylinderParticleEmitter"
  82942. * @returns a string containing the class name
  82943. */
  82944. getClassName(): string;
  82945. /**
  82946. * Serializes the particle system to a JSON object.
  82947. * @returns the JSON object
  82948. */
  82949. serialize(): any;
  82950. /**
  82951. * Parse properties from a JSON object
  82952. * @param serializationObject defines the JSON object
  82953. */
  82954. parse(serializationObject: any): void;
  82955. }
  82956. /**
  82957. * Particle emitter emitting particles from the inside of a cylinder.
  82958. * It emits the particles randomly between two vectors.
  82959. */
  82960. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  82961. /**
  82962. * The min limit of the emission direction.
  82963. */
  82964. direction1: Vector3;
  82965. /**
  82966. * The max limit of the emission direction.
  82967. */
  82968. direction2: Vector3;
  82969. /**
  82970. * Creates a new instance CylinderDirectedParticleEmitter
  82971. * @param radius the radius of the emission cylinder (1 by default)
  82972. * @param height the height of the emission cylinder (1 by default)
  82973. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82974. * @param direction1 the min limit of the emission direction (up vector by default)
  82975. * @param direction2 the max limit of the emission direction (up vector by default)
  82976. */
  82977. constructor(radius?: number, height?: number, radiusRange?: number,
  82978. /**
  82979. * The min limit of the emission direction.
  82980. */
  82981. direction1?: Vector3,
  82982. /**
  82983. * The max limit of the emission direction.
  82984. */
  82985. direction2?: Vector3);
  82986. /**
  82987. * Called by the particle System when the direction is computed for the created particle.
  82988. * @param worldMatrix is the world matrix of the particle system
  82989. * @param directionToUpdate is the direction vector to update with the result
  82990. * @param particle is the particle we are computed the direction for
  82991. */
  82992. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82993. /**
  82994. * Clones the current emitter and returns a copy of it
  82995. * @returns the new emitter
  82996. */
  82997. clone(): CylinderDirectedParticleEmitter;
  82998. /**
  82999. * Called by the GPUParticleSystem to setup the update shader
  83000. * @param effect defines the update shader
  83001. */
  83002. applyToShader(effect: Effect): void;
  83003. /**
  83004. * Returns a string to use to update the GPU particles update shader
  83005. * @returns a string containng the defines string
  83006. */
  83007. getEffectDefines(): string;
  83008. /**
  83009. * Returns the string "CylinderDirectedParticleEmitter"
  83010. * @returns a string containing the class name
  83011. */
  83012. getClassName(): string;
  83013. /**
  83014. * Serializes the particle system to a JSON object.
  83015. * @returns the JSON object
  83016. */
  83017. serialize(): any;
  83018. /**
  83019. * Parse properties from a JSON object
  83020. * @param serializationObject defines the JSON object
  83021. */
  83022. parse(serializationObject: any): void;
  83023. }
  83024. }
  83025. declare module BABYLON {
  83026. /**
  83027. * Particle emitter emitting particles from the inside of a hemisphere.
  83028. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83029. */
  83030. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83031. /**
  83032. * The radius of the emission hemisphere.
  83033. */
  83034. radius: number;
  83035. /**
  83036. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83037. */
  83038. radiusRange: number;
  83039. /**
  83040. * How much to randomize the particle direction [0-1].
  83041. */
  83042. directionRandomizer: number;
  83043. /**
  83044. * Creates a new instance HemisphericParticleEmitter
  83045. * @param radius the radius of the emission hemisphere (1 by default)
  83046. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83047. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83048. */
  83049. constructor(
  83050. /**
  83051. * The radius of the emission hemisphere.
  83052. */
  83053. radius?: number,
  83054. /**
  83055. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83056. */
  83057. radiusRange?: number,
  83058. /**
  83059. * How much to randomize the particle direction [0-1].
  83060. */
  83061. directionRandomizer?: number);
  83062. /**
  83063. * Called by the particle System when the direction is computed for the created particle.
  83064. * @param worldMatrix is the world matrix of the particle system
  83065. * @param directionToUpdate is the direction vector to update with the result
  83066. * @param particle is the particle we are computed the direction for
  83067. */
  83068. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83069. /**
  83070. * Called by the particle System when the position is computed for the created particle.
  83071. * @param worldMatrix is the world matrix of the particle system
  83072. * @param positionToUpdate is the position vector to update with the result
  83073. * @param particle is the particle we are computed the position for
  83074. */
  83075. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83076. /**
  83077. * Clones the current emitter and returns a copy of it
  83078. * @returns the new emitter
  83079. */
  83080. clone(): HemisphericParticleEmitter;
  83081. /**
  83082. * Called by the GPUParticleSystem to setup the update shader
  83083. * @param effect defines the update shader
  83084. */
  83085. applyToShader(effect: Effect): void;
  83086. /**
  83087. * Returns a string to use to update the GPU particles update shader
  83088. * @returns a string containng the defines string
  83089. */
  83090. getEffectDefines(): string;
  83091. /**
  83092. * Returns the string "HemisphericParticleEmitter"
  83093. * @returns a string containing the class name
  83094. */
  83095. getClassName(): string;
  83096. /**
  83097. * Serializes the particle system to a JSON object.
  83098. * @returns the JSON object
  83099. */
  83100. serialize(): any;
  83101. /**
  83102. * Parse properties from a JSON object
  83103. * @param serializationObject defines the JSON object
  83104. */
  83105. parse(serializationObject: any): void;
  83106. }
  83107. }
  83108. declare module BABYLON {
  83109. /**
  83110. * Particle emitter emitting particles from a point.
  83111. * It emits the particles randomly between 2 given directions.
  83112. */
  83113. export class PointParticleEmitter implements IParticleEmitterType {
  83114. /**
  83115. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83116. */
  83117. direction1: Vector3;
  83118. /**
  83119. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83120. */
  83121. direction2: Vector3;
  83122. /**
  83123. * Creates a new instance PointParticleEmitter
  83124. */
  83125. constructor();
  83126. /**
  83127. * Called by the particle System when the direction is computed for the created particle.
  83128. * @param worldMatrix is the world matrix of the particle system
  83129. * @param directionToUpdate is the direction vector to update with the result
  83130. * @param particle is the particle we are computed the direction for
  83131. */
  83132. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83133. /**
  83134. * Called by the particle System when the position is computed for the created particle.
  83135. * @param worldMatrix is the world matrix of the particle system
  83136. * @param positionToUpdate is the position vector to update with the result
  83137. * @param particle is the particle we are computed the position for
  83138. */
  83139. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83140. /**
  83141. * Clones the current emitter and returns a copy of it
  83142. * @returns the new emitter
  83143. */
  83144. clone(): PointParticleEmitter;
  83145. /**
  83146. * Called by the GPUParticleSystem to setup the update shader
  83147. * @param effect defines the update shader
  83148. */
  83149. applyToShader(effect: Effect): void;
  83150. /**
  83151. * Returns a string to use to update the GPU particles update shader
  83152. * @returns a string containng the defines string
  83153. */
  83154. getEffectDefines(): string;
  83155. /**
  83156. * Returns the string "PointParticleEmitter"
  83157. * @returns a string containing the class name
  83158. */
  83159. getClassName(): string;
  83160. /**
  83161. * Serializes the particle system to a JSON object.
  83162. * @returns the JSON object
  83163. */
  83164. serialize(): any;
  83165. /**
  83166. * Parse properties from a JSON object
  83167. * @param serializationObject defines the JSON object
  83168. */
  83169. parse(serializationObject: any): void;
  83170. }
  83171. }
  83172. declare module BABYLON {
  83173. /**
  83174. * Particle emitter emitting particles from the inside of a sphere.
  83175. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83176. */
  83177. export class SphereParticleEmitter implements IParticleEmitterType {
  83178. /**
  83179. * The radius of the emission sphere.
  83180. */
  83181. radius: number;
  83182. /**
  83183. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83184. */
  83185. radiusRange: number;
  83186. /**
  83187. * How much to randomize the particle direction [0-1].
  83188. */
  83189. directionRandomizer: number;
  83190. /**
  83191. * Creates a new instance SphereParticleEmitter
  83192. * @param radius the radius of the emission sphere (1 by default)
  83193. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83194. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83195. */
  83196. constructor(
  83197. /**
  83198. * The radius of the emission sphere.
  83199. */
  83200. radius?: number,
  83201. /**
  83202. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83203. */
  83204. radiusRange?: number,
  83205. /**
  83206. * How much to randomize the particle direction [0-1].
  83207. */
  83208. directionRandomizer?: number);
  83209. /**
  83210. * Called by the particle System when the direction is computed for the created particle.
  83211. * @param worldMatrix is the world matrix of the particle system
  83212. * @param directionToUpdate is the direction vector to update with the result
  83213. * @param particle is the particle we are computed the direction for
  83214. */
  83215. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83216. /**
  83217. * Called by the particle System when the position is computed for the created particle.
  83218. * @param worldMatrix is the world matrix of the particle system
  83219. * @param positionToUpdate is the position vector to update with the result
  83220. * @param particle is the particle we are computed the position for
  83221. */
  83222. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83223. /**
  83224. * Clones the current emitter and returns a copy of it
  83225. * @returns the new emitter
  83226. */
  83227. clone(): SphereParticleEmitter;
  83228. /**
  83229. * Called by the GPUParticleSystem to setup the update shader
  83230. * @param effect defines the update shader
  83231. */
  83232. applyToShader(effect: Effect): void;
  83233. /**
  83234. * Returns a string to use to update the GPU particles update shader
  83235. * @returns a string containng the defines string
  83236. */
  83237. getEffectDefines(): string;
  83238. /**
  83239. * Returns the string "SphereParticleEmitter"
  83240. * @returns a string containing the class name
  83241. */
  83242. getClassName(): string;
  83243. /**
  83244. * Serializes the particle system to a JSON object.
  83245. * @returns the JSON object
  83246. */
  83247. serialize(): any;
  83248. /**
  83249. * Parse properties from a JSON object
  83250. * @param serializationObject defines the JSON object
  83251. */
  83252. parse(serializationObject: any): void;
  83253. }
  83254. /**
  83255. * Particle emitter emitting particles from the inside of a sphere.
  83256. * It emits the particles randomly between two vectors.
  83257. */
  83258. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83259. /**
  83260. * The min limit of the emission direction.
  83261. */
  83262. direction1: Vector3;
  83263. /**
  83264. * The max limit of the emission direction.
  83265. */
  83266. direction2: Vector3;
  83267. /**
  83268. * Creates a new instance SphereDirectedParticleEmitter
  83269. * @param radius the radius of the emission sphere (1 by default)
  83270. * @param direction1 the min limit of the emission direction (up vector by default)
  83271. * @param direction2 the max limit of the emission direction (up vector by default)
  83272. */
  83273. constructor(radius?: number,
  83274. /**
  83275. * The min limit of the emission direction.
  83276. */
  83277. direction1?: Vector3,
  83278. /**
  83279. * The max limit of the emission direction.
  83280. */
  83281. direction2?: Vector3);
  83282. /**
  83283. * Called by the particle System when the direction is computed for the created particle.
  83284. * @param worldMatrix is the world matrix of the particle system
  83285. * @param directionToUpdate is the direction vector to update with the result
  83286. * @param particle is the particle we are computed the direction for
  83287. */
  83288. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83289. /**
  83290. * Clones the current emitter and returns a copy of it
  83291. * @returns the new emitter
  83292. */
  83293. clone(): SphereDirectedParticleEmitter;
  83294. /**
  83295. * Called by the GPUParticleSystem to setup the update shader
  83296. * @param effect defines the update shader
  83297. */
  83298. applyToShader(effect: Effect): void;
  83299. /**
  83300. * Returns a string to use to update the GPU particles update shader
  83301. * @returns a string containng the defines string
  83302. */
  83303. getEffectDefines(): string;
  83304. /**
  83305. * Returns the string "SphereDirectedParticleEmitter"
  83306. * @returns a string containing the class name
  83307. */
  83308. getClassName(): string;
  83309. /**
  83310. * Serializes the particle system to a JSON object.
  83311. * @returns the JSON object
  83312. */
  83313. serialize(): any;
  83314. /**
  83315. * Parse properties from a JSON object
  83316. * @param serializationObject defines the JSON object
  83317. */
  83318. parse(serializationObject: any): void;
  83319. }
  83320. }
  83321. declare module BABYLON {
  83322. /**
  83323. * Interface representing a particle system in Babylon.js.
  83324. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83325. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83326. */
  83327. export interface IParticleSystem {
  83328. /**
  83329. * List of animations used by the particle system.
  83330. */
  83331. animations: Animation[];
  83332. /**
  83333. * The id of the Particle system.
  83334. */
  83335. id: string;
  83336. /**
  83337. * The name of the Particle system.
  83338. */
  83339. name: string;
  83340. /**
  83341. * The emitter represents the Mesh or position we are attaching the particle system to.
  83342. */
  83343. emitter: Nullable<AbstractMesh | Vector3>;
  83344. /**
  83345. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83346. */
  83347. isBillboardBased: boolean;
  83348. /**
  83349. * The rendering group used by the Particle system to chose when to render.
  83350. */
  83351. renderingGroupId: number;
  83352. /**
  83353. * The layer mask we are rendering the particles through.
  83354. */
  83355. layerMask: number;
  83356. /**
  83357. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83358. */
  83359. updateSpeed: number;
  83360. /**
  83361. * The amount of time the particle system is running (depends of the overall update speed).
  83362. */
  83363. targetStopDuration: number;
  83364. /**
  83365. * The texture used to render each particle. (this can be a spritesheet)
  83366. */
  83367. particleTexture: Nullable<Texture>;
  83368. /**
  83369. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83370. */
  83371. blendMode: number;
  83372. /**
  83373. * Minimum life time of emitting particles.
  83374. */
  83375. minLifeTime: number;
  83376. /**
  83377. * Maximum life time of emitting particles.
  83378. */
  83379. maxLifeTime: number;
  83380. /**
  83381. * Minimum Size of emitting particles.
  83382. */
  83383. minSize: number;
  83384. /**
  83385. * Maximum Size of emitting particles.
  83386. */
  83387. maxSize: number;
  83388. /**
  83389. * Minimum scale of emitting particles on X axis.
  83390. */
  83391. minScaleX: number;
  83392. /**
  83393. * Maximum scale of emitting particles on X axis.
  83394. */
  83395. maxScaleX: number;
  83396. /**
  83397. * Minimum scale of emitting particles on Y axis.
  83398. */
  83399. minScaleY: number;
  83400. /**
  83401. * Maximum scale of emitting particles on Y axis.
  83402. */
  83403. maxScaleY: number;
  83404. /**
  83405. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83406. */
  83407. color1: Color4;
  83408. /**
  83409. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83410. */
  83411. color2: Color4;
  83412. /**
  83413. * Color the particle will have at the end of its lifetime.
  83414. */
  83415. colorDead: Color4;
  83416. /**
  83417. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83418. */
  83419. emitRate: number;
  83420. /**
  83421. * You can use gravity if you want to give an orientation to your particles.
  83422. */
  83423. gravity: Vector3;
  83424. /**
  83425. * Minimum power of emitting particles.
  83426. */
  83427. minEmitPower: number;
  83428. /**
  83429. * Maximum power of emitting particles.
  83430. */
  83431. maxEmitPower: number;
  83432. /**
  83433. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83434. */
  83435. minAngularSpeed: number;
  83436. /**
  83437. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83438. */
  83439. maxAngularSpeed: number;
  83440. /**
  83441. * Gets or sets the minimal initial rotation in radians.
  83442. */
  83443. minInitialRotation: number;
  83444. /**
  83445. * Gets or sets the maximal initial rotation in radians.
  83446. */
  83447. maxInitialRotation: number;
  83448. /**
  83449. * The particle emitter type defines the emitter used by the particle system.
  83450. * It can be for example box, sphere, or cone...
  83451. */
  83452. particleEmitterType: Nullable<IParticleEmitterType>;
  83453. /**
  83454. * Defines the delay in milliseconds before starting the system (0 by default)
  83455. */
  83456. startDelay: number;
  83457. /**
  83458. * 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
  83459. */
  83460. preWarmCycles: number;
  83461. /**
  83462. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83463. */
  83464. preWarmStepOffset: number;
  83465. /**
  83466. * 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)
  83467. */
  83468. spriteCellChangeSpeed: number;
  83469. /**
  83470. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83471. */
  83472. startSpriteCellID: number;
  83473. /**
  83474. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83475. */
  83476. endSpriteCellID: number;
  83477. /**
  83478. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83479. */
  83480. spriteCellWidth: number;
  83481. /**
  83482. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83483. */
  83484. spriteCellHeight: number;
  83485. /**
  83486. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83487. */
  83488. spriteRandomStartCell: boolean;
  83489. /**
  83490. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83491. */
  83492. isAnimationSheetEnabled: boolean;
  83493. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83494. translationPivot: Vector2;
  83495. /**
  83496. * Gets or sets a texture used to add random noise to particle positions
  83497. */
  83498. noiseTexture: Nullable<BaseTexture>;
  83499. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83500. noiseStrength: Vector3;
  83501. /**
  83502. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83503. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83504. */
  83505. billboardMode: number;
  83506. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83507. limitVelocityDamping: number;
  83508. /**
  83509. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83510. */
  83511. beginAnimationOnStart: boolean;
  83512. /**
  83513. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83514. */
  83515. beginAnimationFrom: number;
  83516. /**
  83517. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83518. */
  83519. beginAnimationTo: number;
  83520. /**
  83521. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83522. */
  83523. beginAnimationLoop: boolean;
  83524. /**
  83525. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83526. */
  83527. disposeOnStop: boolean;
  83528. /**
  83529. * Gets the maximum number of particles active at the same time.
  83530. * @returns The max number of active particles.
  83531. */
  83532. getCapacity(): number;
  83533. /**
  83534. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83535. * @returns True if it has been started, otherwise false.
  83536. */
  83537. isStarted(): boolean;
  83538. /**
  83539. * Animates the particle system for this frame.
  83540. */
  83541. animate(): void;
  83542. /**
  83543. * Renders the particle system in its current state.
  83544. * @returns the current number of particles
  83545. */
  83546. render(): number;
  83547. /**
  83548. * Dispose the particle system and frees its associated resources.
  83549. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83550. */
  83551. dispose(disposeTexture?: boolean): void;
  83552. /**
  83553. * Clones the particle system.
  83554. * @param name The name of the cloned object
  83555. * @param newEmitter The new emitter to use
  83556. * @returns the cloned particle system
  83557. */
  83558. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83559. /**
  83560. * Serializes the particle system to a JSON object.
  83561. * @returns the JSON object
  83562. */
  83563. serialize(): any;
  83564. /**
  83565. * Rebuild the particle system
  83566. */
  83567. rebuild(): void;
  83568. /**
  83569. * Starts the particle system and begins to emit
  83570. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83571. */
  83572. start(delay?: number): void;
  83573. /**
  83574. * Stops the particle system.
  83575. */
  83576. stop(): void;
  83577. /**
  83578. * Remove all active particles
  83579. */
  83580. reset(): void;
  83581. /**
  83582. * Is this system ready to be used/rendered
  83583. * @return true if the system is ready
  83584. */
  83585. isReady(): boolean;
  83586. /**
  83587. * Adds a new color gradient
  83588. * @param gradient defines the gradient to use (between 0 and 1)
  83589. * @param color1 defines the color to affect to the specified gradient
  83590. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83591. * @returns the current particle system
  83592. */
  83593. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83594. /**
  83595. * Remove a specific color gradient
  83596. * @param gradient defines the gradient to remove
  83597. * @returns the current particle system
  83598. */
  83599. removeColorGradient(gradient: number): IParticleSystem;
  83600. /**
  83601. * Adds a new size gradient
  83602. * @param gradient defines the gradient to use (between 0 and 1)
  83603. * @param factor defines the size factor to affect to the specified gradient
  83604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83605. * @returns the current particle system
  83606. */
  83607. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83608. /**
  83609. * Remove a specific size gradient
  83610. * @param gradient defines the gradient to remove
  83611. * @returns the current particle system
  83612. */
  83613. removeSizeGradient(gradient: number): IParticleSystem;
  83614. /**
  83615. * Gets the current list of color gradients.
  83616. * You must use addColorGradient and removeColorGradient to udpate this list
  83617. * @returns the list of color gradients
  83618. */
  83619. getColorGradients(): Nullable<Array<ColorGradient>>;
  83620. /**
  83621. * Gets the current list of size gradients.
  83622. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83623. * @returns the list of size gradients
  83624. */
  83625. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83626. /**
  83627. * Gets the current list of angular speed gradients.
  83628. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83629. * @returns the list of angular speed gradients
  83630. */
  83631. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83632. /**
  83633. * Adds a new angular speed gradient
  83634. * @param gradient defines the gradient to use (between 0 and 1)
  83635. * @param factor defines the angular speed to affect to the specified gradient
  83636. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83637. * @returns the current particle system
  83638. */
  83639. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83640. /**
  83641. * Remove a specific angular speed gradient
  83642. * @param gradient defines the gradient to remove
  83643. * @returns the current particle system
  83644. */
  83645. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83646. /**
  83647. * Gets the current list of velocity gradients.
  83648. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83649. * @returns the list of velocity gradients
  83650. */
  83651. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83652. /**
  83653. * Adds a new velocity gradient
  83654. * @param gradient defines the gradient to use (between 0 and 1)
  83655. * @param factor defines the velocity to affect to the specified gradient
  83656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83657. * @returns the current particle system
  83658. */
  83659. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83660. /**
  83661. * Remove a specific velocity gradient
  83662. * @param gradient defines the gradient to remove
  83663. * @returns the current particle system
  83664. */
  83665. removeVelocityGradient(gradient: number): IParticleSystem;
  83666. /**
  83667. * Gets the current list of limit velocity gradients.
  83668. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83669. * @returns the list of limit velocity gradients
  83670. */
  83671. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83672. /**
  83673. * Adds a new limit velocity gradient
  83674. * @param gradient defines the gradient to use (between 0 and 1)
  83675. * @param factor defines the limit velocity to affect to the specified gradient
  83676. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83677. * @returns the current particle system
  83678. */
  83679. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83680. /**
  83681. * Remove a specific limit velocity gradient
  83682. * @param gradient defines the gradient to remove
  83683. * @returns the current particle system
  83684. */
  83685. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83686. /**
  83687. * Adds a new drag gradient
  83688. * @param gradient defines the gradient to use (between 0 and 1)
  83689. * @param factor defines the drag to affect to the specified gradient
  83690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83691. * @returns the current particle system
  83692. */
  83693. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83694. /**
  83695. * Remove a specific drag gradient
  83696. * @param gradient defines the gradient to remove
  83697. * @returns the current particle system
  83698. */
  83699. removeDragGradient(gradient: number): IParticleSystem;
  83700. /**
  83701. * Gets the current list of drag gradients.
  83702. * You must use addDragGradient and removeDragGradient to udpate this list
  83703. * @returns the list of drag gradients
  83704. */
  83705. getDragGradients(): Nullable<Array<FactorGradient>>;
  83706. /**
  83707. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83708. * @param gradient defines the gradient to use (between 0 and 1)
  83709. * @param factor defines the emit rate to affect to the specified gradient
  83710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83711. * @returns the current particle system
  83712. */
  83713. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83714. /**
  83715. * Remove a specific emit rate gradient
  83716. * @param gradient defines the gradient to remove
  83717. * @returns the current particle system
  83718. */
  83719. removeEmitRateGradient(gradient: number): IParticleSystem;
  83720. /**
  83721. * Gets the current list of emit rate gradients.
  83722. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83723. * @returns the list of emit rate gradients
  83724. */
  83725. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83726. /**
  83727. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83728. * @param gradient defines the gradient to use (between 0 and 1)
  83729. * @param factor defines the start size to affect to the specified gradient
  83730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83731. * @returns the current particle system
  83732. */
  83733. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83734. /**
  83735. * Remove a specific start size gradient
  83736. * @param gradient defines the gradient to remove
  83737. * @returns the current particle system
  83738. */
  83739. removeStartSizeGradient(gradient: number): IParticleSystem;
  83740. /**
  83741. * Gets the current list of start size gradients.
  83742. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83743. * @returns the list of start size gradients
  83744. */
  83745. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83746. /**
  83747. * Adds a new life time gradient
  83748. * @param gradient defines the gradient to use (between 0 and 1)
  83749. * @param factor defines the life time factor to affect to the specified gradient
  83750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83751. * @returns the current particle system
  83752. */
  83753. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83754. /**
  83755. * Remove a specific life time gradient
  83756. * @param gradient defines the gradient to remove
  83757. * @returns the current particle system
  83758. */
  83759. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83760. /**
  83761. * Gets the current list of life time gradients.
  83762. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83763. * @returns the list of life time gradients
  83764. */
  83765. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83766. /**
  83767. * Gets the current list of color gradients.
  83768. * You must use addColorGradient and removeColorGradient to udpate this list
  83769. * @returns the list of color gradients
  83770. */
  83771. getColorGradients(): Nullable<Array<ColorGradient>>;
  83772. /**
  83773. * Adds a new ramp gradient used to remap particle colors
  83774. * @param gradient defines the gradient to use (between 0 and 1)
  83775. * @param color defines the color to affect to the specified gradient
  83776. * @returns the current particle system
  83777. */
  83778. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  83779. /**
  83780. * Gets the current list of ramp gradients.
  83781. * You must use addRampGradient and removeRampGradient to udpate this list
  83782. * @returns the list of ramp gradients
  83783. */
  83784. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83785. /** Gets or sets a boolean indicating that ramp gradients must be used
  83786. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83787. */
  83788. useRampGradients: boolean;
  83789. /**
  83790. * Adds a new color remap gradient
  83791. * @param gradient defines the gradient to use (between 0 and 1)
  83792. * @param min defines the color remap minimal range
  83793. * @param max defines the color remap maximal range
  83794. * @returns the current particle system
  83795. */
  83796. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83797. /**
  83798. * Gets the current list of color remap gradients.
  83799. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83800. * @returns the list of color remap gradients
  83801. */
  83802. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83803. /**
  83804. * Adds a new alpha remap gradient
  83805. * @param gradient defines the gradient to use (between 0 and 1)
  83806. * @param min defines the alpha remap minimal range
  83807. * @param max defines the alpha remap maximal range
  83808. * @returns the current particle system
  83809. */
  83810. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83811. /**
  83812. * Gets the current list of alpha remap gradients.
  83813. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83814. * @returns the list of alpha remap gradients
  83815. */
  83816. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83817. /**
  83818. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83819. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83820. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83821. * @returns the emitter
  83822. */
  83823. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83824. /**
  83825. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83826. * @param radius The radius of the hemisphere to emit from
  83827. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83828. * @returns the emitter
  83829. */
  83830. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  83831. /**
  83832. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83833. * @param radius The radius of the sphere to emit from
  83834. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83835. * @returns the emitter
  83836. */
  83837. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  83838. /**
  83839. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83840. * @param radius The radius of the sphere to emit from
  83841. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83842. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83843. * @returns the emitter
  83844. */
  83845. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83846. /**
  83847. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83848. * @param radius The radius of the emission cylinder
  83849. * @param height The height of the emission cylinder
  83850. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83851. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83852. * @returns the emitter
  83853. */
  83854. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  83855. /**
  83856. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83857. * @param radius The radius of the cylinder to emit from
  83858. * @param height The height of the emission cylinder
  83859. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83860. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83861. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83862. * @returns the emitter
  83863. */
  83864. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83865. /**
  83866. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83867. * @param radius The radius of the cone to emit from
  83868. * @param angle The base angle of the cone
  83869. * @returns the emitter
  83870. */
  83871. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  83872. /**
  83873. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83874. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83875. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83876. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83877. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83878. * @returns the emitter
  83879. */
  83880. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83881. /**
  83882. * Get hosting scene
  83883. * @returns the scene
  83884. */
  83885. getScene(): Scene;
  83886. }
  83887. }
  83888. declare module BABYLON {
  83889. /** @hidden */
  83890. export var linePixelShader: {
  83891. name: string;
  83892. shader: string;
  83893. };
  83894. }
  83895. declare module BABYLON {
  83896. /** @hidden */
  83897. export var lineVertexShader: {
  83898. name: string;
  83899. shader: string;
  83900. };
  83901. }
  83902. declare module BABYLON {
  83903. interface AbstractMesh {
  83904. /**
  83905. * Gets the edgesRenderer associated with the mesh
  83906. */
  83907. edgesRenderer: Nullable<EdgesRenderer>;
  83908. }
  83909. interface LinesMesh {
  83910. /**
  83911. * Enables the edge rendering mode on the mesh.
  83912. * This mode makes the mesh edges visible
  83913. * @param epsilon defines the maximal distance between two angles to detect a face
  83914. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83915. * @returns the currentAbstractMesh
  83916. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83917. */
  83918. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  83919. }
  83920. interface InstancedLinesMesh {
  83921. /**
  83922. * Enables the edge rendering mode on the mesh.
  83923. * This mode makes the mesh edges visible
  83924. * @param epsilon defines the maximal distance between two angles to detect a face
  83925. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83926. * @returns the current InstancedLinesMesh
  83927. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83928. */
  83929. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  83930. }
  83931. /**
  83932. * Defines the minimum contract an Edges renderer should follow.
  83933. */
  83934. export interface IEdgesRenderer extends IDisposable {
  83935. /**
  83936. * Gets or sets a boolean indicating if the edgesRenderer is active
  83937. */
  83938. isEnabled: boolean;
  83939. /**
  83940. * Renders the edges of the attached mesh,
  83941. */
  83942. render(): void;
  83943. /**
  83944. * Checks wether or not the edges renderer is ready to render.
  83945. * @return true if ready, otherwise false.
  83946. */
  83947. isReady(): boolean;
  83948. }
  83949. /**
  83950. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  83951. */
  83952. export class EdgesRenderer implements IEdgesRenderer {
  83953. /**
  83954. * Define the size of the edges with an orthographic camera
  83955. */
  83956. edgesWidthScalerForOrthographic: number;
  83957. /**
  83958. * Define the size of the edges with a perspective camera
  83959. */
  83960. edgesWidthScalerForPerspective: number;
  83961. protected _source: AbstractMesh;
  83962. protected _linesPositions: number[];
  83963. protected _linesNormals: number[];
  83964. protected _linesIndices: number[];
  83965. protected _epsilon: number;
  83966. protected _indicesCount: number;
  83967. protected _lineShader: ShaderMaterial;
  83968. protected _ib: DataBuffer;
  83969. protected _buffers: {
  83970. [key: string]: Nullable<VertexBuffer>;
  83971. };
  83972. protected _checkVerticesInsteadOfIndices: boolean;
  83973. private _meshRebuildObserver;
  83974. private _meshDisposeObserver;
  83975. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  83976. isEnabled: boolean;
  83977. /**
  83978. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  83979. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  83980. * @param source Mesh used to create edges
  83981. * @param epsilon sum of angles in adjacency to check for edge
  83982. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  83983. * @param generateEdgesLines - should generate Lines or only prepare resources.
  83984. */
  83985. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  83986. protected _prepareRessources(): void;
  83987. /** @hidden */
  83988. _rebuild(): void;
  83989. /**
  83990. * Releases the required resources for the edges renderer
  83991. */
  83992. dispose(): void;
  83993. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  83994. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  83995. /**
  83996. * Checks if the pair of p0 and p1 is en edge
  83997. * @param faceIndex
  83998. * @param edge
  83999. * @param faceNormals
  84000. * @param p0
  84001. * @param p1
  84002. * @private
  84003. */
  84004. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84005. /**
  84006. * push line into the position, normal and index buffer
  84007. * @protected
  84008. */
  84009. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84010. /**
  84011. * Generates lines edges from adjacencjes
  84012. * @private
  84013. */
  84014. _generateEdgesLines(): void;
  84015. /**
  84016. * Checks wether or not the edges renderer is ready to render.
  84017. * @return true if ready, otherwise false.
  84018. */
  84019. isReady(): boolean;
  84020. /**
  84021. * Renders the edges of the attached mesh,
  84022. */
  84023. render(): void;
  84024. }
  84025. /**
  84026. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84027. */
  84028. export class LineEdgesRenderer extends EdgesRenderer {
  84029. /**
  84030. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84031. * @param source LineMesh used to generate edges
  84032. * @param epsilon not important (specified angle for edge detection)
  84033. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84034. */
  84035. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84036. /**
  84037. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84038. */
  84039. _generateEdgesLines(): void;
  84040. }
  84041. }
  84042. declare module BABYLON {
  84043. /**
  84044. * This represents the object necessary to create a rendering group.
  84045. * This is exclusively used and created by the rendering manager.
  84046. * To modify the behavior, you use the available helpers in your scene or meshes.
  84047. * @hidden
  84048. */
  84049. export class RenderingGroup {
  84050. index: number;
  84051. private static _zeroVector;
  84052. private _scene;
  84053. private _opaqueSubMeshes;
  84054. private _transparentSubMeshes;
  84055. private _alphaTestSubMeshes;
  84056. private _depthOnlySubMeshes;
  84057. private _particleSystems;
  84058. private _spriteManagers;
  84059. private _opaqueSortCompareFn;
  84060. private _alphaTestSortCompareFn;
  84061. private _transparentSortCompareFn;
  84062. private _renderOpaque;
  84063. private _renderAlphaTest;
  84064. private _renderTransparent;
  84065. /** @hidden */
  84066. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84067. onBeforeTransparentRendering: () => void;
  84068. /**
  84069. * Set the opaque sort comparison function.
  84070. * If null the sub meshes will be render in the order they were created
  84071. */
  84072. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84073. /**
  84074. * Set the alpha test sort comparison function.
  84075. * If null the sub meshes will be render in the order they were created
  84076. */
  84077. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84078. /**
  84079. * Set the transparent sort comparison function.
  84080. * If null the sub meshes will be render in the order they were created
  84081. */
  84082. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84083. /**
  84084. * Creates a new rendering group.
  84085. * @param index The rendering group index
  84086. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84087. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84088. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84089. */
  84090. 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>);
  84091. /**
  84092. * Render all the sub meshes contained in the group.
  84093. * @param customRenderFunction Used to override the default render behaviour of the group.
  84094. * @returns true if rendered some submeshes.
  84095. */
  84096. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84097. /**
  84098. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84099. * @param subMeshes The submeshes to render
  84100. */
  84101. private renderOpaqueSorted;
  84102. /**
  84103. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84104. * @param subMeshes The submeshes to render
  84105. */
  84106. private renderAlphaTestSorted;
  84107. /**
  84108. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84109. * @param subMeshes The submeshes to render
  84110. */
  84111. private renderTransparentSorted;
  84112. /**
  84113. * Renders the submeshes in a specified order.
  84114. * @param subMeshes The submeshes to sort before render
  84115. * @param sortCompareFn The comparison function use to sort
  84116. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84117. * @param transparent Specifies to activate blending if true
  84118. */
  84119. private static renderSorted;
  84120. /**
  84121. * Renders the submeshes in the order they were dispatched (no sort applied).
  84122. * @param subMeshes The submeshes to render
  84123. */
  84124. private static renderUnsorted;
  84125. /**
  84126. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84127. * are rendered back to front if in the same alpha index.
  84128. *
  84129. * @param a The first submesh
  84130. * @param b The second submesh
  84131. * @returns The result of the comparison
  84132. */
  84133. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84134. /**
  84135. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84136. * are rendered back to front.
  84137. *
  84138. * @param a The first submesh
  84139. * @param b The second submesh
  84140. * @returns The result of the comparison
  84141. */
  84142. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84143. /**
  84144. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84145. * are rendered front to back (prevent overdraw).
  84146. *
  84147. * @param a The first submesh
  84148. * @param b The second submesh
  84149. * @returns The result of the comparison
  84150. */
  84151. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84152. /**
  84153. * Resets the different lists of submeshes to prepare a new frame.
  84154. */
  84155. prepare(): void;
  84156. dispose(): void;
  84157. /**
  84158. * Inserts the submesh in its correct queue depending on its material.
  84159. * @param subMesh The submesh to dispatch
  84160. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84161. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84162. */
  84163. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84164. dispatchSprites(spriteManager: ISpriteManager): void;
  84165. dispatchParticles(particleSystem: IParticleSystem): void;
  84166. private _renderParticles;
  84167. private _renderSprites;
  84168. }
  84169. }
  84170. declare module BABYLON {
  84171. /**
  84172. * Interface describing the different options available in the rendering manager
  84173. * regarding Auto Clear between groups.
  84174. */
  84175. export interface IRenderingManagerAutoClearSetup {
  84176. /**
  84177. * Defines whether or not autoclear is enable.
  84178. */
  84179. autoClear: boolean;
  84180. /**
  84181. * Defines whether or not to autoclear the depth buffer.
  84182. */
  84183. depth: boolean;
  84184. /**
  84185. * Defines whether or not to autoclear the stencil buffer.
  84186. */
  84187. stencil: boolean;
  84188. }
  84189. /**
  84190. * This class is used by the onRenderingGroupObservable
  84191. */
  84192. export class RenderingGroupInfo {
  84193. /**
  84194. * The Scene that being rendered
  84195. */
  84196. scene: Scene;
  84197. /**
  84198. * The camera currently used for the rendering pass
  84199. */
  84200. camera: Nullable<Camera>;
  84201. /**
  84202. * The ID of the renderingGroup being processed
  84203. */
  84204. renderingGroupId: number;
  84205. }
  84206. /**
  84207. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84208. * It is enable to manage the different groups as well as the different necessary sort functions.
  84209. * This should not be used directly aside of the few static configurations
  84210. */
  84211. export class RenderingManager {
  84212. /**
  84213. * The max id used for rendering groups (not included)
  84214. */
  84215. static MAX_RENDERINGGROUPS: number;
  84216. /**
  84217. * The min id used for rendering groups (included)
  84218. */
  84219. static MIN_RENDERINGGROUPS: number;
  84220. /**
  84221. * Used to globally prevent autoclearing scenes.
  84222. */
  84223. static AUTOCLEAR: boolean;
  84224. /**
  84225. * @hidden
  84226. */
  84227. _useSceneAutoClearSetup: boolean;
  84228. private _scene;
  84229. private _renderingGroups;
  84230. private _depthStencilBufferAlreadyCleaned;
  84231. private _autoClearDepthStencil;
  84232. private _customOpaqueSortCompareFn;
  84233. private _customAlphaTestSortCompareFn;
  84234. private _customTransparentSortCompareFn;
  84235. private _renderingGroupInfo;
  84236. /**
  84237. * Instantiates a new rendering group for a particular scene
  84238. * @param scene Defines the scene the groups belongs to
  84239. */
  84240. constructor(scene: Scene);
  84241. private _clearDepthStencilBuffer;
  84242. /**
  84243. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84244. * @hidden
  84245. */
  84246. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84247. /**
  84248. * Resets the different information of the group to prepare a new frame
  84249. * @hidden
  84250. */
  84251. reset(): void;
  84252. /**
  84253. * Dispose and release the group and its associated resources.
  84254. * @hidden
  84255. */
  84256. dispose(): void;
  84257. /**
  84258. * Clear the info related to rendering groups preventing retention points during dispose.
  84259. */
  84260. freeRenderingGroups(): void;
  84261. private _prepareRenderingGroup;
  84262. /**
  84263. * Add a sprite manager to the rendering manager in order to render it this frame.
  84264. * @param spriteManager Define the sprite manager to render
  84265. */
  84266. dispatchSprites(spriteManager: ISpriteManager): void;
  84267. /**
  84268. * Add a particle system to the rendering manager in order to render it this frame.
  84269. * @param particleSystem Define the particle system to render
  84270. */
  84271. dispatchParticles(particleSystem: IParticleSystem): void;
  84272. /**
  84273. * Add a submesh to the manager in order to render it this frame
  84274. * @param subMesh The submesh to dispatch
  84275. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84276. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84277. */
  84278. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84279. /**
  84280. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84281. * This allowed control for front to back rendering or reversly depending of the special needs.
  84282. *
  84283. * @param renderingGroupId The rendering group id corresponding to its index
  84284. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84285. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84286. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84287. */
  84288. 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;
  84289. /**
  84290. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84291. *
  84292. * @param renderingGroupId The rendering group id corresponding to its index
  84293. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84294. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84295. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84296. */
  84297. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84298. /**
  84299. * Gets the current auto clear configuration for one rendering group of the rendering
  84300. * manager.
  84301. * @param index the rendering group index to get the information for
  84302. * @returns The auto clear setup for the requested rendering group
  84303. */
  84304. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84305. }
  84306. }
  84307. declare module BABYLON {
  84308. /**
  84309. * This Helps creating a texture that will be created from a camera in your scene.
  84310. * It is basically a dynamic texture that could be used to create special effects for instance.
  84311. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84312. */
  84313. export class RenderTargetTexture extends Texture {
  84314. isCube: boolean;
  84315. /**
  84316. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84317. */
  84318. static readonly REFRESHRATE_RENDER_ONCE: number;
  84319. /**
  84320. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84321. */
  84322. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84323. /**
  84324. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84325. * the central point of your effect and can save a lot of performances.
  84326. */
  84327. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84328. /**
  84329. * Use this predicate to dynamically define the list of mesh you want to render.
  84330. * If set, the renderList property will be overwritten.
  84331. */
  84332. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84333. private _renderList;
  84334. /**
  84335. * Use this list to define the list of mesh you want to render.
  84336. */
  84337. renderList: Nullable<Array<AbstractMesh>>;
  84338. private _hookArray;
  84339. /**
  84340. * Define if particles should be rendered in your texture.
  84341. */
  84342. renderParticles: boolean;
  84343. /**
  84344. * Define if sprites should be rendered in your texture.
  84345. */
  84346. renderSprites: boolean;
  84347. /**
  84348. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84349. */
  84350. coordinatesMode: number;
  84351. /**
  84352. * Define the camera used to render the texture.
  84353. */
  84354. activeCamera: Nullable<Camera>;
  84355. /**
  84356. * Override the render function of the texture with your own one.
  84357. */
  84358. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84359. /**
  84360. * Define if camera post processes should be use while rendering the texture.
  84361. */
  84362. useCameraPostProcesses: boolean;
  84363. /**
  84364. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84365. */
  84366. ignoreCameraViewport: boolean;
  84367. private _postProcessManager;
  84368. private _postProcesses;
  84369. private _resizeObserver;
  84370. /**
  84371. * An event triggered when the texture is unbind.
  84372. */
  84373. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84374. /**
  84375. * An event triggered when the texture is unbind.
  84376. */
  84377. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84378. private _onAfterUnbindObserver;
  84379. /**
  84380. * Set a after unbind callback in the texture.
  84381. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84382. */
  84383. onAfterUnbind: () => void;
  84384. /**
  84385. * An event triggered before rendering the texture
  84386. */
  84387. onBeforeRenderObservable: Observable<number>;
  84388. private _onBeforeRenderObserver;
  84389. /**
  84390. * Set a before render callback in the texture.
  84391. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84392. */
  84393. onBeforeRender: (faceIndex: number) => void;
  84394. /**
  84395. * An event triggered after rendering the texture
  84396. */
  84397. onAfterRenderObservable: Observable<number>;
  84398. private _onAfterRenderObserver;
  84399. /**
  84400. * Set a after render callback in the texture.
  84401. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84402. */
  84403. onAfterRender: (faceIndex: number) => void;
  84404. /**
  84405. * An event triggered after the texture clear
  84406. */
  84407. onClearObservable: Observable<Engine>;
  84408. private _onClearObserver;
  84409. /**
  84410. * Set a clear callback in the texture.
  84411. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84412. */
  84413. onClear: (Engine: Engine) => void;
  84414. /**
  84415. * Define the clear color of the Render Target if it should be different from the scene.
  84416. */
  84417. clearColor: Color4;
  84418. protected _size: number | {
  84419. width: number;
  84420. height: number;
  84421. };
  84422. protected _initialSizeParameter: number | {
  84423. width: number;
  84424. height: number;
  84425. } | {
  84426. ratio: number;
  84427. };
  84428. protected _sizeRatio: Nullable<number>;
  84429. /** @hidden */
  84430. _generateMipMaps: boolean;
  84431. protected _renderingManager: RenderingManager;
  84432. /** @hidden */
  84433. _waitingRenderList: string[];
  84434. protected _doNotChangeAspectRatio: boolean;
  84435. protected _currentRefreshId: number;
  84436. protected _refreshRate: number;
  84437. protected _textureMatrix: Matrix;
  84438. protected _samples: number;
  84439. protected _renderTargetOptions: RenderTargetCreationOptions;
  84440. /**
  84441. * Gets render target creation options that were used.
  84442. */
  84443. readonly renderTargetOptions: RenderTargetCreationOptions;
  84444. protected _engine: Engine;
  84445. protected _onRatioRescale(): void;
  84446. /**
  84447. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84448. * It must define where the camera used to render the texture is set
  84449. */
  84450. boundingBoxPosition: Vector3;
  84451. private _boundingBoxSize;
  84452. /**
  84453. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84454. * When defined, the cubemap will switch to local mode
  84455. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84456. * @example https://www.babylonjs-playground.com/#RNASML
  84457. */
  84458. boundingBoxSize: Vector3;
  84459. /**
  84460. * In case the RTT has been created with a depth texture, get the associated
  84461. * depth texture.
  84462. * Otherwise, return null.
  84463. */
  84464. depthStencilTexture: Nullable<InternalTexture>;
  84465. /**
  84466. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84467. * or used a shadow, depth texture...
  84468. * @param name The friendly name of the texture
  84469. * @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)
  84470. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84471. * @param generateMipMaps True if mip maps need to be generated after render.
  84472. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84473. * @param type The type of the buffer in the RTT (int, half float, float...)
  84474. * @param isCube True if a cube texture needs to be created
  84475. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84476. * @param generateDepthBuffer True to generate a depth buffer
  84477. * @param generateStencilBuffer True to generate a stencil buffer
  84478. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84479. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84480. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84481. */
  84482. constructor(name: string, size: number | {
  84483. width: number;
  84484. height: number;
  84485. } | {
  84486. ratio: number;
  84487. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84488. /**
  84489. * Creates a depth stencil texture.
  84490. * This is only available in WebGL 2 or with the depth texture extension available.
  84491. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84492. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84493. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84494. */
  84495. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84496. private _processSizeParameter;
  84497. /**
  84498. * Define the number of samples to use in case of MSAA.
  84499. * It defaults to one meaning no MSAA has been enabled.
  84500. */
  84501. samples: number;
  84502. /**
  84503. * Resets the refresh counter of the texture and start bak from scratch.
  84504. * Could be useful to regenerate the texture if it is setup to render only once.
  84505. */
  84506. resetRefreshCounter(): void;
  84507. /**
  84508. * Define the refresh rate of the texture or the rendering frequency.
  84509. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84510. */
  84511. refreshRate: number;
  84512. /**
  84513. * Adds a post process to the render target rendering passes.
  84514. * @param postProcess define the post process to add
  84515. */
  84516. addPostProcess(postProcess: PostProcess): void;
  84517. /**
  84518. * Clear all the post processes attached to the render target
  84519. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84520. */
  84521. clearPostProcesses(dispose?: boolean): void;
  84522. /**
  84523. * Remove one of the post process from the list of attached post processes to the texture
  84524. * @param postProcess define the post process to remove from the list
  84525. */
  84526. removePostProcess(postProcess: PostProcess): void;
  84527. /** @hidden */
  84528. _shouldRender(): boolean;
  84529. /**
  84530. * Gets the actual render size of the texture.
  84531. * @returns the width of the render size
  84532. */
  84533. getRenderSize(): number;
  84534. /**
  84535. * Gets the actual render width of the texture.
  84536. * @returns the width of the render size
  84537. */
  84538. getRenderWidth(): number;
  84539. /**
  84540. * Gets the actual render height of the texture.
  84541. * @returns the height of the render size
  84542. */
  84543. getRenderHeight(): number;
  84544. /**
  84545. * Get if the texture can be rescaled or not.
  84546. */
  84547. readonly canRescale: boolean;
  84548. /**
  84549. * Resize the texture using a ratio.
  84550. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84551. */
  84552. scale(ratio: number): void;
  84553. /**
  84554. * Get the texture reflection matrix used to rotate/transform the reflection.
  84555. * @returns the reflection matrix
  84556. */
  84557. getReflectionTextureMatrix(): Matrix;
  84558. /**
  84559. * Resize the texture to a new desired size.
  84560. * Be carrefull as it will recreate all the data in the new texture.
  84561. * @param size Define the new size. It can be:
  84562. * - a number for squared texture,
  84563. * - an object containing { width: number, height: number }
  84564. * - or an object containing a ratio { ratio: number }
  84565. */
  84566. resize(size: number | {
  84567. width: number;
  84568. height: number;
  84569. } | {
  84570. ratio: number;
  84571. }): void;
  84572. /**
  84573. * Renders all the objects from the render list into the texture.
  84574. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84575. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84576. */
  84577. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84578. private _bestReflectionRenderTargetDimension;
  84579. /**
  84580. * @hidden
  84581. * @param faceIndex face index to bind to if this is a cubetexture
  84582. */
  84583. _bindFrameBuffer(faceIndex?: number): void;
  84584. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84585. private renderToTarget;
  84586. /**
  84587. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84588. * This allowed control for front to back rendering or reversly depending of the special needs.
  84589. *
  84590. * @param renderingGroupId The rendering group id corresponding to its index
  84591. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84592. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84593. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84594. */
  84595. 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;
  84596. /**
  84597. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84598. *
  84599. * @param renderingGroupId The rendering group id corresponding to its index
  84600. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84601. */
  84602. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84603. /**
  84604. * Clones the texture.
  84605. * @returns the cloned texture
  84606. */
  84607. clone(): RenderTargetTexture;
  84608. /**
  84609. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84610. * @returns The JSON representation of the texture
  84611. */
  84612. serialize(): any;
  84613. /**
  84614. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84615. */
  84616. disposeFramebufferObjects(): void;
  84617. /**
  84618. * Dispose the texture and release its associated resources.
  84619. */
  84620. dispose(): void;
  84621. /** @hidden */
  84622. _rebuild(): void;
  84623. /**
  84624. * Clear the info related to rendering groups preventing retention point in material dispose.
  84625. */
  84626. freeRenderingGroups(): void;
  84627. /**
  84628. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84629. * @returns the view count
  84630. */
  84631. getViewCount(): number;
  84632. }
  84633. }
  84634. declare module BABYLON {
  84635. /**
  84636. * Base class for the main features of a material in Babylon.js
  84637. */
  84638. export class Material implements IAnimatable {
  84639. /**
  84640. * Returns the triangle fill mode
  84641. */
  84642. static readonly TriangleFillMode: number;
  84643. /**
  84644. * Returns the wireframe mode
  84645. */
  84646. static readonly WireFrameFillMode: number;
  84647. /**
  84648. * Returns the point fill mode
  84649. */
  84650. static readonly PointFillMode: number;
  84651. /**
  84652. * Returns the point list draw mode
  84653. */
  84654. static readonly PointListDrawMode: number;
  84655. /**
  84656. * Returns the line list draw mode
  84657. */
  84658. static readonly LineListDrawMode: number;
  84659. /**
  84660. * Returns the line loop draw mode
  84661. */
  84662. static readonly LineLoopDrawMode: number;
  84663. /**
  84664. * Returns the line strip draw mode
  84665. */
  84666. static readonly LineStripDrawMode: number;
  84667. /**
  84668. * Returns the triangle strip draw mode
  84669. */
  84670. static readonly TriangleStripDrawMode: number;
  84671. /**
  84672. * Returns the triangle fan draw mode
  84673. */
  84674. static readonly TriangleFanDrawMode: number;
  84675. /**
  84676. * Stores the clock-wise side orientation
  84677. */
  84678. static readonly ClockWiseSideOrientation: number;
  84679. /**
  84680. * Stores the counter clock-wise side orientation
  84681. */
  84682. static readonly CounterClockWiseSideOrientation: number;
  84683. /**
  84684. * The dirty texture flag value
  84685. */
  84686. static readonly TextureDirtyFlag: number;
  84687. /**
  84688. * The dirty light flag value
  84689. */
  84690. static readonly LightDirtyFlag: number;
  84691. /**
  84692. * The dirty fresnel flag value
  84693. */
  84694. static readonly FresnelDirtyFlag: number;
  84695. /**
  84696. * The dirty attribute flag value
  84697. */
  84698. static readonly AttributesDirtyFlag: number;
  84699. /**
  84700. * The dirty misc flag value
  84701. */
  84702. static readonly MiscDirtyFlag: number;
  84703. /**
  84704. * The all dirty flag value
  84705. */
  84706. static readonly AllDirtyFlag: number;
  84707. /**
  84708. * The ID of the material
  84709. */
  84710. id: string;
  84711. /**
  84712. * Gets or sets the unique id of the material
  84713. */
  84714. uniqueId: number;
  84715. /**
  84716. * The name of the material
  84717. */
  84718. name: string;
  84719. /**
  84720. * Gets or sets user defined metadata
  84721. */
  84722. metadata: any;
  84723. /**
  84724. * For internal use only. Please do not use.
  84725. */
  84726. reservedDataStore: any;
  84727. /**
  84728. * Specifies if the ready state should be checked on each call
  84729. */
  84730. checkReadyOnEveryCall: boolean;
  84731. /**
  84732. * Specifies if the ready state should be checked once
  84733. */
  84734. checkReadyOnlyOnce: boolean;
  84735. /**
  84736. * The state of the material
  84737. */
  84738. state: string;
  84739. /**
  84740. * The alpha value of the material
  84741. */
  84742. protected _alpha: number;
  84743. /**
  84744. * List of inspectable custom properties (used by the Inspector)
  84745. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84746. */
  84747. inspectableCustomProperties: IInspectable[];
  84748. /**
  84749. * Sets the alpha value of the material
  84750. */
  84751. /**
  84752. * Gets the alpha value of the material
  84753. */
  84754. alpha: number;
  84755. /**
  84756. * Specifies if back face culling is enabled
  84757. */
  84758. protected _backFaceCulling: boolean;
  84759. /**
  84760. * Sets the back-face culling state
  84761. */
  84762. /**
  84763. * Gets the back-face culling state
  84764. */
  84765. backFaceCulling: boolean;
  84766. /**
  84767. * Stores the value for side orientation
  84768. */
  84769. sideOrientation: number;
  84770. /**
  84771. * Callback triggered when the material is compiled
  84772. */
  84773. onCompiled: Nullable<(effect: Effect) => void>;
  84774. /**
  84775. * Callback triggered when an error occurs
  84776. */
  84777. onError: Nullable<(effect: Effect, errors: string) => void>;
  84778. /**
  84779. * Callback triggered to get the render target textures
  84780. */
  84781. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84782. /**
  84783. * Gets a boolean indicating that current material needs to register RTT
  84784. */
  84785. readonly hasRenderTargetTextures: boolean;
  84786. /**
  84787. * Specifies if the material should be serialized
  84788. */
  84789. doNotSerialize: boolean;
  84790. /**
  84791. * @hidden
  84792. */
  84793. _storeEffectOnSubMeshes: boolean;
  84794. /**
  84795. * Stores the animations for the material
  84796. */
  84797. animations: Nullable<Array<Animation>>;
  84798. /**
  84799. * An event triggered when the material is disposed
  84800. */
  84801. onDisposeObservable: Observable<Material>;
  84802. /**
  84803. * An observer which watches for dispose events
  84804. */
  84805. private _onDisposeObserver;
  84806. private _onUnBindObservable;
  84807. /**
  84808. * Called during a dispose event
  84809. */
  84810. onDispose: () => void;
  84811. private _onBindObservable;
  84812. /**
  84813. * An event triggered when the material is bound
  84814. */
  84815. readonly onBindObservable: Observable<AbstractMesh>;
  84816. /**
  84817. * An observer which watches for bind events
  84818. */
  84819. private _onBindObserver;
  84820. /**
  84821. * Called during a bind event
  84822. */
  84823. onBind: (Mesh: AbstractMesh) => void;
  84824. /**
  84825. * An event triggered when the material is unbound
  84826. */
  84827. readonly onUnBindObservable: Observable<Material>;
  84828. /**
  84829. * Stores the value of the alpha mode
  84830. */
  84831. private _alphaMode;
  84832. /**
  84833. * Sets the value of the alpha mode.
  84834. *
  84835. * | Value | Type | Description |
  84836. * | --- | --- | --- |
  84837. * | 0 | ALPHA_DISABLE | |
  84838. * | 1 | ALPHA_ADD | |
  84839. * | 2 | ALPHA_COMBINE | |
  84840. * | 3 | ALPHA_SUBTRACT | |
  84841. * | 4 | ALPHA_MULTIPLY | |
  84842. * | 5 | ALPHA_MAXIMIZED | |
  84843. * | 6 | ALPHA_ONEONE | |
  84844. * | 7 | ALPHA_PREMULTIPLIED | |
  84845. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84846. * | 9 | ALPHA_INTERPOLATE | |
  84847. * | 10 | ALPHA_SCREENMODE | |
  84848. *
  84849. */
  84850. /**
  84851. * Gets the value of the alpha mode
  84852. */
  84853. alphaMode: number;
  84854. /**
  84855. * Stores the state of the need depth pre-pass value
  84856. */
  84857. private _needDepthPrePass;
  84858. /**
  84859. * Sets the need depth pre-pass value
  84860. */
  84861. /**
  84862. * Gets the depth pre-pass value
  84863. */
  84864. needDepthPrePass: boolean;
  84865. /**
  84866. * Specifies if depth writing should be disabled
  84867. */
  84868. disableDepthWrite: boolean;
  84869. /**
  84870. * Specifies if depth writing should be forced
  84871. */
  84872. forceDepthWrite: boolean;
  84873. /**
  84874. * Specifies if there should be a separate pass for culling
  84875. */
  84876. separateCullingPass: boolean;
  84877. /**
  84878. * Stores the state specifing if fog should be enabled
  84879. */
  84880. private _fogEnabled;
  84881. /**
  84882. * Sets the state for enabling fog
  84883. */
  84884. /**
  84885. * Gets the value of the fog enabled state
  84886. */
  84887. fogEnabled: boolean;
  84888. /**
  84889. * Stores the size of points
  84890. */
  84891. pointSize: number;
  84892. /**
  84893. * Stores the z offset value
  84894. */
  84895. zOffset: number;
  84896. /**
  84897. * Gets a value specifying if wireframe mode is enabled
  84898. */
  84899. /**
  84900. * Sets the state of wireframe mode
  84901. */
  84902. wireframe: boolean;
  84903. /**
  84904. * Gets the value specifying if point clouds are enabled
  84905. */
  84906. /**
  84907. * Sets the state of point cloud mode
  84908. */
  84909. pointsCloud: boolean;
  84910. /**
  84911. * Gets the material fill mode
  84912. */
  84913. /**
  84914. * Sets the material fill mode
  84915. */
  84916. fillMode: number;
  84917. /**
  84918. * @hidden
  84919. * Stores the effects for the material
  84920. */
  84921. _effect: Nullable<Effect>;
  84922. /**
  84923. * @hidden
  84924. * Specifies if the material was previously ready
  84925. */
  84926. _wasPreviouslyReady: boolean;
  84927. /**
  84928. * Specifies if uniform buffers should be used
  84929. */
  84930. private _useUBO;
  84931. /**
  84932. * Stores a reference to the scene
  84933. */
  84934. private _scene;
  84935. /**
  84936. * Stores the fill mode state
  84937. */
  84938. private _fillMode;
  84939. /**
  84940. * Specifies if the depth write state should be cached
  84941. */
  84942. private _cachedDepthWriteState;
  84943. /**
  84944. * Stores the uniform buffer
  84945. */
  84946. protected _uniformBuffer: UniformBuffer;
  84947. /** @hidden */
  84948. _indexInSceneMaterialArray: number;
  84949. /** @hidden */
  84950. meshMap: Nullable<{
  84951. [id: string]: AbstractMesh | undefined;
  84952. }>;
  84953. /**
  84954. * Creates a material instance
  84955. * @param name defines the name of the material
  84956. * @param scene defines the scene to reference
  84957. * @param doNotAdd specifies if the material should be added to the scene
  84958. */
  84959. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84960. /**
  84961. * Returns a string representation of the current material
  84962. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84963. * @returns a string with material information
  84964. */
  84965. toString(fullDetails?: boolean): string;
  84966. /**
  84967. * Gets the class name of the material
  84968. * @returns a string with the class name of the material
  84969. */
  84970. getClassName(): string;
  84971. /**
  84972. * Specifies if updates for the material been locked
  84973. */
  84974. readonly isFrozen: boolean;
  84975. /**
  84976. * Locks updates for the material
  84977. */
  84978. freeze(): void;
  84979. /**
  84980. * Unlocks updates for the material
  84981. */
  84982. unfreeze(): void;
  84983. /**
  84984. * Specifies if the material is ready to be used
  84985. * @param mesh defines the mesh to check
  84986. * @param useInstances specifies if instances should be used
  84987. * @returns a boolean indicating if the material is ready to be used
  84988. */
  84989. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84990. /**
  84991. * Specifies that the submesh is ready to be used
  84992. * @param mesh defines the mesh to check
  84993. * @param subMesh defines which submesh to check
  84994. * @param useInstances specifies that instances should be used
  84995. * @returns a boolean indicating that the submesh is ready or not
  84996. */
  84997. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84998. /**
  84999. * Returns the material effect
  85000. * @returns the effect associated with the material
  85001. */
  85002. getEffect(): Nullable<Effect>;
  85003. /**
  85004. * Returns the current scene
  85005. * @returns a Scene
  85006. */
  85007. getScene(): Scene;
  85008. /**
  85009. * Specifies if the material will require alpha blending
  85010. * @returns a boolean specifying if alpha blending is needed
  85011. */
  85012. needAlphaBlending(): boolean;
  85013. /**
  85014. * Specifies if the mesh will require alpha blending
  85015. * @param mesh defines the mesh to check
  85016. * @returns a boolean specifying if alpha blending is needed for the mesh
  85017. */
  85018. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85019. /**
  85020. * Specifies if this material should be rendered in alpha test mode
  85021. * @returns a boolean specifying if an alpha test is needed.
  85022. */
  85023. needAlphaTesting(): boolean;
  85024. /**
  85025. * Gets the texture used for the alpha test
  85026. * @returns the texture to use for alpha testing
  85027. */
  85028. getAlphaTestTexture(): Nullable<BaseTexture>;
  85029. /**
  85030. * Marks the material to indicate that it needs to be re-calculated
  85031. */
  85032. markDirty(): void;
  85033. /** @hidden */
  85034. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85035. /**
  85036. * Binds the material to the mesh
  85037. * @param world defines the world transformation matrix
  85038. * @param mesh defines the mesh to bind the material to
  85039. */
  85040. bind(world: Matrix, mesh?: Mesh): void;
  85041. /**
  85042. * Binds the submesh to the material
  85043. * @param world defines the world transformation matrix
  85044. * @param mesh defines the mesh containing the submesh
  85045. * @param subMesh defines the submesh to bind the material to
  85046. */
  85047. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85048. /**
  85049. * Binds the world matrix to the material
  85050. * @param world defines the world transformation matrix
  85051. */
  85052. bindOnlyWorldMatrix(world: Matrix): void;
  85053. /**
  85054. * Binds the scene's uniform buffer to the effect.
  85055. * @param effect defines the effect to bind to the scene uniform buffer
  85056. * @param sceneUbo defines the uniform buffer storing scene data
  85057. */
  85058. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85059. /**
  85060. * Binds the view matrix to the effect
  85061. * @param effect defines the effect to bind the view matrix to
  85062. */
  85063. bindView(effect: Effect): void;
  85064. /**
  85065. * Binds the view projection matrix to the effect
  85066. * @param effect defines the effect to bind the view projection matrix to
  85067. */
  85068. bindViewProjection(effect: Effect): void;
  85069. /**
  85070. * Specifies if material alpha testing should be turned on for the mesh
  85071. * @param mesh defines the mesh to check
  85072. */
  85073. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85074. /**
  85075. * Processes to execute after binding the material to a mesh
  85076. * @param mesh defines the rendered mesh
  85077. */
  85078. protected _afterBind(mesh?: Mesh): void;
  85079. /**
  85080. * Unbinds the material from the mesh
  85081. */
  85082. unbind(): void;
  85083. /**
  85084. * Gets the active textures from the material
  85085. * @returns an array of textures
  85086. */
  85087. getActiveTextures(): BaseTexture[];
  85088. /**
  85089. * Specifies if the material uses a texture
  85090. * @param texture defines the texture to check against the material
  85091. * @returns a boolean specifying if the material uses the texture
  85092. */
  85093. hasTexture(texture: BaseTexture): boolean;
  85094. /**
  85095. * Makes a duplicate of the material, and gives it a new name
  85096. * @param name defines the new name for the duplicated material
  85097. * @returns the cloned material
  85098. */
  85099. clone(name: string): Nullable<Material>;
  85100. /**
  85101. * Gets the meshes bound to the material
  85102. * @returns an array of meshes bound to the material
  85103. */
  85104. getBindedMeshes(): AbstractMesh[];
  85105. /**
  85106. * Force shader compilation
  85107. * @param mesh defines the mesh associated with this material
  85108. * @param onCompiled defines a function to execute once the material is compiled
  85109. * @param options defines the options to configure the compilation
  85110. */
  85111. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85112. clipPlane: boolean;
  85113. }>): void;
  85114. /**
  85115. * Force shader compilation
  85116. * @param mesh defines the mesh that will use this material
  85117. * @param options defines additional options for compiling the shaders
  85118. * @returns a promise that resolves when the compilation completes
  85119. */
  85120. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85121. clipPlane: boolean;
  85122. }>): Promise<void>;
  85123. private static readonly _AllDirtyCallBack;
  85124. private static readonly _ImageProcessingDirtyCallBack;
  85125. private static readonly _TextureDirtyCallBack;
  85126. private static readonly _FresnelDirtyCallBack;
  85127. private static readonly _MiscDirtyCallBack;
  85128. private static readonly _LightsDirtyCallBack;
  85129. private static readonly _AttributeDirtyCallBack;
  85130. private static _FresnelAndMiscDirtyCallBack;
  85131. private static _TextureAndMiscDirtyCallBack;
  85132. private static readonly _DirtyCallbackArray;
  85133. private static readonly _RunDirtyCallBacks;
  85134. /**
  85135. * Marks a define in the material to indicate that it needs to be re-computed
  85136. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85137. */
  85138. markAsDirty(flag: number): void;
  85139. /**
  85140. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85141. * @param func defines a function which checks material defines against the submeshes
  85142. */
  85143. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85144. /**
  85145. * Indicates that we need to re-calculated for all submeshes
  85146. */
  85147. protected _markAllSubMeshesAsAllDirty(): void;
  85148. /**
  85149. * Indicates that image processing needs to be re-calculated for all submeshes
  85150. */
  85151. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85152. /**
  85153. * Indicates that textures need to be re-calculated for all submeshes
  85154. */
  85155. protected _markAllSubMeshesAsTexturesDirty(): void;
  85156. /**
  85157. * Indicates that fresnel needs to be re-calculated for all submeshes
  85158. */
  85159. protected _markAllSubMeshesAsFresnelDirty(): void;
  85160. /**
  85161. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85162. */
  85163. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85164. /**
  85165. * Indicates that lights need to be re-calculated for all submeshes
  85166. */
  85167. protected _markAllSubMeshesAsLightsDirty(): void;
  85168. /**
  85169. * Indicates that attributes need to be re-calculated for all submeshes
  85170. */
  85171. protected _markAllSubMeshesAsAttributesDirty(): void;
  85172. /**
  85173. * Indicates that misc needs to be re-calculated for all submeshes
  85174. */
  85175. protected _markAllSubMeshesAsMiscDirty(): void;
  85176. /**
  85177. * Indicates that textures and misc need to be re-calculated for all submeshes
  85178. */
  85179. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85180. /**
  85181. * Disposes the material
  85182. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85183. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85184. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85185. */
  85186. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85187. /** @hidden */
  85188. private releaseVertexArrayObject;
  85189. /**
  85190. * Serializes this material
  85191. * @returns the serialized material object
  85192. */
  85193. serialize(): any;
  85194. /**
  85195. * Creates a material from parsed material data
  85196. * @param parsedMaterial defines parsed material data
  85197. * @param scene defines the hosting scene
  85198. * @param rootUrl defines the root URL to use to load textures
  85199. * @returns a new material
  85200. */
  85201. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85202. }
  85203. }
  85204. declare module BABYLON {
  85205. /**
  85206. * Base class for submeshes
  85207. */
  85208. export class BaseSubMesh {
  85209. /** @hidden */
  85210. _materialDefines: Nullable<MaterialDefines>;
  85211. /** @hidden */
  85212. _materialEffect: Nullable<Effect>;
  85213. /**
  85214. * Gets associated effect
  85215. */
  85216. readonly effect: Nullable<Effect>;
  85217. /**
  85218. * Sets associated effect (effect used to render this submesh)
  85219. * @param effect defines the effect to associate with
  85220. * @param defines defines the set of defines used to compile this effect
  85221. */
  85222. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85223. }
  85224. /**
  85225. * Defines a subdivision inside a mesh
  85226. */
  85227. export class SubMesh extends BaseSubMesh implements ICullable {
  85228. /** the material index to use */
  85229. materialIndex: number;
  85230. /** vertex index start */
  85231. verticesStart: number;
  85232. /** vertices count */
  85233. verticesCount: number;
  85234. /** index start */
  85235. indexStart: number;
  85236. /** indices count */
  85237. indexCount: number;
  85238. /** @hidden */
  85239. _linesIndexCount: number;
  85240. private _mesh;
  85241. private _renderingMesh;
  85242. private _boundingInfo;
  85243. private _linesIndexBuffer;
  85244. /** @hidden */
  85245. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85246. /** @hidden */
  85247. _trianglePlanes: Plane[];
  85248. /** @hidden */
  85249. _lastColliderTransformMatrix: Nullable<Matrix>;
  85250. /** @hidden */
  85251. _renderId: number;
  85252. /** @hidden */
  85253. _alphaIndex: number;
  85254. /** @hidden */
  85255. _distanceToCamera: number;
  85256. /** @hidden */
  85257. _id: number;
  85258. private _currentMaterial;
  85259. /**
  85260. * Add a new submesh to a mesh
  85261. * @param materialIndex defines the material index to use
  85262. * @param verticesStart defines vertex index start
  85263. * @param verticesCount defines vertices count
  85264. * @param indexStart defines index start
  85265. * @param indexCount defines indices count
  85266. * @param mesh defines the parent mesh
  85267. * @param renderingMesh defines an optional rendering mesh
  85268. * @param createBoundingBox defines if bounding box should be created for this submesh
  85269. * @returns the new submesh
  85270. */
  85271. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85272. /**
  85273. * Creates a new submesh
  85274. * @param materialIndex defines the material index to use
  85275. * @param verticesStart defines vertex index start
  85276. * @param verticesCount defines vertices count
  85277. * @param indexStart defines index start
  85278. * @param indexCount defines indices count
  85279. * @param mesh defines the parent mesh
  85280. * @param renderingMesh defines an optional rendering mesh
  85281. * @param createBoundingBox defines if bounding box should be created for this submesh
  85282. */
  85283. constructor(
  85284. /** the material index to use */
  85285. materialIndex: number,
  85286. /** vertex index start */
  85287. verticesStart: number,
  85288. /** vertices count */
  85289. verticesCount: number,
  85290. /** index start */
  85291. indexStart: number,
  85292. /** indices count */
  85293. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85294. /**
  85295. * Returns true if this submesh covers the entire parent mesh
  85296. * @ignorenaming
  85297. */
  85298. readonly IsGlobal: boolean;
  85299. /**
  85300. * Returns the submesh BoudingInfo object
  85301. * @returns current bounding info (or mesh's one if the submesh is global)
  85302. */
  85303. getBoundingInfo(): BoundingInfo;
  85304. /**
  85305. * Sets the submesh BoundingInfo
  85306. * @param boundingInfo defines the new bounding info to use
  85307. * @returns the SubMesh
  85308. */
  85309. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85310. /**
  85311. * Returns the mesh of the current submesh
  85312. * @return the parent mesh
  85313. */
  85314. getMesh(): AbstractMesh;
  85315. /**
  85316. * Returns the rendering mesh of the submesh
  85317. * @returns the rendering mesh (could be different from parent mesh)
  85318. */
  85319. getRenderingMesh(): Mesh;
  85320. /**
  85321. * Returns the submesh material
  85322. * @returns null or the current material
  85323. */
  85324. getMaterial(): Nullable<Material>;
  85325. /**
  85326. * Sets a new updated BoundingInfo object to the submesh
  85327. * @param data defines an optional position array to use to determine the bounding info
  85328. * @returns the SubMesh
  85329. */
  85330. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85331. /** @hidden */
  85332. _checkCollision(collider: Collider): boolean;
  85333. /**
  85334. * Updates the submesh BoundingInfo
  85335. * @param world defines the world matrix to use to update the bounding info
  85336. * @returns the submesh
  85337. */
  85338. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85339. /**
  85340. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85341. * @param frustumPlanes defines the frustum planes
  85342. * @returns true if the submesh is intersecting with the frustum
  85343. */
  85344. isInFrustum(frustumPlanes: Plane[]): boolean;
  85345. /**
  85346. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85347. * @param frustumPlanes defines the frustum planes
  85348. * @returns true if the submesh is inside the frustum
  85349. */
  85350. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85351. /**
  85352. * Renders the submesh
  85353. * @param enableAlphaMode defines if alpha needs to be used
  85354. * @returns the submesh
  85355. */
  85356. render(enableAlphaMode: boolean): SubMesh;
  85357. /**
  85358. * @hidden
  85359. */
  85360. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85361. /**
  85362. * Checks if the submesh intersects with a ray
  85363. * @param ray defines the ray to test
  85364. * @returns true is the passed ray intersects the submesh bounding box
  85365. */
  85366. canIntersects(ray: Ray): boolean;
  85367. /**
  85368. * Intersects current submesh with a ray
  85369. * @param ray defines the ray to test
  85370. * @param positions defines mesh's positions array
  85371. * @param indices defines mesh's indices array
  85372. * @param fastCheck defines if only bounding info should be used
  85373. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85374. * @returns intersection info or null if no intersection
  85375. */
  85376. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85377. /** @hidden */
  85378. private _intersectLines;
  85379. /** @hidden */
  85380. private _intersectUnIndexedLines;
  85381. /** @hidden */
  85382. private _intersectTriangles;
  85383. /** @hidden */
  85384. private _intersectUnIndexedTriangles;
  85385. /** @hidden */
  85386. _rebuild(): void;
  85387. /**
  85388. * Creates a new submesh from the passed mesh
  85389. * @param newMesh defines the new hosting mesh
  85390. * @param newRenderingMesh defines an optional rendering mesh
  85391. * @returns the new submesh
  85392. */
  85393. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85394. /**
  85395. * Release associated resources
  85396. */
  85397. dispose(): void;
  85398. /**
  85399. * Gets the class name
  85400. * @returns the string "SubMesh".
  85401. */
  85402. getClassName(): string;
  85403. /**
  85404. * Creates a new submesh from indices data
  85405. * @param materialIndex the index of the main mesh material
  85406. * @param startIndex the index where to start the copy in the mesh indices array
  85407. * @param indexCount the number of indices to copy then from the startIndex
  85408. * @param mesh the main mesh to create the submesh from
  85409. * @param renderingMesh the optional rendering mesh
  85410. * @returns a new submesh
  85411. */
  85412. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85413. }
  85414. }
  85415. declare module BABYLON {
  85416. /**
  85417. * Class used to store geometry data (vertex buffers + index buffer)
  85418. */
  85419. export class Geometry implements IGetSetVerticesData {
  85420. /**
  85421. * Gets or sets the ID of the geometry
  85422. */
  85423. id: string;
  85424. /**
  85425. * Gets or sets the unique ID of the geometry
  85426. */
  85427. uniqueId: number;
  85428. /**
  85429. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85430. */
  85431. delayLoadState: number;
  85432. /**
  85433. * Gets the file containing the data to load when running in delay load state
  85434. */
  85435. delayLoadingFile: Nullable<string>;
  85436. /**
  85437. * Callback called when the geometry is updated
  85438. */
  85439. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85440. private _scene;
  85441. private _engine;
  85442. private _meshes;
  85443. private _totalVertices;
  85444. /** @hidden */
  85445. _indices: IndicesArray;
  85446. /** @hidden */
  85447. _vertexBuffers: {
  85448. [key: string]: VertexBuffer;
  85449. };
  85450. private _isDisposed;
  85451. private _extend;
  85452. private _boundingBias;
  85453. /** @hidden */
  85454. _delayInfo: Array<string>;
  85455. private _indexBuffer;
  85456. private _indexBufferIsUpdatable;
  85457. /** @hidden */
  85458. _boundingInfo: Nullable<BoundingInfo>;
  85459. /** @hidden */
  85460. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85461. /** @hidden */
  85462. _softwareSkinningFrameId: number;
  85463. private _vertexArrayObjects;
  85464. private _updatable;
  85465. /** @hidden */
  85466. _positions: Nullable<Vector3[]>;
  85467. /**
  85468. * 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
  85469. */
  85470. /**
  85471. * 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
  85472. */
  85473. boundingBias: Vector2;
  85474. /**
  85475. * Static function used to attach a new empty geometry to a mesh
  85476. * @param mesh defines the mesh to attach the geometry to
  85477. * @returns the new Geometry
  85478. */
  85479. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85480. /**
  85481. * Creates a new geometry
  85482. * @param id defines the unique ID
  85483. * @param scene defines the hosting scene
  85484. * @param vertexData defines the VertexData used to get geometry data
  85485. * @param updatable defines if geometry must be updatable (false by default)
  85486. * @param mesh defines the mesh that will be associated with the geometry
  85487. */
  85488. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85489. /**
  85490. * Gets the current extend of the geometry
  85491. */
  85492. readonly extend: {
  85493. minimum: Vector3;
  85494. maximum: Vector3;
  85495. };
  85496. /**
  85497. * Gets the hosting scene
  85498. * @returns the hosting Scene
  85499. */
  85500. getScene(): Scene;
  85501. /**
  85502. * Gets the hosting engine
  85503. * @returns the hosting Engine
  85504. */
  85505. getEngine(): Engine;
  85506. /**
  85507. * Defines if the geometry is ready to use
  85508. * @returns true if the geometry is ready to be used
  85509. */
  85510. isReady(): boolean;
  85511. /**
  85512. * Gets a value indicating that the geometry should not be serialized
  85513. */
  85514. readonly doNotSerialize: boolean;
  85515. /** @hidden */
  85516. _rebuild(): void;
  85517. /**
  85518. * Affects all geometry data in one call
  85519. * @param vertexData defines the geometry data
  85520. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85521. */
  85522. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85523. /**
  85524. * Set specific vertex data
  85525. * @param kind defines the data kind (Position, normal, etc...)
  85526. * @param data defines the vertex data to use
  85527. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85528. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85529. */
  85530. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85531. /**
  85532. * Removes a specific vertex data
  85533. * @param kind defines the data kind (Position, normal, etc...)
  85534. */
  85535. removeVerticesData(kind: string): void;
  85536. /**
  85537. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85538. * @param buffer defines the vertex buffer to use
  85539. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85540. */
  85541. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85542. /**
  85543. * Update a specific vertex buffer
  85544. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85545. * It will do nothing if the buffer is not updatable
  85546. * @param kind defines the data kind (Position, normal, etc...)
  85547. * @param data defines the data to use
  85548. * @param offset defines the offset in the target buffer where to store the data
  85549. * @param useBytes set to true if the offset is in bytes
  85550. */
  85551. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85552. /**
  85553. * Update a specific vertex buffer
  85554. * This function will create a new buffer if the current one is not updatable
  85555. * @param kind defines the data kind (Position, normal, etc...)
  85556. * @param data defines the data to use
  85557. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85558. */
  85559. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85560. private _updateBoundingInfo;
  85561. /** @hidden */
  85562. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85563. /**
  85564. * Gets total number of vertices
  85565. * @returns the total number of vertices
  85566. */
  85567. getTotalVertices(): number;
  85568. /**
  85569. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85570. * @param kind defines the data kind (Position, normal, etc...)
  85571. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85572. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85573. * @returns a float array containing vertex data
  85574. */
  85575. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85576. /**
  85577. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85578. * @param kind defines the data kind (Position, normal, etc...)
  85579. * @returns true if the vertex buffer with the specified kind is updatable
  85580. */
  85581. isVertexBufferUpdatable(kind: string): boolean;
  85582. /**
  85583. * Gets a specific vertex buffer
  85584. * @param kind defines the data kind (Position, normal, etc...)
  85585. * @returns a VertexBuffer
  85586. */
  85587. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85588. /**
  85589. * Returns all vertex buffers
  85590. * @return an object holding all vertex buffers indexed by kind
  85591. */
  85592. getVertexBuffers(): Nullable<{
  85593. [key: string]: VertexBuffer;
  85594. }>;
  85595. /**
  85596. * Gets a boolean indicating if specific vertex buffer is present
  85597. * @param kind defines the data kind (Position, normal, etc...)
  85598. * @returns true if data is present
  85599. */
  85600. isVerticesDataPresent(kind: string): boolean;
  85601. /**
  85602. * Gets a list of all attached data kinds (Position, normal, etc...)
  85603. * @returns a list of string containing all kinds
  85604. */
  85605. getVerticesDataKinds(): string[];
  85606. /**
  85607. * Update index buffer
  85608. * @param indices defines the indices to store in the index buffer
  85609. * @param offset defines the offset in the target buffer where to store the data
  85610. * @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)
  85611. */
  85612. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85613. /**
  85614. * Creates a new index buffer
  85615. * @param indices defines the indices to store in the index buffer
  85616. * @param totalVertices defines the total number of vertices (could be null)
  85617. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85618. */
  85619. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85620. /**
  85621. * Return the total number of indices
  85622. * @returns the total number of indices
  85623. */
  85624. getTotalIndices(): number;
  85625. /**
  85626. * Gets the index buffer array
  85627. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85628. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85629. * @returns the index buffer array
  85630. */
  85631. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85632. /**
  85633. * Gets the index buffer
  85634. * @return the index buffer
  85635. */
  85636. getIndexBuffer(): Nullable<DataBuffer>;
  85637. /** @hidden */
  85638. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85639. /**
  85640. * Release the associated resources for a specific mesh
  85641. * @param mesh defines the source mesh
  85642. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85643. */
  85644. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85645. /**
  85646. * Apply current geometry to a given mesh
  85647. * @param mesh defines the mesh to apply geometry to
  85648. */
  85649. applyToMesh(mesh: Mesh): void;
  85650. private _updateExtend;
  85651. private _applyToMesh;
  85652. private notifyUpdate;
  85653. /**
  85654. * Load the geometry if it was flagged as delay loaded
  85655. * @param scene defines the hosting scene
  85656. * @param onLoaded defines a callback called when the geometry is loaded
  85657. */
  85658. load(scene: Scene, onLoaded?: () => void): void;
  85659. private _queueLoad;
  85660. /**
  85661. * Invert the geometry to move from a right handed system to a left handed one.
  85662. */
  85663. toLeftHanded(): void;
  85664. /** @hidden */
  85665. _resetPointsArrayCache(): void;
  85666. /** @hidden */
  85667. _generatePointsArray(): boolean;
  85668. /**
  85669. * Gets a value indicating if the geometry is disposed
  85670. * @returns true if the geometry was disposed
  85671. */
  85672. isDisposed(): boolean;
  85673. private _disposeVertexArrayObjects;
  85674. /**
  85675. * Free all associated resources
  85676. */
  85677. dispose(): void;
  85678. /**
  85679. * Clone the current geometry into a new geometry
  85680. * @param id defines the unique ID of the new geometry
  85681. * @returns a new geometry object
  85682. */
  85683. copy(id: string): Geometry;
  85684. /**
  85685. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85686. * @return a JSON representation of the current geometry data (without the vertices data)
  85687. */
  85688. serialize(): any;
  85689. private toNumberArray;
  85690. /**
  85691. * Serialize all vertices data into a JSON oject
  85692. * @returns a JSON representation of the current geometry data
  85693. */
  85694. serializeVerticeData(): any;
  85695. /**
  85696. * Extracts a clone of a mesh geometry
  85697. * @param mesh defines the source mesh
  85698. * @param id defines the unique ID of the new geometry object
  85699. * @returns the new geometry object
  85700. */
  85701. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85702. /**
  85703. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85704. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85705. * Be aware Math.random() could cause collisions, but:
  85706. * "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"
  85707. * @returns a string containing a new GUID
  85708. */
  85709. static RandomId(): string;
  85710. /** @hidden */
  85711. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85712. private static _CleanMatricesWeights;
  85713. /**
  85714. * Create a new geometry from persisted data (Using .babylon file format)
  85715. * @param parsedVertexData defines the persisted data
  85716. * @param scene defines the hosting scene
  85717. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85718. * @returns the new geometry object
  85719. */
  85720. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85721. }
  85722. }
  85723. declare module BABYLON {
  85724. /**
  85725. * Define an interface for all classes that will get and set the data on vertices
  85726. */
  85727. export interface IGetSetVerticesData {
  85728. /**
  85729. * Gets a boolean indicating if specific vertex data is present
  85730. * @param kind defines the vertex data kind to use
  85731. * @returns true is data kind is present
  85732. */
  85733. isVerticesDataPresent(kind: string): boolean;
  85734. /**
  85735. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85736. * @param kind defines the data kind (Position, normal, etc...)
  85737. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85738. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85739. * @returns a float array containing vertex data
  85740. */
  85741. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85742. /**
  85743. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85744. * @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.
  85745. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85746. * @returns the indices array or an empty array if the mesh has no geometry
  85747. */
  85748. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85749. /**
  85750. * Set specific vertex data
  85751. * @param kind defines the data kind (Position, normal, etc...)
  85752. * @param data defines the vertex data to use
  85753. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85754. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85755. */
  85756. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85757. /**
  85758. * Update a specific associated vertex buffer
  85759. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85760. * - VertexBuffer.PositionKind
  85761. * - VertexBuffer.UVKind
  85762. * - VertexBuffer.UV2Kind
  85763. * - VertexBuffer.UV3Kind
  85764. * - VertexBuffer.UV4Kind
  85765. * - VertexBuffer.UV5Kind
  85766. * - VertexBuffer.UV6Kind
  85767. * - VertexBuffer.ColorKind
  85768. * - VertexBuffer.MatricesIndicesKind
  85769. * - VertexBuffer.MatricesIndicesExtraKind
  85770. * - VertexBuffer.MatricesWeightsKind
  85771. * - VertexBuffer.MatricesWeightsExtraKind
  85772. * @param data defines the data source
  85773. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85774. * @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)
  85775. */
  85776. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85777. /**
  85778. * Creates a new index buffer
  85779. * @param indices defines the indices to store in the index buffer
  85780. * @param totalVertices defines the total number of vertices (could be null)
  85781. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85782. */
  85783. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85784. }
  85785. /**
  85786. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85787. */
  85788. export class VertexData {
  85789. /**
  85790. * Mesh side orientation : usually the external or front surface
  85791. */
  85792. static readonly FRONTSIDE: number;
  85793. /**
  85794. * Mesh side orientation : usually the internal or back surface
  85795. */
  85796. static readonly BACKSIDE: number;
  85797. /**
  85798. * Mesh side orientation : both internal and external or front and back surfaces
  85799. */
  85800. static readonly DOUBLESIDE: number;
  85801. /**
  85802. * Mesh side orientation : by default, `FRONTSIDE`
  85803. */
  85804. static readonly DEFAULTSIDE: number;
  85805. /**
  85806. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85807. */
  85808. positions: Nullable<FloatArray>;
  85809. /**
  85810. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85811. */
  85812. normals: Nullable<FloatArray>;
  85813. /**
  85814. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85815. */
  85816. tangents: Nullable<FloatArray>;
  85817. /**
  85818. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85819. */
  85820. uvs: Nullable<FloatArray>;
  85821. /**
  85822. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85823. */
  85824. uvs2: Nullable<FloatArray>;
  85825. /**
  85826. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85827. */
  85828. uvs3: Nullable<FloatArray>;
  85829. /**
  85830. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85831. */
  85832. uvs4: Nullable<FloatArray>;
  85833. /**
  85834. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85835. */
  85836. uvs5: Nullable<FloatArray>;
  85837. /**
  85838. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85839. */
  85840. uvs6: Nullable<FloatArray>;
  85841. /**
  85842. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85843. */
  85844. colors: Nullable<FloatArray>;
  85845. /**
  85846. * 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).
  85847. */
  85848. matricesIndices: Nullable<FloatArray>;
  85849. /**
  85850. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85851. */
  85852. matricesWeights: Nullable<FloatArray>;
  85853. /**
  85854. * An array extending the number of possible indices
  85855. */
  85856. matricesIndicesExtra: Nullable<FloatArray>;
  85857. /**
  85858. * An array extending the number of possible weights when the number of indices is extended
  85859. */
  85860. matricesWeightsExtra: Nullable<FloatArray>;
  85861. /**
  85862. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85863. */
  85864. indices: Nullable<IndicesArray>;
  85865. /**
  85866. * Uses the passed data array to set the set the values for the specified kind of data
  85867. * @param data a linear array of floating numbers
  85868. * @param kind the type of data that is being set, eg positions, colors etc
  85869. */
  85870. set(data: FloatArray, kind: string): void;
  85871. /**
  85872. * Associates the vertexData to the passed Mesh.
  85873. * Sets it as updatable or not (default `false`)
  85874. * @param mesh the mesh the vertexData is applied to
  85875. * @param updatable when used and having the value true allows new data to update the vertexData
  85876. * @returns the VertexData
  85877. */
  85878. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85879. /**
  85880. * Associates the vertexData to the passed Geometry.
  85881. * Sets it as updatable or not (default `false`)
  85882. * @param geometry the geometry the vertexData is applied to
  85883. * @param updatable when used and having the value true allows new data to update the vertexData
  85884. * @returns VertexData
  85885. */
  85886. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85887. /**
  85888. * Updates the associated mesh
  85889. * @param mesh the mesh to be updated
  85890. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85891. * @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
  85892. * @returns VertexData
  85893. */
  85894. updateMesh(mesh: Mesh): VertexData;
  85895. /**
  85896. * Updates the associated geometry
  85897. * @param geometry the geometry to be updated
  85898. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85899. * @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
  85900. * @returns VertexData.
  85901. */
  85902. updateGeometry(geometry: Geometry): VertexData;
  85903. private _applyTo;
  85904. private _update;
  85905. /**
  85906. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85907. * @param matrix the transforming matrix
  85908. * @returns the VertexData
  85909. */
  85910. transform(matrix: Matrix): VertexData;
  85911. /**
  85912. * Merges the passed VertexData into the current one
  85913. * @param other the VertexData to be merged into the current one
  85914. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85915. * @returns the modified VertexData
  85916. */
  85917. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85918. private _mergeElement;
  85919. private _validate;
  85920. /**
  85921. * Serializes the VertexData
  85922. * @returns a serialized object
  85923. */
  85924. serialize(): any;
  85925. /**
  85926. * Extracts the vertexData from a mesh
  85927. * @param mesh the mesh from which to extract the VertexData
  85928. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85929. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85930. * @returns the object VertexData associated to the passed mesh
  85931. */
  85932. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85933. /**
  85934. * Extracts the vertexData from the geometry
  85935. * @param geometry the geometry from which to extract the VertexData
  85936. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85937. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85938. * @returns the object VertexData associated to the passed mesh
  85939. */
  85940. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85941. private static _ExtractFrom;
  85942. /**
  85943. * Creates the VertexData for a Ribbon
  85944. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85945. * * pathArray array of paths, each of which an array of successive Vector3
  85946. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85947. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85948. * * 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
  85949. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85950. * * 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)
  85951. * * 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)
  85952. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85953. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85954. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85955. * @returns the VertexData of the ribbon
  85956. */
  85957. static CreateRibbon(options: {
  85958. pathArray: Vector3[][];
  85959. closeArray?: boolean;
  85960. closePath?: boolean;
  85961. offset?: number;
  85962. sideOrientation?: number;
  85963. frontUVs?: Vector4;
  85964. backUVs?: Vector4;
  85965. invertUV?: boolean;
  85966. uvs?: Vector2[];
  85967. colors?: Color4[];
  85968. }): VertexData;
  85969. /**
  85970. * Creates the VertexData for a box
  85971. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85972. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85973. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85974. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85975. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85976. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85977. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85978. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85979. * * 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)
  85980. * * 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)
  85981. * @returns the VertexData of the box
  85982. */
  85983. static CreateBox(options: {
  85984. size?: number;
  85985. width?: number;
  85986. height?: number;
  85987. depth?: number;
  85988. faceUV?: Vector4[];
  85989. faceColors?: Color4[];
  85990. sideOrientation?: number;
  85991. frontUVs?: Vector4;
  85992. backUVs?: Vector4;
  85993. }): VertexData;
  85994. /**
  85995. * Creates the VertexData for a tiled box
  85996. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85997. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85998. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85999. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86000. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86001. * @returns the VertexData of the box
  86002. */
  86003. static CreateTiledBox(options: {
  86004. pattern?: number;
  86005. width?: number;
  86006. height?: number;
  86007. depth?: number;
  86008. tileSize?: number;
  86009. tileWidth?: number;
  86010. tileHeight?: number;
  86011. alignHorizontal?: number;
  86012. alignVertical?: number;
  86013. faceUV?: Vector4[];
  86014. faceColors?: Color4[];
  86015. sideOrientation?: number;
  86016. }): VertexData;
  86017. /**
  86018. * Creates the VertexData for a tiled plane
  86019. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86020. * * pattern a limited pattern arrangement depending on the number
  86021. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86022. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86023. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86024. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86025. * * 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)
  86026. * * 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)
  86027. * @returns the VertexData of the tiled plane
  86028. */
  86029. static CreateTiledPlane(options: {
  86030. pattern?: number;
  86031. tileSize?: number;
  86032. tileWidth?: number;
  86033. tileHeight?: number;
  86034. size?: number;
  86035. width?: number;
  86036. height?: number;
  86037. alignHorizontal?: number;
  86038. alignVertical?: number;
  86039. sideOrientation?: number;
  86040. frontUVs?: Vector4;
  86041. backUVs?: Vector4;
  86042. }): VertexData;
  86043. /**
  86044. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86045. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86046. * * segments sets the number of horizontal strips optional, default 32
  86047. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86048. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86049. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86050. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86051. * * 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
  86052. * * 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
  86053. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86054. * * 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)
  86055. * * 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)
  86056. * @returns the VertexData of the ellipsoid
  86057. */
  86058. static CreateSphere(options: {
  86059. segments?: number;
  86060. diameter?: number;
  86061. diameterX?: number;
  86062. diameterY?: number;
  86063. diameterZ?: number;
  86064. arc?: number;
  86065. slice?: number;
  86066. sideOrientation?: number;
  86067. frontUVs?: Vector4;
  86068. backUVs?: Vector4;
  86069. }): VertexData;
  86070. /**
  86071. * Creates the VertexData for a cylinder, cone or prism
  86072. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86073. * * height sets the height (y direction) of the cylinder, optional, default 2
  86074. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86075. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86076. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86077. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86078. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86079. * * 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
  86080. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86081. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86082. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86083. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86084. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86085. * * 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)
  86086. * * 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)
  86087. * @returns the VertexData of the cylinder, cone or prism
  86088. */
  86089. static CreateCylinder(options: {
  86090. height?: number;
  86091. diameterTop?: number;
  86092. diameterBottom?: number;
  86093. diameter?: number;
  86094. tessellation?: number;
  86095. subdivisions?: number;
  86096. arc?: number;
  86097. faceColors?: Color4[];
  86098. faceUV?: Vector4[];
  86099. hasRings?: boolean;
  86100. enclose?: boolean;
  86101. sideOrientation?: number;
  86102. frontUVs?: Vector4;
  86103. backUVs?: Vector4;
  86104. }): VertexData;
  86105. /**
  86106. * Creates the VertexData for a torus
  86107. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86108. * * diameter the diameter of the torus, optional default 1
  86109. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86110. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86111. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86112. * * 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)
  86113. * * 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)
  86114. * @returns the VertexData of the torus
  86115. */
  86116. static CreateTorus(options: {
  86117. diameter?: number;
  86118. thickness?: number;
  86119. tessellation?: number;
  86120. sideOrientation?: number;
  86121. frontUVs?: Vector4;
  86122. backUVs?: Vector4;
  86123. }): VertexData;
  86124. /**
  86125. * Creates the VertexData of the LineSystem
  86126. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86127. * - lines an array of lines, each line being an array of successive Vector3
  86128. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86129. * @returns the VertexData of the LineSystem
  86130. */
  86131. static CreateLineSystem(options: {
  86132. lines: Vector3[][];
  86133. colors?: Nullable<Color4[][]>;
  86134. }): VertexData;
  86135. /**
  86136. * Create the VertexData for a DashedLines
  86137. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86138. * - points an array successive Vector3
  86139. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86140. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86141. * - dashNb the intended total number of dashes, optional, default 200
  86142. * @returns the VertexData for the DashedLines
  86143. */
  86144. static CreateDashedLines(options: {
  86145. points: Vector3[];
  86146. dashSize?: number;
  86147. gapSize?: number;
  86148. dashNb?: number;
  86149. }): VertexData;
  86150. /**
  86151. * Creates the VertexData for a Ground
  86152. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86153. * - width the width (x direction) of the ground, optional, default 1
  86154. * - height the height (z direction) of the ground, optional, default 1
  86155. * - subdivisions the number of subdivisions per side, optional, default 1
  86156. * @returns the VertexData of the Ground
  86157. */
  86158. static CreateGround(options: {
  86159. width?: number;
  86160. height?: number;
  86161. subdivisions?: number;
  86162. subdivisionsX?: number;
  86163. subdivisionsY?: number;
  86164. }): VertexData;
  86165. /**
  86166. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86167. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86168. * * xmin the ground minimum X coordinate, optional, default -1
  86169. * * zmin the ground minimum Z coordinate, optional, default -1
  86170. * * xmax the ground maximum X coordinate, optional, default 1
  86171. * * zmax the ground maximum Z coordinate, optional, default 1
  86172. * * 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}
  86173. * * 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}
  86174. * @returns the VertexData of the TiledGround
  86175. */
  86176. static CreateTiledGround(options: {
  86177. xmin: number;
  86178. zmin: number;
  86179. xmax: number;
  86180. zmax: number;
  86181. subdivisions?: {
  86182. w: number;
  86183. h: number;
  86184. };
  86185. precision?: {
  86186. w: number;
  86187. h: number;
  86188. };
  86189. }): VertexData;
  86190. /**
  86191. * Creates the VertexData of the Ground designed from a heightmap
  86192. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86193. * * width the width (x direction) of the ground
  86194. * * height the height (z direction) of the ground
  86195. * * subdivisions the number of subdivisions per side
  86196. * * minHeight the minimum altitude on the ground, optional, default 0
  86197. * * maxHeight the maximum altitude on the ground, optional default 1
  86198. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86199. * * buffer the array holding the image color data
  86200. * * bufferWidth the width of image
  86201. * * bufferHeight the height of image
  86202. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86203. * @returns the VertexData of the Ground designed from a heightmap
  86204. */
  86205. static CreateGroundFromHeightMap(options: {
  86206. width: number;
  86207. height: number;
  86208. subdivisions: number;
  86209. minHeight: number;
  86210. maxHeight: number;
  86211. colorFilter: Color3;
  86212. buffer: Uint8Array;
  86213. bufferWidth: number;
  86214. bufferHeight: number;
  86215. alphaFilter: number;
  86216. }): VertexData;
  86217. /**
  86218. * Creates the VertexData for a Plane
  86219. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86220. * * size sets the width and height of the plane to the value of size, optional default 1
  86221. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86222. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86223. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86224. * * 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)
  86225. * * 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)
  86226. * @returns the VertexData of the box
  86227. */
  86228. static CreatePlane(options: {
  86229. size?: number;
  86230. width?: number;
  86231. height?: number;
  86232. sideOrientation?: number;
  86233. frontUVs?: Vector4;
  86234. backUVs?: Vector4;
  86235. }): VertexData;
  86236. /**
  86237. * Creates the VertexData of the Disc or regular Polygon
  86238. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86239. * * radius the radius of the disc, optional default 0.5
  86240. * * tessellation the number of polygon sides, optional, default 64
  86241. * * 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
  86242. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86243. * * 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)
  86244. * * 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)
  86245. * @returns the VertexData of the box
  86246. */
  86247. static CreateDisc(options: {
  86248. radius?: number;
  86249. tessellation?: number;
  86250. arc?: number;
  86251. sideOrientation?: number;
  86252. frontUVs?: Vector4;
  86253. backUVs?: Vector4;
  86254. }): VertexData;
  86255. /**
  86256. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86257. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86258. * @param polygon a mesh built from polygonTriangulation.build()
  86259. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86260. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86261. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86262. * @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)
  86263. * @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)
  86264. * @returns the VertexData of the Polygon
  86265. */
  86266. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86267. /**
  86268. * Creates the VertexData of the IcoSphere
  86269. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86270. * * radius the radius of the IcoSphere, optional default 1
  86271. * * radiusX allows stretching in the x direction, optional, default radius
  86272. * * radiusY allows stretching in the y direction, optional, default radius
  86273. * * radiusZ allows stretching in the z direction, optional, default radius
  86274. * * flat when true creates a flat shaded mesh, optional, default true
  86275. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86276. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86277. * * 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)
  86278. * * 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)
  86279. * @returns the VertexData of the IcoSphere
  86280. */
  86281. static CreateIcoSphere(options: {
  86282. radius?: number;
  86283. radiusX?: number;
  86284. radiusY?: number;
  86285. radiusZ?: number;
  86286. flat?: boolean;
  86287. subdivisions?: number;
  86288. sideOrientation?: number;
  86289. frontUVs?: Vector4;
  86290. backUVs?: Vector4;
  86291. }): VertexData;
  86292. /**
  86293. * Creates the VertexData for a Polyhedron
  86294. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86295. * * type provided types are:
  86296. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86297. * * 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)
  86298. * * size the size of the IcoSphere, optional default 1
  86299. * * sizeX allows stretching in the x direction, optional, default size
  86300. * * sizeY allows stretching in the y direction, optional, default size
  86301. * * sizeZ allows stretching in the z direction, optional, default size
  86302. * * 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
  86303. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86304. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86305. * * flat when true creates a flat shaded mesh, optional, default true
  86306. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86308. * * 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)
  86309. * * 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)
  86310. * @returns the VertexData of the Polyhedron
  86311. */
  86312. static CreatePolyhedron(options: {
  86313. type?: number;
  86314. size?: number;
  86315. sizeX?: number;
  86316. sizeY?: number;
  86317. sizeZ?: number;
  86318. custom?: any;
  86319. faceUV?: Vector4[];
  86320. faceColors?: Color4[];
  86321. flat?: boolean;
  86322. sideOrientation?: number;
  86323. frontUVs?: Vector4;
  86324. backUVs?: Vector4;
  86325. }): VertexData;
  86326. /**
  86327. * Creates the VertexData for a TorusKnot
  86328. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86329. * * radius the radius of the torus knot, optional, default 2
  86330. * * tube the thickness of the tube, optional, default 0.5
  86331. * * radialSegments the number of sides on each tube segments, optional, default 32
  86332. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86333. * * p the number of windings around the z axis, optional, default 2
  86334. * * q the number of windings around the x axis, optional, default 3
  86335. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86336. * * 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)
  86337. * * 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)
  86338. * @returns the VertexData of the Torus Knot
  86339. */
  86340. static CreateTorusKnot(options: {
  86341. radius?: number;
  86342. tube?: number;
  86343. radialSegments?: number;
  86344. tubularSegments?: number;
  86345. p?: number;
  86346. q?: number;
  86347. sideOrientation?: number;
  86348. frontUVs?: Vector4;
  86349. backUVs?: Vector4;
  86350. }): VertexData;
  86351. /**
  86352. * Compute normals for given positions and indices
  86353. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86354. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86355. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86356. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86357. * * facetNormals : optional array of facet normals (vector3)
  86358. * * facetPositions : optional array of facet positions (vector3)
  86359. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86360. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86361. * * bInfo : optional bounding info, required for facetPartitioning computation
  86362. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86363. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86364. * * useRightHandedSystem: optional boolean to for right handed system computation
  86365. * * depthSort : optional boolean to enable the facet depth sort computation
  86366. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86367. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86368. */
  86369. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86370. facetNormals?: any;
  86371. facetPositions?: any;
  86372. facetPartitioning?: any;
  86373. ratio?: number;
  86374. bInfo?: any;
  86375. bbSize?: Vector3;
  86376. subDiv?: any;
  86377. useRightHandedSystem?: boolean;
  86378. depthSort?: boolean;
  86379. distanceTo?: Vector3;
  86380. depthSortedFacets?: any;
  86381. }): void;
  86382. /** @hidden */
  86383. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86384. /**
  86385. * Applies VertexData created from the imported parameters to the geometry
  86386. * @param parsedVertexData the parsed data from an imported file
  86387. * @param geometry the geometry to apply the VertexData to
  86388. */
  86389. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86390. }
  86391. }
  86392. declare module BABYLON {
  86393. /**
  86394. * Class containing static functions to help procedurally build meshes
  86395. */
  86396. export class DiscBuilder {
  86397. /**
  86398. * Creates a plane polygonal mesh. By default, this is a disc
  86399. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86400. * * 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
  86401. * * 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
  86402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  86404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86405. * @param name defines the name of the mesh
  86406. * @param options defines the options used to create the mesh
  86407. * @param scene defines the hosting scene
  86408. * @returns the plane polygonal mesh
  86409. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86410. */
  86411. static CreateDisc(name: string, options: {
  86412. radius?: number;
  86413. tessellation?: number;
  86414. arc?: number;
  86415. updatable?: boolean;
  86416. sideOrientation?: number;
  86417. frontUVs?: Vector4;
  86418. backUVs?: Vector4;
  86419. }, scene?: Nullable<Scene>): Mesh;
  86420. }
  86421. }
  86422. declare module BABYLON {
  86423. /**
  86424. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86425. *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.
  86426. * The SPS is also a particle system. It provides some methods to manage the particles.
  86427. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86428. *
  86429. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86430. */
  86431. export class SolidParticleSystem implements IDisposable {
  86432. /**
  86433. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86434. * Example : var p = SPS.particles[i];
  86435. */
  86436. particles: SolidParticle[];
  86437. /**
  86438. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86439. */
  86440. nbParticles: number;
  86441. /**
  86442. * If the particles must ever face the camera (default false). Useful for planar particles.
  86443. */
  86444. billboard: boolean;
  86445. /**
  86446. * Recompute normals when adding a shape
  86447. */
  86448. recomputeNormals: boolean;
  86449. /**
  86450. * This a counter ofr your own usage. It's not set by any SPS functions.
  86451. */
  86452. counter: number;
  86453. /**
  86454. * The SPS name. This name is also given to the underlying mesh.
  86455. */
  86456. name: string;
  86457. /**
  86458. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86459. */
  86460. mesh: Mesh;
  86461. /**
  86462. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86463. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86464. */
  86465. vars: any;
  86466. /**
  86467. * This array is populated when the SPS is set as 'pickable'.
  86468. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86469. * Each element of this array is an object `{idx: int, faceId: int}`.
  86470. * `idx` is the picked particle index in the `SPS.particles` array
  86471. * `faceId` is the picked face index counted within this particle.
  86472. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86473. */
  86474. pickedParticles: {
  86475. idx: number;
  86476. faceId: number;
  86477. }[];
  86478. /**
  86479. * This array is populated when `enableDepthSort` is set to true.
  86480. * Each element of this array is an instance of the class DepthSortedParticle.
  86481. */
  86482. depthSortedParticles: DepthSortedParticle[];
  86483. /**
  86484. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86485. * @hidden
  86486. */
  86487. _bSphereOnly: boolean;
  86488. /**
  86489. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86490. * @hidden
  86491. */
  86492. _bSphereRadiusFactor: number;
  86493. private _scene;
  86494. private _positions;
  86495. private _indices;
  86496. private _normals;
  86497. private _colors;
  86498. private _uvs;
  86499. private _indices32;
  86500. private _positions32;
  86501. private _normals32;
  86502. private _fixedNormal32;
  86503. private _colors32;
  86504. private _uvs32;
  86505. private _index;
  86506. private _updatable;
  86507. private _pickable;
  86508. private _isVisibilityBoxLocked;
  86509. private _alwaysVisible;
  86510. private _depthSort;
  86511. private _shapeCounter;
  86512. private _copy;
  86513. private _color;
  86514. private _computeParticleColor;
  86515. private _computeParticleTexture;
  86516. private _computeParticleRotation;
  86517. private _computeParticleVertex;
  86518. private _computeBoundingBox;
  86519. private _depthSortParticles;
  86520. private _camera;
  86521. private _mustUnrotateFixedNormals;
  86522. private _particlesIntersect;
  86523. private _needs32Bits;
  86524. /**
  86525. * Creates a SPS (Solid Particle System) object.
  86526. * @param name (String) is the SPS name, this will be the underlying mesh name.
  86527. * @param scene (Scene) is the scene in which the SPS is added.
  86528. * @param options defines the options of the sps e.g.
  86529. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  86530. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  86531. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  86532. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  86533. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  86534. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  86535. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  86536. */
  86537. constructor(name: string, scene: Scene, options?: {
  86538. updatable?: boolean;
  86539. isPickable?: boolean;
  86540. enableDepthSort?: boolean;
  86541. particleIntersection?: boolean;
  86542. boundingSphereOnly?: boolean;
  86543. bSphereRadiusFactor?: number;
  86544. });
  86545. /**
  86546. * Builds the SPS underlying mesh. Returns a standard Mesh.
  86547. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  86548. * @returns the created mesh
  86549. */
  86550. buildMesh(): Mesh;
  86551. /**
  86552. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  86553. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  86554. * Thus the particles generated from `digest()` have their property `position` set yet.
  86555. * @param mesh ( Mesh ) is the mesh to be digested
  86556. * @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
  86557. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  86558. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  86559. * @returns the current SPS
  86560. */
  86561. digest(mesh: Mesh, options?: {
  86562. facetNb?: number;
  86563. number?: number;
  86564. delta?: number;
  86565. }): SolidParticleSystem;
  86566. private _unrotateFixedNormals;
  86567. private _resetCopy;
  86568. private _meshBuilder;
  86569. private _posToShape;
  86570. private _uvsToShapeUV;
  86571. private _addParticle;
  86572. /**
  86573. * Adds some particles to the SPS from the model shape. Returns the shape id.
  86574. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  86575. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  86576. * @param nb (positive integer) the number of particles to be created from this model
  86577. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  86578. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  86579. * @returns the number of shapes in the system
  86580. */
  86581. addShape(mesh: Mesh, nb: number, options?: {
  86582. positionFunction?: any;
  86583. vertexFunction?: any;
  86584. }): number;
  86585. private _rebuildParticle;
  86586. /**
  86587. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  86588. * @returns the SPS.
  86589. */
  86590. rebuildMesh(): SolidParticleSystem;
  86591. /**
  86592. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  86593. * This method calls `updateParticle()` for each particle of the SPS.
  86594. * For an animated SPS, it is usually called within the render loop.
  86595. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  86596. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  86597. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  86598. * @returns the SPS.
  86599. */
  86600. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  86601. /**
  86602. * Disposes the SPS.
  86603. */
  86604. dispose(): void;
  86605. /**
  86606. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  86607. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86608. * @returns the SPS.
  86609. */
  86610. refreshVisibleSize(): SolidParticleSystem;
  86611. /**
  86612. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  86613. * @param size the size (float) of the visibility box
  86614. * note : this doesn't lock the SPS mesh bounding box.
  86615. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86616. */
  86617. setVisibilityBox(size: number): void;
  86618. /**
  86619. * Gets whether the SPS as always visible or not
  86620. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86621. */
  86622. /**
  86623. * Sets the SPS as always visible or not
  86624. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86625. */
  86626. isAlwaysVisible: boolean;
  86627. /**
  86628. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86629. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86630. */
  86631. /**
  86632. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86633. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86634. */
  86635. isVisibilityBoxLocked: boolean;
  86636. /**
  86637. * Tells to `setParticles()` to compute the particle rotations or not.
  86638. * Default value : true. The SPS is faster when it's set to false.
  86639. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86640. */
  86641. /**
  86642. * Gets if `setParticles()` computes the particle rotations or not.
  86643. * Default value : true. The SPS is faster when it's set to false.
  86644. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86645. */
  86646. computeParticleRotation: boolean;
  86647. /**
  86648. * Tells to `setParticles()` to compute the particle colors or not.
  86649. * Default value : true. The SPS is faster when it's set to false.
  86650. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86651. */
  86652. /**
  86653. * Gets if `setParticles()` computes the particle colors or not.
  86654. * Default value : true. The SPS is faster when it's set to false.
  86655. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86656. */
  86657. computeParticleColor: boolean;
  86658. /**
  86659. * Gets if `setParticles()` computes the particle textures or not.
  86660. * Default value : true. The SPS is faster when it's set to false.
  86661. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  86662. */
  86663. computeParticleTexture: boolean;
  86664. /**
  86665. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  86666. * Default value : false. The SPS is faster when it's set to false.
  86667. * Note : the particle custom vertex positions aren't stored values.
  86668. */
  86669. /**
  86670. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  86671. * Default value : false. The SPS is faster when it's set to false.
  86672. * Note : the particle custom vertex positions aren't stored values.
  86673. */
  86674. computeParticleVertex: boolean;
  86675. /**
  86676. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  86677. */
  86678. /**
  86679. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  86680. */
  86681. computeBoundingBox: boolean;
  86682. /**
  86683. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  86684. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86685. * Default : `true`
  86686. */
  86687. /**
  86688. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  86689. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86690. * Default : `true`
  86691. */
  86692. depthSortParticles: boolean;
  86693. /**
  86694. * This function does nothing. It may be overwritten to set all the particle first values.
  86695. * The SPS doesn't call this function, you may have to call it by your own.
  86696. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86697. */
  86698. initParticles(): void;
  86699. /**
  86700. * This function does nothing. It may be overwritten to recycle a particle.
  86701. * The SPS doesn't call this function, you may have to call it by your own.
  86702. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86703. * @param particle The particle to recycle
  86704. * @returns the recycled particle
  86705. */
  86706. recycleParticle(particle: SolidParticle): SolidParticle;
  86707. /**
  86708. * Updates a particle : this function should be overwritten by the user.
  86709. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  86710. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86711. * @example : just set a particle position or velocity and recycle conditions
  86712. * @param particle The particle to update
  86713. * @returns the updated particle
  86714. */
  86715. updateParticle(particle: SolidParticle): SolidParticle;
  86716. /**
  86717. * Updates a vertex of a particle : it can be overwritten by the user.
  86718. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  86719. * @param particle the current particle
  86720. * @param vertex the current index of the current particle
  86721. * @param pt the index of the current vertex in the particle shape
  86722. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  86723. * @example : just set a vertex particle position
  86724. * @returns the updated vertex
  86725. */
  86726. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  86727. /**
  86728. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  86729. * This does nothing and may be overwritten by the user.
  86730. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86731. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86732. * @param update the boolean update value actually passed to setParticles()
  86733. */
  86734. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86735. /**
  86736. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  86737. * This will be passed three parameters.
  86738. * This does nothing and may be overwritten by the user.
  86739. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86740. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86741. * @param update the boolean update value actually passed to setParticles()
  86742. */
  86743. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86744. }
  86745. }
  86746. declare module BABYLON {
  86747. /**
  86748. * Represents one particle of a solid particle system.
  86749. */
  86750. export class SolidParticle {
  86751. /**
  86752. * particle global index
  86753. */
  86754. idx: number;
  86755. /**
  86756. * The color of the particle
  86757. */
  86758. color: Nullable<Color4>;
  86759. /**
  86760. * The world space position of the particle.
  86761. */
  86762. position: Vector3;
  86763. /**
  86764. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  86765. */
  86766. rotation: Vector3;
  86767. /**
  86768. * The world space rotation quaternion of the particle.
  86769. */
  86770. rotationQuaternion: Nullable<Quaternion>;
  86771. /**
  86772. * The scaling of the particle.
  86773. */
  86774. scaling: Vector3;
  86775. /**
  86776. * The uvs of the particle.
  86777. */
  86778. uvs: Vector4;
  86779. /**
  86780. * The current speed of the particle.
  86781. */
  86782. velocity: Vector3;
  86783. /**
  86784. * The pivot point in the particle local space.
  86785. */
  86786. pivot: Vector3;
  86787. /**
  86788. * Must the particle be translated from its pivot point in its local space ?
  86789. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  86790. * Default : false
  86791. */
  86792. translateFromPivot: boolean;
  86793. /**
  86794. * Is the particle active or not ?
  86795. */
  86796. alive: boolean;
  86797. /**
  86798. * Is the particle visible or not ?
  86799. */
  86800. isVisible: boolean;
  86801. /**
  86802. * Index of this particle in the global "positions" array (Internal use)
  86803. * @hidden
  86804. */
  86805. _pos: number;
  86806. /**
  86807. * @hidden Index of this particle in the global "indices" array (Internal use)
  86808. */
  86809. _ind: number;
  86810. /**
  86811. * @hidden ModelShape of this particle (Internal use)
  86812. */
  86813. _model: ModelShape;
  86814. /**
  86815. * ModelShape id of this particle
  86816. */
  86817. shapeId: number;
  86818. /**
  86819. * Index of the particle in its shape id (Internal use)
  86820. */
  86821. idxInShape: number;
  86822. /**
  86823. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  86824. */
  86825. _modelBoundingInfo: BoundingInfo;
  86826. /**
  86827. * @hidden Particle BoundingInfo object (Internal use)
  86828. */
  86829. _boundingInfo: BoundingInfo;
  86830. /**
  86831. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  86832. */
  86833. _sps: SolidParticleSystem;
  86834. /**
  86835. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  86836. */
  86837. _stillInvisible: boolean;
  86838. /**
  86839. * @hidden Last computed particle rotation matrix
  86840. */
  86841. _rotationMatrix: number[];
  86842. /**
  86843. * Parent particle Id, if any.
  86844. * Default null.
  86845. */
  86846. parentId: Nullable<number>;
  86847. /**
  86848. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  86849. * The possible values are :
  86850. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86851. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86852. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86853. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86854. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86855. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  86856. * */
  86857. cullingStrategy: number;
  86858. /**
  86859. * @hidden Internal global position in the SPS.
  86860. */
  86861. _globalPosition: Vector3;
  86862. /**
  86863. * Creates a Solid Particle object.
  86864. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  86865. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  86866. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  86867. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  86868. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  86869. * @param shapeId (integer) is the model shape identifier in the SPS.
  86870. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  86871. * @param sps defines the sps it is associated to
  86872. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  86873. */
  86874. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  86875. /**
  86876. * Legacy support, changed scale to scaling
  86877. */
  86878. /**
  86879. * Legacy support, changed scale to scaling
  86880. */
  86881. scale: Vector3;
  86882. /**
  86883. * Legacy support, changed quaternion to rotationQuaternion
  86884. */
  86885. /**
  86886. * Legacy support, changed quaternion to rotationQuaternion
  86887. */
  86888. quaternion: Nullable<Quaternion>;
  86889. /**
  86890. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  86891. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  86892. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  86893. * @returns true if it intersects
  86894. */
  86895. intersectsMesh(target: Mesh | SolidParticle): boolean;
  86896. /**
  86897. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  86898. * A particle is in the frustum if its bounding box intersects the frustum
  86899. * @param frustumPlanes defines the frustum to test
  86900. * @returns true if the particle is in the frustum planes
  86901. */
  86902. isInFrustum(frustumPlanes: Plane[]): boolean;
  86903. /**
  86904. * get the rotation matrix of the particle
  86905. * @hidden
  86906. */
  86907. getRotationMatrix(m: Matrix): void;
  86908. }
  86909. /**
  86910. * Represents the shape of the model used by one particle of a solid particle system.
  86911. * SPS internal tool, don't use it manually.
  86912. */
  86913. export class ModelShape {
  86914. /**
  86915. * The shape id
  86916. * @hidden
  86917. */
  86918. shapeID: number;
  86919. /**
  86920. * flat array of model positions (internal use)
  86921. * @hidden
  86922. */
  86923. _shape: Vector3[];
  86924. /**
  86925. * flat array of model UVs (internal use)
  86926. * @hidden
  86927. */
  86928. _shapeUV: number[];
  86929. /**
  86930. * length of the shape in the model indices array (internal use)
  86931. * @hidden
  86932. */
  86933. _indicesLength: number;
  86934. /**
  86935. * Custom position function (internal use)
  86936. * @hidden
  86937. */
  86938. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  86939. /**
  86940. * Custom vertex function (internal use)
  86941. * @hidden
  86942. */
  86943. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  86944. /**
  86945. * 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.
  86946. * SPS internal tool, don't use it manually.
  86947. * @hidden
  86948. */
  86949. 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>);
  86950. }
  86951. /**
  86952. * Represents a Depth Sorted Particle in the solid particle system.
  86953. */
  86954. export class DepthSortedParticle {
  86955. /**
  86956. * Index of the particle in the "indices" array
  86957. */
  86958. ind: number;
  86959. /**
  86960. * Length of the particle shape in the "indices" array
  86961. */
  86962. indicesLength: number;
  86963. /**
  86964. * Squared distance from the particle to the camera
  86965. */
  86966. sqDistance: number;
  86967. }
  86968. }
  86969. declare module BABYLON {
  86970. /**
  86971. * @hidden
  86972. */
  86973. export class _MeshCollisionData {
  86974. _checkCollisions: boolean;
  86975. _collisionMask: number;
  86976. _collisionGroup: number;
  86977. _collider: Nullable<Collider>;
  86978. _oldPositionForCollisions: Vector3;
  86979. _diffPositionForCollisions: Vector3;
  86980. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  86981. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  86982. }
  86983. }
  86984. declare module BABYLON {
  86985. /** @hidden */
  86986. class _FacetDataStorage {
  86987. facetPositions: Vector3[];
  86988. facetNormals: Vector3[];
  86989. facetPartitioning: number[][];
  86990. facetNb: number;
  86991. partitioningSubdivisions: number;
  86992. partitioningBBoxRatio: number;
  86993. facetDataEnabled: boolean;
  86994. facetParameters: any;
  86995. bbSize: Vector3;
  86996. subDiv: {
  86997. max: number;
  86998. X: number;
  86999. Y: number;
  87000. Z: number;
  87001. };
  87002. facetDepthSort: boolean;
  87003. facetDepthSortEnabled: boolean;
  87004. depthSortedIndices: IndicesArray;
  87005. depthSortedFacets: {
  87006. ind: number;
  87007. sqDistance: number;
  87008. }[];
  87009. facetDepthSortFunction: (f1: {
  87010. ind: number;
  87011. sqDistance: number;
  87012. }, f2: {
  87013. ind: number;
  87014. sqDistance: number;
  87015. }) => number;
  87016. facetDepthSortFrom: Vector3;
  87017. facetDepthSortOrigin: Vector3;
  87018. invertedMatrix: Matrix;
  87019. }
  87020. /**
  87021. * @hidden
  87022. **/
  87023. class _InternalAbstractMeshDataInfo {
  87024. _hasVertexAlpha: boolean;
  87025. _useVertexColors: boolean;
  87026. _numBoneInfluencers: number;
  87027. _applyFog: boolean;
  87028. _receiveShadows: boolean;
  87029. _facetData: _FacetDataStorage;
  87030. _visibility: number;
  87031. _skeleton: Nullable<Skeleton>;
  87032. _layerMask: number;
  87033. _computeBonesUsingShaders: boolean;
  87034. _isActive: boolean;
  87035. _onlyForInstances: boolean;
  87036. _isActiveIntermediate: boolean;
  87037. _onlyForInstancesIntermediate: boolean;
  87038. }
  87039. /**
  87040. * Class used to store all common mesh properties
  87041. */
  87042. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  87043. /** No occlusion */
  87044. static OCCLUSION_TYPE_NONE: number;
  87045. /** Occlusion set to optimisitic */
  87046. static OCCLUSION_TYPE_OPTIMISTIC: number;
  87047. /** Occlusion set to strict */
  87048. static OCCLUSION_TYPE_STRICT: number;
  87049. /** Use an accurante occlusion algorithm */
  87050. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  87051. /** Use a conservative occlusion algorithm */
  87052. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  87053. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  87054. * Test order :
  87055. * Is the bounding sphere outside the frustum ?
  87056. * If not, are the bounding box vertices outside the frustum ?
  87057. * It not, then the cullable object is in the frustum.
  87058. */
  87059. static readonly CULLINGSTRATEGY_STANDARD: number;
  87060. /** Culling strategy : Bounding Sphere Only.
  87061. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  87062. * It's also less accurate than the standard because some not visible objects can still be selected.
  87063. * Test : is the bounding sphere outside the frustum ?
  87064. * If not, then the cullable object is in the frustum.
  87065. */
  87066. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  87067. /** Culling strategy : Optimistic Inclusion.
  87068. * This in an inclusion test first, then the standard exclusion test.
  87069. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  87070. * 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.
  87071. * Anyway, it's as accurate as the standard strategy.
  87072. * Test :
  87073. * Is the cullable object bounding sphere center in the frustum ?
  87074. * If not, apply the default culling strategy.
  87075. */
  87076. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  87077. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  87078. * This in an inclusion test first, then the bounding sphere only exclusion test.
  87079. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  87080. * 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.
  87081. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  87082. * Test :
  87083. * Is the cullable object bounding sphere center in the frustum ?
  87084. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  87085. */
  87086. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  87087. /**
  87088. * No billboard
  87089. */
  87090. static readonly BILLBOARDMODE_NONE: number;
  87091. /** Billboard on X axis */
  87092. static readonly BILLBOARDMODE_X: number;
  87093. /** Billboard on Y axis */
  87094. static readonly BILLBOARDMODE_Y: number;
  87095. /** Billboard on Z axis */
  87096. static readonly BILLBOARDMODE_Z: number;
  87097. /** Billboard on all axes */
  87098. static readonly BILLBOARDMODE_ALL: number;
  87099. /** @hidden */
  87100. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  87101. /**
  87102. * The culling strategy to use to check whether the mesh must be rendered or not.
  87103. * This value can be changed at any time and will be used on the next render mesh selection.
  87104. * The possible values are :
  87105. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87106. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87107. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87108. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87109. * Please read each static variable documentation to get details about the culling process.
  87110. * */
  87111. cullingStrategy: number;
  87112. /**
  87113. * Gets the number of facets in the mesh
  87114. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87115. */
  87116. readonly facetNb: number;
  87117. /**
  87118. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  87119. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87120. */
  87121. partitioningSubdivisions: number;
  87122. /**
  87123. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  87124. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  87125. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87126. */
  87127. partitioningBBoxRatio: number;
  87128. /**
  87129. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  87130. * Works only for updatable meshes.
  87131. * Doesn't work with multi-materials
  87132. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87133. */
  87134. mustDepthSortFacets: boolean;
  87135. /**
  87136. * The location (Vector3) where the facet depth sort must be computed from.
  87137. * By default, the active camera position.
  87138. * Used only when facet depth sort is enabled
  87139. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87140. */
  87141. facetDepthSortFrom: Vector3;
  87142. /**
  87143. * gets a boolean indicating if facetData is enabled
  87144. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87145. */
  87146. readonly isFacetDataEnabled: boolean;
  87147. /** @hidden */
  87148. _updateNonUniformScalingState(value: boolean): boolean;
  87149. /**
  87150. * An event triggered when this mesh collides with another one
  87151. */
  87152. onCollideObservable: Observable<AbstractMesh>;
  87153. /** Set a function to call when this mesh collides with another one */
  87154. onCollide: () => void;
  87155. /**
  87156. * An event triggered when the collision's position changes
  87157. */
  87158. onCollisionPositionChangeObservable: Observable<Vector3>;
  87159. /** Set a function to call when the collision's position changes */
  87160. onCollisionPositionChange: () => void;
  87161. /**
  87162. * An event triggered when material is changed
  87163. */
  87164. onMaterialChangedObservable: Observable<AbstractMesh>;
  87165. /**
  87166. * Gets or sets the orientation for POV movement & rotation
  87167. */
  87168. definedFacingForward: boolean;
  87169. /** @hidden */
  87170. _occlusionQuery: Nullable<WebGLQuery>;
  87171. /** @hidden */
  87172. _renderingGroup: Nullable<RenderingGroup>;
  87173. /**
  87174. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87175. */
  87176. /**
  87177. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87178. */
  87179. visibility: number;
  87180. /** Gets or sets the alpha index used to sort transparent meshes
  87181. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  87182. */
  87183. alphaIndex: number;
  87184. /**
  87185. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  87186. */
  87187. isVisible: boolean;
  87188. /**
  87189. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  87190. */
  87191. isPickable: boolean;
  87192. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  87193. showSubMeshesBoundingBox: boolean;
  87194. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  87195. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  87196. */
  87197. isBlocker: boolean;
  87198. /**
  87199. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  87200. */
  87201. enablePointerMoveEvents: boolean;
  87202. /**
  87203. * Specifies the rendering group id for this mesh (0 by default)
  87204. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  87205. */
  87206. renderingGroupId: number;
  87207. private _material;
  87208. /** Gets or sets current material */
  87209. material: Nullable<Material>;
  87210. /**
  87211. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  87212. * @see http://doc.babylonjs.com/babylon101/shadows
  87213. */
  87214. receiveShadows: boolean;
  87215. /** Defines color to use when rendering outline */
  87216. outlineColor: Color3;
  87217. /** Define width to use when rendering outline */
  87218. outlineWidth: number;
  87219. /** Defines color to use when rendering overlay */
  87220. overlayColor: Color3;
  87221. /** Defines alpha to use when rendering overlay */
  87222. overlayAlpha: number;
  87223. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  87224. hasVertexAlpha: boolean;
  87225. /** 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) */
  87226. useVertexColors: boolean;
  87227. /**
  87228. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  87229. */
  87230. computeBonesUsingShaders: boolean;
  87231. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  87232. numBoneInfluencers: number;
  87233. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  87234. applyFog: boolean;
  87235. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  87236. useOctreeForRenderingSelection: boolean;
  87237. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  87238. useOctreeForPicking: boolean;
  87239. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  87240. useOctreeForCollisions: boolean;
  87241. /**
  87242. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  87243. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  87244. */
  87245. layerMask: number;
  87246. /**
  87247. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  87248. */
  87249. alwaysSelectAsActiveMesh: boolean;
  87250. /**
  87251. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  87252. */
  87253. doNotSyncBoundingInfo: boolean;
  87254. /**
  87255. * Gets or sets the current action manager
  87256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87257. */
  87258. actionManager: Nullable<AbstractActionManager>;
  87259. private _meshCollisionData;
  87260. /**
  87261. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  87262. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87263. */
  87264. ellipsoid: Vector3;
  87265. /**
  87266. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  87267. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87268. */
  87269. ellipsoidOffset: Vector3;
  87270. /**
  87271. * Gets or sets a collision mask used to mask collisions (default is -1).
  87272. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87273. */
  87274. collisionMask: number;
  87275. /**
  87276. * Gets or sets the current collision group mask (-1 by default).
  87277. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87278. */
  87279. collisionGroup: number;
  87280. /**
  87281. * Defines edge width used when edgesRenderer is enabled
  87282. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87283. */
  87284. edgesWidth: number;
  87285. /**
  87286. * Defines edge color used when edgesRenderer is enabled
  87287. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87288. */
  87289. edgesColor: Color4;
  87290. /** @hidden */
  87291. _edgesRenderer: Nullable<IEdgesRenderer>;
  87292. /** @hidden */
  87293. _masterMesh: Nullable<AbstractMesh>;
  87294. /** @hidden */
  87295. _boundingInfo: Nullable<BoundingInfo>;
  87296. /** @hidden */
  87297. _renderId: number;
  87298. /**
  87299. * Gets or sets the list of subMeshes
  87300. * @see http://doc.babylonjs.com/how_to/multi_materials
  87301. */
  87302. subMeshes: SubMesh[];
  87303. /** @hidden */
  87304. _intersectionsInProgress: AbstractMesh[];
  87305. /** @hidden */
  87306. _unIndexed: boolean;
  87307. /** @hidden */
  87308. _lightSources: Light[];
  87309. /** Gets the list of lights affecting that mesh */
  87310. readonly lightSources: Light[];
  87311. /** @hidden */
  87312. readonly _positions: Nullable<Vector3[]>;
  87313. /** @hidden */
  87314. _waitingData: {
  87315. lods: Nullable<any>;
  87316. actions: Nullable<any>;
  87317. freezeWorldMatrix: Nullable<boolean>;
  87318. };
  87319. /** @hidden */
  87320. _bonesTransformMatrices: Nullable<Float32Array>;
  87321. /**
  87322. * Gets or sets a skeleton to apply skining transformations
  87323. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87324. */
  87325. skeleton: Nullable<Skeleton>;
  87326. /**
  87327. * An event triggered when the mesh is rebuilt.
  87328. */
  87329. onRebuildObservable: Observable<AbstractMesh>;
  87330. /**
  87331. * Creates a new AbstractMesh
  87332. * @param name defines the name of the mesh
  87333. * @param scene defines the hosting scene
  87334. */
  87335. constructor(name: string, scene?: Nullable<Scene>);
  87336. /**
  87337. * Returns the string "AbstractMesh"
  87338. * @returns "AbstractMesh"
  87339. */
  87340. getClassName(): string;
  87341. /**
  87342. * Gets a string representation of the current mesh
  87343. * @param fullDetails defines a boolean indicating if full details must be included
  87344. * @returns a string representation of the current mesh
  87345. */
  87346. toString(fullDetails?: boolean): string;
  87347. /**
  87348. * @hidden
  87349. */
  87350. protected _getEffectiveParent(): Nullable<Node>;
  87351. /** @hidden */
  87352. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87353. /** @hidden */
  87354. _rebuild(): void;
  87355. /** @hidden */
  87356. _resyncLightSources(): void;
  87357. /** @hidden */
  87358. _resyncLighSource(light: Light): void;
  87359. /** @hidden */
  87360. _unBindEffect(): void;
  87361. /** @hidden */
  87362. _removeLightSource(light: Light): void;
  87363. private _markSubMeshesAsDirty;
  87364. /** @hidden */
  87365. _markSubMeshesAsLightDirty(): void;
  87366. /** @hidden */
  87367. _markSubMeshesAsAttributesDirty(): void;
  87368. /** @hidden */
  87369. _markSubMeshesAsMiscDirty(): void;
  87370. /**
  87371. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87372. */
  87373. scaling: Vector3;
  87374. /**
  87375. * Returns true if the mesh is blocked. Implemented by child classes
  87376. */
  87377. readonly isBlocked: boolean;
  87378. /**
  87379. * Returns the mesh itself by default. Implemented by child classes
  87380. * @param camera defines the camera to use to pick the right LOD level
  87381. * @returns the currentAbstractMesh
  87382. */
  87383. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87384. /**
  87385. * Returns 0 by default. Implemented by child classes
  87386. * @returns an integer
  87387. */
  87388. getTotalVertices(): number;
  87389. /**
  87390. * Returns a positive integer : the total number of indices in this mesh geometry.
  87391. * @returns the numner of indices or zero if the mesh has no geometry.
  87392. */
  87393. getTotalIndices(): number;
  87394. /**
  87395. * Returns null by default. Implemented by child classes
  87396. * @returns null
  87397. */
  87398. getIndices(): Nullable<IndicesArray>;
  87399. /**
  87400. * Returns the array of the requested vertex data kind. Implemented by child classes
  87401. * @param kind defines the vertex data kind to use
  87402. * @returns null
  87403. */
  87404. getVerticesData(kind: string): Nullable<FloatArray>;
  87405. /**
  87406. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87407. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87408. * Note that a new underlying VertexBuffer object is created each call.
  87409. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87410. * @param kind defines vertex data kind:
  87411. * * VertexBuffer.PositionKind
  87412. * * VertexBuffer.UVKind
  87413. * * VertexBuffer.UV2Kind
  87414. * * VertexBuffer.UV3Kind
  87415. * * VertexBuffer.UV4Kind
  87416. * * VertexBuffer.UV5Kind
  87417. * * VertexBuffer.UV6Kind
  87418. * * VertexBuffer.ColorKind
  87419. * * VertexBuffer.MatricesIndicesKind
  87420. * * VertexBuffer.MatricesIndicesExtraKind
  87421. * * VertexBuffer.MatricesWeightsKind
  87422. * * VertexBuffer.MatricesWeightsExtraKind
  87423. * @param data defines the data source
  87424. * @param updatable defines if the data must be flagged as updatable (or static)
  87425. * @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
  87426. * @returns the current mesh
  87427. */
  87428. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87429. /**
  87430. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87431. * If the mesh has no geometry, it is simply returned as it is.
  87432. * @param kind defines vertex data kind:
  87433. * * VertexBuffer.PositionKind
  87434. * * VertexBuffer.UVKind
  87435. * * VertexBuffer.UV2Kind
  87436. * * VertexBuffer.UV3Kind
  87437. * * VertexBuffer.UV4Kind
  87438. * * VertexBuffer.UV5Kind
  87439. * * VertexBuffer.UV6Kind
  87440. * * VertexBuffer.ColorKind
  87441. * * VertexBuffer.MatricesIndicesKind
  87442. * * VertexBuffer.MatricesIndicesExtraKind
  87443. * * VertexBuffer.MatricesWeightsKind
  87444. * * VertexBuffer.MatricesWeightsExtraKind
  87445. * @param data defines the data source
  87446. * @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
  87447. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87448. * @returns the current mesh
  87449. */
  87450. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87451. /**
  87452. * Sets the mesh indices,
  87453. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87454. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87455. * @param totalVertices Defines the total number of vertices
  87456. * @returns the current mesh
  87457. */
  87458. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87459. /**
  87460. * Gets a boolean indicating if specific vertex data is present
  87461. * @param kind defines the vertex data kind to use
  87462. * @returns true is data kind is present
  87463. */
  87464. isVerticesDataPresent(kind: string): boolean;
  87465. /**
  87466. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  87467. * @returns a BoundingInfo
  87468. */
  87469. getBoundingInfo(): BoundingInfo;
  87470. /**
  87471. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87472. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87473. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87474. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87475. * @returns the current mesh
  87476. */
  87477. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  87478. /**
  87479. * Overwrite the current bounding info
  87480. * @param boundingInfo defines the new bounding info
  87481. * @returns the current mesh
  87482. */
  87483. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87484. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87485. readonly useBones: boolean;
  87486. /** @hidden */
  87487. _preActivate(): void;
  87488. /** @hidden */
  87489. _preActivateForIntermediateRendering(renderId: number): void;
  87490. /** @hidden */
  87491. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87492. /** @hidden */
  87493. _postActivate(): void;
  87494. /** @hidden */
  87495. _freeze(): void;
  87496. /** @hidden */
  87497. _unFreeze(): void;
  87498. /**
  87499. * Gets the current world matrix
  87500. * @returns a Matrix
  87501. */
  87502. getWorldMatrix(): Matrix;
  87503. /** @hidden */
  87504. _getWorldMatrixDeterminant(): number;
  87505. /**
  87506. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87507. */
  87508. readonly isAnInstance: boolean;
  87509. /**
  87510. * Perform relative position change from the point of view of behind the front of the mesh.
  87511. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87512. * Supports definition of mesh facing forward or backward
  87513. * @param amountRight defines the distance on the right axis
  87514. * @param amountUp defines the distance on the up axis
  87515. * @param amountForward defines the distance on the forward axis
  87516. * @returns the current mesh
  87517. */
  87518. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87519. /**
  87520. * Calculate relative position change from the point of view of behind the front of the mesh.
  87521. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87522. * Supports definition of mesh facing forward or backward
  87523. * @param amountRight defines the distance on the right axis
  87524. * @param amountUp defines the distance on the up axis
  87525. * @param amountForward defines the distance on the forward axis
  87526. * @returns the new displacement vector
  87527. */
  87528. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  87529. /**
  87530. * Perform relative rotation change from the point of view of behind the front of the mesh.
  87531. * Supports definition of mesh facing forward or backward
  87532. * @param flipBack defines the flip
  87533. * @param twirlClockwise defines the twirl
  87534. * @param tiltRight defines the tilt
  87535. * @returns the current mesh
  87536. */
  87537. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  87538. /**
  87539. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  87540. * Supports definition of mesh facing forward or backward.
  87541. * @param flipBack defines the flip
  87542. * @param twirlClockwise defines the twirl
  87543. * @param tiltRight defines the tilt
  87544. * @returns the new rotation vector
  87545. */
  87546. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  87547. /**
  87548. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87549. * This means the mesh underlying bounding box and sphere are recomputed.
  87550. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87551. * @returns the current mesh
  87552. */
  87553. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  87554. /** @hidden */
  87555. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  87556. /** @hidden */
  87557. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  87558. /** @hidden */
  87559. _updateBoundingInfo(): AbstractMesh;
  87560. /** @hidden */
  87561. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  87562. /** @hidden */
  87563. protected _afterComputeWorldMatrix(): void;
  87564. /** @hidden */
  87565. readonly _effectiveMesh: AbstractMesh;
  87566. /**
  87567. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87568. * A mesh is in the frustum if its bounding box intersects the frustum
  87569. * @param frustumPlanes defines the frustum to test
  87570. * @returns true if the mesh is in the frustum planes
  87571. */
  87572. isInFrustum(frustumPlanes: Plane[]): boolean;
  87573. /**
  87574. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  87575. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  87576. * @param frustumPlanes defines the frustum to test
  87577. * @returns true if the mesh is completely in the frustum planes
  87578. */
  87579. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87580. /**
  87581. * True if the mesh intersects another mesh or a SolidParticle object
  87582. * @param mesh defines a target mesh or SolidParticle to test
  87583. * @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)
  87584. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  87585. * @returns true if there is an intersection
  87586. */
  87587. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  87588. /**
  87589. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  87590. * @param point defines the point to test
  87591. * @returns true if there is an intersection
  87592. */
  87593. intersectsPoint(point: Vector3): boolean;
  87594. /**
  87595. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  87596. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87597. */
  87598. checkCollisions: boolean;
  87599. /**
  87600. * Gets Collider object used to compute collisions (not physics)
  87601. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87602. */
  87603. readonly collider: Nullable<Collider>;
  87604. /**
  87605. * Move the mesh using collision engine
  87606. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87607. * @param displacement defines the requested displacement vector
  87608. * @returns the current mesh
  87609. */
  87610. moveWithCollisions(displacement: Vector3): AbstractMesh;
  87611. private _onCollisionPositionChange;
  87612. /** @hidden */
  87613. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  87614. /** @hidden */
  87615. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  87616. /** @hidden */
  87617. _checkCollision(collider: Collider): AbstractMesh;
  87618. /** @hidden */
  87619. _generatePointsArray(): boolean;
  87620. /**
  87621. * Checks if the passed Ray intersects with the mesh
  87622. * @param ray defines the ray to use
  87623. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  87624. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87625. * @returns the picking info
  87626. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87627. */
  87628. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  87629. /**
  87630. * Clones the current mesh
  87631. * @param name defines the mesh name
  87632. * @param newParent defines the new mesh parent
  87633. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  87634. * @returns the new mesh
  87635. */
  87636. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87637. /**
  87638. * Disposes all the submeshes of the current meshnp
  87639. * @returns the current mesh
  87640. */
  87641. releaseSubMeshes(): AbstractMesh;
  87642. /**
  87643. * Releases resources associated with this abstract mesh.
  87644. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87645. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87646. */
  87647. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87648. /**
  87649. * Adds the passed mesh as a child to the current mesh
  87650. * @param mesh defines the child mesh
  87651. * @returns the current mesh
  87652. */
  87653. addChild(mesh: AbstractMesh): AbstractMesh;
  87654. /**
  87655. * Removes the passed mesh from the current mesh children list
  87656. * @param mesh defines the child mesh
  87657. * @returns the current mesh
  87658. */
  87659. removeChild(mesh: AbstractMesh): AbstractMesh;
  87660. /** @hidden */
  87661. private _initFacetData;
  87662. /**
  87663. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  87664. * This method can be called within the render loop.
  87665. * 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
  87666. * @returns the current mesh
  87667. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87668. */
  87669. updateFacetData(): AbstractMesh;
  87670. /**
  87671. * Returns the facetLocalNormals array.
  87672. * The normals are expressed in the mesh local spac
  87673. * @returns an array of Vector3
  87674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87675. */
  87676. getFacetLocalNormals(): Vector3[];
  87677. /**
  87678. * Returns the facetLocalPositions array.
  87679. * The facet positions are expressed in the mesh local space
  87680. * @returns an array of Vector3
  87681. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87682. */
  87683. getFacetLocalPositions(): Vector3[];
  87684. /**
  87685. * Returns the facetLocalPartioning array
  87686. * @returns an array of array of numbers
  87687. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87688. */
  87689. getFacetLocalPartitioning(): number[][];
  87690. /**
  87691. * Returns the i-th facet position in the world system.
  87692. * This method allocates a new Vector3 per call
  87693. * @param i defines the facet index
  87694. * @returns a new Vector3
  87695. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87696. */
  87697. getFacetPosition(i: number): Vector3;
  87698. /**
  87699. * Sets the reference Vector3 with the i-th facet position in the world system
  87700. * @param i defines the facet index
  87701. * @param ref defines the target vector
  87702. * @returns the current mesh
  87703. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87704. */
  87705. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  87706. /**
  87707. * Returns the i-th facet normal in the world system.
  87708. * This method allocates a new Vector3 per call
  87709. * @param i defines the facet index
  87710. * @returns a new Vector3
  87711. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87712. */
  87713. getFacetNormal(i: number): Vector3;
  87714. /**
  87715. * Sets the reference Vector3 with the i-th facet normal in the world system
  87716. * @param i defines the facet index
  87717. * @param ref defines the target vector
  87718. * @returns the current mesh
  87719. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87720. */
  87721. getFacetNormalToRef(i: number, ref: Vector3): this;
  87722. /**
  87723. * 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)
  87724. * @param x defines x coordinate
  87725. * @param y defines y coordinate
  87726. * @param z defines z coordinate
  87727. * @returns the array of facet indexes
  87728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87729. */
  87730. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  87731. /**
  87732. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  87733. * @param projected sets as the (x,y,z) world projection on the facet
  87734. * @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
  87735. * @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
  87736. * @param x defines x coordinate
  87737. * @param y defines y coordinate
  87738. * @param z defines z coordinate
  87739. * @returns the face index if found (or null instead)
  87740. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87741. */
  87742. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87743. /**
  87744. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  87745. * @param projected sets as the (x,y,z) local projection on the facet
  87746. * @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
  87747. * @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
  87748. * @param x defines x coordinate
  87749. * @param y defines y coordinate
  87750. * @param z defines z coordinate
  87751. * @returns the face index if found (or null instead)
  87752. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87753. */
  87754. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87755. /**
  87756. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  87757. * @returns the parameters
  87758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87759. */
  87760. getFacetDataParameters(): any;
  87761. /**
  87762. * Disables the feature FacetData and frees the related memory
  87763. * @returns the current mesh
  87764. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87765. */
  87766. disableFacetData(): AbstractMesh;
  87767. /**
  87768. * Updates the AbstractMesh indices array
  87769. * @param indices defines the data source
  87770. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87771. * @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)
  87772. * @returns the current mesh
  87773. */
  87774. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  87775. /**
  87776. * Creates new normals data for the mesh
  87777. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  87778. * @returns the current mesh
  87779. */
  87780. createNormals(updatable: boolean): AbstractMesh;
  87781. /**
  87782. * Align the mesh with a normal
  87783. * @param normal defines the normal to use
  87784. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  87785. * @returns the current mesh
  87786. */
  87787. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  87788. /** @hidden */
  87789. _checkOcclusionQuery(): boolean;
  87790. /**
  87791. * Disables the mesh edge rendering mode
  87792. * @returns the currentAbstractMesh
  87793. */
  87794. disableEdgesRendering(): AbstractMesh;
  87795. /**
  87796. * Enables the edge rendering mode on the mesh.
  87797. * This mode makes the mesh edges visible
  87798. * @param epsilon defines the maximal distance between two angles to detect a face
  87799. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87800. * @returns the currentAbstractMesh
  87801. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87802. */
  87803. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87804. }
  87805. }
  87806. declare module BABYLON {
  87807. /**
  87808. * Interface used to define ActionEvent
  87809. */
  87810. export interface IActionEvent {
  87811. /** The mesh or sprite that triggered the action */
  87812. source: any;
  87813. /** The X mouse cursor position at the time of the event */
  87814. pointerX: number;
  87815. /** The Y mouse cursor position at the time of the event */
  87816. pointerY: number;
  87817. /** The mesh that is currently pointed at (can be null) */
  87818. meshUnderPointer: Nullable<AbstractMesh>;
  87819. /** the original (browser) event that triggered the ActionEvent */
  87820. sourceEvent?: any;
  87821. /** additional data for the event */
  87822. additionalData?: any;
  87823. }
  87824. /**
  87825. * ActionEvent is the event being sent when an action is triggered.
  87826. */
  87827. export class ActionEvent implements IActionEvent {
  87828. /** The mesh or sprite that triggered the action */
  87829. source: any;
  87830. /** The X mouse cursor position at the time of the event */
  87831. pointerX: number;
  87832. /** The Y mouse cursor position at the time of the event */
  87833. pointerY: number;
  87834. /** The mesh that is currently pointed at (can be null) */
  87835. meshUnderPointer: Nullable<AbstractMesh>;
  87836. /** the original (browser) event that triggered the ActionEvent */
  87837. sourceEvent?: any;
  87838. /** additional data for the event */
  87839. additionalData?: any;
  87840. /**
  87841. * Creates a new ActionEvent
  87842. * @param source The mesh or sprite that triggered the action
  87843. * @param pointerX The X mouse cursor position at the time of the event
  87844. * @param pointerY The Y mouse cursor position at the time of the event
  87845. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  87846. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  87847. * @param additionalData additional data for the event
  87848. */
  87849. constructor(
  87850. /** The mesh or sprite that triggered the action */
  87851. source: any,
  87852. /** The X mouse cursor position at the time of the event */
  87853. pointerX: number,
  87854. /** The Y mouse cursor position at the time of the event */
  87855. pointerY: number,
  87856. /** The mesh that is currently pointed at (can be null) */
  87857. meshUnderPointer: Nullable<AbstractMesh>,
  87858. /** the original (browser) event that triggered the ActionEvent */
  87859. sourceEvent?: any,
  87860. /** additional data for the event */
  87861. additionalData?: any);
  87862. /**
  87863. * Helper function to auto-create an ActionEvent from a source mesh.
  87864. * @param source The source mesh that triggered the event
  87865. * @param evt The original (browser) event
  87866. * @param additionalData additional data for the event
  87867. * @returns the new ActionEvent
  87868. */
  87869. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  87870. /**
  87871. * Helper function to auto-create an ActionEvent from a source sprite
  87872. * @param source The source sprite that triggered the event
  87873. * @param scene Scene associated with the sprite
  87874. * @param evt The original (browser) event
  87875. * @param additionalData additional data for the event
  87876. * @returns the new ActionEvent
  87877. */
  87878. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  87879. /**
  87880. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  87881. * @param scene the scene where the event occurred
  87882. * @param evt The original (browser) event
  87883. * @returns the new ActionEvent
  87884. */
  87885. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  87886. /**
  87887. * Helper function to auto-create an ActionEvent from a primitive
  87888. * @param prim defines the target primitive
  87889. * @param pointerPos defines the pointer position
  87890. * @param evt The original (browser) event
  87891. * @param additionalData additional data for the event
  87892. * @returns the new ActionEvent
  87893. */
  87894. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  87895. }
  87896. }
  87897. declare module BABYLON {
  87898. /**
  87899. * Abstract class used to decouple action Manager from scene and meshes.
  87900. * Do not instantiate.
  87901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87902. */
  87903. export abstract class AbstractActionManager implements IDisposable {
  87904. /** Gets the list of active triggers */
  87905. static Triggers: {
  87906. [key: string]: number;
  87907. };
  87908. /** Gets the cursor to use when hovering items */
  87909. hoverCursor: string;
  87910. /** Gets the list of actions */
  87911. actions: IAction[];
  87912. /**
  87913. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  87914. */
  87915. isRecursive: boolean;
  87916. /**
  87917. * Releases all associated resources
  87918. */
  87919. abstract dispose(): void;
  87920. /**
  87921. * Does this action manager has pointer triggers
  87922. */
  87923. abstract readonly hasPointerTriggers: boolean;
  87924. /**
  87925. * Does this action manager has pick triggers
  87926. */
  87927. abstract readonly hasPickTriggers: boolean;
  87928. /**
  87929. * Process a specific trigger
  87930. * @param trigger defines the trigger to process
  87931. * @param evt defines the event details to be processed
  87932. */
  87933. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  87934. /**
  87935. * Does this action manager handles actions of any of the given triggers
  87936. * @param triggers defines the triggers to be tested
  87937. * @return a boolean indicating whether one (or more) of the triggers is handled
  87938. */
  87939. abstract hasSpecificTriggers(triggers: number[]): boolean;
  87940. /**
  87941. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87942. * speed.
  87943. * @param triggerA defines the trigger to be tested
  87944. * @param triggerB defines the trigger to be tested
  87945. * @return a boolean indicating whether one (or more) of the triggers is handled
  87946. */
  87947. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87948. /**
  87949. * Does this action manager handles actions of a given trigger
  87950. * @param trigger defines the trigger to be tested
  87951. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87952. * @return whether the trigger is handled
  87953. */
  87954. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87955. /**
  87956. * Serialize this manager to a JSON object
  87957. * @param name defines the property name to store this manager
  87958. * @returns a JSON representation of this manager
  87959. */
  87960. abstract serialize(name: string): any;
  87961. /**
  87962. * Registers an action to this action manager
  87963. * @param action defines the action to be registered
  87964. * @return the action amended (prepared) after registration
  87965. */
  87966. abstract registerAction(action: IAction): Nullable<IAction>;
  87967. /**
  87968. * Unregisters an action to this action manager
  87969. * @param action defines the action to be unregistered
  87970. * @return a boolean indicating whether the action has been unregistered
  87971. */
  87972. abstract unregisterAction(action: IAction): Boolean;
  87973. /**
  87974. * Does exist one action manager with at least one trigger
  87975. **/
  87976. static readonly HasTriggers: boolean;
  87977. /**
  87978. * Does exist one action manager with at least one pick trigger
  87979. **/
  87980. static readonly HasPickTriggers: boolean;
  87981. /**
  87982. * Does exist one action manager that handles actions of a given trigger
  87983. * @param trigger defines the trigger to be tested
  87984. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  87985. **/
  87986. static HasSpecificTrigger(trigger: number): boolean;
  87987. }
  87988. }
  87989. declare module BABYLON {
  87990. /**
  87991. * Defines how a node can be built from a string name.
  87992. */
  87993. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  87994. /**
  87995. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  87996. */
  87997. export class Node implements IBehaviorAware<Node> {
  87998. /** @hidden */
  87999. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  88000. private static _NodeConstructors;
  88001. /**
  88002. * Add a new node constructor
  88003. * @param type defines the type name of the node to construct
  88004. * @param constructorFunc defines the constructor function
  88005. */
  88006. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  88007. /**
  88008. * Returns a node constructor based on type name
  88009. * @param type defines the type name
  88010. * @param name defines the new node name
  88011. * @param scene defines the hosting scene
  88012. * @param options defines optional options to transmit to constructors
  88013. * @returns the new constructor or null
  88014. */
  88015. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  88016. /**
  88017. * Gets or sets the name of the node
  88018. */
  88019. name: string;
  88020. /**
  88021. * Gets or sets the id of the node
  88022. */
  88023. id: string;
  88024. /**
  88025. * Gets or sets the unique id of the node
  88026. */
  88027. uniqueId: number;
  88028. /**
  88029. * Gets or sets a string used to store user defined state for the node
  88030. */
  88031. state: string;
  88032. /**
  88033. * Gets or sets an object used to store user defined information for the node
  88034. */
  88035. metadata: any;
  88036. /**
  88037. * For internal use only. Please do not use.
  88038. */
  88039. reservedDataStore: any;
  88040. /**
  88041. * List of inspectable custom properties (used by the Inspector)
  88042. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88043. */
  88044. inspectableCustomProperties: IInspectable[];
  88045. /**
  88046. * Gets or sets a boolean used to define if the node must be serialized
  88047. */
  88048. doNotSerialize: boolean;
  88049. /** @hidden */
  88050. _isDisposed: boolean;
  88051. /**
  88052. * Gets a list of Animations associated with the node
  88053. */
  88054. animations: Animation[];
  88055. protected _ranges: {
  88056. [name: string]: Nullable<AnimationRange>;
  88057. };
  88058. /**
  88059. * Callback raised when the node is ready to be used
  88060. */
  88061. onReady: Nullable<(node: Node) => void>;
  88062. private _isEnabled;
  88063. private _isParentEnabled;
  88064. private _isReady;
  88065. /** @hidden */
  88066. _currentRenderId: number;
  88067. private _parentUpdateId;
  88068. /** @hidden */
  88069. _childUpdateId: number;
  88070. /** @hidden */
  88071. _waitingParentId: Nullable<string>;
  88072. /** @hidden */
  88073. _scene: Scene;
  88074. /** @hidden */
  88075. _cache: any;
  88076. private _parentNode;
  88077. private _children;
  88078. /** @hidden */
  88079. _worldMatrix: Matrix;
  88080. /** @hidden */
  88081. _worldMatrixDeterminant: number;
  88082. /** @hidden */
  88083. _worldMatrixDeterminantIsDirty: boolean;
  88084. /** @hidden */
  88085. private _sceneRootNodesIndex;
  88086. /**
  88087. * Gets a boolean indicating if the node has been disposed
  88088. * @returns true if the node was disposed
  88089. */
  88090. isDisposed(): boolean;
  88091. /**
  88092. * Gets or sets the parent of the node (without keeping the current position in the scene)
  88093. * @see https://doc.babylonjs.com/how_to/parenting
  88094. */
  88095. parent: Nullable<Node>;
  88096. private addToSceneRootNodes;
  88097. private removeFromSceneRootNodes;
  88098. private _animationPropertiesOverride;
  88099. /**
  88100. * Gets or sets the animation properties override
  88101. */
  88102. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88103. /**
  88104. * Gets a string idenfifying the name of the class
  88105. * @returns "Node" string
  88106. */
  88107. getClassName(): string;
  88108. /** @hidden */
  88109. readonly _isNode: boolean;
  88110. /**
  88111. * An event triggered when the mesh is disposed
  88112. */
  88113. onDisposeObservable: Observable<Node>;
  88114. private _onDisposeObserver;
  88115. /**
  88116. * Sets a callback that will be raised when the node will be disposed
  88117. */
  88118. onDispose: () => void;
  88119. /**
  88120. * Creates a new Node
  88121. * @param name the name and id to be given to this node
  88122. * @param scene the scene this node will be added to
  88123. * @param addToRootNodes the node will be added to scene.rootNodes
  88124. */
  88125. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  88126. /**
  88127. * Gets the scene of the node
  88128. * @returns a scene
  88129. */
  88130. getScene(): Scene;
  88131. /**
  88132. * Gets the engine of the node
  88133. * @returns a Engine
  88134. */
  88135. getEngine(): Engine;
  88136. private _behaviors;
  88137. /**
  88138. * Attach a behavior to the node
  88139. * @see http://doc.babylonjs.com/features/behaviour
  88140. * @param behavior defines the behavior to attach
  88141. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  88142. * @returns the current Node
  88143. */
  88144. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  88145. /**
  88146. * Remove an attached behavior
  88147. * @see http://doc.babylonjs.com/features/behaviour
  88148. * @param behavior defines the behavior to attach
  88149. * @returns the current Node
  88150. */
  88151. removeBehavior(behavior: Behavior<Node>): Node;
  88152. /**
  88153. * Gets the list of attached behaviors
  88154. * @see http://doc.babylonjs.com/features/behaviour
  88155. */
  88156. readonly behaviors: Behavior<Node>[];
  88157. /**
  88158. * Gets an attached behavior by name
  88159. * @param name defines the name of the behavior to look for
  88160. * @see http://doc.babylonjs.com/features/behaviour
  88161. * @returns null if behavior was not found else the requested behavior
  88162. */
  88163. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  88164. /**
  88165. * Returns the latest update of the World matrix
  88166. * @returns a Matrix
  88167. */
  88168. getWorldMatrix(): Matrix;
  88169. /** @hidden */
  88170. _getWorldMatrixDeterminant(): number;
  88171. /**
  88172. * Returns directly the latest state of the mesh World matrix.
  88173. * A Matrix is returned.
  88174. */
  88175. readonly worldMatrixFromCache: Matrix;
  88176. /** @hidden */
  88177. _initCache(): void;
  88178. /** @hidden */
  88179. updateCache(force?: boolean): void;
  88180. /** @hidden */
  88181. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  88182. /** @hidden */
  88183. _updateCache(ignoreParentClass?: boolean): void;
  88184. /** @hidden */
  88185. _isSynchronized(): boolean;
  88186. /** @hidden */
  88187. _markSyncedWithParent(): void;
  88188. /** @hidden */
  88189. isSynchronizedWithParent(): boolean;
  88190. /** @hidden */
  88191. isSynchronized(): boolean;
  88192. /**
  88193. * Is this node ready to be used/rendered
  88194. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88195. * @return true if the node is ready
  88196. */
  88197. isReady(completeCheck?: boolean): boolean;
  88198. /**
  88199. * Is this node enabled?
  88200. * 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
  88201. * @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
  88202. * @return whether this node (and its parent) is enabled
  88203. */
  88204. isEnabled(checkAncestors?: boolean): boolean;
  88205. /** @hidden */
  88206. protected _syncParentEnabledState(): void;
  88207. /**
  88208. * Set the enabled state of this node
  88209. * @param value defines the new enabled state
  88210. */
  88211. setEnabled(value: boolean): void;
  88212. /**
  88213. * Is this node a descendant of the given node?
  88214. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  88215. * @param ancestor defines the parent node to inspect
  88216. * @returns a boolean indicating if this node is a descendant of the given node
  88217. */
  88218. isDescendantOf(ancestor: Node): boolean;
  88219. /** @hidden */
  88220. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  88221. /**
  88222. * Will return all nodes that have this node as ascendant
  88223. * @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
  88224. * @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
  88225. * @return all children nodes of all types
  88226. */
  88227. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  88228. /**
  88229. * Get all child-meshes of this node
  88230. * @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)
  88231. * @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
  88232. * @returns an array of AbstractMesh
  88233. */
  88234. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  88235. /**
  88236. * Get all direct children of this node
  88237. * @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
  88238. * @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)
  88239. * @returns an array of Node
  88240. */
  88241. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  88242. /** @hidden */
  88243. _setReady(state: boolean): void;
  88244. /**
  88245. * Get an animation by name
  88246. * @param name defines the name of the animation to look for
  88247. * @returns null if not found else the requested animation
  88248. */
  88249. getAnimationByName(name: string): Nullable<Animation>;
  88250. /**
  88251. * Creates an animation range for this node
  88252. * @param name defines the name of the range
  88253. * @param from defines the starting key
  88254. * @param to defines the end key
  88255. */
  88256. createAnimationRange(name: string, from: number, to: number): void;
  88257. /**
  88258. * Delete a specific animation range
  88259. * @param name defines the name of the range to delete
  88260. * @param deleteFrames defines if animation frames from the range must be deleted as well
  88261. */
  88262. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88263. /**
  88264. * Get an animation range by name
  88265. * @param name defines the name of the animation range to look for
  88266. * @returns null if not found else the requested animation range
  88267. */
  88268. getAnimationRange(name: string): Nullable<AnimationRange>;
  88269. /**
  88270. * Gets the list of all animation ranges defined on this node
  88271. * @returns an array
  88272. */
  88273. getAnimationRanges(): Nullable<AnimationRange>[];
  88274. /**
  88275. * Will start the animation sequence
  88276. * @param name defines the range frames for animation sequence
  88277. * @param loop defines if the animation should loop (false by default)
  88278. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  88279. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  88280. * @returns the object created for this animation. If range does not exist, it will return null
  88281. */
  88282. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88283. /**
  88284. * Serialize animation ranges into a JSON compatible object
  88285. * @returns serialization object
  88286. */
  88287. serializeAnimationRanges(): any;
  88288. /**
  88289. * Computes the world matrix of the node
  88290. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88291. * @returns the world matrix
  88292. */
  88293. computeWorldMatrix(force?: boolean): Matrix;
  88294. /**
  88295. * Releases resources associated with this node.
  88296. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88297. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88298. */
  88299. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88300. /**
  88301. * Parse animation range data from a serialization object and store them into a given node
  88302. * @param node defines where to store the animation ranges
  88303. * @param parsedNode defines the serialization object to read data from
  88304. * @param scene defines the hosting scene
  88305. */
  88306. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88307. /**
  88308. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88309. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88310. * @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
  88311. * @returns the new bounding vectors
  88312. */
  88313. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88314. min: Vector3;
  88315. max: Vector3;
  88316. };
  88317. }
  88318. }
  88319. declare module BABYLON {
  88320. /**
  88321. * @hidden
  88322. */
  88323. export class _IAnimationState {
  88324. key: number;
  88325. repeatCount: number;
  88326. workValue?: any;
  88327. loopMode?: number;
  88328. offsetValue?: any;
  88329. highLimitValue?: any;
  88330. }
  88331. /**
  88332. * Class used to store any kind of animation
  88333. */
  88334. export class Animation {
  88335. /**Name of the animation */
  88336. name: string;
  88337. /**Property to animate */
  88338. targetProperty: string;
  88339. /**The frames per second of the animation */
  88340. framePerSecond: number;
  88341. /**The data type of the animation */
  88342. dataType: number;
  88343. /**The loop mode of the animation */
  88344. loopMode?: number | undefined;
  88345. /**Specifies if blending should be enabled */
  88346. enableBlending?: boolean | undefined;
  88347. /**
  88348. * Use matrix interpolation instead of using direct key value when animating matrices
  88349. */
  88350. static AllowMatricesInterpolation: boolean;
  88351. /**
  88352. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88353. */
  88354. static AllowMatrixDecomposeForInterpolation: boolean;
  88355. /**
  88356. * Stores the key frames of the animation
  88357. */
  88358. private _keys;
  88359. /**
  88360. * Stores the easing function of the animation
  88361. */
  88362. private _easingFunction;
  88363. /**
  88364. * @hidden Internal use only
  88365. */
  88366. _runtimeAnimations: RuntimeAnimation[];
  88367. /**
  88368. * The set of event that will be linked to this animation
  88369. */
  88370. private _events;
  88371. /**
  88372. * Stores an array of target property paths
  88373. */
  88374. targetPropertyPath: string[];
  88375. /**
  88376. * Stores the blending speed of the animation
  88377. */
  88378. blendingSpeed: number;
  88379. /**
  88380. * Stores the animation ranges for the animation
  88381. */
  88382. private _ranges;
  88383. /**
  88384. * @hidden Internal use
  88385. */
  88386. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88387. /**
  88388. * Sets up an animation
  88389. * @param property The property to animate
  88390. * @param animationType The animation type to apply
  88391. * @param framePerSecond The frames per second of the animation
  88392. * @param easingFunction The easing function used in the animation
  88393. * @returns The created animation
  88394. */
  88395. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88396. /**
  88397. * Create and start an animation on a node
  88398. * @param name defines the name of the global animation that will be run on all nodes
  88399. * @param node defines the root node where the animation will take place
  88400. * @param targetProperty defines property to animate
  88401. * @param framePerSecond defines the number of frame per second yo use
  88402. * @param totalFrame defines the number of frames in total
  88403. * @param from defines the initial value
  88404. * @param to defines the final value
  88405. * @param loopMode defines which loop mode you want to use (off by default)
  88406. * @param easingFunction defines the easing function to use (linear by default)
  88407. * @param onAnimationEnd defines the callback to call when animation end
  88408. * @returns the animatable created for this animation
  88409. */
  88410. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88411. /**
  88412. * Create and start an animation on a node and its descendants
  88413. * @param name defines the name of the global animation that will be run on all nodes
  88414. * @param node defines the root node where the animation will take place
  88415. * @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
  88416. * @param targetProperty defines property to animate
  88417. * @param framePerSecond defines the number of frame per second to use
  88418. * @param totalFrame defines the number of frames in total
  88419. * @param from defines the initial value
  88420. * @param to defines the final value
  88421. * @param loopMode defines which loop mode you want to use (off by default)
  88422. * @param easingFunction defines the easing function to use (linear by default)
  88423. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88424. * @returns the list of animatables created for all nodes
  88425. * @example https://www.babylonjs-playground.com/#MH0VLI
  88426. */
  88427. 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[]>;
  88428. /**
  88429. * Creates a new animation, merges it with the existing animations and starts it
  88430. * @param name Name of the animation
  88431. * @param node Node which contains the scene that begins the animations
  88432. * @param targetProperty Specifies which property to animate
  88433. * @param framePerSecond The frames per second of the animation
  88434. * @param totalFrame The total number of frames
  88435. * @param from The frame at the beginning of the animation
  88436. * @param to The frame at the end of the animation
  88437. * @param loopMode Specifies the loop mode of the animation
  88438. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88439. * @param onAnimationEnd Callback to run once the animation is complete
  88440. * @returns Nullable animation
  88441. */
  88442. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88443. /**
  88444. * Transition property of an host to the target Value
  88445. * @param property The property to transition
  88446. * @param targetValue The target Value of the property
  88447. * @param host The object where the property to animate belongs
  88448. * @param scene Scene used to run the animation
  88449. * @param frameRate Framerate (in frame/s) to use
  88450. * @param transition The transition type we want to use
  88451. * @param duration The duration of the animation, in milliseconds
  88452. * @param onAnimationEnd Callback trigger at the end of the animation
  88453. * @returns Nullable animation
  88454. */
  88455. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88456. /**
  88457. * Return the array of runtime animations currently using this animation
  88458. */
  88459. readonly runtimeAnimations: RuntimeAnimation[];
  88460. /**
  88461. * Specifies if any of the runtime animations are currently running
  88462. */
  88463. readonly hasRunningRuntimeAnimations: boolean;
  88464. /**
  88465. * Initializes the animation
  88466. * @param name Name of the animation
  88467. * @param targetProperty Property to animate
  88468. * @param framePerSecond The frames per second of the animation
  88469. * @param dataType The data type of the animation
  88470. * @param loopMode The loop mode of the animation
  88471. * @param enableBlending Specifies if blending should be enabled
  88472. */
  88473. constructor(
  88474. /**Name of the animation */
  88475. name: string,
  88476. /**Property to animate */
  88477. targetProperty: string,
  88478. /**The frames per second of the animation */
  88479. framePerSecond: number,
  88480. /**The data type of the animation */
  88481. dataType: number,
  88482. /**The loop mode of the animation */
  88483. loopMode?: number | undefined,
  88484. /**Specifies if blending should be enabled */
  88485. enableBlending?: boolean | undefined);
  88486. /**
  88487. * Converts the animation to a string
  88488. * @param fullDetails support for multiple levels of logging within scene loading
  88489. * @returns String form of the animation
  88490. */
  88491. toString(fullDetails?: boolean): string;
  88492. /**
  88493. * Add an event to this animation
  88494. * @param event Event to add
  88495. */
  88496. addEvent(event: AnimationEvent): void;
  88497. /**
  88498. * Remove all events found at the given frame
  88499. * @param frame The frame to remove events from
  88500. */
  88501. removeEvents(frame: number): void;
  88502. /**
  88503. * Retrieves all the events from the animation
  88504. * @returns Events from the animation
  88505. */
  88506. getEvents(): AnimationEvent[];
  88507. /**
  88508. * Creates an animation range
  88509. * @param name Name of the animation range
  88510. * @param from Starting frame of the animation range
  88511. * @param to Ending frame of the animation
  88512. */
  88513. createRange(name: string, from: number, to: number): void;
  88514. /**
  88515. * Deletes an animation range by name
  88516. * @param name Name of the animation range to delete
  88517. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88518. */
  88519. deleteRange(name: string, deleteFrames?: boolean): void;
  88520. /**
  88521. * Gets the animation range by name, or null if not defined
  88522. * @param name Name of the animation range
  88523. * @returns Nullable animation range
  88524. */
  88525. getRange(name: string): Nullable<AnimationRange>;
  88526. /**
  88527. * Gets the key frames from the animation
  88528. * @returns The key frames of the animation
  88529. */
  88530. getKeys(): Array<IAnimationKey>;
  88531. /**
  88532. * Gets the highest frame rate of the animation
  88533. * @returns Highest frame rate of the animation
  88534. */
  88535. getHighestFrame(): number;
  88536. /**
  88537. * Gets the easing function of the animation
  88538. * @returns Easing function of the animation
  88539. */
  88540. getEasingFunction(): IEasingFunction;
  88541. /**
  88542. * Sets the easing function of the animation
  88543. * @param easingFunction A custom mathematical formula for animation
  88544. */
  88545. setEasingFunction(easingFunction: EasingFunction): void;
  88546. /**
  88547. * Interpolates a scalar linearly
  88548. * @param startValue Start value of the animation curve
  88549. * @param endValue End value of the animation curve
  88550. * @param gradient Scalar amount to interpolate
  88551. * @returns Interpolated scalar value
  88552. */
  88553. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  88554. /**
  88555. * Interpolates a scalar cubically
  88556. * @param startValue Start value of the animation curve
  88557. * @param outTangent End tangent of the animation
  88558. * @param endValue End value of the animation curve
  88559. * @param inTangent Start tangent of the animation curve
  88560. * @param gradient Scalar amount to interpolate
  88561. * @returns Interpolated scalar value
  88562. */
  88563. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  88564. /**
  88565. * Interpolates a quaternion using a spherical linear interpolation
  88566. * @param startValue Start value of the animation curve
  88567. * @param endValue End value of the animation curve
  88568. * @param gradient Scalar amount to interpolate
  88569. * @returns Interpolated quaternion value
  88570. */
  88571. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  88572. /**
  88573. * Interpolates a quaternion cubically
  88574. * @param startValue Start value of the animation curve
  88575. * @param outTangent End tangent of the animation curve
  88576. * @param endValue End value of the animation curve
  88577. * @param inTangent Start tangent of the animation curve
  88578. * @param gradient Scalar amount to interpolate
  88579. * @returns Interpolated quaternion value
  88580. */
  88581. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  88582. /**
  88583. * Interpolates a Vector3 linearl
  88584. * @param startValue Start value of the animation curve
  88585. * @param endValue End value of the animation curve
  88586. * @param gradient Scalar amount to interpolate
  88587. * @returns Interpolated scalar value
  88588. */
  88589. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  88590. /**
  88591. * Interpolates a Vector3 cubically
  88592. * @param startValue Start value of the animation curve
  88593. * @param outTangent End tangent of the animation
  88594. * @param endValue End value of the animation curve
  88595. * @param inTangent Start tangent of the animation curve
  88596. * @param gradient Scalar amount to interpolate
  88597. * @returns InterpolatedVector3 value
  88598. */
  88599. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  88600. /**
  88601. * Interpolates a Vector2 linearly
  88602. * @param startValue Start value of the animation curve
  88603. * @param endValue End value of the animation curve
  88604. * @param gradient Scalar amount to interpolate
  88605. * @returns Interpolated Vector2 value
  88606. */
  88607. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  88608. /**
  88609. * Interpolates a Vector2 cubically
  88610. * @param startValue Start value of the animation curve
  88611. * @param outTangent End tangent of the animation
  88612. * @param endValue End value of the animation curve
  88613. * @param inTangent Start tangent of the animation curve
  88614. * @param gradient Scalar amount to interpolate
  88615. * @returns Interpolated Vector2 value
  88616. */
  88617. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  88618. /**
  88619. * Interpolates a size linearly
  88620. * @param startValue Start value of the animation curve
  88621. * @param endValue End value of the animation curve
  88622. * @param gradient Scalar amount to interpolate
  88623. * @returns Interpolated Size value
  88624. */
  88625. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  88626. /**
  88627. * Interpolates a Color3 linearly
  88628. * @param startValue Start value of the animation curve
  88629. * @param endValue End value of the animation curve
  88630. * @param gradient Scalar amount to interpolate
  88631. * @returns Interpolated Color3 value
  88632. */
  88633. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  88634. /**
  88635. * @hidden Internal use only
  88636. */
  88637. _getKeyValue(value: any): any;
  88638. /**
  88639. * @hidden Internal use only
  88640. */
  88641. _interpolate(currentFrame: number, state: _IAnimationState): any;
  88642. /**
  88643. * Defines the function to use to interpolate matrices
  88644. * @param startValue defines the start matrix
  88645. * @param endValue defines the end matrix
  88646. * @param gradient defines the gradient between both matrices
  88647. * @param result defines an optional target matrix where to store the interpolation
  88648. * @returns the interpolated matrix
  88649. */
  88650. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  88651. /**
  88652. * Makes a copy of the animation
  88653. * @returns Cloned animation
  88654. */
  88655. clone(): Animation;
  88656. /**
  88657. * Sets the key frames of the animation
  88658. * @param values The animation key frames to set
  88659. */
  88660. setKeys(values: Array<IAnimationKey>): void;
  88661. /**
  88662. * Serializes the animation to an object
  88663. * @returns Serialized object
  88664. */
  88665. serialize(): any;
  88666. /**
  88667. * Float animation type
  88668. */
  88669. private static _ANIMATIONTYPE_FLOAT;
  88670. /**
  88671. * Vector3 animation type
  88672. */
  88673. private static _ANIMATIONTYPE_VECTOR3;
  88674. /**
  88675. * Quaternion animation type
  88676. */
  88677. private static _ANIMATIONTYPE_QUATERNION;
  88678. /**
  88679. * Matrix animation type
  88680. */
  88681. private static _ANIMATIONTYPE_MATRIX;
  88682. /**
  88683. * Color3 animation type
  88684. */
  88685. private static _ANIMATIONTYPE_COLOR3;
  88686. /**
  88687. * Vector2 animation type
  88688. */
  88689. private static _ANIMATIONTYPE_VECTOR2;
  88690. /**
  88691. * Size animation type
  88692. */
  88693. private static _ANIMATIONTYPE_SIZE;
  88694. /**
  88695. * Relative Loop Mode
  88696. */
  88697. private static _ANIMATIONLOOPMODE_RELATIVE;
  88698. /**
  88699. * Cycle Loop Mode
  88700. */
  88701. private static _ANIMATIONLOOPMODE_CYCLE;
  88702. /**
  88703. * Constant Loop Mode
  88704. */
  88705. private static _ANIMATIONLOOPMODE_CONSTANT;
  88706. /**
  88707. * Get the float animation type
  88708. */
  88709. static readonly ANIMATIONTYPE_FLOAT: number;
  88710. /**
  88711. * Get the Vector3 animation type
  88712. */
  88713. static readonly ANIMATIONTYPE_VECTOR3: number;
  88714. /**
  88715. * Get the Vector2 animation type
  88716. */
  88717. static readonly ANIMATIONTYPE_VECTOR2: number;
  88718. /**
  88719. * Get the Size animation type
  88720. */
  88721. static readonly ANIMATIONTYPE_SIZE: number;
  88722. /**
  88723. * Get the Quaternion animation type
  88724. */
  88725. static readonly ANIMATIONTYPE_QUATERNION: number;
  88726. /**
  88727. * Get the Matrix animation type
  88728. */
  88729. static readonly ANIMATIONTYPE_MATRIX: number;
  88730. /**
  88731. * Get the Color3 animation type
  88732. */
  88733. static readonly ANIMATIONTYPE_COLOR3: number;
  88734. /**
  88735. * Get the Relative Loop Mode
  88736. */
  88737. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  88738. /**
  88739. * Get the Cycle Loop Mode
  88740. */
  88741. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  88742. /**
  88743. * Get the Constant Loop Mode
  88744. */
  88745. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  88746. /** @hidden */
  88747. static _UniversalLerp(left: any, right: any, amount: number): any;
  88748. /**
  88749. * Parses an animation object and creates an animation
  88750. * @param parsedAnimation Parsed animation object
  88751. * @returns Animation object
  88752. */
  88753. static Parse(parsedAnimation: any): Animation;
  88754. /**
  88755. * Appends the serialized animations from the source animations
  88756. * @param source Source containing the animations
  88757. * @param destination Target to store the animations
  88758. */
  88759. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88760. }
  88761. }
  88762. declare module BABYLON {
  88763. /**
  88764. * Base class of all the textures in babylon.
  88765. * It groups all the common properties the materials, post process, lights... might need
  88766. * in order to make a correct use of the texture.
  88767. */
  88768. export class BaseTexture implements IAnimatable {
  88769. /**
  88770. * Default anisotropic filtering level for the application.
  88771. * It is set to 4 as a good tradeoff between perf and quality.
  88772. */
  88773. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  88774. /**
  88775. * Gets or sets the unique id of the texture
  88776. */
  88777. uniqueId: number;
  88778. /**
  88779. * Define the name of the texture.
  88780. */
  88781. name: string;
  88782. /**
  88783. * Gets or sets an object used to store user defined information.
  88784. */
  88785. metadata: any;
  88786. /**
  88787. * For internal use only. Please do not use.
  88788. */
  88789. reservedDataStore: any;
  88790. private _hasAlpha;
  88791. /**
  88792. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  88793. */
  88794. hasAlpha: boolean;
  88795. /**
  88796. * Defines if the alpha value should be determined via the rgb values.
  88797. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  88798. */
  88799. getAlphaFromRGB: boolean;
  88800. /**
  88801. * Intensity or strength of the texture.
  88802. * It is commonly used by materials to fine tune the intensity of the texture
  88803. */
  88804. level: number;
  88805. /**
  88806. * Define the UV chanel to use starting from 0 and defaulting to 0.
  88807. * This is part of the texture as textures usually maps to one uv set.
  88808. */
  88809. coordinatesIndex: number;
  88810. private _coordinatesMode;
  88811. /**
  88812. * How a texture is mapped.
  88813. *
  88814. * | Value | Type | Description |
  88815. * | ----- | ----------------------------------- | ----------- |
  88816. * | 0 | EXPLICIT_MODE | |
  88817. * | 1 | SPHERICAL_MODE | |
  88818. * | 2 | PLANAR_MODE | |
  88819. * | 3 | CUBIC_MODE | |
  88820. * | 4 | PROJECTION_MODE | |
  88821. * | 5 | SKYBOX_MODE | |
  88822. * | 6 | INVCUBIC_MODE | |
  88823. * | 7 | EQUIRECTANGULAR_MODE | |
  88824. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  88825. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  88826. */
  88827. coordinatesMode: number;
  88828. /**
  88829. * | Value | Type | Description |
  88830. * | ----- | ------------------ | ----------- |
  88831. * | 0 | CLAMP_ADDRESSMODE | |
  88832. * | 1 | WRAP_ADDRESSMODE | |
  88833. * | 2 | MIRROR_ADDRESSMODE | |
  88834. */
  88835. wrapU: number;
  88836. /**
  88837. * | Value | Type | Description |
  88838. * | ----- | ------------------ | ----------- |
  88839. * | 0 | CLAMP_ADDRESSMODE | |
  88840. * | 1 | WRAP_ADDRESSMODE | |
  88841. * | 2 | MIRROR_ADDRESSMODE | |
  88842. */
  88843. wrapV: number;
  88844. /**
  88845. * | Value | Type | Description |
  88846. * | ----- | ------------------ | ----------- |
  88847. * | 0 | CLAMP_ADDRESSMODE | |
  88848. * | 1 | WRAP_ADDRESSMODE | |
  88849. * | 2 | MIRROR_ADDRESSMODE | |
  88850. */
  88851. wrapR: number;
  88852. /**
  88853. * With compliant hardware and browser (supporting anisotropic filtering)
  88854. * this defines the level of anisotropic filtering in the texture.
  88855. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  88856. */
  88857. anisotropicFilteringLevel: number;
  88858. /**
  88859. * Define if the texture is a cube texture or if false a 2d texture.
  88860. */
  88861. isCube: boolean;
  88862. /**
  88863. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  88864. */
  88865. is3D: boolean;
  88866. /**
  88867. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  88868. * HDR texture are usually stored in linear space.
  88869. * This only impacts the PBR and Background materials
  88870. */
  88871. gammaSpace: boolean;
  88872. /**
  88873. * Gets whether or not the texture contains RGBD data.
  88874. */
  88875. readonly isRGBD: boolean;
  88876. /**
  88877. * Is Z inverted in the texture (useful in a cube texture).
  88878. */
  88879. invertZ: boolean;
  88880. /**
  88881. * Are mip maps generated for this texture or not.
  88882. */
  88883. readonly noMipmap: boolean;
  88884. /**
  88885. * @hidden
  88886. */
  88887. lodLevelInAlpha: boolean;
  88888. /**
  88889. * With prefiltered texture, defined the offset used during the prefiltering steps.
  88890. */
  88891. lodGenerationOffset: number;
  88892. /**
  88893. * With prefiltered texture, defined the scale used during the prefiltering steps.
  88894. */
  88895. lodGenerationScale: number;
  88896. /**
  88897. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  88898. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  88899. * average roughness values.
  88900. */
  88901. linearSpecularLOD: boolean;
  88902. /**
  88903. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  88904. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  88905. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  88906. */
  88907. irradianceTexture: Nullable<BaseTexture>;
  88908. /**
  88909. * Define if the texture is a render target.
  88910. */
  88911. isRenderTarget: boolean;
  88912. /**
  88913. * Define the unique id of the texture in the scene.
  88914. */
  88915. readonly uid: string;
  88916. /**
  88917. * Return a string representation of the texture.
  88918. * @returns the texture as a string
  88919. */
  88920. toString(): string;
  88921. /**
  88922. * Get the class name of the texture.
  88923. * @returns "BaseTexture"
  88924. */
  88925. getClassName(): string;
  88926. /**
  88927. * Define the list of animation attached to the texture.
  88928. */
  88929. animations: Animation[];
  88930. /**
  88931. * An event triggered when the texture is disposed.
  88932. */
  88933. onDisposeObservable: Observable<BaseTexture>;
  88934. private _onDisposeObserver;
  88935. /**
  88936. * Callback triggered when the texture has been disposed.
  88937. * Kept for back compatibility, you can use the onDisposeObservable instead.
  88938. */
  88939. onDispose: () => void;
  88940. /**
  88941. * Define the current state of the loading sequence when in delayed load mode.
  88942. */
  88943. delayLoadState: number;
  88944. private _scene;
  88945. /** @hidden */
  88946. _texture: Nullable<InternalTexture>;
  88947. private _uid;
  88948. /**
  88949. * Define if the texture is preventinga material to render or not.
  88950. * If not and the texture is not ready, the engine will use a default black texture instead.
  88951. */
  88952. readonly isBlocking: boolean;
  88953. /**
  88954. * Instantiates a new BaseTexture.
  88955. * Base class of all the textures in babylon.
  88956. * It groups all the common properties the materials, post process, lights... might need
  88957. * in order to make a correct use of the texture.
  88958. * @param scene Define the scene the texture blongs to
  88959. */
  88960. constructor(scene: Nullable<Scene>);
  88961. /**
  88962. * Get the scene the texture belongs to.
  88963. * @returns the scene or null if undefined
  88964. */
  88965. getScene(): Nullable<Scene>;
  88966. /**
  88967. * Get the texture transform matrix used to offset tile the texture for istance.
  88968. * @returns the transformation matrix
  88969. */
  88970. getTextureMatrix(): Matrix;
  88971. /**
  88972. * Get the texture reflection matrix used to rotate/transform the reflection.
  88973. * @returns the reflection matrix
  88974. */
  88975. getReflectionTextureMatrix(): Matrix;
  88976. /**
  88977. * Get the underlying lower level texture from Babylon.
  88978. * @returns the insternal texture
  88979. */
  88980. getInternalTexture(): Nullable<InternalTexture>;
  88981. /**
  88982. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  88983. * @returns true if ready or not blocking
  88984. */
  88985. isReadyOrNotBlocking(): boolean;
  88986. /**
  88987. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  88988. * @returns true if fully ready
  88989. */
  88990. isReady(): boolean;
  88991. private _cachedSize;
  88992. /**
  88993. * Get the size of the texture.
  88994. * @returns the texture size.
  88995. */
  88996. getSize(): ISize;
  88997. /**
  88998. * Get the base size of the texture.
  88999. * It can be different from the size if the texture has been resized for POT for instance
  89000. * @returns the base size
  89001. */
  89002. getBaseSize(): ISize;
  89003. /**
  89004. * Update the sampling mode of the texture.
  89005. * Default is Trilinear mode.
  89006. *
  89007. * | Value | Type | Description |
  89008. * | ----- | ------------------ | ----------- |
  89009. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  89010. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  89011. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  89012. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  89013. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  89014. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  89015. * | 7 | NEAREST_LINEAR | |
  89016. * | 8 | NEAREST_NEAREST | |
  89017. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  89018. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  89019. * | 11 | LINEAR_LINEAR | |
  89020. * | 12 | LINEAR_NEAREST | |
  89021. *
  89022. * > _mag_: magnification filter (close to the viewer)
  89023. * > _min_: minification filter (far from the viewer)
  89024. * > _mip_: filter used between mip map levels
  89025. *@param samplingMode Define the new sampling mode of the texture
  89026. */
  89027. updateSamplingMode(samplingMode: number): void;
  89028. /**
  89029. * Scales the texture if is `canRescale()`
  89030. * @param ratio the resize factor we want to use to rescale
  89031. */
  89032. scale(ratio: number): void;
  89033. /**
  89034. * Get if the texture can rescale.
  89035. */
  89036. readonly canRescale: boolean;
  89037. /** @hidden */
  89038. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89039. /** @hidden */
  89040. _rebuild(): void;
  89041. /**
  89042. * Triggers the load sequence in delayed load mode.
  89043. */
  89044. delayLoad(): void;
  89045. /**
  89046. * Clones the texture.
  89047. * @returns the cloned texture
  89048. */
  89049. clone(): Nullable<BaseTexture>;
  89050. /**
  89051. * Get the texture underlying type (INT, FLOAT...)
  89052. */
  89053. readonly textureType: number;
  89054. /**
  89055. * Get the texture underlying format (RGB, RGBA...)
  89056. */
  89057. readonly textureFormat: number;
  89058. /**
  89059. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89060. * This will returns an RGBA array buffer containing either in values (0-255) or
  89061. * float values (0-1) depending of the underlying buffer type.
  89062. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89063. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89064. * @param buffer defines a user defined buffer to fill with data (can be null)
  89065. * @returns The Array buffer containing the pixels data.
  89066. */
  89067. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89068. /**
  89069. * Release and destroy the underlying lower level texture aka internalTexture.
  89070. */
  89071. releaseInternalTexture(): void;
  89072. /**
  89073. * Get the polynomial representation of the texture data.
  89074. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  89075. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  89076. */
  89077. sphericalPolynomial: Nullable<SphericalPolynomial>;
  89078. /** @hidden */
  89079. readonly _lodTextureHigh: Nullable<BaseTexture>;
  89080. /** @hidden */
  89081. readonly _lodTextureMid: Nullable<BaseTexture>;
  89082. /** @hidden */
  89083. readonly _lodTextureLow: Nullable<BaseTexture>;
  89084. /**
  89085. * Dispose the texture and release its associated resources.
  89086. */
  89087. dispose(): void;
  89088. /**
  89089. * Serialize the texture into a JSON representation that can be parsed later on.
  89090. * @returns the JSON representation of the texture
  89091. */
  89092. serialize(): any;
  89093. /**
  89094. * Helper function to be called back once a list of texture contains only ready textures.
  89095. * @param textures Define the list of textures to wait for
  89096. * @param callback Define the callback triggered once the entire list will be ready
  89097. */
  89098. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89099. }
  89100. }
  89101. declare module BABYLON {
  89102. /**
  89103. * Uniform buffer objects.
  89104. *
  89105. * Handles blocks of uniform on the GPU.
  89106. *
  89107. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89108. *
  89109. * For more information, please refer to :
  89110. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89111. */
  89112. export class UniformBuffer {
  89113. private _engine;
  89114. private _buffer;
  89115. private _data;
  89116. private _bufferData;
  89117. private _dynamic?;
  89118. private _uniformLocations;
  89119. private _uniformSizes;
  89120. private _uniformLocationPointer;
  89121. private _needSync;
  89122. private _noUBO;
  89123. private _currentEffect;
  89124. private static _MAX_UNIFORM_SIZE;
  89125. private static _tempBuffer;
  89126. /**
  89127. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89128. * This is dynamic to allow compat with webgl 1 and 2.
  89129. * You will need to pass the name of the uniform as well as the value.
  89130. */
  89131. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89132. /**
  89133. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89134. * This is dynamic to allow compat with webgl 1 and 2.
  89135. * You will need to pass the name of the uniform as well as the value.
  89136. */
  89137. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89138. /**
  89139. * Lambda to Update a single float in a uniform buffer.
  89140. * This is dynamic to allow compat with webgl 1 and 2.
  89141. * You will need to pass the name of the uniform as well as the value.
  89142. */
  89143. updateFloat: (name: string, x: number) => void;
  89144. /**
  89145. * Lambda to Update a vec2 of float in a uniform buffer.
  89146. * This is dynamic to allow compat with webgl 1 and 2.
  89147. * You will need to pass the name of the uniform as well as the value.
  89148. */
  89149. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89150. /**
  89151. * Lambda to Update a vec3 of float in a uniform buffer.
  89152. * This is dynamic to allow compat with webgl 1 and 2.
  89153. * You will need to pass the name of the uniform as well as the value.
  89154. */
  89155. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89156. /**
  89157. * Lambda to Update a vec4 of float in a uniform buffer.
  89158. * This is dynamic to allow compat with webgl 1 and 2.
  89159. * You will need to pass the name of the uniform as well as the value.
  89160. */
  89161. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89162. /**
  89163. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89164. * This is dynamic to allow compat with webgl 1 and 2.
  89165. * You will need to pass the name of the uniform as well as the value.
  89166. */
  89167. updateMatrix: (name: string, mat: Matrix) => void;
  89168. /**
  89169. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89170. * This is dynamic to allow compat with webgl 1 and 2.
  89171. * You will need to pass the name of the uniform as well as the value.
  89172. */
  89173. updateVector3: (name: string, vector: Vector3) => void;
  89174. /**
  89175. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89176. * This is dynamic to allow compat with webgl 1 and 2.
  89177. * You will need to pass the name of the uniform as well as the value.
  89178. */
  89179. updateVector4: (name: string, vector: Vector4) => void;
  89180. /**
  89181. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89182. * This is dynamic to allow compat with webgl 1 and 2.
  89183. * You will need to pass the name of the uniform as well as the value.
  89184. */
  89185. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89186. /**
  89187. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89188. * This is dynamic to allow compat with webgl 1 and 2.
  89189. * You will need to pass the name of the uniform as well as the value.
  89190. */
  89191. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89192. /**
  89193. * Instantiates a new Uniform buffer objects.
  89194. *
  89195. * Handles blocks of uniform on the GPU.
  89196. *
  89197. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89198. *
  89199. * For more information, please refer to :
  89200. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89201. * @param engine Define the engine the buffer is associated with
  89202. * @param data Define the data contained in the buffer
  89203. * @param dynamic Define if the buffer is updatable
  89204. */
  89205. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89206. /**
  89207. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89208. * or just falling back on setUniformXXX calls.
  89209. */
  89210. readonly useUbo: boolean;
  89211. /**
  89212. * Indicates if the WebGL underlying uniform buffer is in sync
  89213. * with the javascript cache data.
  89214. */
  89215. readonly isSync: boolean;
  89216. /**
  89217. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89218. * Also, a dynamic UniformBuffer will disable cache verification and always
  89219. * update the underlying WebGL uniform buffer to the GPU.
  89220. * @returns if Dynamic, otherwise false
  89221. */
  89222. isDynamic(): boolean;
  89223. /**
  89224. * The data cache on JS side.
  89225. * @returns the underlying data as a float array
  89226. */
  89227. getData(): Float32Array;
  89228. /**
  89229. * The underlying WebGL Uniform buffer.
  89230. * @returns the webgl buffer
  89231. */
  89232. getBuffer(): Nullable<DataBuffer>;
  89233. /**
  89234. * std140 layout specifies how to align data within an UBO structure.
  89235. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89236. * for specs.
  89237. */
  89238. private _fillAlignment;
  89239. /**
  89240. * Adds an uniform in the buffer.
  89241. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89242. * for the layout to be correct !
  89243. * @param name Name of the uniform, as used in the uniform block in the shader.
  89244. * @param size Data size, or data directly.
  89245. */
  89246. addUniform(name: string, size: number | number[]): void;
  89247. /**
  89248. * Adds a Matrix 4x4 to the uniform buffer.
  89249. * @param name Name of the uniform, as used in the uniform block in the shader.
  89250. * @param mat A 4x4 matrix.
  89251. */
  89252. addMatrix(name: string, mat: Matrix): void;
  89253. /**
  89254. * Adds a vec2 to the uniform buffer.
  89255. * @param name Name of the uniform, as used in the uniform block in the shader.
  89256. * @param x Define the x component value of the vec2
  89257. * @param y Define the y component value of the vec2
  89258. */
  89259. addFloat2(name: string, x: number, y: number): void;
  89260. /**
  89261. * Adds a vec3 to the uniform buffer.
  89262. * @param name Name of the uniform, as used in the uniform block in the shader.
  89263. * @param x Define the x component value of the vec3
  89264. * @param y Define the y component value of the vec3
  89265. * @param z Define the z component value of the vec3
  89266. */
  89267. addFloat3(name: string, x: number, y: number, z: number): void;
  89268. /**
  89269. * Adds a vec3 to the uniform buffer.
  89270. * @param name Name of the uniform, as used in the uniform block in the shader.
  89271. * @param color Define the vec3 from a Color
  89272. */
  89273. addColor3(name: string, color: Color3): void;
  89274. /**
  89275. * Adds a vec4 to the uniform buffer.
  89276. * @param name Name of the uniform, as used in the uniform block in the shader.
  89277. * @param color Define the rgb components from a Color
  89278. * @param alpha Define the a component of the vec4
  89279. */
  89280. addColor4(name: string, color: Color3, alpha: number): void;
  89281. /**
  89282. * Adds a vec3 to the uniform buffer.
  89283. * @param name Name of the uniform, as used in the uniform block in the shader.
  89284. * @param vector Define the vec3 components from a Vector
  89285. */
  89286. addVector3(name: string, vector: Vector3): void;
  89287. /**
  89288. * Adds a Matrix 3x3 to the uniform buffer.
  89289. * @param name Name of the uniform, as used in the uniform block in the shader.
  89290. */
  89291. addMatrix3x3(name: string): void;
  89292. /**
  89293. * Adds a Matrix 2x2 to the uniform buffer.
  89294. * @param name Name of the uniform, as used in the uniform block in the shader.
  89295. */
  89296. addMatrix2x2(name: string): void;
  89297. /**
  89298. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89299. */
  89300. create(): void;
  89301. /** @hidden */
  89302. _rebuild(): void;
  89303. /**
  89304. * Updates the WebGL Uniform Buffer on the GPU.
  89305. * If the `dynamic` flag is set to true, no cache comparison is done.
  89306. * Otherwise, the buffer will be updated only if the cache differs.
  89307. */
  89308. update(): void;
  89309. /**
  89310. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89311. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89312. * @param data Define the flattened data
  89313. * @param size Define the size of the data.
  89314. */
  89315. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89316. private _updateMatrix3x3ForUniform;
  89317. private _updateMatrix3x3ForEffect;
  89318. private _updateMatrix2x2ForEffect;
  89319. private _updateMatrix2x2ForUniform;
  89320. private _updateFloatForEffect;
  89321. private _updateFloatForUniform;
  89322. private _updateFloat2ForEffect;
  89323. private _updateFloat2ForUniform;
  89324. private _updateFloat3ForEffect;
  89325. private _updateFloat3ForUniform;
  89326. private _updateFloat4ForEffect;
  89327. private _updateFloat4ForUniform;
  89328. private _updateMatrixForEffect;
  89329. private _updateMatrixForUniform;
  89330. private _updateVector3ForEffect;
  89331. private _updateVector3ForUniform;
  89332. private _updateVector4ForEffect;
  89333. private _updateVector4ForUniform;
  89334. private _updateColor3ForEffect;
  89335. private _updateColor3ForUniform;
  89336. private _updateColor4ForEffect;
  89337. private _updateColor4ForUniform;
  89338. /**
  89339. * Sets a sampler uniform on the effect.
  89340. * @param name Define the name of the sampler.
  89341. * @param texture Define the texture to set in the sampler
  89342. */
  89343. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89344. /**
  89345. * Directly updates the value of the uniform in the cache AND on the GPU.
  89346. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89347. * @param data Define the flattened data
  89348. */
  89349. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89350. /**
  89351. * Binds this uniform buffer to an effect.
  89352. * @param effect Define the effect to bind the buffer to
  89353. * @param name Name of the uniform block in the shader.
  89354. */
  89355. bindToEffect(effect: Effect, name: string): void;
  89356. /**
  89357. * Disposes the uniform buffer.
  89358. */
  89359. dispose(): void;
  89360. }
  89361. }
  89362. declare module BABYLON {
  89363. /**
  89364. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89365. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89366. */
  89367. export class Analyser {
  89368. /**
  89369. * Gets or sets the smoothing
  89370. * @ignorenaming
  89371. */
  89372. SMOOTHING: number;
  89373. /**
  89374. * Gets or sets the FFT table size
  89375. * @ignorenaming
  89376. */
  89377. FFT_SIZE: number;
  89378. /**
  89379. * Gets or sets the bar graph amplitude
  89380. * @ignorenaming
  89381. */
  89382. BARGRAPHAMPLITUDE: number;
  89383. /**
  89384. * Gets or sets the position of the debug canvas
  89385. * @ignorenaming
  89386. */
  89387. DEBUGCANVASPOS: {
  89388. x: number;
  89389. y: number;
  89390. };
  89391. /**
  89392. * Gets or sets the debug canvas size
  89393. * @ignorenaming
  89394. */
  89395. DEBUGCANVASSIZE: {
  89396. width: number;
  89397. height: number;
  89398. };
  89399. private _byteFreqs;
  89400. private _byteTime;
  89401. private _floatFreqs;
  89402. private _webAudioAnalyser;
  89403. private _debugCanvas;
  89404. private _debugCanvasContext;
  89405. private _scene;
  89406. private _registerFunc;
  89407. private _audioEngine;
  89408. /**
  89409. * Creates a new analyser
  89410. * @param scene defines hosting scene
  89411. */
  89412. constructor(scene: Scene);
  89413. /**
  89414. * Get the number of data values you will have to play with for the visualization
  89415. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89416. * @returns a number
  89417. */
  89418. getFrequencyBinCount(): number;
  89419. /**
  89420. * Gets the current frequency data as a byte array
  89421. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89422. * @returns a Uint8Array
  89423. */
  89424. getByteFrequencyData(): Uint8Array;
  89425. /**
  89426. * Gets the current waveform as a byte array
  89427. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89428. * @returns a Uint8Array
  89429. */
  89430. getByteTimeDomainData(): Uint8Array;
  89431. /**
  89432. * Gets the current frequency data as a float array
  89433. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89434. * @returns a Float32Array
  89435. */
  89436. getFloatFrequencyData(): Float32Array;
  89437. /**
  89438. * Renders the debug canvas
  89439. */
  89440. drawDebugCanvas(): void;
  89441. /**
  89442. * Stops rendering the debug canvas and removes it
  89443. */
  89444. stopDebugCanvas(): void;
  89445. /**
  89446. * Connects two audio nodes
  89447. * @param inputAudioNode defines first node to connect
  89448. * @param outputAudioNode defines second node to connect
  89449. */
  89450. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89451. /**
  89452. * Releases all associated resources
  89453. */
  89454. dispose(): void;
  89455. }
  89456. }
  89457. declare module BABYLON {
  89458. /**
  89459. * This represents an audio engine and it is responsible
  89460. * to play, synchronize and analyse sounds throughout the application.
  89461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89462. */
  89463. export interface IAudioEngine extends IDisposable {
  89464. /**
  89465. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89466. */
  89467. readonly canUseWebAudio: boolean;
  89468. /**
  89469. * Gets the current AudioContext if available.
  89470. */
  89471. readonly audioContext: Nullable<AudioContext>;
  89472. /**
  89473. * The master gain node defines the global audio volume of your audio engine.
  89474. */
  89475. readonly masterGain: GainNode;
  89476. /**
  89477. * Gets whether or not mp3 are supported by your browser.
  89478. */
  89479. readonly isMP3supported: boolean;
  89480. /**
  89481. * Gets whether or not ogg are supported by your browser.
  89482. */
  89483. readonly isOGGsupported: boolean;
  89484. /**
  89485. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89486. * @ignoreNaming
  89487. */
  89488. WarnedWebAudioUnsupported: boolean;
  89489. /**
  89490. * Defines if the audio engine relies on a custom unlocked button.
  89491. * In this case, the embedded button will not be displayed.
  89492. */
  89493. useCustomUnlockedButton: boolean;
  89494. /**
  89495. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89496. */
  89497. readonly unlocked: boolean;
  89498. /**
  89499. * Event raised when audio has been unlocked on the browser.
  89500. */
  89501. onAudioUnlockedObservable: Observable<AudioEngine>;
  89502. /**
  89503. * Event raised when audio has been locked on the browser.
  89504. */
  89505. onAudioLockedObservable: Observable<AudioEngine>;
  89506. /**
  89507. * Flags the audio engine in Locked state.
  89508. * This happens due to new browser policies preventing audio to autoplay.
  89509. */
  89510. lock(): void;
  89511. /**
  89512. * Unlocks the audio engine once a user action has been done on the dom.
  89513. * This is helpful to resume play once browser policies have been satisfied.
  89514. */
  89515. unlock(): void;
  89516. }
  89517. /**
  89518. * This represents the default audio engine used in babylon.
  89519. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89521. */
  89522. export class AudioEngine implements IAudioEngine {
  89523. private _audioContext;
  89524. private _audioContextInitialized;
  89525. private _muteButton;
  89526. private _hostElement;
  89527. /**
  89528. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89529. */
  89530. canUseWebAudio: boolean;
  89531. /**
  89532. * The master gain node defines the global audio volume of your audio engine.
  89533. */
  89534. masterGain: GainNode;
  89535. /**
  89536. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89537. * @ignoreNaming
  89538. */
  89539. WarnedWebAudioUnsupported: boolean;
  89540. /**
  89541. * Gets whether or not mp3 are supported by your browser.
  89542. */
  89543. isMP3supported: boolean;
  89544. /**
  89545. * Gets whether or not ogg are supported by your browser.
  89546. */
  89547. isOGGsupported: boolean;
  89548. /**
  89549. * Gets whether audio has been unlocked on the device.
  89550. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  89551. * a user interaction has happened.
  89552. */
  89553. unlocked: boolean;
  89554. /**
  89555. * Defines if the audio engine relies on a custom unlocked button.
  89556. * In this case, the embedded button will not be displayed.
  89557. */
  89558. useCustomUnlockedButton: boolean;
  89559. /**
  89560. * Event raised when audio has been unlocked on the browser.
  89561. */
  89562. onAudioUnlockedObservable: Observable<AudioEngine>;
  89563. /**
  89564. * Event raised when audio has been locked on the browser.
  89565. */
  89566. onAudioLockedObservable: Observable<AudioEngine>;
  89567. /**
  89568. * Gets the current AudioContext if available.
  89569. */
  89570. readonly audioContext: Nullable<AudioContext>;
  89571. private _connectedAnalyser;
  89572. /**
  89573. * Instantiates a new audio engine.
  89574. *
  89575. * There should be only one per page as some browsers restrict the number
  89576. * of audio contexts you can create.
  89577. * @param hostElement defines the host element where to display the mute icon if necessary
  89578. */
  89579. constructor(hostElement?: Nullable<HTMLElement>);
  89580. /**
  89581. * Flags the audio engine in Locked state.
  89582. * This happens due to new browser policies preventing audio to autoplay.
  89583. */
  89584. lock(): void;
  89585. /**
  89586. * Unlocks the audio engine once a user action has been done on the dom.
  89587. * This is helpful to resume play once browser policies have been satisfied.
  89588. */
  89589. unlock(): void;
  89590. private _resumeAudioContext;
  89591. private _initializeAudioContext;
  89592. private _tryToRun;
  89593. private _triggerRunningState;
  89594. private _triggerSuspendedState;
  89595. private _displayMuteButton;
  89596. private _moveButtonToTopLeft;
  89597. private _onResize;
  89598. private _hideMuteButton;
  89599. /**
  89600. * Destroy and release the resources associated with the audio ccontext.
  89601. */
  89602. dispose(): void;
  89603. /**
  89604. * Gets the global volume sets on the master gain.
  89605. * @returns the global volume if set or -1 otherwise
  89606. */
  89607. getGlobalVolume(): number;
  89608. /**
  89609. * Sets the global volume of your experience (sets on the master gain).
  89610. * @param newVolume Defines the new global volume of the application
  89611. */
  89612. setGlobalVolume(newVolume: number): void;
  89613. /**
  89614. * Connect the audio engine to an audio analyser allowing some amazing
  89615. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89616. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89617. * @param analyser The analyser to connect to the engine
  89618. */
  89619. connectToAnalyser(analyser: Analyser): void;
  89620. }
  89621. }
  89622. declare module BABYLON {
  89623. /**
  89624. * Interface used to present a loading screen while loading a scene
  89625. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89626. */
  89627. export interface ILoadingScreen {
  89628. /**
  89629. * Function called to display the loading screen
  89630. */
  89631. displayLoadingUI: () => void;
  89632. /**
  89633. * Function called to hide the loading screen
  89634. */
  89635. hideLoadingUI: () => void;
  89636. /**
  89637. * Gets or sets the color to use for the background
  89638. */
  89639. loadingUIBackgroundColor: string;
  89640. /**
  89641. * Gets or sets the text to display while loading
  89642. */
  89643. loadingUIText: string;
  89644. }
  89645. /**
  89646. * Class used for the default loading screen
  89647. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89648. */
  89649. export class DefaultLoadingScreen implements ILoadingScreen {
  89650. private _renderingCanvas;
  89651. private _loadingText;
  89652. private _loadingDivBackgroundColor;
  89653. private _loadingDiv;
  89654. private _loadingTextDiv;
  89655. /** Gets or sets the logo url to use for the default loading screen */
  89656. static DefaultLogoUrl: string;
  89657. /** Gets or sets the spinner url to use for the default loading screen */
  89658. static DefaultSpinnerUrl: string;
  89659. /**
  89660. * Creates a new default loading screen
  89661. * @param _renderingCanvas defines the canvas used to render the scene
  89662. * @param _loadingText defines the default text to display
  89663. * @param _loadingDivBackgroundColor defines the default background color
  89664. */
  89665. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  89666. /**
  89667. * Function called to display the loading screen
  89668. */
  89669. displayLoadingUI(): void;
  89670. /**
  89671. * Function called to hide the loading screen
  89672. */
  89673. hideLoadingUI(): void;
  89674. /**
  89675. * Gets or sets the text to display while loading
  89676. */
  89677. loadingUIText: string;
  89678. /**
  89679. * Gets or sets the color to use for the background
  89680. */
  89681. loadingUIBackgroundColor: string;
  89682. private _resizeLoadingUI;
  89683. }
  89684. }
  89685. declare module BABYLON {
  89686. /** @hidden */
  89687. export class WebGLPipelineContext implements IPipelineContext {
  89688. engine: Engine;
  89689. program: Nullable<WebGLProgram>;
  89690. context?: WebGLRenderingContext;
  89691. vertexShader?: WebGLShader;
  89692. fragmentShader?: WebGLShader;
  89693. isParallelCompiled: boolean;
  89694. onCompiled?: () => void;
  89695. transformFeedback?: WebGLTransformFeedback | null;
  89696. readonly isAsync: boolean;
  89697. readonly isReady: boolean;
  89698. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89699. }
  89700. }
  89701. declare module BABYLON {
  89702. /** @hidden */
  89703. export class WebGLDataBuffer extends DataBuffer {
  89704. private _buffer;
  89705. constructor(resource: WebGLBuffer);
  89706. readonly underlyingResource: any;
  89707. }
  89708. }
  89709. declare module BABYLON {
  89710. /** @hidden */
  89711. export class WebGL2ShaderProcessor implements IShaderProcessor {
  89712. attributeProcessor(attribute: string): string;
  89713. varyingProcessor(varying: string, isFragment: boolean): string;
  89714. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  89715. }
  89716. }
  89717. declare module BABYLON {
  89718. /**
  89719. * Settings for finer control over video usage
  89720. */
  89721. export interface VideoTextureSettings {
  89722. /**
  89723. * Applies `autoplay` to video, if specified
  89724. */
  89725. autoPlay?: boolean;
  89726. /**
  89727. * Applies `loop` to video, if specified
  89728. */
  89729. loop?: boolean;
  89730. /**
  89731. * Automatically updates internal texture from video at every frame in the render loop
  89732. */
  89733. autoUpdateTexture: boolean;
  89734. /**
  89735. * Image src displayed during the video loading or until the user interacts with the video.
  89736. */
  89737. poster?: string;
  89738. }
  89739. /**
  89740. * If you want to display a video in your scene, this is the special texture for that.
  89741. * This special texture works similar to other textures, with the exception of a few parameters.
  89742. * @see https://doc.babylonjs.com/how_to/video_texture
  89743. */
  89744. export class VideoTexture extends Texture {
  89745. /**
  89746. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  89747. */
  89748. readonly autoUpdateTexture: boolean;
  89749. /**
  89750. * The video instance used by the texture internally
  89751. */
  89752. readonly video: HTMLVideoElement;
  89753. private _onUserActionRequestedObservable;
  89754. /**
  89755. * Event triggerd when a dom action is required by the user to play the video.
  89756. * This happens due to recent changes in browser policies preventing video to auto start.
  89757. */
  89758. readonly onUserActionRequestedObservable: Observable<Texture>;
  89759. private _generateMipMaps;
  89760. private _engine;
  89761. private _stillImageCaptured;
  89762. private _displayingPosterTexture;
  89763. private _settings;
  89764. private _createInternalTextureOnEvent;
  89765. /**
  89766. * Creates a video texture.
  89767. * If you want to display a video in your scene, this is the special texture for that.
  89768. * This special texture works similar to other textures, with the exception of a few parameters.
  89769. * @see https://doc.babylonjs.com/how_to/video_texture
  89770. * @param name optional name, will detect from video source, if not defined
  89771. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  89772. * @param scene is obviously the current scene.
  89773. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  89774. * @param invertY is false by default but can be used to invert video on Y axis
  89775. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  89776. * @param settings allows finer control over video usage
  89777. */
  89778. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  89779. private _getName;
  89780. private _getVideo;
  89781. private _createInternalTexture;
  89782. private reset;
  89783. /**
  89784. * @hidden Internal method to initiate `update`.
  89785. */
  89786. _rebuild(): void;
  89787. /**
  89788. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  89789. */
  89790. update(): void;
  89791. /**
  89792. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  89793. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  89794. */
  89795. updateTexture(isVisible: boolean): void;
  89796. protected _updateInternalTexture: () => void;
  89797. /**
  89798. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  89799. * @param url New url.
  89800. */
  89801. updateURL(url: string): void;
  89802. /**
  89803. * Dispose the texture and release its associated resources.
  89804. */
  89805. dispose(): void;
  89806. /**
  89807. * Creates a video texture straight from a stream.
  89808. * @param scene Define the scene the texture should be created in
  89809. * @param stream Define the stream the texture should be created from
  89810. * @returns The created video texture as a promise
  89811. */
  89812. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  89813. /**
  89814. * Creates a video texture straight from your WebCam video feed.
  89815. * @param scene Define the scene the texture should be created in
  89816. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89817. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89818. * @returns The created video texture as a promise
  89819. */
  89820. static CreateFromWebCamAsync(scene: Scene, constraints: {
  89821. minWidth: number;
  89822. maxWidth: number;
  89823. minHeight: number;
  89824. maxHeight: number;
  89825. deviceId: string;
  89826. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  89827. /**
  89828. * Creates a video texture straight from your WebCam video feed.
  89829. * @param scene Define the scene the texture should be created in
  89830. * @param onReady Define a callback to triggered once the texture will be ready
  89831. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89832. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89833. */
  89834. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  89835. minWidth: number;
  89836. maxWidth: number;
  89837. minHeight: number;
  89838. maxHeight: number;
  89839. deviceId: string;
  89840. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  89841. }
  89842. }
  89843. declare module BABYLON {
  89844. /**
  89845. * Interface for attribute information associated with buffer instanciation
  89846. */
  89847. export class InstancingAttributeInfo {
  89848. /**
  89849. * Index/offset of the attribute in the vertex shader
  89850. */
  89851. index: number;
  89852. /**
  89853. * size of the attribute, 1, 2, 3 or 4
  89854. */
  89855. attributeSize: number;
  89856. /**
  89857. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  89858. * default is FLOAT
  89859. */
  89860. attribyteType: number;
  89861. /**
  89862. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  89863. */
  89864. normalized: boolean;
  89865. /**
  89866. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  89867. */
  89868. offset: number;
  89869. /**
  89870. * Name of the GLSL attribute, for debugging purpose only
  89871. */
  89872. attributeName: string;
  89873. }
  89874. /**
  89875. * Define options used to create a depth texture
  89876. */
  89877. export class DepthTextureCreationOptions {
  89878. /** Specifies whether or not a stencil should be allocated in the texture */
  89879. generateStencil?: boolean;
  89880. /** Specifies whether or not bilinear filtering is enable on the texture */
  89881. bilinearFiltering?: boolean;
  89882. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  89883. comparisonFunction?: number;
  89884. /** Specifies if the created texture is a cube texture */
  89885. isCube?: boolean;
  89886. }
  89887. /**
  89888. * Class used to describe the capabilities of the engine relatively to the current browser
  89889. */
  89890. export class EngineCapabilities {
  89891. /** Maximum textures units per fragment shader */
  89892. maxTexturesImageUnits: number;
  89893. /** Maximum texture units per vertex shader */
  89894. maxVertexTextureImageUnits: number;
  89895. /** Maximum textures units in the entire pipeline */
  89896. maxCombinedTexturesImageUnits: number;
  89897. /** Maximum texture size */
  89898. maxTextureSize: number;
  89899. /** Maximum cube texture size */
  89900. maxCubemapTextureSize: number;
  89901. /** Maximum render texture size */
  89902. maxRenderTextureSize: number;
  89903. /** Maximum number of vertex attributes */
  89904. maxVertexAttribs: number;
  89905. /** Maximum number of varyings */
  89906. maxVaryingVectors: number;
  89907. /** Maximum number of uniforms per vertex shader */
  89908. maxVertexUniformVectors: number;
  89909. /** Maximum number of uniforms per fragment shader */
  89910. maxFragmentUniformVectors: number;
  89911. /** Defines if standard derivates (dx/dy) are supported */
  89912. standardDerivatives: boolean;
  89913. /** Defines if s3tc texture compression is supported */
  89914. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  89915. /** Defines if pvrtc texture compression is supported */
  89916. pvrtc: any;
  89917. /** Defines if etc1 texture compression is supported */
  89918. etc1: any;
  89919. /** Defines if etc2 texture compression is supported */
  89920. etc2: any;
  89921. /** Defines if astc texture compression is supported */
  89922. astc: any;
  89923. /** Defines if float textures are supported */
  89924. textureFloat: boolean;
  89925. /** Defines if vertex array objects are supported */
  89926. vertexArrayObject: boolean;
  89927. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  89928. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  89929. /** Gets the maximum level of anisotropy supported */
  89930. maxAnisotropy: number;
  89931. /** Defines if instancing is supported */
  89932. instancedArrays: boolean;
  89933. /** Defines if 32 bits indices are supported */
  89934. uintIndices: boolean;
  89935. /** Defines if high precision shaders are supported */
  89936. highPrecisionShaderSupported: boolean;
  89937. /** Defines if depth reading in the fragment shader is supported */
  89938. fragmentDepthSupported: boolean;
  89939. /** Defines if float texture linear filtering is supported*/
  89940. textureFloatLinearFiltering: boolean;
  89941. /** Defines if rendering to float textures is supported */
  89942. textureFloatRender: boolean;
  89943. /** Defines if half float textures are supported*/
  89944. textureHalfFloat: boolean;
  89945. /** Defines if half float texture linear filtering is supported*/
  89946. textureHalfFloatLinearFiltering: boolean;
  89947. /** Defines if rendering to half float textures is supported */
  89948. textureHalfFloatRender: boolean;
  89949. /** Defines if textureLOD shader command is supported */
  89950. textureLOD: boolean;
  89951. /** Defines if draw buffers extension is supported */
  89952. drawBuffersExtension: boolean;
  89953. /** Defines if depth textures are supported */
  89954. depthTextureExtension: boolean;
  89955. /** Defines if float color buffer are supported */
  89956. colorBufferFloat: boolean;
  89957. /** Gets disjoint timer query extension (null if not supported) */
  89958. timerQuery: EXT_disjoint_timer_query;
  89959. /** Defines if timestamp can be used with timer query */
  89960. canUseTimestampForTimerQuery: boolean;
  89961. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  89962. multiview: any;
  89963. /** Function used to let the system compiles shaders in background */
  89964. parallelShaderCompile: {
  89965. COMPLETION_STATUS_KHR: number;
  89966. };
  89967. }
  89968. /** Interface defining initialization parameters for Engine class */
  89969. export interface EngineOptions extends WebGLContextAttributes {
  89970. /**
  89971. * Defines if the engine should no exceed a specified device ratio
  89972. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  89973. */
  89974. limitDeviceRatio?: number;
  89975. /**
  89976. * Defines if webvr should be enabled automatically
  89977. * @see http://doc.babylonjs.com/how_to/webvr_camera
  89978. */
  89979. autoEnableWebVR?: boolean;
  89980. /**
  89981. * Defines if webgl2 should be turned off even if supported
  89982. * @see http://doc.babylonjs.com/features/webgl2
  89983. */
  89984. disableWebGL2Support?: boolean;
  89985. /**
  89986. * Defines if webaudio should be initialized as well
  89987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89988. */
  89989. audioEngine?: boolean;
  89990. /**
  89991. * Defines if animations should run using a deterministic lock step
  89992. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89993. */
  89994. deterministicLockstep?: boolean;
  89995. /** Defines the maximum steps to use with deterministic lock step mode */
  89996. lockstepMaxSteps?: number;
  89997. /**
  89998. * Defines that engine should ignore context lost events
  89999. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  90000. */
  90001. doNotHandleContextLost?: boolean;
  90002. /**
  90003. * Defines that engine should ignore modifying touch action attribute and style
  90004. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  90005. */
  90006. doNotHandleTouchAction?: boolean;
  90007. /**
  90008. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  90009. */
  90010. useHighPrecisionFloats?: boolean;
  90011. }
  90012. /**
  90013. * Defines the interface used by display changed events
  90014. */
  90015. export interface IDisplayChangedEventArgs {
  90016. /** Gets the vrDisplay object (if any) */
  90017. vrDisplay: Nullable<any>;
  90018. /** Gets a boolean indicating if webVR is supported */
  90019. vrSupported: boolean;
  90020. }
  90021. /**
  90022. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  90023. */
  90024. export class Engine {
  90025. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  90026. static ExceptionList: ({
  90027. key: string;
  90028. capture: string;
  90029. captureConstraint: number;
  90030. targets: string[];
  90031. } | {
  90032. key: string;
  90033. capture: null;
  90034. captureConstraint: null;
  90035. targets: string[];
  90036. })[];
  90037. /** Gets the list of created engines */
  90038. static readonly Instances: Engine[];
  90039. /**
  90040. * Gets the latest created engine
  90041. */
  90042. static readonly LastCreatedEngine: Nullable<Engine>;
  90043. /**
  90044. * Gets the latest created scene
  90045. */
  90046. static readonly LastCreatedScene: Nullable<Scene>;
  90047. /**
  90048. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  90049. * @param flag defines which part of the materials must be marked as dirty
  90050. * @param predicate defines a predicate used to filter which materials should be affected
  90051. */
  90052. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90053. /** @hidden */
  90054. static _TextureLoaders: IInternalTextureLoader[];
  90055. /** Defines that alpha blending is disabled */
  90056. static readonly ALPHA_DISABLE: number;
  90057. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  90058. static readonly ALPHA_ADD: number;
  90059. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  90060. static readonly ALPHA_COMBINE: number;
  90061. /** Defines that alpha blending to DEST - SRC * DEST */
  90062. static readonly ALPHA_SUBTRACT: number;
  90063. /** Defines that alpha blending to SRC * DEST */
  90064. static readonly ALPHA_MULTIPLY: number;
  90065. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  90066. static readonly ALPHA_MAXIMIZED: number;
  90067. /** Defines that alpha blending to SRC + DEST */
  90068. static readonly ALPHA_ONEONE: number;
  90069. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  90070. static readonly ALPHA_PREMULTIPLIED: number;
  90071. /**
  90072. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  90073. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  90074. */
  90075. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  90076. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  90077. static readonly ALPHA_INTERPOLATE: number;
  90078. /**
  90079. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  90080. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  90081. */
  90082. static readonly ALPHA_SCREENMODE: number;
  90083. /** Defines that the ressource is not delayed*/
  90084. static readonly DELAYLOADSTATE_NONE: number;
  90085. /** Defines that the ressource was successfully delay loaded */
  90086. static readonly DELAYLOADSTATE_LOADED: number;
  90087. /** Defines that the ressource is currently delay loading */
  90088. static readonly DELAYLOADSTATE_LOADING: number;
  90089. /** Defines that the ressource is delayed and has not started loading */
  90090. static readonly DELAYLOADSTATE_NOTLOADED: number;
  90091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  90092. static readonly NEVER: number;
  90093. /** 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 */
  90094. static readonly ALWAYS: number;
  90095. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  90096. static readonly LESS: number;
  90097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  90098. static readonly EQUAL: number;
  90099. /** 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 */
  90100. static readonly LEQUAL: number;
  90101. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  90102. static readonly GREATER: number;
  90103. /** 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 */
  90104. static readonly GEQUAL: number;
  90105. /** 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 */
  90106. static readonly NOTEQUAL: number;
  90107. /** Passed to stencilOperation to specify that stencil value must be kept */
  90108. static readonly KEEP: number;
  90109. /** Passed to stencilOperation to specify that stencil value must be replaced */
  90110. static readonly REPLACE: number;
  90111. /** Passed to stencilOperation to specify that stencil value must be incremented */
  90112. static readonly INCR: number;
  90113. /** Passed to stencilOperation to specify that stencil value must be decremented */
  90114. static readonly DECR: number;
  90115. /** Passed to stencilOperation to specify that stencil value must be inverted */
  90116. static readonly INVERT: number;
  90117. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  90118. static readonly INCR_WRAP: number;
  90119. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  90120. static readonly DECR_WRAP: number;
  90121. /** Texture is not repeating outside of 0..1 UVs */
  90122. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  90123. /** Texture is repeating outside of 0..1 UVs */
  90124. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  90125. /** Texture is repeating and mirrored */
  90126. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  90127. /** ALPHA */
  90128. static readonly TEXTUREFORMAT_ALPHA: number;
  90129. /** LUMINANCE */
  90130. static readonly TEXTUREFORMAT_LUMINANCE: number;
  90131. /** LUMINANCE_ALPHA */
  90132. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  90133. /** RGB */
  90134. static readonly TEXTUREFORMAT_RGB: number;
  90135. /** RGBA */
  90136. static readonly TEXTUREFORMAT_RGBA: number;
  90137. /** RED */
  90138. static readonly TEXTUREFORMAT_RED: number;
  90139. /** RED (2nd reference) */
  90140. static readonly TEXTUREFORMAT_R: number;
  90141. /** RG */
  90142. static readonly TEXTUREFORMAT_RG: number;
  90143. /** RED_INTEGER */
  90144. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  90145. /** RED_INTEGER (2nd reference) */
  90146. static readonly TEXTUREFORMAT_R_INTEGER: number;
  90147. /** RG_INTEGER */
  90148. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  90149. /** RGB_INTEGER */
  90150. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  90151. /** RGBA_INTEGER */
  90152. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  90153. /** UNSIGNED_BYTE */
  90154. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  90155. /** UNSIGNED_BYTE (2nd reference) */
  90156. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  90157. /** FLOAT */
  90158. static readonly TEXTURETYPE_FLOAT: number;
  90159. /** HALF_FLOAT */
  90160. static readonly TEXTURETYPE_HALF_FLOAT: number;
  90161. /** BYTE */
  90162. static readonly TEXTURETYPE_BYTE: number;
  90163. /** SHORT */
  90164. static readonly TEXTURETYPE_SHORT: number;
  90165. /** UNSIGNED_SHORT */
  90166. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  90167. /** INT */
  90168. static readonly TEXTURETYPE_INT: number;
  90169. /** UNSIGNED_INT */
  90170. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  90171. /** UNSIGNED_SHORT_4_4_4_4 */
  90172. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  90173. /** UNSIGNED_SHORT_5_5_5_1 */
  90174. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  90175. /** UNSIGNED_SHORT_5_6_5 */
  90176. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  90177. /** UNSIGNED_INT_2_10_10_10_REV */
  90178. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  90179. /** UNSIGNED_INT_24_8 */
  90180. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  90181. /** UNSIGNED_INT_10F_11F_11F_REV */
  90182. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  90183. /** UNSIGNED_INT_5_9_9_9_REV */
  90184. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  90185. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  90186. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  90187. /** nearest is mag = nearest and min = nearest and mip = linear */
  90188. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  90189. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90190. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  90191. /** Trilinear is mag = linear and min = linear and mip = linear */
  90192. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  90193. /** nearest is mag = nearest and min = nearest and mip = linear */
  90194. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  90195. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90196. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  90197. /** Trilinear is mag = linear and min = linear and mip = linear */
  90198. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  90199. /** mag = nearest and min = nearest and mip = nearest */
  90200. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  90201. /** mag = nearest and min = linear and mip = nearest */
  90202. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  90203. /** mag = nearest and min = linear and mip = linear */
  90204. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  90205. /** mag = nearest and min = linear and mip = none */
  90206. static readonly TEXTURE_NEAREST_LINEAR: number;
  90207. /** mag = nearest and min = nearest and mip = none */
  90208. static readonly TEXTURE_NEAREST_NEAREST: number;
  90209. /** mag = linear and min = nearest and mip = nearest */
  90210. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  90211. /** mag = linear and min = nearest and mip = linear */
  90212. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  90213. /** mag = linear and min = linear and mip = none */
  90214. static readonly TEXTURE_LINEAR_LINEAR: number;
  90215. /** mag = linear and min = nearest and mip = none */
  90216. static readonly TEXTURE_LINEAR_NEAREST: number;
  90217. /** Explicit coordinates mode */
  90218. static readonly TEXTURE_EXPLICIT_MODE: number;
  90219. /** Spherical coordinates mode */
  90220. static readonly TEXTURE_SPHERICAL_MODE: number;
  90221. /** Planar coordinates mode */
  90222. static readonly TEXTURE_PLANAR_MODE: number;
  90223. /** Cubic coordinates mode */
  90224. static readonly TEXTURE_CUBIC_MODE: number;
  90225. /** Projection coordinates mode */
  90226. static readonly TEXTURE_PROJECTION_MODE: number;
  90227. /** Skybox coordinates mode */
  90228. static readonly TEXTURE_SKYBOX_MODE: number;
  90229. /** Inverse Cubic coordinates mode */
  90230. static readonly TEXTURE_INVCUBIC_MODE: number;
  90231. /** Equirectangular coordinates mode */
  90232. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  90233. /** Equirectangular Fixed coordinates mode */
  90234. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  90235. /** Equirectangular Fixed Mirrored coordinates mode */
  90236. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  90237. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  90238. static readonly SCALEMODE_FLOOR: number;
  90239. /** Defines that texture rescaling will look for the nearest power of 2 size */
  90240. static readonly SCALEMODE_NEAREST: number;
  90241. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  90242. static readonly SCALEMODE_CEILING: number;
  90243. /**
  90244. * Returns the current npm package of the sdk
  90245. */
  90246. static readonly NpmPackage: string;
  90247. /**
  90248. * Returns the current version of the framework
  90249. */
  90250. static readonly Version: string;
  90251. /**
  90252. * Returns a string describing the current engine
  90253. */
  90254. readonly description: string;
  90255. /**
  90256. * Gets or sets the epsilon value used by collision engine
  90257. */
  90258. static CollisionsEpsilon: number;
  90259. /**
  90260. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  90261. */
  90262. static ShadersRepository: string;
  90263. /**
  90264. * Method called to create the default loading screen.
  90265. * This can be overriden in your own app.
  90266. * @param canvas The rendering canvas element
  90267. * @returns The loading screen
  90268. */
  90269. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  90270. /**
  90271. * Method called to create the default rescale post process on each engine.
  90272. */
  90273. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  90274. /** @hidden */
  90275. _shaderProcessor: IShaderProcessor;
  90276. /**
  90277. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  90278. */
  90279. forcePOTTextures: boolean;
  90280. /**
  90281. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  90282. */
  90283. isFullscreen: boolean;
  90284. /**
  90285. * Gets a boolean indicating if the pointer is currently locked
  90286. */
  90287. isPointerLock: boolean;
  90288. /**
  90289. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  90290. */
  90291. cullBackFaces: boolean;
  90292. /**
  90293. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  90294. */
  90295. renderEvenInBackground: boolean;
  90296. /**
  90297. * Gets or sets a boolean indicating that cache can be kept between frames
  90298. */
  90299. preventCacheWipeBetweenFrames: boolean;
  90300. /**
  90301. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90302. **/
  90303. enableOfflineSupport: boolean;
  90304. /**
  90305. * 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)
  90306. **/
  90307. disableManifestCheck: boolean;
  90308. /**
  90309. * Gets the list of created scenes
  90310. */
  90311. scenes: Scene[];
  90312. /**
  90313. * Event raised when a new scene is created
  90314. */
  90315. onNewSceneAddedObservable: Observable<Scene>;
  90316. /**
  90317. * Gets the list of created postprocesses
  90318. */
  90319. postProcesses: PostProcess[];
  90320. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90321. validateShaderPrograms: boolean;
  90322. /**
  90323. * Observable event triggered each time the rendering canvas is resized
  90324. */
  90325. onResizeObservable: Observable<Engine>;
  90326. /**
  90327. * Observable event triggered each time the canvas loses focus
  90328. */
  90329. onCanvasBlurObservable: Observable<Engine>;
  90330. /**
  90331. * Observable event triggered each time the canvas gains focus
  90332. */
  90333. onCanvasFocusObservable: Observable<Engine>;
  90334. /**
  90335. * Observable event triggered each time the canvas receives pointerout event
  90336. */
  90337. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90338. /**
  90339. * Observable event triggered before each texture is initialized
  90340. */
  90341. onBeforeTextureInitObservable: Observable<Texture>;
  90342. /**
  90343. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90344. */
  90345. disableUniformBuffers: boolean;
  90346. /** @hidden */
  90347. _uniformBuffers: UniformBuffer[];
  90348. /**
  90349. * Gets a boolean indicating that the engine supports uniform buffers
  90350. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90351. */
  90352. readonly supportsUniformBuffers: boolean;
  90353. /**
  90354. * Observable raised when the engine begins a new frame
  90355. */
  90356. onBeginFrameObservable: Observable<Engine>;
  90357. /**
  90358. * If set, will be used to request the next animation frame for the render loop
  90359. */
  90360. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90361. /**
  90362. * Observable raised when the engine ends the current frame
  90363. */
  90364. onEndFrameObservable: Observable<Engine>;
  90365. /**
  90366. * Observable raised when the engine is about to compile a shader
  90367. */
  90368. onBeforeShaderCompilationObservable: Observable<Engine>;
  90369. /**
  90370. * Observable raised when the engine has jsut compiled a shader
  90371. */
  90372. onAfterShaderCompilationObservable: Observable<Engine>;
  90373. /** @hidden */
  90374. _gl: WebGLRenderingContext;
  90375. private _renderingCanvas;
  90376. private _windowIsBackground;
  90377. private _webGLVersion;
  90378. protected _highPrecisionShadersAllowed: boolean;
  90379. /** @hidden */
  90380. readonly _shouldUseHighPrecisionShader: boolean;
  90381. /**
  90382. * Gets a boolean indicating that only power of 2 textures are supported
  90383. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90384. */
  90385. readonly needPOTTextures: boolean;
  90386. /** @hidden */
  90387. _badOS: boolean;
  90388. /** @hidden */
  90389. _badDesktopOS: boolean;
  90390. /**
  90391. * Gets the audio engine
  90392. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90393. * @ignorenaming
  90394. */
  90395. static audioEngine: IAudioEngine;
  90396. /**
  90397. * Default AudioEngine factory responsible of creating the Audio Engine.
  90398. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90399. */
  90400. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90401. /**
  90402. * Default offline support factory responsible of creating a tool used to store data locally.
  90403. * By default, this will create a Database object if the workload has been embedded.
  90404. */
  90405. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90406. private _onFocus;
  90407. private _onBlur;
  90408. private _onCanvasPointerOut;
  90409. private _onCanvasBlur;
  90410. private _onCanvasFocus;
  90411. private _onFullscreenChange;
  90412. private _onPointerLockChange;
  90413. private _hardwareScalingLevel;
  90414. /** @hidden */
  90415. _caps: EngineCapabilities;
  90416. private _pointerLockRequested;
  90417. private _isStencilEnable;
  90418. private _colorWrite;
  90419. private _loadingScreen;
  90420. /** @hidden */
  90421. _drawCalls: PerfCounter;
  90422. private _glVersion;
  90423. private _glRenderer;
  90424. private _glVendor;
  90425. private _videoTextureSupported;
  90426. private _renderingQueueLaunched;
  90427. private _activeRenderLoops;
  90428. private _deterministicLockstep;
  90429. private _lockstepMaxSteps;
  90430. /**
  90431. * Observable signaled when a context lost event is raised
  90432. */
  90433. onContextLostObservable: Observable<Engine>;
  90434. /**
  90435. * Observable signaled when a context restored event is raised
  90436. */
  90437. onContextRestoredObservable: Observable<Engine>;
  90438. private _onContextLost;
  90439. private _onContextRestored;
  90440. private _contextWasLost;
  90441. /** @hidden */
  90442. _doNotHandleContextLost: boolean;
  90443. /**
  90444. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90445. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90446. */
  90447. doNotHandleContextLost: boolean;
  90448. private _performanceMonitor;
  90449. private _fps;
  90450. private _deltaTime;
  90451. /**
  90452. * Turn this value on if you want to pause FPS computation when in background
  90453. */
  90454. disablePerformanceMonitorInBackground: boolean;
  90455. /**
  90456. * Gets the performance monitor attached to this engine
  90457. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90458. */
  90459. readonly performanceMonitor: PerformanceMonitor;
  90460. /**
  90461. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90462. */
  90463. disableVertexArrayObjects: boolean;
  90464. /** @hidden */
  90465. protected _depthCullingState: _DepthCullingState;
  90466. /** @hidden */
  90467. protected _stencilState: _StencilState;
  90468. /** @hidden */
  90469. protected _alphaState: _AlphaState;
  90470. /** @hidden */
  90471. protected _alphaMode: number;
  90472. /** @hidden */
  90473. _internalTexturesCache: InternalTexture[];
  90474. /** @hidden */
  90475. protected _activeChannel: number;
  90476. private _currentTextureChannel;
  90477. /** @hidden */
  90478. protected _boundTexturesCache: {
  90479. [key: string]: Nullable<InternalTexture>;
  90480. };
  90481. /** @hidden */
  90482. protected _currentEffect: Nullable<Effect>;
  90483. /** @hidden */
  90484. protected _currentProgram: Nullable<WebGLProgram>;
  90485. private _compiledEffects;
  90486. private _vertexAttribArraysEnabled;
  90487. /** @hidden */
  90488. protected _cachedViewport: Nullable<Viewport>;
  90489. private _cachedVertexArrayObject;
  90490. /** @hidden */
  90491. protected _cachedVertexBuffers: any;
  90492. /** @hidden */
  90493. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90494. /** @hidden */
  90495. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90496. /** @hidden */
  90497. _currentRenderTarget: Nullable<InternalTexture>;
  90498. private _uintIndicesCurrentlySet;
  90499. private _currentBoundBuffer;
  90500. /** @hidden */
  90501. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90502. private _currentBufferPointers;
  90503. private _currentInstanceLocations;
  90504. private _currentInstanceBuffers;
  90505. private _textureUnits;
  90506. /** @hidden */
  90507. _workingCanvas: Nullable<HTMLCanvasElement>;
  90508. /** @hidden */
  90509. _workingContext: Nullable<CanvasRenderingContext2D>;
  90510. private _rescalePostProcess;
  90511. private _dummyFramebuffer;
  90512. private _externalData;
  90513. /** @hidden */
  90514. _bindedRenderFunction: any;
  90515. private _vaoRecordInProgress;
  90516. private _mustWipeVertexAttributes;
  90517. private _emptyTexture;
  90518. private _emptyCubeTexture;
  90519. private _emptyTexture3D;
  90520. /** @hidden */
  90521. _frameHandler: number;
  90522. private _nextFreeTextureSlots;
  90523. private _maxSimultaneousTextures;
  90524. private _activeRequests;
  90525. private _texturesSupported;
  90526. /** @hidden */
  90527. _textureFormatInUse: Nullable<string>;
  90528. /**
  90529. * Gets the list of texture formats supported
  90530. */
  90531. readonly texturesSupported: Array<string>;
  90532. /**
  90533. * Gets the list of texture formats in use
  90534. */
  90535. readonly textureFormatInUse: Nullable<string>;
  90536. /**
  90537. * Gets the current viewport
  90538. */
  90539. readonly currentViewport: Nullable<Viewport>;
  90540. /**
  90541. * Gets the default empty texture
  90542. */
  90543. readonly emptyTexture: InternalTexture;
  90544. /**
  90545. * Gets the default empty 3D texture
  90546. */
  90547. readonly emptyTexture3D: InternalTexture;
  90548. /**
  90549. * Gets the default empty cube texture
  90550. */
  90551. readonly emptyCubeTexture: InternalTexture;
  90552. /**
  90553. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  90554. */
  90555. readonly premultipliedAlpha: boolean;
  90556. /**
  90557. * Creates a new engine
  90558. * @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
  90559. * @param antialias defines enable antialiasing (default: false)
  90560. * @param options defines further options to be sent to the getContext() function
  90561. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  90562. */
  90563. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  90564. /**
  90565. * Initializes a webVR display and starts listening to display change events
  90566. * The onVRDisplayChangedObservable will be notified upon these changes
  90567. * @returns The onVRDisplayChangedObservable
  90568. */
  90569. initWebVR(): Observable<IDisplayChangedEventArgs>;
  90570. /** @hidden */
  90571. _prepareVRComponent(): void;
  90572. /** @hidden */
  90573. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  90574. /** @hidden */
  90575. _submitVRFrame(): void;
  90576. /**
  90577. * Call this function to leave webVR mode
  90578. * Will do nothing if webVR is not supported or if there is no webVR device
  90579. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90580. */
  90581. disableVR(): void;
  90582. /**
  90583. * Gets a boolean indicating that the system is in VR mode and is presenting
  90584. * @returns true if VR mode is engaged
  90585. */
  90586. isVRPresenting(): boolean;
  90587. /** @hidden */
  90588. _requestVRFrame(): void;
  90589. private _disableTouchAction;
  90590. private _rebuildInternalTextures;
  90591. private _rebuildEffects;
  90592. /**
  90593. * Gets a boolean indicating if all created effects are ready
  90594. * @returns true if all effects are ready
  90595. */
  90596. areAllEffectsReady(): boolean;
  90597. private _rebuildBuffers;
  90598. private _initGLContext;
  90599. /**
  90600. * Gets version of the current webGL context
  90601. */
  90602. readonly webGLVersion: number;
  90603. /**
  90604. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  90605. */
  90606. readonly isStencilEnable: boolean;
  90607. /** @hidden */
  90608. _prepareWorkingCanvas(): void;
  90609. /**
  90610. * Reset the texture cache to empty state
  90611. */
  90612. resetTextureCache(): void;
  90613. /**
  90614. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  90615. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90616. * @returns true if engine is in deterministic lock step mode
  90617. */
  90618. isDeterministicLockStep(): boolean;
  90619. /**
  90620. * Gets the max steps when engine is running in deterministic lock step
  90621. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90622. * @returns the max steps
  90623. */
  90624. getLockstepMaxSteps(): number;
  90625. /**
  90626. * Gets an object containing information about the current webGL context
  90627. * @returns an object containing the vender, the renderer and the version of the current webGL context
  90628. */
  90629. getGlInfo(): {
  90630. vendor: string;
  90631. renderer: string;
  90632. version: string;
  90633. };
  90634. /**
  90635. * Gets current aspect ratio
  90636. * @param camera defines the camera to use to get the aspect ratio
  90637. * @param useScreen defines if screen size must be used (or the current render target if any)
  90638. * @returns a number defining the aspect ratio
  90639. */
  90640. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  90641. /**
  90642. * Gets current screen aspect ratio
  90643. * @returns a number defining the aspect ratio
  90644. */
  90645. getScreenAspectRatio(): number;
  90646. /**
  90647. * Gets the current render width
  90648. * @param useScreen defines if screen size must be used (or the current render target if any)
  90649. * @returns a number defining the current render width
  90650. */
  90651. getRenderWidth(useScreen?: boolean): number;
  90652. /**
  90653. * Gets the current render height
  90654. * @param useScreen defines if screen size must be used (or the current render target if any)
  90655. * @returns a number defining the current render height
  90656. */
  90657. getRenderHeight(useScreen?: boolean): number;
  90658. /**
  90659. * Gets the HTML canvas attached with the current webGL context
  90660. * @returns a HTML canvas
  90661. */
  90662. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  90663. /**
  90664. * Gets the client rect of the HTML canvas attached with the current webGL context
  90665. * @returns a client rectanglee
  90666. */
  90667. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  90668. /**
  90669. * Defines the hardware scaling level.
  90670. * By default the hardware scaling level is computed from the window device ratio.
  90671. * 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.
  90672. * @param level defines the level to use
  90673. */
  90674. setHardwareScalingLevel(level: number): void;
  90675. /**
  90676. * Gets the current hardware scaling level.
  90677. * By default the hardware scaling level is computed from the window device ratio.
  90678. * 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.
  90679. * @returns a number indicating the current hardware scaling level
  90680. */
  90681. getHardwareScalingLevel(): number;
  90682. /**
  90683. * Gets the list of loaded textures
  90684. * @returns an array containing all loaded textures
  90685. */
  90686. getLoadedTexturesCache(): InternalTexture[];
  90687. /**
  90688. * Gets the object containing all engine capabilities
  90689. * @returns the EngineCapabilities object
  90690. */
  90691. getCaps(): EngineCapabilities;
  90692. /**
  90693. * Gets the current depth function
  90694. * @returns a number defining the depth function
  90695. */
  90696. getDepthFunction(): Nullable<number>;
  90697. /**
  90698. * Sets the current depth function
  90699. * @param depthFunc defines the function to use
  90700. */
  90701. setDepthFunction(depthFunc: number): void;
  90702. /**
  90703. * Sets the current depth function to GREATER
  90704. */
  90705. setDepthFunctionToGreater(): void;
  90706. /**
  90707. * Sets the current depth function to GEQUAL
  90708. */
  90709. setDepthFunctionToGreaterOrEqual(): void;
  90710. /**
  90711. * Sets the current depth function to LESS
  90712. */
  90713. setDepthFunctionToLess(): void;
  90714. private _cachedStencilBuffer;
  90715. private _cachedStencilFunction;
  90716. private _cachedStencilMask;
  90717. private _cachedStencilOperationPass;
  90718. private _cachedStencilOperationFail;
  90719. private _cachedStencilOperationDepthFail;
  90720. private _cachedStencilReference;
  90721. /**
  90722. * Caches the the state of the stencil buffer
  90723. */
  90724. cacheStencilState(): void;
  90725. /**
  90726. * Restores the state of the stencil buffer
  90727. */
  90728. restoreStencilState(): void;
  90729. /**
  90730. * Sets the current depth function to LEQUAL
  90731. */
  90732. setDepthFunctionToLessOrEqual(): void;
  90733. /**
  90734. * Gets a boolean indicating if stencil buffer is enabled
  90735. * @returns the current stencil buffer state
  90736. */
  90737. getStencilBuffer(): boolean;
  90738. /**
  90739. * Enable or disable the stencil buffer
  90740. * @param enable defines if the stencil buffer must be enabled or disabled
  90741. */
  90742. setStencilBuffer(enable: boolean): void;
  90743. /**
  90744. * Gets the current stencil mask
  90745. * @returns a number defining the new stencil mask to use
  90746. */
  90747. getStencilMask(): number;
  90748. /**
  90749. * Sets the current stencil mask
  90750. * @param mask defines the new stencil mask to use
  90751. */
  90752. setStencilMask(mask: number): void;
  90753. /**
  90754. * Gets the current stencil function
  90755. * @returns a number defining the stencil function to use
  90756. */
  90757. getStencilFunction(): number;
  90758. /**
  90759. * Gets the current stencil reference value
  90760. * @returns a number defining the stencil reference value to use
  90761. */
  90762. getStencilFunctionReference(): number;
  90763. /**
  90764. * Gets the current stencil mask
  90765. * @returns a number defining the stencil mask to use
  90766. */
  90767. getStencilFunctionMask(): number;
  90768. /**
  90769. * Sets the current stencil function
  90770. * @param stencilFunc defines the new stencil function to use
  90771. */
  90772. setStencilFunction(stencilFunc: number): void;
  90773. /**
  90774. * Sets the current stencil reference
  90775. * @param reference defines the new stencil reference to use
  90776. */
  90777. setStencilFunctionReference(reference: number): void;
  90778. /**
  90779. * Sets the current stencil mask
  90780. * @param mask defines the new stencil mask to use
  90781. */
  90782. setStencilFunctionMask(mask: number): void;
  90783. /**
  90784. * Gets the current stencil operation when stencil fails
  90785. * @returns a number defining stencil operation to use when stencil fails
  90786. */
  90787. getStencilOperationFail(): number;
  90788. /**
  90789. * Gets the current stencil operation when depth fails
  90790. * @returns a number defining stencil operation to use when depth fails
  90791. */
  90792. getStencilOperationDepthFail(): number;
  90793. /**
  90794. * Gets the current stencil operation when stencil passes
  90795. * @returns a number defining stencil operation to use when stencil passes
  90796. */
  90797. getStencilOperationPass(): number;
  90798. /**
  90799. * Sets the stencil operation to use when stencil fails
  90800. * @param operation defines the stencil operation to use when stencil fails
  90801. */
  90802. setStencilOperationFail(operation: number): void;
  90803. /**
  90804. * Sets the stencil operation to use when depth fails
  90805. * @param operation defines the stencil operation to use when depth fails
  90806. */
  90807. setStencilOperationDepthFail(operation: number): void;
  90808. /**
  90809. * Sets the stencil operation to use when stencil passes
  90810. * @param operation defines the stencil operation to use when stencil passes
  90811. */
  90812. setStencilOperationPass(operation: number): void;
  90813. /**
  90814. * Sets a boolean indicating if the dithering state is enabled or disabled
  90815. * @param value defines the dithering state
  90816. */
  90817. setDitheringState(value: boolean): void;
  90818. /**
  90819. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  90820. * @param value defines the rasterizer state
  90821. */
  90822. setRasterizerState(value: boolean): void;
  90823. /**
  90824. * stop executing a render loop function and remove it from the execution array
  90825. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  90826. */
  90827. stopRenderLoop(renderFunction?: () => void): void;
  90828. /** @hidden */
  90829. _renderLoop(): void;
  90830. /**
  90831. * Register and execute a render loop. The engine can have more than one render function
  90832. * @param renderFunction defines the function to continuously execute
  90833. */
  90834. runRenderLoop(renderFunction: () => void): void;
  90835. /**
  90836. * Toggle full screen mode
  90837. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90838. */
  90839. switchFullscreen(requestPointerLock: boolean): void;
  90840. /**
  90841. * Enters full screen mode
  90842. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90843. */
  90844. enterFullscreen(requestPointerLock: boolean): void;
  90845. /**
  90846. * Exits full screen mode
  90847. */
  90848. exitFullscreen(): void;
  90849. /**
  90850. * Enters Pointerlock mode
  90851. */
  90852. enterPointerlock(): void;
  90853. /**
  90854. * Exits Pointerlock mode
  90855. */
  90856. exitPointerlock(): void;
  90857. /**
  90858. * Clear the current render buffer or the current render target (if any is set up)
  90859. * @param color defines the color to use
  90860. * @param backBuffer defines if the back buffer must be cleared
  90861. * @param depth defines if the depth buffer must be cleared
  90862. * @param stencil defines if the stencil buffer must be cleared
  90863. */
  90864. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  90865. /**
  90866. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  90867. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90868. * @param y defines the y-coordinate of the corner of the clear rectangle
  90869. * @param width defines the width of the clear rectangle
  90870. * @param height defines the height of the clear rectangle
  90871. * @param clearColor defines the clear color
  90872. */
  90873. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  90874. /**
  90875. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  90876. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90877. * @param y defines the y-coordinate of the corner of the clear rectangle
  90878. * @param width defines the width of the clear rectangle
  90879. * @param height defines the height of the clear rectangle
  90880. */
  90881. enableScissor(x: number, y: number, width: number, height: number): void;
  90882. /**
  90883. * Disable previously set scissor test rectangle
  90884. */
  90885. disableScissor(): void;
  90886. private _viewportCached;
  90887. /** @hidden */
  90888. _viewport(x: number, y: number, width: number, height: number): void;
  90889. /**
  90890. * Set the WebGL's viewport
  90891. * @param viewport defines the viewport element to be used
  90892. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  90893. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  90894. */
  90895. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  90896. /**
  90897. * Directly set the WebGL Viewport
  90898. * @param x defines the x coordinate of the viewport (in screen space)
  90899. * @param y defines the y coordinate of the viewport (in screen space)
  90900. * @param width defines the width of the viewport (in screen space)
  90901. * @param height defines the height of the viewport (in screen space)
  90902. * @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
  90903. */
  90904. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  90905. /**
  90906. * Begin a new frame
  90907. */
  90908. beginFrame(): void;
  90909. /**
  90910. * Enf the current frame
  90911. */
  90912. endFrame(): void;
  90913. /**
  90914. * Resize the view according to the canvas' size
  90915. */
  90916. resize(): void;
  90917. /**
  90918. * Force a specific size of the canvas
  90919. * @param width defines the new canvas' width
  90920. * @param height defines the new canvas' height
  90921. */
  90922. setSize(width: number, height: number): void;
  90923. /**
  90924. * Binds the frame buffer to the specified texture.
  90925. * @param texture The texture to render to or null for the default canvas
  90926. * @param faceIndex The face of the texture to render to in case of cube texture
  90927. * @param requiredWidth The width of the target to render to
  90928. * @param requiredHeight The height of the target to render to
  90929. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  90930. * @param depthStencilTexture The depth stencil texture to use to render
  90931. * @param lodLevel defines le lod level to bind to the frame buffer
  90932. */
  90933. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  90934. /** @hidden */
  90935. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  90936. /**
  90937. * Unbind the current render target texture from the webGL context
  90938. * @param texture defines the render target texture to unbind
  90939. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  90940. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  90941. */
  90942. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  90943. /**
  90944. * Force the mipmap generation for the given render target texture
  90945. * @param texture defines the render target texture to use
  90946. */
  90947. generateMipMapsForCubemap(texture: InternalTexture): void;
  90948. /**
  90949. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  90950. */
  90951. flushFramebuffer(): void;
  90952. /**
  90953. * Unbind the current render target and bind the default framebuffer
  90954. */
  90955. restoreDefaultFramebuffer(): void;
  90956. /**
  90957. * Create an uniform buffer
  90958. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90959. * @param elements defines the content of the uniform buffer
  90960. * @returns the webGL uniform buffer
  90961. */
  90962. createUniformBuffer(elements: FloatArray): DataBuffer;
  90963. /**
  90964. * Create a dynamic uniform buffer
  90965. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90966. * @param elements defines the content of the uniform buffer
  90967. * @returns the webGL uniform buffer
  90968. */
  90969. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  90970. /**
  90971. * Update an existing uniform buffer
  90972. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90973. * @param uniformBuffer defines the target uniform buffer
  90974. * @param elements defines the content to update
  90975. * @param offset defines the offset in the uniform buffer where update should start
  90976. * @param count defines the size of the data to update
  90977. */
  90978. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  90979. private _resetVertexBufferBinding;
  90980. /**
  90981. * Creates a vertex buffer
  90982. * @param data the data for the vertex buffer
  90983. * @returns the new WebGL static buffer
  90984. */
  90985. createVertexBuffer(data: DataArray): DataBuffer;
  90986. /**
  90987. * Creates a dynamic vertex buffer
  90988. * @param data the data for the dynamic vertex buffer
  90989. * @returns the new WebGL dynamic buffer
  90990. */
  90991. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  90992. /**
  90993. * Update a dynamic index buffer
  90994. * @param indexBuffer defines the target index buffer
  90995. * @param indices defines the data to update
  90996. * @param offset defines the offset in the target index buffer where update should start
  90997. */
  90998. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  90999. /**
  91000. * Updates a dynamic vertex buffer.
  91001. * @param vertexBuffer the vertex buffer to update
  91002. * @param data the data used to update the vertex buffer
  91003. * @param byteOffset the byte offset of the data
  91004. * @param byteLength the byte length of the data
  91005. */
  91006. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91007. private _resetIndexBufferBinding;
  91008. /**
  91009. * Creates a new index buffer
  91010. * @param indices defines the content of the index buffer
  91011. * @param updatable defines if the index buffer must be updatable
  91012. * @returns a new webGL buffer
  91013. */
  91014. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  91015. /**
  91016. * Bind a webGL buffer to the webGL context
  91017. * @param buffer defines the buffer to bind
  91018. */
  91019. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  91020. /**
  91021. * Bind an uniform buffer to the current webGL context
  91022. * @param buffer defines the buffer to bind
  91023. */
  91024. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  91025. /**
  91026. * Bind a buffer to the current webGL context at a given location
  91027. * @param buffer defines the buffer to bind
  91028. * @param location defines the index where to bind the buffer
  91029. */
  91030. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  91031. /**
  91032. * Bind a specific block at a given index in a specific shader program
  91033. * @param pipelineContext defines the pipeline context to use
  91034. * @param blockName defines the block name
  91035. * @param index defines the index where to bind the block
  91036. */
  91037. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  91038. private bindIndexBuffer;
  91039. private bindBuffer;
  91040. /**
  91041. * update the bound buffer with the given data
  91042. * @param data defines the data to update
  91043. */
  91044. updateArrayBuffer(data: Float32Array): void;
  91045. private _vertexAttribPointer;
  91046. private _bindIndexBufferWithCache;
  91047. private _bindVertexBuffersAttributes;
  91048. /**
  91049. * Records a vertex array object
  91050. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91051. * @param vertexBuffers defines the list of vertex buffers to store
  91052. * @param indexBuffer defines the index buffer to store
  91053. * @param effect defines the effect to store
  91054. * @returns the new vertex array object
  91055. */
  91056. recordVertexArrayObject(vertexBuffers: {
  91057. [key: string]: VertexBuffer;
  91058. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  91059. /**
  91060. * Bind a specific vertex array object
  91061. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91062. * @param vertexArrayObject defines the vertex array object to bind
  91063. * @param indexBuffer defines the index buffer to bind
  91064. */
  91065. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  91066. /**
  91067. * Bind webGl buffers directly to the webGL context
  91068. * @param vertexBuffer defines the vertex buffer to bind
  91069. * @param indexBuffer defines the index buffer to bind
  91070. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  91071. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  91072. * @param effect defines the effect associated with the vertex buffer
  91073. */
  91074. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  91075. private _unbindVertexArrayObject;
  91076. /**
  91077. * Bind a list of vertex buffers to the webGL context
  91078. * @param vertexBuffers defines the list of vertex buffers to bind
  91079. * @param indexBuffer defines the index buffer to bind
  91080. * @param effect defines the effect associated with the vertex buffers
  91081. */
  91082. bindBuffers(vertexBuffers: {
  91083. [key: string]: Nullable<VertexBuffer>;
  91084. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  91085. /**
  91086. * Unbind all instance attributes
  91087. */
  91088. unbindInstanceAttributes(): void;
  91089. /**
  91090. * Release and free the memory of a vertex array object
  91091. * @param vao defines the vertex array object to delete
  91092. */
  91093. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  91094. /** @hidden */
  91095. _releaseBuffer(buffer: DataBuffer): boolean;
  91096. /**
  91097. * Creates a webGL buffer to use with instanciation
  91098. * @param capacity defines the size of the buffer
  91099. * @returns the webGL buffer
  91100. */
  91101. createInstancesBuffer(capacity: number): DataBuffer;
  91102. /**
  91103. * Delete a webGL buffer used with instanciation
  91104. * @param buffer defines the webGL buffer to delete
  91105. */
  91106. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  91107. /**
  91108. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  91109. * @param instancesBuffer defines the webGL buffer to update and bind
  91110. * @param data defines the data to store in the buffer
  91111. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  91112. */
  91113. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  91114. /**
  91115. * Apply all cached states (depth, culling, stencil and alpha)
  91116. */
  91117. applyStates(): void;
  91118. /**
  91119. * Send a draw order
  91120. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91121. * @param indexStart defines the starting index
  91122. * @param indexCount defines the number of index to draw
  91123. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91124. */
  91125. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  91126. /**
  91127. * Draw a list of points
  91128. * @param verticesStart defines the index of first vertex to draw
  91129. * @param verticesCount defines the count of vertices to draw
  91130. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91131. */
  91132. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91133. /**
  91134. * Draw a list of unindexed primitives
  91135. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91136. * @param verticesStart defines the index of first vertex to draw
  91137. * @param verticesCount defines the count of vertices to draw
  91138. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91139. */
  91140. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91141. /**
  91142. * Draw a list of indexed primitives
  91143. * @param fillMode defines the primitive to use
  91144. * @param indexStart defines the starting index
  91145. * @param indexCount defines the number of index to draw
  91146. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91147. */
  91148. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  91149. /**
  91150. * Draw a list of unindexed primitives
  91151. * @param fillMode defines the primitive to use
  91152. * @param verticesStart defines the index of first vertex to draw
  91153. * @param verticesCount defines the count of vertices to draw
  91154. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91155. */
  91156. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91157. private _drawMode;
  91158. /** @hidden */
  91159. _releaseEffect(effect: Effect): void;
  91160. /** @hidden */
  91161. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  91162. /**
  91163. * Create a new effect (used to store vertex/fragment shaders)
  91164. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  91165. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  91166. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  91167. * @param samplers defines an array of string used to represent textures
  91168. * @param defines defines the string containing the defines to use to compile the shaders
  91169. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  91170. * @param onCompiled defines a function to call when the effect creation is successful
  91171. * @param onError defines a function to call when the effect creation has failed
  91172. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  91173. * @returns the new Effect
  91174. */
  91175. 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;
  91176. private _compileShader;
  91177. private _compileRawShader;
  91178. /**
  91179. * Directly creates a webGL program
  91180. * @param pipelineContext defines the pipeline context to attach to
  91181. * @param vertexCode defines the vertex shader code to use
  91182. * @param fragmentCode defines the fragment shader code to use
  91183. * @param context defines the webGL context to use (if not set, the current one will be used)
  91184. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91185. * @returns the new webGL program
  91186. */
  91187. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91188. /**
  91189. * Creates a webGL program
  91190. * @param pipelineContext defines the pipeline context to attach to
  91191. * @param vertexCode defines the vertex shader code to use
  91192. * @param fragmentCode defines the fragment shader code to use
  91193. * @param defines defines the string containing the defines to use to compile the shaders
  91194. * @param context defines the webGL context to use (if not set, the current one will be used)
  91195. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91196. * @returns the new webGL program
  91197. */
  91198. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91199. /**
  91200. * Creates a new pipeline context
  91201. * @returns the new pipeline
  91202. */
  91203. createPipelineContext(): WebGLPipelineContext;
  91204. private _createShaderProgram;
  91205. private _finalizePipelineContext;
  91206. /** @hidden */
  91207. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  91208. /** @hidden */
  91209. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  91210. /** @hidden */
  91211. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  91212. /**
  91213. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  91214. * @param pipelineContext defines the pipeline context to use
  91215. * @param uniformsNames defines the list of uniform names
  91216. * @returns an array of webGL uniform locations
  91217. */
  91218. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  91219. /**
  91220. * Gets the lsit of active attributes for a given webGL program
  91221. * @param pipelineContext defines the pipeline context to use
  91222. * @param attributesNames defines the list of attribute names to get
  91223. * @returns an array of indices indicating the offset of each attribute
  91224. */
  91225. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  91226. /**
  91227. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  91228. * @param effect defines the effect to activate
  91229. */
  91230. enableEffect(effect: Nullable<Effect>): void;
  91231. /**
  91232. * Set the value of an uniform to an array of int32
  91233. * @param uniform defines the webGL uniform location where to store the value
  91234. * @param array defines the array of int32 to store
  91235. */
  91236. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91237. /**
  91238. * Set the value of an uniform to an array of int32 (stored as vec2)
  91239. * @param uniform defines the webGL uniform location where to store the value
  91240. * @param array defines the array of int32 to store
  91241. */
  91242. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91243. /**
  91244. * Set the value of an uniform to an array of int32 (stored as vec3)
  91245. * @param uniform defines the webGL uniform location where to store the value
  91246. * @param array defines the array of int32 to store
  91247. */
  91248. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91249. /**
  91250. * Set the value of an uniform to an array of int32 (stored as vec4)
  91251. * @param uniform defines the webGL uniform location where to store the value
  91252. * @param array defines the array of int32 to store
  91253. */
  91254. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91255. /**
  91256. * Set the value of an uniform to an array of float32
  91257. * @param uniform defines the webGL uniform location where to store the value
  91258. * @param array defines the array of float32 to store
  91259. */
  91260. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91261. /**
  91262. * Set the value of an uniform to an array of float32 (stored as vec2)
  91263. * @param uniform defines the webGL uniform location where to store the value
  91264. * @param array defines the array of float32 to store
  91265. */
  91266. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91267. /**
  91268. * Set the value of an uniform to an array of float32 (stored as vec3)
  91269. * @param uniform defines the webGL uniform location where to store the value
  91270. * @param array defines the array of float32 to store
  91271. */
  91272. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91273. /**
  91274. * Set the value of an uniform to an array of float32 (stored as vec4)
  91275. * @param uniform defines the webGL uniform location where to store the value
  91276. * @param array defines the array of float32 to store
  91277. */
  91278. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91279. /**
  91280. * Set the value of an uniform to an array of number
  91281. * @param uniform defines the webGL uniform location where to store the value
  91282. * @param array defines the array of number to store
  91283. */
  91284. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91285. /**
  91286. * Set the value of an uniform to an array of number (stored as vec2)
  91287. * @param uniform defines the webGL uniform location where to store the value
  91288. * @param array defines the array of number to store
  91289. */
  91290. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91291. /**
  91292. * Set the value of an uniform to an array of number (stored as vec3)
  91293. * @param uniform defines the webGL uniform location where to store the value
  91294. * @param array defines the array of number to store
  91295. */
  91296. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91297. /**
  91298. * Set the value of an uniform to an array of number (stored as vec4)
  91299. * @param uniform defines the webGL uniform location where to store the value
  91300. * @param array defines the array of number to store
  91301. */
  91302. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91303. /**
  91304. * Set the value of an uniform to an array of float32 (stored as matrices)
  91305. * @param uniform defines the webGL uniform location where to store the value
  91306. * @param matrices defines the array of float32 to store
  91307. */
  91308. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91309. /**
  91310. * Set the value of an uniform to a matrix
  91311. * @param uniform defines the webGL uniform location where to store the value
  91312. * @param matrix defines the matrix to store
  91313. */
  91314. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91315. /**
  91316. * Set the value of an uniform to a matrix (3x3)
  91317. * @param uniform defines the webGL uniform location where to store the value
  91318. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91319. */
  91320. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91321. /**
  91322. * Set the value of an uniform to a matrix (2x2)
  91323. * @param uniform defines the webGL uniform location where to store the value
  91324. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91325. */
  91326. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91327. /**
  91328. * Set the value of an uniform to a number (int)
  91329. * @param uniform defines the webGL uniform location where to store the value
  91330. * @param value defines the int number to store
  91331. */
  91332. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91333. /**
  91334. * Set the value of an uniform to a number (float)
  91335. * @param uniform defines the webGL uniform location where to store the value
  91336. * @param value defines the float number to store
  91337. */
  91338. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91339. /**
  91340. * Set the value of an uniform to a vec2
  91341. * @param uniform defines the webGL uniform location where to store the value
  91342. * @param x defines the 1st component of the value
  91343. * @param y defines the 2nd component of the value
  91344. */
  91345. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91346. /**
  91347. * Set the value of an uniform to a vec3
  91348. * @param uniform defines the webGL uniform location where to store the value
  91349. * @param x defines the 1st component of the value
  91350. * @param y defines the 2nd component of the value
  91351. * @param z defines the 3rd component of the value
  91352. */
  91353. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91354. /**
  91355. * Set the value of an uniform to a boolean
  91356. * @param uniform defines the webGL uniform location where to store the value
  91357. * @param bool defines the boolean to store
  91358. */
  91359. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91360. /**
  91361. * Set the value of an uniform to a vec4
  91362. * @param uniform defines the webGL uniform location where to store the value
  91363. * @param x defines the 1st component of the value
  91364. * @param y defines the 2nd component of the value
  91365. * @param z defines the 3rd component of the value
  91366. * @param w defines the 4th component of the value
  91367. */
  91368. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91369. /**
  91370. * Set the value of an uniform to a Color3
  91371. * @param uniform defines the webGL uniform location where to store the value
  91372. * @param color3 defines the color to store
  91373. */
  91374. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91375. /**
  91376. * Set the value of an uniform to a Color3 and an alpha value
  91377. * @param uniform defines the webGL uniform location where to store the value
  91378. * @param color3 defines the color to store
  91379. * @param alpha defines the alpha component to store
  91380. */
  91381. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91382. /**
  91383. * Sets a Color4 on a uniform variable
  91384. * @param uniform defines the uniform location
  91385. * @param color4 defines the value to be set
  91386. */
  91387. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91388. /**
  91389. * Set various states to the webGL context
  91390. * @param culling defines backface culling state
  91391. * @param zOffset defines the value to apply to zOffset (0 by default)
  91392. * @param force defines if states must be applied even if cache is up to date
  91393. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91394. */
  91395. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91396. /**
  91397. * Set the z offset to apply to current rendering
  91398. * @param value defines the offset to apply
  91399. */
  91400. setZOffset(value: number): void;
  91401. /**
  91402. * Gets the current value of the zOffset
  91403. * @returns the current zOffset state
  91404. */
  91405. getZOffset(): number;
  91406. /**
  91407. * Enable or disable depth buffering
  91408. * @param enable defines the state to set
  91409. */
  91410. setDepthBuffer(enable: boolean): void;
  91411. /**
  91412. * Gets a boolean indicating if depth writing is enabled
  91413. * @returns the current depth writing state
  91414. */
  91415. getDepthWrite(): boolean;
  91416. /**
  91417. * Enable or disable depth writing
  91418. * @param enable defines the state to set
  91419. */
  91420. setDepthWrite(enable: boolean): void;
  91421. /**
  91422. * Enable or disable color writing
  91423. * @param enable defines the state to set
  91424. */
  91425. setColorWrite(enable: boolean): void;
  91426. /**
  91427. * Gets a boolean indicating if color writing is enabled
  91428. * @returns the current color writing state
  91429. */
  91430. getColorWrite(): boolean;
  91431. /**
  91432. * Sets alpha constants used by some alpha blending modes
  91433. * @param r defines the red component
  91434. * @param g defines the green component
  91435. * @param b defines the blue component
  91436. * @param a defines the alpha component
  91437. */
  91438. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91439. /**
  91440. * Sets the current alpha mode
  91441. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91442. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91443. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91444. */
  91445. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91446. /**
  91447. * Gets the current alpha mode
  91448. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91449. * @returns the current alpha mode
  91450. */
  91451. getAlphaMode(): number;
  91452. /**
  91453. * Clears the list of texture accessible through engine.
  91454. * This can help preventing texture load conflict due to name collision.
  91455. */
  91456. clearInternalTexturesCache(): void;
  91457. /**
  91458. * Force the entire cache to be cleared
  91459. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91460. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91461. */
  91462. wipeCaches(bruteForce?: boolean): void;
  91463. /**
  91464. * Set the compressed texture format to use, based on the formats you have, and the formats
  91465. * supported by the hardware / browser.
  91466. *
  91467. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91468. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91469. * to API arguments needed to compressed textures. This puts the burden on the container
  91470. * generator to house the arcane code for determining these for current & future formats.
  91471. *
  91472. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91473. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91474. *
  91475. * Note: The result of this call is not taken into account when a texture is base64.
  91476. *
  91477. * @param formatsAvailable defines the list of those format families you have created
  91478. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91479. *
  91480. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91481. * @returns The extension selected.
  91482. */
  91483. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91484. /** @hidden */
  91485. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91486. min: number;
  91487. mag: number;
  91488. };
  91489. /** @hidden */
  91490. _createTexture(): WebGLTexture;
  91491. /**
  91492. * Usually called from Texture.ts.
  91493. * Passed information to create a WebGLTexture
  91494. * @param urlArg defines a value which contains one of the following:
  91495. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91496. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91497. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91498. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91499. * @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)
  91500. * @param scene needed for loading to the correct scene
  91501. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91502. * @param onLoad optional callback to be called upon successful completion
  91503. * @param onError optional callback to be called upon failure
  91504. * @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
  91505. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91506. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91507. * @param forcedExtension defines the extension to use to pick the right loader
  91508. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91509. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91510. */
  91511. 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;
  91512. /**
  91513. * @hidden
  91514. * Rescales a texture
  91515. * @param source input texutre
  91516. * @param destination destination texture
  91517. * @param scene scene to use to render the resize
  91518. * @param internalFormat format to use when resizing
  91519. * @param onComplete callback to be called when resize has completed
  91520. */
  91521. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  91522. private _unpackFlipYCached;
  91523. /**
  91524. * In case you are sharing the context with other applications, it might
  91525. * be interested to not cache the unpack flip y state to ensure a consistent
  91526. * value would be set.
  91527. */
  91528. enableUnpackFlipYCached: boolean;
  91529. /** @hidden */
  91530. _unpackFlipY(value: boolean): void;
  91531. /** @hidden */
  91532. _getUnpackAlignement(): number;
  91533. /**
  91534. * Creates a dynamic texture
  91535. * @param width defines the width of the texture
  91536. * @param height defines the height of the texture
  91537. * @param generateMipMaps defines if the engine should generate the mip levels
  91538. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91539. * @returns the dynamic texture inside an InternalTexture
  91540. */
  91541. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  91542. /**
  91543. * Update the sampling mode of a given texture
  91544. * @param samplingMode defines the required sampling mode
  91545. * @param texture defines the texture to update
  91546. */
  91547. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  91548. /**
  91549. * Update the content of a dynamic texture
  91550. * @param texture defines the texture to update
  91551. * @param canvas defines the canvas containing the source
  91552. * @param invertY defines if data must be stored with Y axis inverted
  91553. * @param premulAlpha defines if alpha is stored as premultiplied
  91554. * @param format defines the format of the data
  91555. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  91556. */
  91557. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  91558. /**
  91559. * Update a video texture
  91560. * @param texture defines the texture to update
  91561. * @param video defines the video element to use
  91562. * @param invertY defines if data must be stored with Y axis inverted
  91563. */
  91564. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  91565. /**
  91566. * Updates a depth texture Comparison Mode and Function.
  91567. * If the comparison Function is equal to 0, the mode will be set to none.
  91568. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  91569. * @param texture The texture to set the comparison function for
  91570. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  91571. */
  91572. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  91573. /** @hidden */
  91574. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  91575. width: number;
  91576. height: number;
  91577. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  91578. /**
  91579. * Creates a depth stencil texture.
  91580. * This is only available in WebGL 2 or with the depth texture extension available.
  91581. * @param size The size of face edge in the texture.
  91582. * @param options The options defining the texture.
  91583. * @returns The texture
  91584. */
  91585. createDepthStencilTexture(size: number | {
  91586. width: number;
  91587. height: number;
  91588. }, options: DepthTextureCreationOptions): InternalTexture;
  91589. /**
  91590. * Creates a depth stencil texture.
  91591. * This is only available in WebGL 2 or with the depth texture extension available.
  91592. * @param size The size of face edge in the texture.
  91593. * @param options The options defining the texture.
  91594. * @returns The texture
  91595. */
  91596. private _createDepthStencilTexture;
  91597. /**
  91598. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  91599. * @param renderTarget The render target to set the frame buffer for
  91600. */
  91601. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  91602. /**
  91603. * Creates a new render target texture
  91604. * @param size defines the size of the texture
  91605. * @param options defines the options used to create the texture
  91606. * @returns a new render target texture stored in an InternalTexture
  91607. */
  91608. createRenderTargetTexture(size: number | {
  91609. width: number;
  91610. height: number;
  91611. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  91612. /** @hidden */
  91613. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  91614. /**
  91615. * Updates the sample count of a render target texture
  91616. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  91617. * @param texture defines the texture to update
  91618. * @param samples defines the sample count to set
  91619. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  91620. */
  91621. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  91622. /** @hidden */
  91623. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91624. /** @hidden */
  91625. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  91626. /** @hidden */
  91627. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91628. /** @hidden */
  91629. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  91630. /**
  91631. * @hidden
  91632. */
  91633. _setCubeMapTextureParams(loadMipmap: boolean): void;
  91634. private _prepareWebGLTextureContinuation;
  91635. private _prepareWebGLTexture;
  91636. /** @hidden */
  91637. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  91638. /** @hidden */
  91639. _releaseFramebufferObjects(texture: InternalTexture): void;
  91640. /** @hidden */
  91641. _releaseTexture(texture: InternalTexture): void;
  91642. private setProgram;
  91643. private _boundUniforms;
  91644. /**
  91645. * Binds an effect to the webGL context
  91646. * @param effect defines the effect to bind
  91647. */
  91648. bindSamplers(effect: Effect): void;
  91649. private _activateCurrentTexture;
  91650. /** @hidden */
  91651. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  91652. /** @hidden */
  91653. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  91654. /**
  91655. * Sets a texture to the webGL context from a postprocess
  91656. * @param channel defines the channel to use
  91657. * @param postProcess defines the source postprocess
  91658. */
  91659. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  91660. /**
  91661. * Binds the output of the passed in post process to the texture channel specified
  91662. * @param channel The channel the texture should be bound to
  91663. * @param postProcess The post process which's output should be bound
  91664. */
  91665. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  91666. /**
  91667. * Unbind all textures from the webGL context
  91668. */
  91669. unbindAllTextures(): void;
  91670. /**
  91671. * Sets a texture to the according uniform.
  91672. * @param channel The texture channel
  91673. * @param uniform The uniform to set
  91674. * @param texture The texture to apply
  91675. */
  91676. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  91677. /**
  91678. * Sets a depth stencil texture from a render target to the according uniform.
  91679. * @param channel The texture channel
  91680. * @param uniform The uniform to set
  91681. * @param texture The render target texture containing the depth stencil texture to apply
  91682. */
  91683. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  91684. private _bindSamplerUniformToChannel;
  91685. private _getTextureWrapMode;
  91686. private _setTexture;
  91687. /**
  91688. * Sets an array of texture to the webGL context
  91689. * @param channel defines the channel where the texture array must be set
  91690. * @param uniform defines the associated uniform location
  91691. * @param textures defines the array of textures to bind
  91692. */
  91693. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  91694. /** @hidden */
  91695. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  91696. private _setTextureParameterFloat;
  91697. private _setTextureParameterInteger;
  91698. /**
  91699. * Reads pixels from the current frame buffer. Please note that this function can be slow
  91700. * @param x defines the x coordinate of the rectangle where pixels must be read
  91701. * @param y defines the y coordinate of the rectangle where pixels must be read
  91702. * @param width defines the width of the rectangle where pixels must be read
  91703. * @param height defines the height of the rectangle where pixels must be read
  91704. * @returns a Uint8Array containing RGBA colors
  91705. */
  91706. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  91707. /**
  91708. * Add an externaly attached data from its key.
  91709. * This method call will fail and return false, if such key already exists.
  91710. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91711. * @param key the unique key that identifies the data
  91712. * @param data the data object to associate to the key for this Engine instance
  91713. * @return true if no such key were already present and the data was added successfully, false otherwise
  91714. */
  91715. addExternalData<T>(key: string, data: T): boolean;
  91716. /**
  91717. * Get an externaly attached data from its key
  91718. * @param key the unique key that identifies the data
  91719. * @return the associated data, if present (can be null), or undefined if not present
  91720. */
  91721. getExternalData<T>(key: string): T;
  91722. /**
  91723. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91724. * @param key the unique key that identifies the data
  91725. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91726. * @return the associated data, can be null if the factory returned null.
  91727. */
  91728. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91729. /**
  91730. * Remove an externaly attached data from the Engine instance
  91731. * @param key the unique key that identifies the data
  91732. * @return true if the data was successfully removed, false if it doesn't exist
  91733. */
  91734. removeExternalData(key: string): boolean;
  91735. /**
  91736. * Unbind all vertex attributes from the webGL context
  91737. */
  91738. unbindAllAttributes(): void;
  91739. /**
  91740. * 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
  91741. */
  91742. releaseEffects(): void;
  91743. /**
  91744. * Dispose and release all associated resources
  91745. */
  91746. dispose(): void;
  91747. /**
  91748. * Display the loading screen
  91749. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91750. */
  91751. displayLoadingUI(): void;
  91752. /**
  91753. * Hide the loading screen
  91754. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91755. */
  91756. hideLoadingUI(): void;
  91757. /**
  91758. * Gets the current loading screen object
  91759. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91760. */
  91761. /**
  91762. * Sets the current loading screen object
  91763. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91764. */
  91765. loadingScreen: ILoadingScreen;
  91766. /**
  91767. * Sets the current loading screen text
  91768. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91769. */
  91770. loadingUIText: string;
  91771. /**
  91772. * Sets the current loading screen background color
  91773. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91774. */
  91775. loadingUIBackgroundColor: string;
  91776. /**
  91777. * Attach a new callback raised when context lost event is fired
  91778. * @param callback defines the callback to call
  91779. */
  91780. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91781. /**
  91782. * Attach a new callback raised when context restored event is fired
  91783. * @param callback defines the callback to call
  91784. */
  91785. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91786. /**
  91787. * Gets the source code of the vertex shader associated with a specific webGL program
  91788. * @param program defines the program to use
  91789. * @returns a string containing the source code of the vertex shader associated with the program
  91790. */
  91791. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  91792. /**
  91793. * Gets the source code of the fragment shader associated with a specific webGL program
  91794. * @param program defines the program to use
  91795. * @returns a string containing the source code of the fragment shader associated with the program
  91796. */
  91797. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  91798. /**
  91799. * Get the current error code of the webGL context
  91800. * @returns the error code
  91801. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  91802. */
  91803. getError(): number;
  91804. /**
  91805. * Gets the current framerate
  91806. * @returns a number representing the framerate
  91807. */
  91808. getFps(): number;
  91809. /**
  91810. * Gets the time spent between current and previous frame
  91811. * @returns a number representing the delta time in ms
  91812. */
  91813. getDeltaTime(): number;
  91814. private _measureFps;
  91815. /** @hidden */
  91816. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  91817. private _canRenderToFloatFramebuffer;
  91818. private _canRenderToHalfFloatFramebuffer;
  91819. private _canRenderToFramebuffer;
  91820. /** @hidden */
  91821. _getWebGLTextureType(type: number): number;
  91822. /** @hidden */
  91823. _getInternalFormat(format: number): number;
  91824. /** @hidden */
  91825. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  91826. /** @hidden */
  91827. _getRGBAMultiSampleBufferFormat(type: number): number;
  91828. /** @hidden */
  91829. _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;
  91830. /** @hidden */
  91831. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91832. /**
  91833. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  91834. * @returns true if the engine can be created
  91835. * @ignorenaming
  91836. */
  91837. static isSupported(): boolean;
  91838. }
  91839. }
  91840. declare module BABYLON {
  91841. /**
  91842. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91843. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91844. */
  91845. export class EffectFallbacks {
  91846. private _defines;
  91847. private _currentRank;
  91848. private _maxRank;
  91849. private _mesh;
  91850. /**
  91851. * Removes the fallback from the bound mesh.
  91852. */
  91853. unBindMesh(): void;
  91854. /**
  91855. * Adds a fallback on the specified property.
  91856. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91857. * @param define The name of the define in the shader
  91858. */
  91859. addFallback(rank: number, define: string): void;
  91860. /**
  91861. * Sets the mesh to use CPU skinning when needing to fallback.
  91862. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91863. * @param mesh The mesh to use the fallbacks.
  91864. */
  91865. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  91866. /**
  91867. * Checks to see if more fallbacks are still availible.
  91868. */
  91869. readonly isMoreFallbacks: boolean;
  91870. /**
  91871. * Removes the defines that should be removed when falling back.
  91872. * @param currentDefines defines the current define statements for the shader.
  91873. * @param effect defines the current effect we try to compile
  91874. * @returns The resulting defines with defines of the current rank removed.
  91875. */
  91876. reduce(currentDefines: string, effect: Effect): string;
  91877. }
  91878. /**
  91879. * Options to be used when creating an effect.
  91880. */
  91881. export class EffectCreationOptions {
  91882. /**
  91883. * Atrributes that will be used in the shader.
  91884. */
  91885. attributes: string[];
  91886. /**
  91887. * Uniform varible names that will be set in the shader.
  91888. */
  91889. uniformsNames: string[];
  91890. /**
  91891. * Uniform buffer varible names that will be set in the shader.
  91892. */
  91893. uniformBuffersNames: string[];
  91894. /**
  91895. * Sampler texture variable names that will be set in the shader.
  91896. */
  91897. samplers: string[];
  91898. /**
  91899. * Define statements that will be set in the shader.
  91900. */
  91901. defines: any;
  91902. /**
  91903. * Possible fallbacks for this effect to improve performance when needed.
  91904. */
  91905. fallbacks: Nullable<EffectFallbacks>;
  91906. /**
  91907. * Callback that will be called when the shader is compiled.
  91908. */
  91909. onCompiled: Nullable<(effect: Effect) => void>;
  91910. /**
  91911. * Callback that will be called if an error occurs during shader compilation.
  91912. */
  91913. onError: Nullable<(effect: Effect, errors: string) => void>;
  91914. /**
  91915. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91916. */
  91917. indexParameters: any;
  91918. /**
  91919. * Max number of lights that can be used in the shader.
  91920. */
  91921. maxSimultaneousLights: number;
  91922. /**
  91923. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  91924. */
  91925. transformFeedbackVaryings: Nullable<string[]>;
  91926. }
  91927. /**
  91928. * Effect containing vertex and fragment shader that can be executed on an object.
  91929. */
  91930. export class Effect implements IDisposable {
  91931. /**
  91932. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  91933. */
  91934. static ShadersRepository: string;
  91935. /**
  91936. * Name of the effect.
  91937. */
  91938. name: any;
  91939. /**
  91940. * String container all the define statements that should be set on the shader.
  91941. */
  91942. defines: string;
  91943. /**
  91944. * Callback that will be called when the shader is compiled.
  91945. */
  91946. onCompiled: Nullable<(effect: Effect) => void>;
  91947. /**
  91948. * Callback that will be called if an error occurs during shader compilation.
  91949. */
  91950. onError: Nullable<(effect: Effect, errors: string) => void>;
  91951. /**
  91952. * Callback that will be called when effect is bound.
  91953. */
  91954. onBind: Nullable<(effect: Effect) => void>;
  91955. /**
  91956. * Unique ID of the effect.
  91957. */
  91958. uniqueId: number;
  91959. /**
  91960. * Observable that will be called when the shader is compiled.
  91961. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  91962. */
  91963. onCompileObservable: Observable<Effect>;
  91964. /**
  91965. * Observable that will be called if an error occurs during shader compilation.
  91966. */
  91967. onErrorObservable: Observable<Effect>;
  91968. /** @hidden */
  91969. _onBindObservable: Nullable<Observable<Effect>>;
  91970. /**
  91971. * Observable that will be called when effect is bound.
  91972. */
  91973. readonly onBindObservable: Observable<Effect>;
  91974. /** @hidden */
  91975. _bonesComputationForcedToCPU: boolean;
  91976. private static _uniqueIdSeed;
  91977. private _engine;
  91978. private _uniformBuffersNames;
  91979. private _uniformsNames;
  91980. private _samplerList;
  91981. private _samplers;
  91982. private _isReady;
  91983. private _compilationError;
  91984. private _attributesNames;
  91985. private _attributes;
  91986. private _uniforms;
  91987. /**
  91988. * Key for the effect.
  91989. * @hidden
  91990. */
  91991. _key: string;
  91992. private _indexParameters;
  91993. private _fallbacks;
  91994. private _vertexSourceCode;
  91995. private _fragmentSourceCode;
  91996. private _vertexSourceCodeOverride;
  91997. private _fragmentSourceCodeOverride;
  91998. private _transformFeedbackVaryings;
  91999. /**
  92000. * Compiled shader to webGL program.
  92001. * @hidden
  92002. */
  92003. _pipelineContext: Nullable<IPipelineContext>;
  92004. private _valueCache;
  92005. private static _baseCache;
  92006. /**
  92007. * Instantiates an effect.
  92008. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92009. * @param baseName Name of the effect.
  92010. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92011. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92012. * @param samplers List of sampler variables that will be passed to the shader.
  92013. * @param engine Engine to be used to render the effect
  92014. * @param defines Define statements to be added to the shader.
  92015. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92016. * @param onCompiled Callback that will be called when the shader is compiled.
  92017. * @param onError Callback that will be called if an error occurs during shader compilation.
  92018. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92019. */
  92020. 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);
  92021. private _useFinalCode;
  92022. /**
  92023. * Unique key for this effect
  92024. */
  92025. readonly key: string;
  92026. /**
  92027. * If the effect has been compiled and prepared.
  92028. * @returns if the effect is compiled and prepared.
  92029. */
  92030. isReady(): boolean;
  92031. /**
  92032. * The engine the effect was initialized with.
  92033. * @returns the engine.
  92034. */
  92035. getEngine(): Engine;
  92036. /**
  92037. * The pipeline context for this effect
  92038. * @returns the associated pipeline context
  92039. */
  92040. getPipelineContext(): Nullable<IPipelineContext>;
  92041. /**
  92042. * The set of names of attribute variables for the shader.
  92043. * @returns An array of attribute names.
  92044. */
  92045. getAttributesNames(): string[];
  92046. /**
  92047. * Returns the attribute at the given index.
  92048. * @param index The index of the attribute.
  92049. * @returns The location of the attribute.
  92050. */
  92051. getAttributeLocation(index: number): number;
  92052. /**
  92053. * Returns the attribute based on the name of the variable.
  92054. * @param name of the attribute to look up.
  92055. * @returns the attribute location.
  92056. */
  92057. getAttributeLocationByName(name: string): number;
  92058. /**
  92059. * The number of attributes.
  92060. * @returns the numnber of attributes.
  92061. */
  92062. getAttributesCount(): number;
  92063. /**
  92064. * Gets the index of a uniform variable.
  92065. * @param uniformName of the uniform to look up.
  92066. * @returns the index.
  92067. */
  92068. getUniformIndex(uniformName: string): number;
  92069. /**
  92070. * Returns the attribute based on the name of the variable.
  92071. * @param uniformName of the uniform to look up.
  92072. * @returns the location of the uniform.
  92073. */
  92074. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92075. /**
  92076. * Returns an array of sampler variable names
  92077. * @returns The array of sampler variable neames.
  92078. */
  92079. getSamplers(): string[];
  92080. /**
  92081. * The error from the last compilation.
  92082. * @returns the error string.
  92083. */
  92084. getCompilationError(): string;
  92085. /**
  92086. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92087. * @param func The callback to be used.
  92088. */
  92089. executeWhenCompiled(func: (effect: Effect) => void): void;
  92090. private _checkIsReady;
  92091. /** @hidden */
  92092. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92093. /** @hidden */
  92094. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92095. /** @hidden */
  92096. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92097. /**
  92098. * Recompiles the webGL program
  92099. * @param vertexSourceCode The source code for the vertex shader.
  92100. * @param fragmentSourceCode The source code for the fragment shader.
  92101. * @param onCompiled Callback called when completed.
  92102. * @param onError Callback called on error.
  92103. * @hidden
  92104. */
  92105. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92106. /**
  92107. * Prepares the effect
  92108. * @hidden
  92109. */
  92110. _prepareEffect(): void;
  92111. /**
  92112. * Checks if the effect is supported. (Must be called after compilation)
  92113. */
  92114. readonly isSupported: boolean;
  92115. /**
  92116. * Binds a texture to the engine to be used as output of the shader.
  92117. * @param channel Name of the output variable.
  92118. * @param texture Texture to bind.
  92119. * @hidden
  92120. */
  92121. _bindTexture(channel: string, texture: InternalTexture): void;
  92122. /**
  92123. * Sets a texture on the engine to be used in the shader.
  92124. * @param channel Name of the sampler variable.
  92125. * @param texture Texture to set.
  92126. */
  92127. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92128. /**
  92129. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92130. * @param channel Name of the sampler variable.
  92131. * @param texture Texture to set.
  92132. */
  92133. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92134. /**
  92135. * Sets an array of textures on the engine to be used in the shader.
  92136. * @param channel Name of the variable.
  92137. * @param textures Textures to set.
  92138. */
  92139. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92140. /**
  92141. * 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)
  92142. * @param channel Name of the sampler variable.
  92143. * @param postProcess Post process to get the input texture from.
  92144. */
  92145. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92146. /**
  92147. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92148. * 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)
  92149. * @param channel Name of the sampler variable.
  92150. * @param postProcess Post process to get the output texture from.
  92151. */
  92152. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92153. /** @hidden */
  92154. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  92155. /** @hidden */
  92156. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92157. /** @hidden */
  92158. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92159. /** @hidden */
  92160. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92161. /**
  92162. * Binds a buffer to a uniform.
  92163. * @param buffer Buffer to bind.
  92164. * @param name Name of the uniform variable to bind to.
  92165. */
  92166. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92167. /**
  92168. * Binds block to a uniform.
  92169. * @param blockName Name of the block to bind.
  92170. * @param index Index to bind.
  92171. */
  92172. bindUniformBlock(blockName: string, index: number): void;
  92173. /**
  92174. * Sets an interger value on a uniform variable.
  92175. * @param uniformName Name of the variable.
  92176. * @param value Value to be set.
  92177. * @returns this effect.
  92178. */
  92179. setInt(uniformName: string, value: number): Effect;
  92180. /**
  92181. * Sets an int array on a uniform variable.
  92182. * @param uniformName Name of the variable.
  92183. * @param array array to be set.
  92184. * @returns this effect.
  92185. */
  92186. setIntArray(uniformName: string, array: Int32Array): Effect;
  92187. /**
  92188. * 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)
  92189. * @param uniformName Name of the variable.
  92190. * @param array array to be set.
  92191. * @returns this effect.
  92192. */
  92193. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92194. /**
  92195. * 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)
  92196. * @param uniformName Name of the variable.
  92197. * @param array array to be set.
  92198. * @returns this effect.
  92199. */
  92200. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92201. /**
  92202. * 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)
  92203. * @param uniformName Name of the variable.
  92204. * @param array array to be set.
  92205. * @returns this effect.
  92206. */
  92207. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92208. /**
  92209. * Sets an float array on a uniform variable.
  92210. * @param uniformName Name of the variable.
  92211. * @param array array to be set.
  92212. * @returns this effect.
  92213. */
  92214. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92215. /**
  92216. * 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)
  92217. * @param uniformName Name of the variable.
  92218. * @param array array to be set.
  92219. * @returns this effect.
  92220. */
  92221. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92222. /**
  92223. * 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)
  92224. * @param uniformName Name of the variable.
  92225. * @param array array to be set.
  92226. * @returns this effect.
  92227. */
  92228. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92229. /**
  92230. * 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)
  92231. * @param uniformName Name of the variable.
  92232. * @param array array to be set.
  92233. * @returns this effect.
  92234. */
  92235. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92236. /**
  92237. * Sets an array on a uniform variable.
  92238. * @param uniformName Name of the variable.
  92239. * @param array array to be set.
  92240. * @returns this effect.
  92241. */
  92242. setArray(uniformName: string, array: number[]): Effect;
  92243. /**
  92244. * 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)
  92245. * @param uniformName Name of the variable.
  92246. * @param array array to be set.
  92247. * @returns this effect.
  92248. */
  92249. setArray2(uniformName: string, array: number[]): Effect;
  92250. /**
  92251. * 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)
  92252. * @param uniformName Name of the variable.
  92253. * @param array array to be set.
  92254. * @returns this effect.
  92255. */
  92256. setArray3(uniformName: string, array: number[]): Effect;
  92257. /**
  92258. * 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)
  92259. * @param uniformName Name of the variable.
  92260. * @param array array to be set.
  92261. * @returns this effect.
  92262. */
  92263. setArray4(uniformName: string, array: number[]): Effect;
  92264. /**
  92265. * Sets matrices on a uniform variable.
  92266. * @param uniformName Name of the variable.
  92267. * @param matrices matrices to be set.
  92268. * @returns this effect.
  92269. */
  92270. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92271. /**
  92272. * Sets matrix on a uniform variable.
  92273. * @param uniformName Name of the variable.
  92274. * @param matrix matrix to be set.
  92275. * @returns this effect.
  92276. */
  92277. setMatrix(uniformName: string, matrix: Matrix): Effect;
  92278. /**
  92279. * 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)
  92280. * @param uniformName Name of the variable.
  92281. * @param matrix matrix to be set.
  92282. * @returns this effect.
  92283. */
  92284. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92285. /**
  92286. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92287. * @param uniformName Name of the variable.
  92288. * @param matrix matrix to be set.
  92289. * @returns this effect.
  92290. */
  92291. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92292. /**
  92293. * Sets a float on a uniform variable.
  92294. * @param uniformName Name of the variable.
  92295. * @param value value to be set.
  92296. * @returns this effect.
  92297. */
  92298. setFloat(uniformName: string, value: number): Effect;
  92299. /**
  92300. * Sets a boolean on a uniform variable.
  92301. * @param uniformName Name of the variable.
  92302. * @param bool value to be set.
  92303. * @returns this effect.
  92304. */
  92305. setBool(uniformName: string, bool: boolean): Effect;
  92306. /**
  92307. * Sets a Vector2 on a uniform variable.
  92308. * @param uniformName Name of the variable.
  92309. * @param vector2 vector2 to be set.
  92310. * @returns this effect.
  92311. */
  92312. setVector2(uniformName: string, vector2: Vector2): Effect;
  92313. /**
  92314. * Sets a float2 on a uniform variable.
  92315. * @param uniformName Name of the variable.
  92316. * @param x First float in float2.
  92317. * @param y Second float in float2.
  92318. * @returns this effect.
  92319. */
  92320. setFloat2(uniformName: string, x: number, y: number): Effect;
  92321. /**
  92322. * Sets a Vector3 on a uniform variable.
  92323. * @param uniformName Name of the variable.
  92324. * @param vector3 Value to be set.
  92325. * @returns this effect.
  92326. */
  92327. setVector3(uniformName: string, vector3: Vector3): Effect;
  92328. /**
  92329. * Sets a float3 on a uniform variable.
  92330. * @param uniformName Name of the variable.
  92331. * @param x First float in float3.
  92332. * @param y Second float in float3.
  92333. * @param z Third float in float3.
  92334. * @returns this effect.
  92335. */
  92336. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92337. /**
  92338. * Sets a Vector4 on a uniform variable.
  92339. * @param uniformName Name of the variable.
  92340. * @param vector4 Value to be set.
  92341. * @returns this effect.
  92342. */
  92343. setVector4(uniformName: string, vector4: Vector4): Effect;
  92344. /**
  92345. * Sets a float4 on a uniform variable.
  92346. * @param uniformName Name of the variable.
  92347. * @param x First float in float4.
  92348. * @param y Second float in float4.
  92349. * @param z Third float in float4.
  92350. * @param w Fourth float in float4.
  92351. * @returns this effect.
  92352. */
  92353. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92354. /**
  92355. * Sets a Color3 on a uniform variable.
  92356. * @param uniformName Name of the variable.
  92357. * @param color3 Value to be set.
  92358. * @returns this effect.
  92359. */
  92360. setColor3(uniformName: string, color3: Color3): Effect;
  92361. /**
  92362. * Sets a Color4 on a uniform variable.
  92363. * @param uniformName Name of the variable.
  92364. * @param color3 Value to be set.
  92365. * @param alpha Alpha value to be set.
  92366. * @returns this effect.
  92367. */
  92368. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92369. /**
  92370. * Sets a Color4 on a uniform variable
  92371. * @param uniformName defines the name of the variable
  92372. * @param color4 defines the value to be set
  92373. * @returns this effect.
  92374. */
  92375. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92376. /** Release all associated resources */
  92377. dispose(): void;
  92378. /**
  92379. * This function will add a new shader to the shader store
  92380. * @param name the name of the shader
  92381. * @param pixelShader optional pixel shader content
  92382. * @param vertexShader optional vertex shader content
  92383. */
  92384. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92385. /**
  92386. * Store of each shader (The can be looked up using effect.key)
  92387. */
  92388. static ShadersStore: {
  92389. [key: string]: string;
  92390. };
  92391. /**
  92392. * Store of each included file for a shader (The can be looked up using effect.key)
  92393. */
  92394. static IncludesShadersStore: {
  92395. [key: string]: string;
  92396. };
  92397. /**
  92398. * Resets the cache of effects.
  92399. */
  92400. static ResetCache(): void;
  92401. }
  92402. }
  92403. declare module BABYLON {
  92404. /**
  92405. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92406. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92407. * 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;
  92408. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92409. */
  92410. export class ColorCurves {
  92411. private _dirty;
  92412. private _tempColor;
  92413. private _globalCurve;
  92414. private _highlightsCurve;
  92415. private _midtonesCurve;
  92416. private _shadowsCurve;
  92417. private _positiveCurve;
  92418. private _negativeCurve;
  92419. private _globalHue;
  92420. private _globalDensity;
  92421. private _globalSaturation;
  92422. private _globalExposure;
  92423. /**
  92424. * Gets the global Hue value.
  92425. * 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).
  92426. */
  92427. /**
  92428. * Sets the global Hue value.
  92429. * 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).
  92430. */
  92431. globalHue: number;
  92432. /**
  92433. * Gets the global Density value.
  92434. * 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.
  92435. * Values less than zero provide a filter of opposite hue.
  92436. */
  92437. /**
  92438. * Sets the global Density value.
  92439. * 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.
  92440. * Values less than zero provide a filter of opposite hue.
  92441. */
  92442. globalDensity: number;
  92443. /**
  92444. * Gets the global Saturation value.
  92445. * 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.
  92446. */
  92447. /**
  92448. * Sets the global Saturation value.
  92449. * 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.
  92450. */
  92451. globalSaturation: number;
  92452. /**
  92453. * Gets the global Exposure value.
  92454. * 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.
  92455. */
  92456. /**
  92457. * Sets the global Exposure value.
  92458. * 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.
  92459. */
  92460. globalExposure: number;
  92461. private _highlightsHue;
  92462. private _highlightsDensity;
  92463. private _highlightsSaturation;
  92464. private _highlightsExposure;
  92465. /**
  92466. * Gets the highlights Hue value.
  92467. * 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).
  92468. */
  92469. /**
  92470. * Sets the highlights Hue value.
  92471. * 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).
  92472. */
  92473. highlightsHue: number;
  92474. /**
  92475. * Gets the highlights Density value.
  92476. * 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.
  92477. * Values less than zero provide a filter of opposite hue.
  92478. */
  92479. /**
  92480. * Sets the highlights Density value.
  92481. * 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.
  92482. * Values less than zero provide a filter of opposite hue.
  92483. */
  92484. highlightsDensity: number;
  92485. /**
  92486. * Gets the highlights Saturation value.
  92487. * 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.
  92488. */
  92489. /**
  92490. * Sets the highlights Saturation value.
  92491. * 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.
  92492. */
  92493. highlightsSaturation: number;
  92494. /**
  92495. * Gets the highlights Exposure value.
  92496. * 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.
  92497. */
  92498. /**
  92499. * Sets the highlights Exposure value.
  92500. * 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.
  92501. */
  92502. highlightsExposure: number;
  92503. private _midtonesHue;
  92504. private _midtonesDensity;
  92505. private _midtonesSaturation;
  92506. private _midtonesExposure;
  92507. /**
  92508. * Gets the midtones Hue value.
  92509. * 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).
  92510. */
  92511. /**
  92512. * Sets the midtones Hue value.
  92513. * 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).
  92514. */
  92515. midtonesHue: number;
  92516. /**
  92517. * Gets the midtones Density value.
  92518. * 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.
  92519. * Values less than zero provide a filter of opposite hue.
  92520. */
  92521. /**
  92522. * Sets the midtones Density value.
  92523. * 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.
  92524. * Values less than zero provide a filter of opposite hue.
  92525. */
  92526. midtonesDensity: number;
  92527. /**
  92528. * Gets the midtones Saturation value.
  92529. * 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.
  92530. */
  92531. /**
  92532. * Sets the midtones Saturation value.
  92533. * 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.
  92534. */
  92535. midtonesSaturation: number;
  92536. /**
  92537. * Gets the midtones Exposure value.
  92538. * 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.
  92539. */
  92540. /**
  92541. * Sets the midtones Exposure value.
  92542. * 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.
  92543. */
  92544. midtonesExposure: number;
  92545. private _shadowsHue;
  92546. private _shadowsDensity;
  92547. private _shadowsSaturation;
  92548. private _shadowsExposure;
  92549. /**
  92550. * Gets the shadows Hue value.
  92551. * 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).
  92552. */
  92553. /**
  92554. * Sets the shadows Hue value.
  92555. * 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).
  92556. */
  92557. shadowsHue: number;
  92558. /**
  92559. * Gets the shadows Density value.
  92560. * 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.
  92561. * Values less than zero provide a filter of opposite hue.
  92562. */
  92563. /**
  92564. * Sets the shadows Density value.
  92565. * 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.
  92566. * Values less than zero provide a filter of opposite hue.
  92567. */
  92568. shadowsDensity: number;
  92569. /**
  92570. * Gets the shadows Saturation value.
  92571. * 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.
  92572. */
  92573. /**
  92574. * Sets the shadows Saturation value.
  92575. * 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.
  92576. */
  92577. shadowsSaturation: number;
  92578. /**
  92579. * Gets the shadows Exposure value.
  92580. * 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.
  92581. */
  92582. /**
  92583. * Sets the shadows Exposure value.
  92584. * 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.
  92585. */
  92586. shadowsExposure: number;
  92587. /**
  92588. * Returns the class name
  92589. * @returns The class name
  92590. */
  92591. getClassName(): string;
  92592. /**
  92593. * Binds the color curves to the shader.
  92594. * @param colorCurves The color curve to bind
  92595. * @param effect The effect to bind to
  92596. * @param positiveUniform The positive uniform shader parameter
  92597. * @param neutralUniform The neutral uniform shader parameter
  92598. * @param negativeUniform The negative uniform shader parameter
  92599. */
  92600. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92601. /**
  92602. * Prepare the list of uniforms associated with the ColorCurves effects.
  92603. * @param uniformsList The list of uniforms used in the effect
  92604. */
  92605. static PrepareUniforms(uniformsList: string[]): void;
  92606. /**
  92607. * Returns color grading data based on a hue, density, saturation and exposure value.
  92608. * @param filterHue The hue of the color filter.
  92609. * @param filterDensity The density of the color filter.
  92610. * @param saturation The saturation.
  92611. * @param exposure The exposure.
  92612. * @param result The result data container.
  92613. */
  92614. private getColorGradingDataToRef;
  92615. /**
  92616. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92617. * @param value The input slider value in range [-100,100].
  92618. * @returns Adjusted value.
  92619. */
  92620. private static applyColorGradingSliderNonlinear;
  92621. /**
  92622. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92623. * @param hue The hue (H) input.
  92624. * @param saturation The saturation (S) input.
  92625. * @param brightness The brightness (B) input.
  92626. * @result An RGBA color represented as Vector4.
  92627. */
  92628. private static fromHSBToRef;
  92629. /**
  92630. * Returns a value clamped between min and max
  92631. * @param value The value to clamp
  92632. * @param min The minimum of value
  92633. * @param max The maximum of value
  92634. * @returns The clamped value.
  92635. */
  92636. private static clamp;
  92637. /**
  92638. * Clones the current color curve instance.
  92639. * @return The cloned curves
  92640. */
  92641. clone(): ColorCurves;
  92642. /**
  92643. * Serializes the current color curve instance to a json representation.
  92644. * @return a JSON representation
  92645. */
  92646. serialize(): any;
  92647. /**
  92648. * Parses the color curve from a json representation.
  92649. * @param source the JSON source to parse
  92650. * @return The parsed curves
  92651. */
  92652. static Parse(source: any): ColorCurves;
  92653. }
  92654. }
  92655. declare module BABYLON {
  92656. /**
  92657. * Interface to follow in your material defines to integrate easily the
  92658. * Image proccessing functions.
  92659. * @hidden
  92660. */
  92661. export interface IImageProcessingConfigurationDefines {
  92662. IMAGEPROCESSING: boolean;
  92663. VIGNETTE: boolean;
  92664. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92665. VIGNETTEBLENDMODEOPAQUE: boolean;
  92666. TONEMAPPING: boolean;
  92667. TONEMAPPING_ACES: boolean;
  92668. CONTRAST: boolean;
  92669. EXPOSURE: boolean;
  92670. COLORCURVES: boolean;
  92671. COLORGRADING: boolean;
  92672. COLORGRADING3D: boolean;
  92673. SAMPLER3DGREENDEPTH: boolean;
  92674. SAMPLER3DBGRMAP: boolean;
  92675. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92676. }
  92677. /**
  92678. * @hidden
  92679. */
  92680. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  92681. IMAGEPROCESSING: boolean;
  92682. VIGNETTE: boolean;
  92683. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92684. VIGNETTEBLENDMODEOPAQUE: boolean;
  92685. TONEMAPPING: boolean;
  92686. TONEMAPPING_ACES: boolean;
  92687. CONTRAST: boolean;
  92688. COLORCURVES: boolean;
  92689. COLORGRADING: boolean;
  92690. COLORGRADING3D: boolean;
  92691. SAMPLER3DGREENDEPTH: boolean;
  92692. SAMPLER3DBGRMAP: boolean;
  92693. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92694. EXPOSURE: boolean;
  92695. constructor();
  92696. }
  92697. /**
  92698. * This groups together the common properties used for image processing either in direct forward pass
  92699. * or through post processing effect depending on the use of the image processing pipeline in your scene
  92700. * or not.
  92701. */
  92702. export class ImageProcessingConfiguration {
  92703. /**
  92704. * Default tone mapping applied in BabylonJS.
  92705. */
  92706. static readonly TONEMAPPING_STANDARD: number;
  92707. /**
  92708. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92709. * to other engines rendering to increase portability.
  92710. */
  92711. static readonly TONEMAPPING_ACES: number;
  92712. /**
  92713. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92714. */
  92715. colorCurves: Nullable<ColorCurves>;
  92716. private _colorCurvesEnabled;
  92717. /**
  92718. * Gets wether the color curves effect is enabled.
  92719. */
  92720. /**
  92721. * Sets wether the color curves effect is enabled.
  92722. */
  92723. colorCurvesEnabled: boolean;
  92724. private _colorGradingTexture;
  92725. /**
  92726. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92727. */
  92728. /**
  92729. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92730. */
  92731. colorGradingTexture: Nullable<BaseTexture>;
  92732. private _colorGradingEnabled;
  92733. /**
  92734. * Gets wether the color grading effect is enabled.
  92735. */
  92736. /**
  92737. * Sets wether the color grading effect is enabled.
  92738. */
  92739. colorGradingEnabled: boolean;
  92740. private _colorGradingWithGreenDepth;
  92741. /**
  92742. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  92743. */
  92744. /**
  92745. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  92746. */
  92747. colorGradingWithGreenDepth: boolean;
  92748. private _colorGradingBGR;
  92749. /**
  92750. * Gets wether the color grading texture contains BGR values.
  92751. */
  92752. /**
  92753. * Sets wether the color grading texture contains BGR values.
  92754. */
  92755. colorGradingBGR: boolean;
  92756. /** @hidden */
  92757. _exposure: number;
  92758. /**
  92759. * Gets the Exposure used in the effect.
  92760. */
  92761. /**
  92762. * Sets the Exposure used in the effect.
  92763. */
  92764. exposure: number;
  92765. private _toneMappingEnabled;
  92766. /**
  92767. * Gets wether the tone mapping effect is enabled.
  92768. */
  92769. /**
  92770. * Sets wether the tone mapping effect is enabled.
  92771. */
  92772. toneMappingEnabled: boolean;
  92773. private _toneMappingType;
  92774. /**
  92775. * Gets the type of tone mapping effect.
  92776. */
  92777. /**
  92778. * Sets the type of tone mapping effect used in BabylonJS.
  92779. */
  92780. toneMappingType: number;
  92781. protected _contrast: number;
  92782. /**
  92783. * Gets the contrast used in the effect.
  92784. */
  92785. /**
  92786. * Sets the contrast used in the effect.
  92787. */
  92788. contrast: number;
  92789. /**
  92790. * Vignette stretch size.
  92791. */
  92792. vignetteStretch: number;
  92793. /**
  92794. * Vignette centre X Offset.
  92795. */
  92796. vignetteCentreX: number;
  92797. /**
  92798. * Vignette centre Y Offset.
  92799. */
  92800. vignetteCentreY: number;
  92801. /**
  92802. * Vignette weight or intensity of the vignette effect.
  92803. */
  92804. vignetteWeight: number;
  92805. /**
  92806. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  92807. * if vignetteEnabled is set to true.
  92808. */
  92809. vignetteColor: Color4;
  92810. /**
  92811. * Camera field of view used by the Vignette effect.
  92812. */
  92813. vignetteCameraFov: number;
  92814. private _vignetteBlendMode;
  92815. /**
  92816. * Gets the vignette blend mode allowing different kind of effect.
  92817. */
  92818. /**
  92819. * Sets the vignette blend mode allowing different kind of effect.
  92820. */
  92821. vignetteBlendMode: number;
  92822. private _vignetteEnabled;
  92823. /**
  92824. * Gets wether the vignette effect is enabled.
  92825. */
  92826. /**
  92827. * Sets wether the vignette effect is enabled.
  92828. */
  92829. vignetteEnabled: boolean;
  92830. private _applyByPostProcess;
  92831. /**
  92832. * Gets wether the image processing is applied through a post process or not.
  92833. */
  92834. /**
  92835. * Sets wether the image processing is applied through a post process or not.
  92836. */
  92837. applyByPostProcess: boolean;
  92838. private _isEnabled;
  92839. /**
  92840. * Gets wether the image processing is enabled or not.
  92841. */
  92842. /**
  92843. * Sets wether the image processing is enabled or not.
  92844. */
  92845. isEnabled: boolean;
  92846. /**
  92847. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  92848. */
  92849. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  92850. /**
  92851. * Method called each time the image processing information changes requires to recompile the effect.
  92852. */
  92853. protected _updateParameters(): void;
  92854. /**
  92855. * Gets the current class name.
  92856. * @return "ImageProcessingConfiguration"
  92857. */
  92858. getClassName(): string;
  92859. /**
  92860. * Prepare the list of uniforms associated with the Image Processing effects.
  92861. * @param uniforms The list of uniforms used in the effect
  92862. * @param defines the list of defines currently in use
  92863. */
  92864. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  92865. /**
  92866. * Prepare the list of samplers associated with the Image Processing effects.
  92867. * @param samplersList The list of uniforms used in the effect
  92868. * @param defines the list of defines currently in use
  92869. */
  92870. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  92871. /**
  92872. * Prepare the list of defines associated to the shader.
  92873. * @param defines the list of defines to complete
  92874. * @param forPostProcess Define if we are currently in post process mode or not
  92875. */
  92876. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  92877. /**
  92878. * Returns true if all the image processing information are ready.
  92879. * @returns True if ready, otherwise, false
  92880. */
  92881. isReady(): boolean;
  92882. /**
  92883. * Binds the image processing to the shader.
  92884. * @param effect The effect to bind to
  92885. * @param aspectRatio Define the current aspect ratio of the effect
  92886. */
  92887. bind(effect: Effect, aspectRatio?: number): void;
  92888. /**
  92889. * Clones the current image processing instance.
  92890. * @return The cloned image processing
  92891. */
  92892. clone(): ImageProcessingConfiguration;
  92893. /**
  92894. * Serializes the current image processing instance to a json representation.
  92895. * @return a JSON representation
  92896. */
  92897. serialize(): any;
  92898. /**
  92899. * Parses the image processing from a json representation.
  92900. * @param source the JSON source to parse
  92901. * @return The parsed image processing
  92902. */
  92903. static Parse(source: any): ImageProcessingConfiguration;
  92904. private static _VIGNETTEMODE_MULTIPLY;
  92905. private static _VIGNETTEMODE_OPAQUE;
  92906. /**
  92907. * Used to apply the vignette as a mix with the pixel color.
  92908. */
  92909. static readonly VIGNETTEMODE_MULTIPLY: number;
  92910. /**
  92911. * Used to apply the vignette as a replacement of the pixel color.
  92912. */
  92913. static readonly VIGNETTEMODE_OPAQUE: number;
  92914. }
  92915. }
  92916. declare module BABYLON {
  92917. /**
  92918. * This represents all the required information to add a fresnel effect on a material:
  92919. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92920. */
  92921. export class FresnelParameters {
  92922. private _isEnabled;
  92923. /**
  92924. * Define if the fresnel effect is enable or not.
  92925. */
  92926. isEnabled: boolean;
  92927. /**
  92928. * Define the color used on edges (grazing angle)
  92929. */
  92930. leftColor: Color3;
  92931. /**
  92932. * Define the color used on center
  92933. */
  92934. rightColor: Color3;
  92935. /**
  92936. * Define bias applied to computed fresnel term
  92937. */
  92938. bias: number;
  92939. /**
  92940. * Defined the power exponent applied to fresnel term
  92941. */
  92942. power: number;
  92943. /**
  92944. * Clones the current fresnel and its valuues
  92945. * @returns a clone fresnel configuration
  92946. */
  92947. clone(): FresnelParameters;
  92948. /**
  92949. * Serializes the current fresnel parameters to a JSON representation.
  92950. * @return the JSON serialization
  92951. */
  92952. serialize(): any;
  92953. /**
  92954. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92955. * @param parsedFresnelParameters Define the JSON representation
  92956. * @returns the parsed parameters
  92957. */
  92958. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92959. }
  92960. }
  92961. declare module BABYLON {
  92962. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  92963. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92964. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92965. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92966. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92967. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92968. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92969. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92970. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92971. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92972. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92973. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92974. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92975. /**
  92976. * Decorator used to define property that can be serialized as reference to a camera
  92977. * @param sourceName defines the name of the property to decorate
  92978. */
  92979. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92980. /**
  92981. * Class used to help serialization objects
  92982. */
  92983. export class SerializationHelper {
  92984. /** @hidden */
  92985. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  92986. /** @hidden */
  92987. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  92988. /** @hidden */
  92989. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  92990. /** @hidden */
  92991. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  92992. /**
  92993. * Appends the serialized animations from the source animations
  92994. * @param source Source containing the animations
  92995. * @param destination Target to store the animations
  92996. */
  92997. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92998. /**
  92999. * Static function used to serialized a specific entity
  93000. * @param entity defines the entity to serialize
  93001. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93002. * @returns a JSON compatible object representing the serialization of the entity
  93003. */
  93004. static Serialize<T>(entity: T, serializationObject?: any): any;
  93005. /**
  93006. * Creates a new entity from a serialization data object
  93007. * @param creationFunction defines a function used to instanciated the new entity
  93008. * @param source defines the source serialization data
  93009. * @param scene defines the hosting scene
  93010. * @param rootUrl defines the root url for resources
  93011. * @returns a new entity
  93012. */
  93013. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93014. /**
  93015. * Clones an object
  93016. * @param creationFunction defines the function used to instanciate the new object
  93017. * @param source defines the source object
  93018. * @returns the cloned object
  93019. */
  93020. static Clone<T>(creationFunction: () => T, source: T): T;
  93021. /**
  93022. * Instanciates a new object based on a source one (some data will be shared between both object)
  93023. * @param creationFunction defines the function used to instanciate the new object
  93024. * @param source defines the source object
  93025. * @returns the new object
  93026. */
  93027. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93028. }
  93029. }
  93030. declare module BABYLON {
  93031. /**
  93032. * This is the base class of all the camera used in the application.
  93033. * @see http://doc.babylonjs.com/features/cameras
  93034. */
  93035. export class Camera extends Node {
  93036. /** @hidden */
  93037. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93038. /**
  93039. * This is the default projection mode used by the cameras.
  93040. * It helps recreating a feeling of perspective and better appreciate depth.
  93041. * This is the best way to simulate real life cameras.
  93042. */
  93043. static readonly PERSPECTIVE_CAMERA: number;
  93044. /**
  93045. * This helps creating camera with an orthographic mode.
  93046. * 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.
  93047. */
  93048. static readonly ORTHOGRAPHIC_CAMERA: number;
  93049. /**
  93050. * This is the default FOV mode for perspective cameras.
  93051. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93052. */
  93053. static readonly FOVMODE_VERTICAL_FIXED: number;
  93054. /**
  93055. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93056. */
  93057. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93058. /**
  93059. * This specifies ther is no need for a camera rig.
  93060. * Basically only one eye is rendered corresponding to the camera.
  93061. */
  93062. static readonly RIG_MODE_NONE: number;
  93063. /**
  93064. * Simulates a camera Rig with one blue eye and one red eye.
  93065. * This can be use with 3d blue and red glasses.
  93066. */
  93067. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93068. /**
  93069. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93070. */
  93071. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93072. /**
  93073. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93074. */
  93075. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93076. /**
  93077. * Defines that both eyes of the camera will be rendered over under each other.
  93078. */
  93079. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93080. /**
  93081. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93082. */
  93083. static readonly RIG_MODE_VR: number;
  93084. /**
  93085. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93086. */
  93087. static readonly RIG_MODE_WEBVR: number;
  93088. /**
  93089. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93090. */
  93091. static readonly RIG_MODE_CUSTOM: number;
  93092. /**
  93093. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93094. */
  93095. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93096. /**
  93097. * Define the input manager associated with the camera.
  93098. */
  93099. inputs: CameraInputsManager<Camera>;
  93100. /** @hidden */
  93101. _position: Vector3;
  93102. /**
  93103. * Define the current local position of the camera in the scene
  93104. */
  93105. position: Vector3;
  93106. /**
  93107. * The vector the camera should consider as up.
  93108. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93109. */
  93110. upVector: Vector3;
  93111. /**
  93112. * Define the current limit on the left side for an orthographic camera
  93113. * In scene unit
  93114. */
  93115. orthoLeft: Nullable<number>;
  93116. /**
  93117. * Define the current limit on the right side for an orthographic camera
  93118. * In scene unit
  93119. */
  93120. orthoRight: Nullable<number>;
  93121. /**
  93122. * Define the current limit on the bottom side for an orthographic camera
  93123. * In scene unit
  93124. */
  93125. orthoBottom: Nullable<number>;
  93126. /**
  93127. * Define the current limit on the top side for an orthographic camera
  93128. * In scene unit
  93129. */
  93130. orthoTop: Nullable<number>;
  93131. /**
  93132. * Field Of View is set in Radians. (default is 0.8)
  93133. */
  93134. fov: number;
  93135. /**
  93136. * Define the minimum distance the camera can see from.
  93137. * This is important to note that the depth buffer are not infinite and the closer it starts
  93138. * the more your scene might encounter depth fighting issue.
  93139. */
  93140. minZ: number;
  93141. /**
  93142. * Define the maximum distance the camera can see to.
  93143. * This is important to note that the depth buffer are not infinite and the further it end
  93144. * the more your scene might encounter depth fighting issue.
  93145. */
  93146. maxZ: number;
  93147. /**
  93148. * Define the default inertia of the camera.
  93149. * This helps giving a smooth feeling to the camera movement.
  93150. */
  93151. inertia: number;
  93152. /**
  93153. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  93154. */
  93155. mode: number;
  93156. /**
  93157. * Define wether the camera is intermediate.
  93158. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93159. */
  93160. isIntermediate: boolean;
  93161. /**
  93162. * Define the viewport of the camera.
  93163. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93164. */
  93165. viewport: Viewport;
  93166. /**
  93167. * Restricts the camera to viewing objects with the same layerMask.
  93168. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93169. */
  93170. layerMask: number;
  93171. /**
  93172. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93173. */
  93174. fovMode: number;
  93175. /**
  93176. * Rig mode of the camera.
  93177. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93178. * This is normally controlled byt the camera themselves as internal use.
  93179. */
  93180. cameraRigMode: number;
  93181. /**
  93182. * Defines the distance between both "eyes" in case of a RIG
  93183. */
  93184. interaxialDistance: number;
  93185. /**
  93186. * Defines if stereoscopic rendering is done side by side or over under.
  93187. */
  93188. isStereoscopicSideBySide: boolean;
  93189. /**
  93190. * 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
  93191. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93192. * else in the scene.
  93193. */
  93194. customRenderTargets: RenderTargetTexture[];
  93195. /**
  93196. * When set, the camera will render to this render target instead of the default canvas
  93197. */
  93198. outputRenderTarget: Nullable<RenderTargetTexture>;
  93199. /**
  93200. * Observable triggered when the camera view matrix has changed.
  93201. */
  93202. onViewMatrixChangedObservable: Observable<Camera>;
  93203. /**
  93204. * Observable triggered when the camera Projection matrix has changed.
  93205. */
  93206. onProjectionMatrixChangedObservable: Observable<Camera>;
  93207. /**
  93208. * Observable triggered when the inputs have been processed.
  93209. */
  93210. onAfterCheckInputsObservable: Observable<Camera>;
  93211. /**
  93212. * Observable triggered when reset has been called and applied to the camera.
  93213. */
  93214. onRestoreStateObservable: Observable<Camera>;
  93215. /** @hidden */
  93216. _cameraRigParams: any;
  93217. /** @hidden */
  93218. _rigCameras: Camera[];
  93219. /** @hidden */
  93220. _rigPostProcess: Nullable<PostProcess>;
  93221. protected _webvrViewMatrix: Matrix;
  93222. /** @hidden */
  93223. _skipRendering: boolean;
  93224. /** @hidden */
  93225. _projectionMatrix: Matrix;
  93226. /** @hidden */
  93227. _postProcesses: Nullable<PostProcess>[];
  93228. /** @hidden */
  93229. _activeMeshes: SmartArray<AbstractMesh>;
  93230. protected _globalPosition: Vector3;
  93231. /** @hidden */
  93232. _computedViewMatrix: Matrix;
  93233. private _doNotComputeProjectionMatrix;
  93234. private _transformMatrix;
  93235. private _frustumPlanes;
  93236. private _refreshFrustumPlanes;
  93237. private _storedFov;
  93238. private _stateStored;
  93239. /**
  93240. * Instantiates a new camera object.
  93241. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93242. * @see http://doc.babylonjs.com/features/cameras
  93243. * @param name Defines the name of the camera in the scene
  93244. * @param position Defines the position of the camera
  93245. * @param scene Defines the scene the camera belongs too
  93246. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93247. */
  93248. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93249. /**
  93250. * Store current camera state (fov, position, etc..)
  93251. * @returns the camera
  93252. */
  93253. storeState(): Camera;
  93254. /**
  93255. * Restores the camera state values if it has been stored. You must call storeState() first
  93256. */
  93257. protected _restoreStateValues(): boolean;
  93258. /**
  93259. * Restored camera state. You must call storeState() first.
  93260. * @returns true if restored and false otherwise
  93261. */
  93262. restoreState(): boolean;
  93263. /**
  93264. * Gets the class name of the camera.
  93265. * @returns the class name
  93266. */
  93267. getClassName(): string;
  93268. /** @hidden */
  93269. readonly _isCamera: boolean;
  93270. /**
  93271. * Gets a string representation of the camera useful for debug purpose.
  93272. * @param fullDetails Defines that a more verboe level of logging is required
  93273. * @returns the string representation
  93274. */
  93275. toString(fullDetails?: boolean): string;
  93276. /**
  93277. * Gets the current world space position of the camera.
  93278. */
  93279. readonly globalPosition: Vector3;
  93280. /**
  93281. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93282. * @returns the active meshe list
  93283. */
  93284. getActiveMeshes(): SmartArray<AbstractMesh>;
  93285. /**
  93286. * Check wether a mesh is part of the current active mesh list of the camera
  93287. * @param mesh Defines the mesh to check
  93288. * @returns true if active, false otherwise
  93289. */
  93290. isActiveMesh(mesh: Mesh): boolean;
  93291. /**
  93292. * Is this camera ready to be used/rendered
  93293. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93294. * @return true if the camera is ready
  93295. */
  93296. isReady(completeCheck?: boolean): boolean;
  93297. /** @hidden */
  93298. _initCache(): void;
  93299. /** @hidden */
  93300. _updateCache(ignoreParentClass?: boolean): void;
  93301. /** @hidden */
  93302. _isSynchronized(): boolean;
  93303. /** @hidden */
  93304. _isSynchronizedViewMatrix(): boolean;
  93305. /** @hidden */
  93306. _isSynchronizedProjectionMatrix(): boolean;
  93307. /**
  93308. * Attach the input controls to a specific dom element to get the input from.
  93309. * @param element Defines the element the controls should be listened from
  93310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93311. */
  93312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93313. /**
  93314. * Detach the current controls from the specified dom element.
  93315. * @param element Defines the element to stop listening the inputs from
  93316. */
  93317. detachControl(element: HTMLElement): void;
  93318. /**
  93319. * Update the camera state according to the different inputs gathered during the frame.
  93320. */
  93321. update(): void;
  93322. /** @hidden */
  93323. _checkInputs(): void;
  93324. /** @hidden */
  93325. readonly rigCameras: Camera[];
  93326. /**
  93327. * Gets the post process used by the rig cameras
  93328. */
  93329. readonly rigPostProcess: Nullable<PostProcess>;
  93330. /**
  93331. * Internal, gets the first post proces.
  93332. * @returns the first post process to be run on this camera.
  93333. */
  93334. _getFirstPostProcess(): Nullable<PostProcess>;
  93335. private _cascadePostProcessesToRigCams;
  93336. /**
  93337. * Attach a post process to the camera.
  93338. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93339. * @param postProcess The post process to attach to the camera
  93340. * @param insertAt The position of the post process in case several of them are in use in the scene
  93341. * @returns the position the post process has been inserted at
  93342. */
  93343. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93344. /**
  93345. * Detach a post process to the camera.
  93346. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93347. * @param postProcess The post process to detach from the camera
  93348. */
  93349. detachPostProcess(postProcess: PostProcess): void;
  93350. /**
  93351. * Gets the current world matrix of the camera
  93352. */
  93353. getWorldMatrix(): Matrix;
  93354. /** @hidden */
  93355. _getViewMatrix(): Matrix;
  93356. /**
  93357. * Gets the current view matrix of the camera.
  93358. * @param force forces the camera to recompute the matrix without looking at the cached state
  93359. * @returns the view matrix
  93360. */
  93361. getViewMatrix(force?: boolean): Matrix;
  93362. /**
  93363. * Freeze the projection matrix.
  93364. * It will prevent the cache check of the camera projection compute and can speed up perf
  93365. * if no parameter of the camera are meant to change
  93366. * @param projection Defines manually a projection if necessary
  93367. */
  93368. freezeProjectionMatrix(projection?: Matrix): void;
  93369. /**
  93370. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93371. */
  93372. unfreezeProjectionMatrix(): void;
  93373. /**
  93374. * Gets the current projection matrix of the camera.
  93375. * @param force forces the camera to recompute the matrix without looking at the cached state
  93376. * @returns the projection matrix
  93377. */
  93378. getProjectionMatrix(force?: boolean): Matrix;
  93379. /**
  93380. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93381. * @returns a Matrix
  93382. */
  93383. getTransformationMatrix(): Matrix;
  93384. private _updateFrustumPlanes;
  93385. /**
  93386. * Checks if a cullable object (mesh...) is in the camera frustum
  93387. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93388. * @param target The object to check
  93389. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93390. * @returns true if the object is in frustum otherwise false
  93391. */
  93392. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93393. /**
  93394. * Checks if a cullable object (mesh...) is in the camera frustum
  93395. * Unlike isInFrustum this cheks the full bounding box
  93396. * @param target The object to check
  93397. * @returns true if the object is in frustum otherwise false
  93398. */
  93399. isCompletelyInFrustum(target: ICullable): boolean;
  93400. /**
  93401. * Gets a ray in the forward direction from the camera.
  93402. * @param length Defines the length of the ray to create
  93403. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93404. * @param origin Defines the start point of the ray which defaults to the camera position
  93405. * @returns the forward ray
  93406. */
  93407. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93408. /**
  93409. * Releases resources associated with this node.
  93410. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93411. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93412. */
  93413. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93414. /** @hidden */
  93415. _isLeftCamera: boolean;
  93416. /**
  93417. * Gets the left camera of a rig setup in case of Rigged Camera
  93418. */
  93419. readonly isLeftCamera: boolean;
  93420. /** @hidden */
  93421. _isRightCamera: boolean;
  93422. /**
  93423. * Gets the right camera of a rig setup in case of Rigged Camera
  93424. */
  93425. readonly isRightCamera: boolean;
  93426. /**
  93427. * Gets the left camera of a rig setup in case of Rigged Camera
  93428. */
  93429. readonly leftCamera: Nullable<FreeCamera>;
  93430. /**
  93431. * Gets the right camera of a rig setup in case of Rigged Camera
  93432. */
  93433. readonly rightCamera: Nullable<FreeCamera>;
  93434. /**
  93435. * Gets the left camera target of a rig setup in case of Rigged Camera
  93436. * @returns the target position
  93437. */
  93438. getLeftTarget(): Nullable<Vector3>;
  93439. /**
  93440. * Gets the right camera target of a rig setup in case of Rigged Camera
  93441. * @returns the target position
  93442. */
  93443. getRightTarget(): Nullable<Vector3>;
  93444. /**
  93445. * @hidden
  93446. */
  93447. setCameraRigMode(mode: number, rigParams: any): void;
  93448. /** @hidden */
  93449. static _setStereoscopicRigMode(camera: Camera): void;
  93450. /** @hidden */
  93451. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93452. /** @hidden */
  93453. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93454. /** @hidden */
  93455. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93456. /** @hidden */
  93457. _getVRProjectionMatrix(): Matrix;
  93458. protected _updateCameraRotationMatrix(): void;
  93459. protected _updateWebVRCameraRotationMatrix(): void;
  93460. /**
  93461. * This function MUST be overwritten by the different WebVR cameras available.
  93462. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93463. * @hidden
  93464. */
  93465. _getWebVRProjectionMatrix(): Matrix;
  93466. /**
  93467. * This function MUST be overwritten by the different WebVR cameras available.
  93468. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93469. * @hidden
  93470. */
  93471. _getWebVRViewMatrix(): Matrix;
  93472. /** @hidden */
  93473. setCameraRigParameter(name: string, value: any): void;
  93474. /**
  93475. * needs to be overridden by children so sub has required properties to be copied
  93476. * @hidden
  93477. */
  93478. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93479. /**
  93480. * May need to be overridden by children
  93481. * @hidden
  93482. */
  93483. _updateRigCameras(): void;
  93484. /** @hidden */
  93485. _setupInputs(): void;
  93486. /**
  93487. * Serialiaze the camera setup to a json represention
  93488. * @returns the JSON representation
  93489. */
  93490. serialize(): any;
  93491. /**
  93492. * Clones the current camera.
  93493. * @param name The cloned camera name
  93494. * @returns the cloned camera
  93495. */
  93496. clone(name: string): Camera;
  93497. /**
  93498. * Gets the direction of the camera relative to a given local axis.
  93499. * @param localAxis Defines the reference axis to provide a relative direction.
  93500. * @return the direction
  93501. */
  93502. getDirection(localAxis: Vector3): Vector3;
  93503. /**
  93504. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93505. * @param localAxis Defines the reference axis to provide a relative direction.
  93506. * @param result Defines the vector to store the result in
  93507. */
  93508. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93509. /**
  93510. * Gets a camera constructor for a given camera type
  93511. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93512. * @param name The name of the camera the result will be able to instantiate
  93513. * @param scene The scene the result will construct the camera in
  93514. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93515. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93516. * @returns a factory method to construc the camera
  93517. */
  93518. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93519. /**
  93520. * Compute the world matrix of the camera.
  93521. * @returns the camera workd matrix
  93522. */
  93523. computeWorldMatrix(): Matrix;
  93524. /**
  93525. * Parse a JSON and creates the camera from the parsed information
  93526. * @param parsedCamera The JSON to parse
  93527. * @param scene The scene to instantiate the camera in
  93528. * @returns the newly constructed camera
  93529. */
  93530. static Parse(parsedCamera: any, scene: Scene): Camera;
  93531. }
  93532. }
  93533. declare module BABYLON {
  93534. /**
  93535. * Interface for any object that can request an animation frame
  93536. */
  93537. export interface ICustomAnimationFrameRequester {
  93538. /**
  93539. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93540. */
  93541. renderFunction?: Function;
  93542. /**
  93543. * Called to request the next frame to render to
  93544. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93545. */
  93546. requestAnimationFrame: Function;
  93547. /**
  93548. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93549. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93550. */
  93551. requestID?: number;
  93552. }
  93553. /**
  93554. * Interface containing an array of animations
  93555. */
  93556. export interface IAnimatable {
  93557. /**
  93558. * Array of animations
  93559. */
  93560. animations: Nullable<Array<Animation>>;
  93561. }
  93562. /** Interface used by value gradients (color, factor, ...) */
  93563. export interface IValueGradient {
  93564. /**
  93565. * Gets or sets the gradient value (between 0 and 1)
  93566. */
  93567. gradient: number;
  93568. }
  93569. /** Class used to store color4 gradient */
  93570. export class ColorGradient implements IValueGradient {
  93571. /**
  93572. * Gets or sets the gradient value (between 0 and 1)
  93573. */
  93574. gradient: number;
  93575. /**
  93576. * Gets or sets first associated color
  93577. */
  93578. color1: Color4;
  93579. /**
  93580. * Gets or sets second associated color
  93581. */
  93582. color2?: Color4;
  93583. /**
  93584. * Will get a color picked randomly between color1 and color2.
  93585. * If color2 is undefined then color1 will be used
  93586. * @param result defines the target Color4 to store the result in
  93587. */
  93588. getColorToRef(result: Color4): void;
  93589. }
  93590. /** Class used to store color 3 gradient */
  93591. export class Color3Gradient implements IValueGradient {
  93592. /**
  93593. * Gets or sets the gradient value (between 0 and 1)
  93594. */
  93595. gradient: number;
  93596. /**
  93597. * Gets or sets the associated color
  93598. */
  93599. color: Color3;
  93600. }
  93601. /** Class used to store factor gradient */
  93602. export class FactorGradient implements IValueGradient {
  93603. /**
  93604. * Gets or sets the gradient value (between 0 and 1)
  93605. */
  93606. gradient: number;
  93607. /**
  93608. * Gets or sets first associated factor
  93609. */
  93610. factor1: number;
  93611. /**
  93612. * Gets or sets second associated factor
  93613. */
  93614. factor2?: number;
  93615. /**
  93616. * Will get a number picked randomly between factor1 and factor2.
  93617. * If factor2 is undefined then factor1 will be used
  93618. * @returns the picked number
  93619. */
  93620. getFactor(): number;
  93621. }
  93622. /**
  93623. * @ignore
  93624. * Application error to support additional information when loading a file
  93625. */
  93626. export class LoadFileError extends Error {
  93627. /** defines the optional web request */
  93628. request?: WebRequest | undefined;
  93629. private static _setPrototypeOf;
  93630. /**
  93631. * Creates a new LoadFileError
  93632. * @param message defines the message of the error
  93633. * @param request defines the optional web request
  93634. */
  93635. constructor(message: string,
  93636. /** defines the optional web request */
  93637. request?: WebRequest | undefined);
  93638. }
  93639. /**
  93640. * Class used to define a retry strategy when error happens while loading assets
  93641. */
  93642. export class RetryStrategy {
  93643. /**
  93644. * Function used to defines an exponential back off strategy
  93645. * @param maxRetries defines the maximum number of retries (3 by default)
  93646. * @param baseInterval defines the interval between retries
  93647. * @returns the strategy function to use
  93648. */
  93649. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  93650. }
  93651. /**
  93652. * File request interface
  93653. */
  93654. export interface IFileRequest {
  93655. /**
  93656. * Raised when the request is complete (success or error).
  93657. */
  93658. onCompleteObservable: Observable<IFileRequest>;
  93659. /**
  93660. * Aborts the request for a file.
  93661. */
  93662. abort: () => void;
  93663. }
  93664. /**
  93665. * Class containing a set of static utilities functions
  93666. */
  93667. export class Tools {
  93668. /**
  93669. * Gets or sets the base URL to use to load assets
  93670. */
  93671. static BaseUrl: string;
  93672. /**
  93673. * Enable/Disable Custom HTTP Request Headers globally.
  93674. * default = false
  93675. * @see CustomRequestHeaders
  93676. */
  93677. static UseCustomRequestHeaders: boolean;
  93678. /**
  93679. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  93680. * i.e. when loading files, where the server/service expects an Authorization header
  93681. */
  93682. static CustomRequestHeaders: {
  93683. [key: string]: string;
  93684. };
  93685. /**
  93686. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  93687. */
  93688. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  93689. /**
  93690. * Default behaviour for cors in the application.
  93691. * It can be a string if the expected behavior is identical in the entire app.
  93692. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  93693. */
  93694. static CorsBehavior: string | ((url: string | string[]) => string);
  93695. /**
  93696. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  93697. * @ignorenaming
  93698. */
  93699. static UseFallbackTexture: boolean;
  93700. /**
  93701. * Use this object to register external classes like custom textures or material
  93702. * to allow the laoders to instantiate them
  93703. */
  93704. static RegisteredExternalClasses: {
  93705. [key: string]: Object;
  93706. };
  93707. /**
  93708. * Texture content used if a texture cannot loaded
  93709. * @ignorenaming
  93710. */
  93711. static fallbackTexture: string;
  93712. /**
  93713. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  93714. * @param u defines the coordinate on X axis
  93715. * @param v defines the coordinate on Y axis
  93716. * @param width defines the width of the source data
  93717. * @param height defines the height of the source data
  93718. * @param pixels defines the source byte array
  93719. * @param color defines the output color
  93720. */
  93721. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  93722. /**
  93723. * Interpolates between a and b via alpha
  93724. * @param a The lower value (returned when alpha = 0)
  93725. * @param b The upper value (returned when alpha = 1)
  93726. * @param alpha The interpolation-factor
  93727. * @return The mixed value
  93728. */
  93729. static Mix(a: number, b: number, alpha: number): number;
  93730. /**
  93731. * Tries to instantiate a new object from a given class name
  93732. * @param className defines the class name to instantiate
  93733. * @returns the new object or null if the system was not able to do the instantiation
  93734. */
  93735. static Instantiate(className: string): any;
  93736. /**
  93737. * Provides a slice function that will work even on IE
  93738. * @param data defines the array to slice
  93739. * @param start defines the start of the data (optional)
  93740. * @param end defines the end of the data (optional)
  93741. * @returns the new sliced array
  93742. */
  93743. static Slice<T>(data: T, start?: number, end?: number): T;
  93744. /**
  93745. * Polyfill for setImmediate
  93746. * @param action defines the action to execute after the current execution block
  93747. */
  93748. static SetImmediate(action: () => void): void;
  93749. /**
  93750. * Function indicating if a number is an exponent of 2
  93751. * @param value defines the value to test
  93752. * @returns true if the value is an exponent of 2
  93753. */
  93754. static IsExponentOfTwo(value: number): boolean;
  93755. private static _tmpFloatArray;
  93756. /**
  93757. * Returns the nearest 32-bit single precision float representation of a Number
  93758. * @param value A Number. If the parameter is of a different type, it will get converted
  93759. * to a number or to NaN if it cannot be converted
  93760. * @returns number
  93761. */
  93762. static FloatRound(value: number): number;
  93763. /**
  93764. * Find the next highest power of two.
  93765. * @param x Number to start search from.
  93766. * @return Next highest power of two.
  93767. */
  93768. static CeilingPOT(x: number): number;
  93769. /**
  93770. * Find the next lowest power of two.
  93771. * @param x Number to start search from.
  93772. * @return Next lowest power of two.
  93773. */
  93774. static FloorPOT(x: number): number;
  93775. /**
  93776. * Find the nearest power of two.
  93777. * @param x Number to start search from.
  93778. * @return Next nearest power of two.
  93779. */
  93780. static NearestPOT(x: number): number;
  93781. /**
  93782. * Get the closest exponent of two
  93783. * @param value defines the value to approximate
  93784. * @param max defines the maximum value to return
  93785. * @param mode defines how to define the closest value
  93786. * @returns closest exponent of two of the given value
  93787. */
  93788. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  93789. /**
  93790. * Extracts the filename from a path
  93791. * @param path defines the path to use
  93792. * @returns the filename
  93793. */
  93794. static GetFilename(path: string): string;
  93795. /**
  93796. * Extracts the "folder" part of a path (everything before the filename).
  93797. * @param uri The URI to extract the info from
  93798. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  93799. * @returns The "folder" part of the path
  93800. */
  93801. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  93802. /**
  93803. * Extracts text content from a DOM element hierarchy
  93804. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  93805. */
  93806. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  93807. /**
  93808. * Convert an angle in radians to degrees
  93809. * @param angle defines the angle to convert
  93810. * @returns the angle in degrees
  93811. */
  93812. static ToDegrees(angle: number): number;
  93813. /**
  93814. * Convert an angle in degrees to radians
  93815. * @param angle defines the angle to convert
  93816. * @returns the angle in radians
  93817. */
  93818. static ToRadians(angle: number): number;
  93819. /**
  93820. * Encode a buffer to a base64 string
  93821. * @param buffer defines the buffer to encode
  93822. * @returns the encoded string
  93823. */
  93824. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  93825. /**
  93826. * Extracts minimum and maximum values from a list of indexed positions
  93827. * @param positions defines the positions to use
  93828. * @param indices defines the indices to the positions
  93829. * @param indexStart defines the start index
  93830. * @param indexCount defines the end index
  93831. * @param bias defines bias value to add to the result
  93832. * @return minimum and maximum values
  93833. */
  93834. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  93835. minimum: Vector3;
  93836. maximum: Vector3;
  93837. };
  93838. /**
  93839. * Extracts minimum and maximum values from a list of positions
  93840. * @param positions defines the positions to use
  93841. * @param start defines the start index in the positions array
  93842. * @param count defines the number of positions to handle
  93843. * @param bias defines bias value to add to the result
  93844. * @param stride defines the stride size to use (distance between two positions in the positions array)
  93845. * @return minimum and maximum values
  93846. */
  93847. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  93848. minimum: Vector3;
  93849. maximum: Vector3;
  93850. };
  93851. /**
  93852. * Returns an array if obj is not an array
  93853. * @param obj defines the object to evaluate as an array
  93854. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  93855. * @returns either obj directly if obj is an array or a new array containing obj
  93856. */
  93857. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  93858. /**
  93859. * Gets the pointer prefix to use
  93860. * @returns "pointer" if touch is enabled. Else returns "mouse"
  93861. */
  93862. static GetPointerPrefix(): string;
  93863. /**
  93864. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  93865. * @param func - the function to be called
  93866. * @param requester - the object that will request the next frame. Falls back to window.
  93867. * @returns frame number
  93868. */
  93869. static QueueNewFrame(func: () => void, requester?: any): number;
  93870. /**
  93871. * Ask the browser to promote the current element to fullscreen rendering mode
  93872. * @param element defines the DOM element to promote
  93873. */
  93874. static RequestFullscreen(element: HTMLElement): void;
  93875. /**
  93876. * Asks the browser to exit fullscreen mode
  93877. */
  93878. static ExitFullscreen(): void;
  93879. /**
  93880. * Ask the browser to promote the current element to pointerlock mode
  93881. * @param element defines the DOM element to promote
  93882. */
  93883. static RequestPointerlock(element: HTMLElement): void;
  93884. /**
  93885. * Asks the browser to exit pointerlock mode
  93886. */
  93887. static ExitPointerlock(): void;
  93888. /**
  93889. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  93890. * @param url define the url we are trying
  93891. * @param element define the dom element where to configure the cors policy
  93892. */
  93893. static SetCorsBehavior(url: string | string[], element: {
  93894. crossOrigin: string | null;
  93895. }): void;
  93896. /**
  93897. * Removes unwanted characters from an url
  93898. * @param url defines the url to clean
  93899. * @returns the cleaned url
  93900. */
  93901. static CleanUrl(url: string): string;
  93902. /**
  93903. * Gets or sets a function used to pre-process url before using them to load assets
  93904. */
  93905. static PreprocessUrl: (url: string) => string;
  93906. /**
  93907. * Loads an image as an HTMLImageElement.
  93908. * @param input url string, ArrayBuffer, or Blob to load
  93909. * @param onLoad callback called when the image successfully loads
  93910. * @param onError callback called when the image fails to load
  93911. * @param offlineProvider offline provider for caching
  93912. * @returns the HTMLImageElement of the loaded image
  93913. */
  93914. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  93915. /**
  93916. * Loads a file
  93917. * @param url url string, ArrayBuffer, or Blob to load
  93918. * @param onSuccess callback called when the file successfully loads
  93919. * @param onProgress callback called while file is loading (if the server supports this mode)
  93920. * @param offlineProvider defines the offline provider for caching
  93921. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  93922. * @param onError callback called when the file fails to load
  93923. * @returns a file request object
  93924. */
  93925. 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;
  93926. /**
  93927. * Loads a file from a url
  93928. * @param url the file url to load
  93929. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  93930. */
  93931. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  93932. /**
  93933. * Load a script (identified by an url). When the url returns, the
  93934. * content of this file is added into a new script element, attached to the DOM (body element)
  93935. * @param scriptUrl defines the url of the script to laod
  93936. * @param onSuccess defines the callback called when the script is loaded
  93937. * @param onError defines the callback to call if an error occurs
  93938. * @param scriptId defines the id of the script element
  93939. */
  93940. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  93941. /**
  93942. * Load an asynchronous script (identified by an url). When the url returns, the
  93943. * content of this file is added into a new script element, attached to the DOM (body element)
  93944. * @param scriptUrl defines the url of the script to laod
  93945. * @param scriptId defines the id of the script element
  93946. * @returns a promise request object
  93947. */
  93948. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  93949. /**
  93950. * Loads a file from a blob
  93951. * @param fileToLoad defines the blob to use
  93952. * @param callback defines the callback to call when data is loaded
  93953. * @param progressCallback defines the callback to call during loading process
  93954. * @returns a file request object
  93955. */
  93956. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  93957. /**
  93958. * Loads a file
  93959. * @param fileToLoad defines the file to load
  93960. * @param callback defines the callback to call when data is loaded
  93961. * @param progressCallBack defines the callback to call during loading process
  93962. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  93963. * @returns a file request object
  93964. */
  93965. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  93966. /**
  93967. * Creates a data url from a given string content
  93968. * @param content defines the content to convert
  93969. * @returns the new data url link
  93970. */
  93971. static FileAsURL(content: string): string;
  93972. /**
  93973. * Format the given number to a specific decimal format
  93974. * @param value defines the number to format
  93975. * @param decimals defines the number of decimals to use
  93976. * @returns the formatted string
  93977. */
  93978. static Format(value: number, decimals?: number): string;
  93979. /**
  93980. * Checks if a given vector is inside a specific range
  93981. * @param v defines the vector to test
  93982. * @param min defines the minimum range
  93983. * @param max defines the maximum range
  93984. */
  93985. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  93986. /**
  93987. * Tries to copy an object by duplicating every property
  93988. * @param source defines the source object
  93989. * @param destination defines the target object
  93990. * @param doNotCopyList defines a list of properties to avoid
  93991. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  93992. */
  93993. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  93994. /**
  93995. * Gets a boolean indicating if the given object has no own property
  93996. * @param obj defines the object to test
  93997. * @returns true if object has no own property
  93998. */
  93999. static IsEmpty(obj: any): boolean;
  94000. /**
  94001. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  94002. * @param str Source string
  94003. * @param suffix Suffix to search for in the source string
  94004. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94005. */
  94006. static EndsWith(str: string, suffix: string): boolean;
  94007. /**
  94008. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  94009. * @param str Source string
  94010. * @param suffix Suffix to search for in the source string
  94011. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94012. */
  94013. static StartsWith(str: string, suffix: string): boolean;
  94014. /**
  94015. * Function used to register events at window level
  94016. * @param events defines the events to register
  94017. */
  94018. static RegisterTopRootEvents(events: {
  94019. name: string;
  94020. handler: Nullable<(e: FocusEvent) => any>;
  94021. }[]): void;
  94022. /**
  94023. * Function used to unregister events from window level
  94024. * @param events defines the events to unregister
  94025. */
  94026. static UnregisterTopRootEvents(events: {
  94027. name: string;
  94028. handler: Nullable<(e: FocusEvent) => any>;
  94029. }[]): void;
  94030. /**
  94031. * @ignore
  94032. */
  94033. static _ScreenshotCanvas: HTMLCanvasElement;
  94034. /**
  94035. * Dumps the current bound framebuffer
  94036. * @param width defines the rendering width
  94037. * @param height defines the rendering height
  94038. * @param engine defines the hosting engine
  94039. * @param successCallback defines the callback triggered once the data are available
  94040. * @param mimeType defines the mime type of the result
  94041. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  94042. */
  94043. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94044. /**
  94045. * Converts the canvas data to blob.
  94046. * This acts as a polyfill for browsers not supporting the to blob function.
  94047. * @param canvas Defines the canvas to extract the data from
  94048. * @param successCallback Defines the callback triggered once the data are available
  94049. * @param mimeType Defines the mime type of the result
  94050. */
  94051. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  94052. /**
  94053. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  94054. * @param successCallback defines the callback triggered once the data are available
  94055. * @param mimeType defines the mime type of the result
  94056. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  94057. */
  94058. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94059. /**
  94060. * Downloads a blob in the browser
  94061. * @param blob defines the blob to download
  94062. * @param fileName defines the name of the downloaded file
  94063. */
  94064. static Download(blob: Blob, fileName: string): void;
  94065. /**
  94066. * Captures a screenshot of the current rendering
  94067. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94068. * @param engine defines the rendering engine
  94069. * @param camera defines the source camera
  94070. * @param size This parameter can be set to a single number or to an object with the
  94071. * following (optional) properties: precision, width, height. If a single number is passed,
  94072. * it will be used for both width and height. If an object is passed, the screenshot size
  94073. * will be derived from the parameters. The precision property is a multiplier allowing
  94074. * rendering at a higher or lower resolution
  94075. * @param successCallback defines the callback receives a single parameter which contains the
  94076. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94077. * src parameter of an <img> to display it
  94078. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  94079. * Check your browser for supported MIME types
  94080. */
  94081. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  94082. /**
  94083. * Generates an image screenshot from the specified camera.
  94084. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94085. * @param engine The engine to use for rendering
  94086. * @param camera The camera to use for rendering
  94087. * @param size This parameter can be set to a single number or to an object with the
  94088. * following (optional) properties: precision, width, height. If a single number is passed,
  94089. * it will be used for both width and height. If an object is passed, the screenshot size
  94090. * will be derived from the parameters. The precision property is a multiplier allowing
  94091. * rendering at a higher or lower resolution
  94092. * @param successCallback The callback receives a single parameter which contains the
  94093. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94094. * src parameter of an <img> to display it
  94095. * @param mimeType The MIME type of the screenshot image (default: image/png).
  94096. * Check your browser for supported MIME types
  94097. * @param samples Texture samples (default: 1)
  94098. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  94099. * @param fileName A name for for the downloaded file.
  94100. */
  94101. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  94102. /**
  94103. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94104. * Be aware Math.random() could cause collisions, but:
  94105. * "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"
  94106. * @returns a pseudo random id
  94107. */
  94108. static RandomId(): string;
  94109. /**
  94110. * Test if the given uri is a base64 string
  94111. * @param uri The uri to test
  94112. * @return True if the uri is a base64 string or false otherwise
  94113. */
  94114. static IsBase64(uri: string): boolean;
  94115. /**
  94116. * Decode the given base64 uri.
  94117. * @param uri The uri to decode
  94118. * @return The decoded base64 data.
  94119. */
  94120. static DecodeBase64(uri: string): ArrayBuffer;
  94121. /**
  94122. * Gets the absolute url.
  94123. * @param url the input url
  94124. * @return the absolute url
  94125. */
  94126. static GetAbsoluteUrl(url: string): string;
  94127. /**
  94128. * No log
  94129. */
  94130. static readonly NoneLogLevel: number;
  94131. /**
  94132. * Only message logs
  94133. */
  94134. static readonly MessageLogLevel: number;
  94135. /**
  94136. * Only warning logs
  94137. */
  94138. static readonly WarningLogLevel: number;
  94139. /**
  94140. * Only error logs
  94141. */
  94142. static readonly ErrorLogLevel: number;
  94143. /**
  94144. * All logs
  94145. */
  94146. static readonly AllLogLevel: number;
  94147. /**
  94148. * Gets a value indicating the number of loading errors
  94149. * @ignorenaming
  94150. */
  94151. static readonly errorsCount: number;
  94152. /**
  94153. * Callback called when a new log is added
  94154. */
  94155. static OnNewCacheEntry: (entry: string) => void;
  94156. /**
  94157. * Log a message to the console
  94158. * @param message defines the message to log
  94159. */
  94160. static Log(message: string): void;
  94161. /**
  94162. * Write a warning message to the console
  94163. * @param message defines the message to log
  94164. */
  94165. static Warn(message: string): void;
  94166. /**
  94167. * Write an error message to the console
  94168. * @param message defines the message to log
  94169. */
  94170. static Error(message: string): void;
  94171. /**
  94172. * Gets current log cache (list of logs)
  94173. */
  94174. static readonly LogCache: string;
  94175. /**
  94176. * Clears the log cache
  94177. */
  94178. static ClearLogCache(): void;
  94179. /**
  94180. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94181. */
  94182. static LogLevels: number;
  94183. /**
  94184. * Checks if the loaded document was accessed via `file:`-Protocol.
  94185. * @returns boolean
  94186. */
  94187. static IsFileURL(): boolean;
  94188. /**
  94189. * Checks if the window object exists
  94190. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  94191. */
  94192. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  94193. /**
  94194. * No performance log
  94195. */
  94196. static readonly PerformanceNoneLogLevel: number;
  94197. /**
  94198. * Use user marks to log performance
  94199. */
  94200. static readonly PerformanceUserMarkLogLevel: number;
  94201. /**
  94202. * Log performance to the console
  94203. */
  94204. static readonly PerformanceConsoleLogLevel: number;
  94205. private static _performance;
  94206. /**
  94207. * Sets the current performance log level
  94208. */
  94209. static PerformanceLogLevel: number;
  94210. private static _StartPerformanceCounterDisabled;
  94211. private static _EndPerformanceCounterDisabled;
  94212. private static _StartUserMark;
  94213. private static _EndUserMark;
  94214. private static _StartPerformanceConsole;
  94215. private static _EndPerformanceConsole;
  94216. /**
  94217. * Starts a performance counter
  94218. */
  94219. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94220. /**
  94221. * Ends a specific performance coutner
  94222. */
  94223. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94224. /**
  94225. * Gets either window.performance.now() if supported or Date.now() else
  94226. */
  94227. static readonly Now: number;
  94228. /**
  94229. * This method will return the name of the class used to create the instance of the given object.
  94230. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  94231. * @param object the object to get the class name from
  94232. * @param isType defines if the object is actually a type
  94233. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  94234. */
  94235. static GetClassName(object: any, isType?: boolean): string;
  94236. /**
  94237. * Gets the first element of an array satisfying a given predicate
  94238. * @param array defines the array to browse
  94239. * @param predicate defines the predicate to use
  94240. * @returns null if not found or the element
  94241. */
  94242. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  94243. /**
  94244. * This method will return the name of the full name of the class, including its owning module (if any).
  94245. * 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).
  94246. * @param object the object to get the class name from
  94247. * @param isType defines if the object is actually a type
  94248. * @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.
  94249. * @ignorenaming
  94250. */
  94251. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  94252. /**
  94253. * Returns a promise that resolves after the given amount of time.
  94254. * @param delay Number of milliseconds to delay
  94255. * @returns Promise that resolves after the given amount of time
  94256. */
  94257. static DelayAsync(delay: number): Promise<void>;
  94258. /**
  94259. * Gets the current gradient from an array of IValueGradient
  94260. * @param ratio defines the current ratio to get
  94261. * @param gradients defines the array of IValueGradient
  94262. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  94263. */
  94264. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  94265. }
  94266. /**
  94267. * This class is used to track a performance counter which is number based.
  94268. * The user has access to many properties which give statistics of different nature.
  94269. *
  94270. * The implementer can track two kinds of Performance Counter: time and count.
  94271. * 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.
  94272. * 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.
  94273. */
  94274. export class PerfCounter {
  94275. /**
  94276. * Gets or sets a global boolean to turn on and off all the counters
  94277. */
  94278. static Enabled: boolean;
  94279. /**
  94280. * Returns the smallest value ever
  94281. */
  94282. readonly min: number;
  94283. /**
  94284. * Returns the biggest value ever
  94285. */
  94286. readonly max: number;
  94287. /**
  94288. * Returns the average value since the performance counter is running
  94289. */
  94290. readonly average: number;
  94291. /**
  94292. * Returns the average value of the last second the counter was monitored
  94293. */
  94294. readonly lastSecAverage: number;
  94295. /**
  94296. * Returns the current value
  94297. */
  94298. readonly current: number;
  94299. /**
  94300. * Gets the accumulated total
  94301. */
  94302. readonly total: number;
  94303. /**
  94304. * Gets the total value count
  94305. */
  94306. readonly count: number;
  94307. /**
  94308. * Creates a new counter
  94309. */
  94310. constructor();
  94311. /**
  94312. * Call this method to start monitoring a new frame.
  94313. * 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.
  94314. */
  94315. fetchNewFrame(): void;
  94316. /**
  94317. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94318. * @param newCount the count value to add to the monitored count
  94319. * @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.
  94320. */
  94321. addCount(newCount: number, fetchResult: boolean): void;
  94322. /**
  94323. * Start monitoring this performance counter
  94324. */
  94325. beginMonitoring(): void;
  94326. /**
  94327. * Compute the time lapsed since the previous beginMonitoring() call.
  94328. * @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
  94329. */
  94330. endMonitoring(newFrame?: boolean): void;
  94331. private _fetchResult;
  94332. private _startMonitoringTime;
  94333. private _min;
  94334. private _max;
  94335. private _average;
  94336. private _current;
  94337. private _totalValueCount;
  94338. private _totalAccumulated;
  94339. private _lastSecAverage;
  94340. private _lastSecAccumulated;
  94341. private _lastSecTime;
  94342. private _lastSecValueCount;
  94343. }
  94344. /**
  94345. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94346. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94347. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94348. * @param name The name of the class, case should be preserved
  94349. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94350. */
  94351. export function className(name: string, module?: string): (target: Object) => void;
  94352. /**
  94353. * An implementation of a loop for asynchronous functions.
  94354. */
  94355. export class AsyncLoop {
  94356. /**
  94357. * Defines the number of iterations for the loop
  94358. */
  94359. iterations: number;
  94360. /**
  94361. * Defines the current index of the loop.
  94362. */
  94363. index: number;
  94364. private _done;
  94365. private _fn;
  94366. private _successCallback;
  94367. /**
  94368. * Constructor.
  94369. * @param iterations the number of iterations.
  94370. * @param func the function to run each iteration
  94371. * @param successCallback the callback that will be called upon succesful execution
  94372. * @param offset starting offset.
  94373. */
  94374. constructor(
  94375. /**
  94376. * Defines the number of iterations for the loop
  94377. */
  94378. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94379. /**
  94380. * Execute the next iteration. Must be called after the last iteration was finished.
  94381. */
  94382. executeNext(): void;
  94383. /**
  94384. * Break the loop and run the success callback.
  94385. */
  94386. breakLoop(): void;
  94387. /**
  94388. * Create and run an async loop.
  94389. * @param iterations the number of iterations.
  94390. * @param fn the function to run each iteration
  94391. * @param successCallback the callback that will be called upon succesful execution
  94392. * @param offset starting offset.
  94393. * @returns the created async loop object
  94394. */
  94395. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94396. /**
  94397. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94398. * @param iterations total number of iterations
  94399. * @param syncedIterations number of synchronous iterations in each async iteration.
  94400. * @param fn the function to call each iteration.
  94401. * @param callback a success call back that will be called when iterating stops.
  94402. * @param breakFunction a break condition (optional)
  94403. * @param timeout timeout settings for the setTimeout function. default - 0.
  94404. * @returns the created async loop object
  94405. */
  94406. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94407. }
  94408. }
  94409. declare module BABYLON {
  94410. /** @hidden */
  94411. export interface ICollisionCoordinator {
  94412. createCollider(): Collider;
  94413. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94414. init(scene: Scene): void;
  94415. }
  94416. /** @hidden */
  94417. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94418. private _scene;
  94419. private _scaledPosition;
  94420. private _scaledVelocity;
  94421. private _finalPosition;
  94422. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94423. createCollider(): Collider;
  94424. init(scene: Scene): void;
  94425. private _collideWithWorld;
  94426. }
  94427. }
  94428. declare module BABYLON {
  94429. /**
  94430. * Class used to manage all inputs for the scene.
  94431. */
  94432. export class InputManager {
  94433. /** The distance in pixel that you have to move to prevent some events */
  94434. static DragMovementThreshold: number;
  94435. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94436. static LongPressDelay: number;
  94437. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94438. static DoubleClickDelay: number;
  94439. /** If you need to check double click without raising a single click at first click, enable this flag */
  94440. static ExclusiveDoubleClickMode: boolean;
  94441. private _wheelEventName;
  94442. private _onPointerMove;
  94443. private _onPointerDown;
  94444. private _onPointerUp;
  94445. private _initClickEvent;
  94446. private _initActionManager;
  94447. private _delayedSimpleClick;
  94448. private _delayedSimpleClickTimeout;
  94449. private _previousDelayedSimpleClickTimeout;
  94450. private _meshPickProceed;
  94451. private _previousButtonPressed;
  94452. private _currentPickResult;
  94453. private _previousPickResult;
  94454. private _totalPointersPressed;
  94455. private _doubleClickOccured;
  94456. private _pointerOverMesh;
  94457. private _pickedDownMesh;
  94458. private _pickedUpMesh;
  94459. private _pointerX;
  94460. private _pointerY;
  94461. private _unTranslatedPointerX;
  94462. private _unTranslatedPointerY;
  94463. private _startingPointerPosition;
  94464. private _previousStartingPointerPosition;
  94465. private _startingPointerTime;
  94466. private _previousStartingPointerTime;
  94467. private _pointerCaptures;
  94468. private _onKeyDown;
  94469. private _onKeyUp;
  94470. private _onCanvasFocusObserver;
  94471. private _onCanvasBlurObserver;
  94472. private _scene;
  94473. /**
  94474. * Creates a new InputManager
  94475. * @param scene defines the hosting scene
  94476. */
  94477. constructor(scene: Scene);
  94478. /**
  94479. * Gets the mesh that is currently under the pointer
  94480. */
  94481. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94482. /**
  94483. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94484. */
  94485. readonly unTranslatedPointer: Vector2;
  94486. /**
  94487. * Gets or sets the current on-screen X position of the pointer
  94488. */
  94489. pointerX: number;
  94490. /**
  94491. * Gets or sets the current on-screen Y position of the pointer
  94492. */
  94493. pointerY: number;
  94494. private _updatePointerPosition;
  94495. private _processPointerMove;
  94496. private _setRayOnPointerInfo;
  94497. private _checkPrePointerObservable;
  94498. /**
  94499. * Use this method to simulate a pointer move on a mesh
  94500. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94501. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94502. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94503. */
  94504. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94505. /**
  94506. * Use this method to simulate a pointer down on a mesh
  94507. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94508. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94509. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94510. */
  94511. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94512. private _processPointerDown;
  94513. /** @hidden */
  94514. _isPointerSwiping(): boolean;
  94515. /**
  94516. * Use this method to simulate a pointer up on a mesh
  94517. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94518. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94519. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94520. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94521. */
  94522. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  94523. private _processPointerUp;
  94524. /**
  94525. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94526. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94527. * @returns true if the pointer was captured
  94528. */
  94529. isPointerCaptured(pointerId?: number): boolean;
  94530. /**
  94531. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  94532. * @param attachUp defines if you want to attach events to pointerup
  94533. * @param attachDown defines if you want to attach events to pointerdown
  94534. * @param attachMove defines if you want to attach events to pointermove
  94535. */
  94536. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  94537. /**
  94538. * Detaches all event handlers
  94539. */
  94540. detachControl(): void;
  94541. /**
  94542. * Force the value of meshUnderPointer
  94543. * @param mesh defines the mesh to use
  94544. */
  94545. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  94546. /**
  94547. * Gets the mesh under the pointer
  94548. * @returns a Mesh or null if no mesh is under the pointer
  94549. */
  94550. getPointerOverMesh(): Nullable<AbstractMesh>;
  94551. }
  94552. }
  94553. declare module BABYLON {
  94554. /**
  94555. * This class defines the direct association between an animation and a target
  94556. */
  94557. export class TargetedAnimation {
  94558. /**
  94559. * Animation to perform
  94560. */
  94561. animation: Animation;
  94562. /**
  94563. * Target to animate
  94564. */
  94565. target: any;
  94566. /**
  94567. * Serialize the object
  94568. * @returns the JSON object representing the current entity
  94569. */
  94570. serialize(): any;
  94571. }
  94572. /**
  94573. * Use this class to create coordinated animations on multiple targets
  94574. */
  94575. export class AnimationGroup implements IDisposable {
  94576. /** The name of the animation group */
  94577. name: string;
  94578. private _scene;
  94579. private _targetedAnimations;
  94580. private _animatables;
  94581. private _from;
  94582. private _to;
  94583. private _isStarted;
  94584. private _isPaused;
  94585. private _speedRatio;
  94586. private _loopAnimation;
  94587. /**
  94588. * Gets or sets the unique id of the node
  94589. */
  94590. uniqueId: number;
  94591. /**
  94592. * This observable will notify when one animation have ended
  94593. */
  94594. onAnimationEndObservable: Observable<TargetedAnimation>;
  94595. /**
  94596. * Observer raised when one animation loops
  94597. */
  94598. onAnimationLoopObservable: Observable<TargetedAnimation>;
  94599. /**
  94600. * This observable will notify when all animations have ended.
  94601. */
  94602. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  94603. /**
  94604. * This observable will notify when all animations have paused.
  94605. */
  94606. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  94607. /**
  94608. * This observable will notify when all animations are playing.
  94609. */
  94610. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  94611. /**
  94612. * Gets the first frame
  94613. */
  94614. readonly from: number;
  94615. /**
  94616. * Gets the last frame
  94617. */
  94618. readonly to: number;
  94619. /**
  94620. * Define if the animations are started
  94621. */
  94622. readonly isStarted: boolean;
  94623. /**
  94624. * Gets a value indicating that the current group is playing
  94625. */
  94626. readonly isPlaying: boolean;
  94627. /**
  94628. * Gets or sets the speed ratio to use for all animations
  94629. */
  94630. /**
  94631. * Gets or sets the speed ratio to use for all animations
  94632. */
  94633. speedRatio: number;
  94634. /**
  94635. * Gets or sets if all animations should loop or not
  94636. */
  94637. loopAnimation: boolean;
  94638. /**
  94639. * Gets the targeted animations for this animation group
  94640. */
  94641. readonly targetedAnimations: Array<TargetedAnimation>;
  94642. /**
  94643. * returning the list of animatables controlled by this animation group.
  94644. */
  94645. readonly animatables: Array<Animatable>;
  94646. /**
  94647. * Instantiates a new Animation Group.
  94648. * This helps managing several animations at once.
  94649. * @see http://doc.babylonjs.com/how_to/group
  94650. * @param name Defines the name of the group
  94651. * @param scene Defines the scene the group belongs to
  94652. */
  94653. constructor(
  94654. /** The name of the animation group */
  94655. name: string, scene?: Nullable<Scene>);
  94656. /**
  94657. * Add an animation (with its target) in the group
  94658. * @param animation defines the animation we want to add
  94659. * @param target defines the target of the animation
  94660. * @returns the TargetedAnimation object
  94661. */
  94662. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  94663. /**
  94664. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  94665. * It can add constant keys at begin or end
  94666. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  94667. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  94668. * @returns the animation group
  94669. */
  94670. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  94671. /**
  94672. * Start all animations on given targets
  94673. * @param loop defines if animations must loop
  94674. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  94675. * @param from defines the from key (optional)
  94676. * @param to defines the to key (optional)
  94677. * @returns the current animation group
  94678. */
  94679. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  94680. /**
  94681. * Pause all animations
  94682. * @returns the animation group
  94683. */
  94684. pause(): AnimationGroup;
  94685. /**
  94686. * Play all animations to initial state
  94687. * This function will start() the animations if they were not started or will restart() them if they were paused
  94688. * @param loop defines if animations must loop
  94689. * @returns the animation group
  94690. */
  94691. play(loop?: boolean): AnimationGroup;
  94692. /**
  94693. * Reset all animations to initial state
  94694. * @returns the animation group
  94695. */
  94696. reset(): AnimationGroup;
  94697. /**
  94698. * Restart animations from key 0
  94699. * @returns the animation group
  94700. */
  94701. restart(): AnimationGroup;
  94702. /**
  94703. * Stop all animations
  94704. * @returns the animation group
  94705. */
  94706. stop(): AnimationGroup;
  94707. /**
  94708. * Set animation weight for all animatables
  94709. * @param weight defines the weight to use
  94710. * @return the animationGroup
  94711. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94712. */
  94713. setWeightForAllAnimatables(weight: number): AnimationGroup;
  94714. /**
  94715. * Synchronize and normalize all animatables with a source animatable
  94716. * @param root defines the root animatable to synchronize with
  94717. * @return the animationGroup
  94718. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94719. */
  94720. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  94721. /**
  94722. * Goes to a specific frame in this animation group
  94723. * @param frame the frame number to go to
  94724. * @return the animationGroup
  94725. */
  94726. goToFrame(frame: number): AnimationGroup;
  94727. /**
  94728. * Dispose all associated resources
  94729. */
  94730. dispose(): void;
  94731. private _checkAnimationGroupEnded;
  94732. /**
  94733. * Clone the current animation group and returns a copy
  94734. * @param newName defines the name of the new group
  94735. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  94736. * @returns the new aniamtion group
  94737. */
  94738. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  94739. /**
  94740. * Serializes the animationGroup to an object
  94741. * @returns Serialized object
  94742. */
  94743. serialize(): any;
  94744. /**
  94745. * Returns a new AnimationGroup object parsed from the source provided.
  94746. * @param parsedAnimationGroup defines the source
  94747. * @param scene defines the scene that will receive the animationGroup
  94748. * @returns a new AnimationGroup
  94749. */
  94750. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  94751. /**
  94752. * Returns the string "AnimationGroup"
  94753. * @returns "AnimationGroup"
  94754. */
  94755. getClassName(): string;
  94756. /**
  94757. * Creates a detailled string about the object
  94758. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  94759. * @returns a string representing the object
  94760. */
  94761. toString(fullDetails?: boolean): string;
  94762. }
  94763. }
  94764. declare module BABYLON {
  94765. /**
  94766. * Define an interface for all classes that will hold resources
  94767. */
  94768. export interface IDisposable {
  94769. /**
  94770. * Releases all held resources
  94771. */
  94772. dispose(): void;
  94773. }
  94774. /** Interface defining initialization parameters for Scene class */
  94775. export interface SceneOptions {
  94776. /**
  94777. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  94778. * It will improve performance when the number of geometries becomes important.
  94779. */
  94780. useGeometryUniqueIdsMap?: boolean;
  94781. /**
  94782. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  94783. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94784. */
  94785. useMaterialMeshMap?: boolean;
  94786. /**
  94787. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  94788. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94789. */
  94790. useClonedMeshhMap?: boolean;
  94791. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  94792. virtual?: boolean;
  94793. }
  94794. /**
  94795. * Represents a scene to be rendered by the engine.
  94796. * @see http://doc.babylonjs.com/features/scene
  94797. */
  94798. export class Scene extends AbstractScene implements IAnimatable {
  94799. private static _uniqueIdCounter;
  94800. /** The fog is deactivated */
  94801. static readonly FOGMODE_NONE: number;
  94802. /** The fog density is following an exponential function */
  94803. static readonly FOGMODE_EXP: number;
  94804. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  94805. static readonly FOGMODE_EXP2: number;
  94806. /** The fog density is following a linear function. */
  94807. static readonly FOGMODE_LINEAR: number;
  94808. /**
  94809. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  94810. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94811. */
  94812. static MinDeltaTime: number;
  94813. /**
  94814. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  94815. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94816. */
  94817. static MaxDeltaTime: number;
  94818. /**
  94819. * Factory used to create the default material.
  94820. * @param name The name of the material to create
  94821. * @param scene The scene to create the material for
  94822. * @returns The default material
  94823. */
  94824. static DefaultMaterialFactory(scene: Scene): Material;
  94825. /**
  94826. * Factory used to create the a collision coordinator.
  94827. * @returns The collision coordinator
  94828. */
  94829. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  94830. /** @hidden */
  94831. _inputManager: InputManager;
  94832. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  94833. cameraToUseForPointers: Nullable<Camera>;
  94834. /** @hidden */
  94835. readonly _isScene: boolean;
  94836. /**
  94837. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  94838. */
  94839. autoClear: boolean;
  94840. /**
  94841. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  94842. */
  94843. autoClearDepthAndStencil: boolean;
  94844. /**
  94845. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  94846. */
  94847. clearColor: Color4;
  94848. /**
  94849. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  94850. */
  94851. ambientColor: Color3;
  94852. /**
  94853. * This is use to store the default BRDF lookup for PBR materials in your scene.
  94854. * It should only be one of the following (if not the default embedded one):
  94855. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  94856. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  94857. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  94858. * The material properties need to be setup according to the type of texture in use.
  94859. */
  94860. environmentBRDFTexture: BaseTexture;
  94861. /** @hidden */
  94862. protected _environmentTexture: Nullable<BaseTexture>;
  94863. /**
  94864. * Texture used in all pbr material as the reflection texture.
  94865. * As in the majority of the scene they are the same (exception for multi room and so on),
  94866. * this is easier to reference from here than from all the materials.
  94867. */
  94868. /**
  94869. * Texture used in all pbr material as the reflection texture.
  94870. * As in the majority of the scene they are the same (exception for multi room and so on),
  94871. * this is easier to set here than in all the materials.
  94872. */
  94873. environmentTexture: Nullable<BaseTexture>;
  94874. /** @hidden */
  94875. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94876. /**
  94877. * Default image processing configuration used either in the rendering
  94878. * Forward main pass or through the imageProcessingPostProcess if present.
  94879. * As in the majority of the scene they are the same (exception for multi camera),
  94880. * this is easier to reference from here than from all the materials and post process.
  94881. *
  94882. * No setter as we it is a shared configuration, you can set the values instead.
  94883. */
  94884. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  94885. private _forceWireframe;
  94886. /**
  94887. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  94888. */
  94889. forceWireframe: boolean;
  94890. private _forcePointsCloud;
  94891. /**
  94892. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  94893. */
  94894. forcePointsCloud: boolean;
  94895. /**
  94896. * Gets or sets the active clipplane 1
  94897. */
  94898. clipPlane: Nullable<Plane>;
  94899. /**
  94900. * Gets or sets the active clipplane 2
  94901. */
  94902. clipPlane2: Nullable<Plane>;
  94903. /**
  94904. * Gets or sets the active clipplane 3
  94905. */
  94906. clipPlane3: Nullable<Plane>;
  94907. /**
  94908. * Gets or sets the active clipplane 4
  94909. */
  94910. clipPlane4: Nullable<Plane>;
  94911. /**
  94912. * Gets or sets a boolean indicating if animations are enabled
  94913. */
  94914. animationsEnabled: boolean;
  94915. private _animationPropertiesOverride;
  94916. /**
  94917. * Gets or sets the animation properties override
  94918. */
  94919. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94920. /**
  94921. * Gets or sets a boolean indicating if a constant deltatime has to be used
  94922. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  94923. */
  94924. useConstantAnimationDeltaTime: boolean;
  94925. /**
  94926. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  94927. * Please note that it requires to run a ray cast through the scene on every frame
  94928. */
  94929. constantlyUpdateMeshUnderPointer: boolean;
  94930. /**
  94931. * Defines the HTML cursor to use when hovering over interactive elements
  94932. */
  94933. hoverCursor: string;
  94934. /**
  94935. * Defines the HTML default cursor to use (empty by default)
  94936. */
  94937. defaultCursor: string;
  94938. /**
  94939. * This is used to call preventDefault() on pointer down
  94940. * in order to block unwanted artifacts like system double clicks
  94941. */
  94942. preventDefaultOnPointerDown: boolean;
  94943. /**
  94944. * This is used to call preventDefault() on pointer up
  94945. * in order to block unwanted artifacts like system double clicks
  94946. */
  94947. preventDefaultOnPointerUp: boolean;
  94948. /**
  94949. * Gets or sets user defined metadata
  94950. */
  94951. metadata: any;
  94952. /**
  94953. * For internal use only. Please do not use.
  94954. */
  94955. reservedDataStore: any;
  94956. /**
  94957. * Gets the name of the plugin used to load this scene (null by default)
  94958. */
  94959. loadingPluginName: string;
  94960. /**
  94961. * Use this array to add regular expressions used to disable offline support for specific urls
  94962. */
  94963. disableOfflineSupportExceptionRules: RegExp[];
  94964. /**
  94965. * An event triggered when the scene is disposed.
  94966. */
  94967. onDisposeObservable: Observable<Scene>;
  94968. private _onDisposeObserver;
  94969. /** Sets a function to be executed when this scene is disposed. */
  94970. onDispose: () => void;
  94971. /**
  94972. * An event triggered before rendering the scene (right after animations and physics)
  94973. */
  94974. onBeforeRenderObservable: Observable<Scene>;
  94975. private _onBeforeRenderObserver;
  94976. /** Sets a function to be executed before rendering this scene */
  94977. beforeRender: Nullable<() => void>;
  94978. /**
  94979. * An event triggered after rendering the scene
  94980. */
  94981. onAfterRenderObservable: Observable<Scene>;
  94982. /**
  94983. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  94984. */
  94985. onAfterRenderCameraObservable: Observable<Camera>;
  94986. private _onAfterRenderObserver;
  94987. /** Sets a function to be executed after rendering this scene */
  94988. afterRender: Nullable<() => void>;
  94989. /**
  94990. * An event triggered before animating the scene
  94991. */
  94992. onBeforeAnimationsObservable: Observable<Scene>;
  94993. /**
  94994. * An event triggered after animations processing
  94995. */
  94996. onAfterAnimationsObservable: Observable<Scene>;
  94997. /**
  94998. * An event triggered before draw calls are ready to be sent
  94999. */
  95000. onBeforeDrawPhaseObservable: Observable<Scene>;
  95001. /**
  95002. * An event triggered after draw calls have been sent
  95003. */
  95004. onAfterDrawPhaseObservable: Observable<Scene>;
  95005. /**
  95006. * An event triggered when the scene is ready
  95007. */
  95008. onReadyObservable: Observable<Scene>;
  95009. /**
  95010. * An event triggered before rendering a camera
  95011. */
  95012. onBeforeCameraRenderObservable: Observable<Camera>;
  95013. private _onBeforeCameraRenderObserver;
  95014. /** Sets a function to be executed before rendering a camera*/
  95015. beforeCameraRender: () => void;
  95016. /**
  95017. * An event triggered after rendering a camera
  95018. */
  95019. onAfterCameraRenderObservable: Observable<Camera>;
  95020. private _onAfterCameraRenderObserver;
  95021. /** Sets a function to be executed after rendering a camera*/
  95022. afterCameraRender: () => void;
  95023. /**
  95024. * An event triggered when active meshes evaluation is about to start
  95025. */
  95026. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  95027. /**
  95028. * An event triggered when active meshes evaluation is done
  95029. */
  95030. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  95031. /**
  95032. * An event triggered when particles rendering is about to start
  95033. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95034. */
  95035. onBeforeParticlesRenderingObservable: Observable<Scene>;
  95036. /**
  95037. * An event triggered when particles rendering is done
  95038. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95039. */
  95040. onAfterParticlesRenderingObservable: Observable<Scene>;
  95041. /**
  95042. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  95043. */
  95044. onDataLoadedObservable: Observable<Scene>;
  95045. /**
  95046. * An event triggered when a camera is created
  95047. */
  95048. onNewCameraAddedObservable: Observable<Camera>;
  95049. /**
  95050. * An event triggered when a camera is removed
  95051. */
  95052. onCameraRemovedObservable: Observable<Camera>;
  95053. /**
  95054. * An event triggered when a light is created
  95055. */
  95056. onNewLightAddedObservable: Observable<Light>;
  95057. /**
  95058. * An event triggered when a light is removed
  95059. */
  95060. onLightRemovedObservable: Observable<Light>;
  95061. /**
  95062. * An event triggered when a geometry is created
  95063. */
  95064. onNewGeometryAddedObservable: Observable<Geometry>;
  95065. /**
  95066. * An event triggered when a geometry is removed
  95067. */
  95068. onGeometryRemovedObservable: Observable<Geometry>;
  95069. /**
  95070. * An event triggered when a transform node is created
  95071. */
  95072. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  95073. /**
  95074. * An event triggered when a transform node is removed
  95075. */
  95076. onTransformNodeRemovedObservable: Observable<TransformNode>;
  95077. /**
  95078. * An event triggered when a mesh is created
  95079. */
  95080. onNewMeshAddedObservable: Observable<AbstractMesh>;
  95081. /**
  95082. * An event triggered when a mesh is removed
  95083. */
  95084. onMeshRemovedObservable: Observable<AbstractMesh>;
  95085. /**
  95086. * An event triggered when a skeleton is created
  95087. */
  95088. onNewSkeletonAddedObservable: Observable<Skeleton>;
  95089. /**
  95090. * An event triggered when a skeleton is removed
  95091. */
  95092. onSkeletonRemovedObservable: Observable<Skeleton>;
  95093. /**
  95094. * An event triggered when a material is created
  95095. */
  95096. onNewMaterialAddedObservable: Observable<Material>;
  95097. /**
  95098. * An event triggered when a material is removed
  95099. */
  95100. onMaterialRemovedObservable: Observable<Material>;
  95101. /**
  95102. * An event triggered when a texture is created
  95103. */
  95104. onNewTextureAddedObservable: Observable<BaseTexture>;
  95105. /**
  95106. * An event triggered when a texture is removed
  95107. */
  95108. onTextureRemovedObservable: Observable<BaseTexture>;
  95109. /**
  95110. * An event triggered when render targets are about to be rendered
  95111. * Can happen multiple times per frame.
  95112. */
  95113. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  95114. /**
  95115. * An event triggered when render targets were rendered.
  95116. * Can happen multiple times per frame.
  95117. */
  95118. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  95119. /**
  95120. * An event triggered before calculating deterministic simulation step
  95121. */
  95122. onBeforeStepObservable: Observable<Scene>;
  95123. /**
  95124. * An event triggered after calculating deterministic simulation step
  95125. */
  95126. onAfterStepObservable: Observable<Scene>;
  95127. /**
  95128. * An event triggered when the activeCamera property is updated
  95129. */
  95130. onActiveCameraChanged: Observable<Scene>;
  95131. /**
  95132. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  95133. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95134. * 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)
  95135. */
  95136. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95137. /**
  95138. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  95139. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95140. * 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)
  95141. */
  95142. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95143. /**
  95144. * This Observable will when a mesh has been imported into the scene.
  95145. */
  95146. onMeshImportedObservable: Observable<AbstractMesh>;
  95147. /**
  95148. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  95149. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  95150. */
  95151. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  95152. /** @hidden */
  95153. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  95154. /**
  95155. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  95156. */
  95157. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  95158. /**
  95159. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  95160. */
  95161. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  95162. /**
  95163. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  95164. */
  95165. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  95166. /** Callback called when a pointer move is detected */
  95167. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95168. /** Callback called when a pointer down is detected */
  95169. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95170. /** Callback called when a pointer up is detected */
  95171. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  95172. /** Callback called when a pointer pick is detected */
  95173. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  95174. /**
  95175. * 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).
  95176. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  95177. */
  95178. onPrePointerObservable: Observable<PointerInfoPre>;
  95179. /**
  95180. * Observable event triggered each time an input event is received from the rendering canvas
  95181. */
  95182. onPointerObservable: Observable<PointerInfo>;
  95183. /**
  95184. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  95185. */
  95186. readonly unTranslatedPointer: Vector2;
  95187. /**
  95188. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  95189. */
  95190. static DragMovementThreshold: number;
  95191. /**
  95192. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  95193. */
  95194. static LongPressDelay: number;
  95195. /**
  95196. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  95197. */
  95198. static DoubleClickDelay: number;
  95199. /** If you need to check double click without raising a single click at first click, enable this flag */
  95200. static ExclusiveDoubleClickMode: boolean;
  95201. /** @hidden */
  95202. _mirroredCameraPosition: Nullable<Vector3>;
  95203. /**
  95204. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  95205. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  95206. */
  95207. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  95208. /**
  95209. * Observable event triggered each time an keyboard event is received from the hosting window
  95210. */
  95211. onKeyboardObservable: Observable<KeyboardInfo>;
  95212. private _useRightHandedSystem;
  95213. /**
  95214. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  95215. */
  95216. useRightHandedSystem: boolean;
  95217. private _timeAccumulator;
  95218. private _currentStepId;
  95219. private _currentInternalStep;
  95220. /**
  95221. * Sets the step Id used by deterministic lock step
  95222. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95223. * @param newStepId defines the step Id
  95224. */
  95225. setStepId(newStepId: number): void;
  95226. /**
  95227. * Gets the step Id used by deterministic lock step
  95228. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95229. * @returns the step Id
  95230. */
  95231. getStepId(): number;
  95232. /**
  95233. * Gets the internal step used by deterministic lock step
  95234. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95235. * @returns the internal step
  95236. */
  95237. getInternalStep(): number;
  95238. private _fogEnabled;
  95239. /**
  95240. * Gets or sets a boolean indicating if fog is enabled on this scene
  95241. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95242. * (Default is true)
  95243. */
  95244. fogEnabled: boolean;
  95245. private _fogMode;
  95246. /**
  95247. * Gets or sets the fog mode to use
  95248. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95249. * | mode | value |
  95250. * | --- | --- |
  95251. * | FOGMODE_NONE | 0 |
  95252. * | FOGMODE_EXP | 1 |
  95253. * | FOGMODE_EXP2 | 2 |
  95254. * | FOGMODE_LINEAR | 3 |
  95255. */
  95256. fogMode: number;
  95257. /**
  95258. * Gets or sets the fog color to use
  95259. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95260. * (Default is Color3(0.2, 0.2, 0.3))
  95261. */
  95262. fogColor: Color3;
  95263. /**
  95264. * Gets or sets the fog density to use
  95265. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95266. * (Default is 0.1)
  95267. */
  95268. fogDensity: number;
  95269. /**
  95270. * Gets or sets the fog start distance to use
  95271. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95272. * (Default is 0)
  95273. */
  95274. fogStart: number;
  95275. /**
  95276. * Gets or sets the fog end distance to use
  95277. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95278. * (Default is 1000)
  95279. */
  95280. fogEnd: number;
  95281. private _shadowsEnabled;
  95282. /**
  95283. * Gets or sets a boolean indicating if shadows are enabled on this scene
  95284. */
  95285. shadowsEnabled: boolean;
  95286. private _lightsEnabled;
  95287. /**
  95288. * Gets or sets a boolean indicating if lights are enabled on this scene
  95289. */
  95290. lightsEnabled: boolean;
  95291. /** All of the active cameras added to this scene. */
  95292. activeCameras: Camera[];
  95293. /** @hidden */
  95294. _activeCamera: Nullable<Camera>;
  95295. /** Gets or sets the current active camera */
  95296. activeCamera: Nullable<Camera>;
  95297. private _defaultMaterial;
  95298. /** The default material used on meshes when no material is affected */
  95299. /** The default material used on meshes when no material is affected */
  95300. defaultMaterial: Material;
  95301. private _texturesEnabled;
  95302. /**
  95303. * Gets or sets a boolean indicating if textures are enabled on this scene
  95304. */
  95305. texturesEnabled: boolean;
  95306. /**
  95307. * Gets or sets a boolean indicating if particles are enabled on this scene
  95308. */
  95309. particlesEnabled: boolean;
  95310. /**
  95311. * Gets or sets a boolean indicating if sprites are enabled on this scene
  95312. */
  95313. spritesEnabled: boolean;
  95314. private _skeletonsEnabled;
  95315. /**
  95316. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  95317. */
  95318. skeletonsEnabled: boolean;
  95319. /**
  95320. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  95321. */
  95322. lensFlaresEnabled: boolean;
  95323. /**
  95324. * Gets or sets a boolean indicating if collisions are enabled on this scene
  95325. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95326. */
  95327. collisionsEnabled: boolean;
  95328. private _collisionCoordinator;
  95329. /** @hidden */
  95330. readonly collisionCoordinator: ICollisionCoordinator;
  95331. /**
  95332. * Defines the gravity applied to this scene (used only for collisions)
  95333. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95334. */
  95335. gravity: Vector3;
  95336. /**
  95337. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  95338. */
  95339. postProcessesEnabled: boolean;
  95340. /**
  95341. * The list of postprocesses added to the scene
  95342. */
  95343. postProcesses: PostProcess[];
  95344. /**
  95345. * Gets the current postprocess manager
  95346. */
  95347. postProcessManager: PostProcessManager;
  95348. /**
  95349. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95350. */
  95351. renderTargetsEnabled: boolean;
  95352. /**
  95353. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95354. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95355. */
  95356. dumpNextRenderTargets: boolean;
  95357. /**
  95358. * The list of user defined render targets added to the scene
  95359. */
  95360. customRenderTargets: RenderTargetTexture[];
  95361. /**
  95362. * Defines if texture loading must be delayed
  95363. * If true, textures will only be loaded when they need to be rendered
  95364. */
  95365. useDelayedTextureLoading: boolean;
  95366. /**
  95367. * Gets the list of meshes imported to the scene through SceneLoader
  95368. */
  95369. importedMeshesFiles: String[];
  95370. /**
  95371. * Gets or sets a boolean indicating if probes are enabled on this scene
  95372. */
  95373. probesEnabled: boolean;
  95374. /**
  95375. * Gets or sets the current offline provider to use to store scene data
  95376. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95377. */
  95378. offlineProvider: IOfflineProvider;
  95379. /**
  95380. * Gets or sets the action manager associated with the scene
  95381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95382. */
  95383. actionManager: AbstractActionManager;
  95384. private _meshesForIntersections;
  95385. /**
  95386. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95387. */
  95388. proceduralTexturesEnabled: boolean;
  95389. private _engine;
  95390. private _totalVertices;
  95391. /** @hidden */
  95392. _activeIndices: PerfCounter;
  95393. /** @hidden */
  95394. _activeParticles: PerfCounter;
  95395. /** @hidden */
  95396. _activeBones: PerfCounter;
  95397. private _animationRatio;
  95398. /** @hidden */
  95399. _animationTimeLast: number;
  95400. /** @hidden */
  95401. _animationTime: number;
  95402. /**
  95403. * Gets or sets a general scale for animation speed
  95404. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95405. */
  95406. animationTimeScale: number;
  95407. /** @hidden */
  95408. _cachedMaterial: Nullable<Material>;
  95409. /** @hidden */
  95410. _cachedEffect: Nullable<Effect>;
  95411. /** @hidden */
  95412. _cachedVisibility: Nullable<number>;
  95413. private _renderId;
  95414. private _frameId;
  95415. private _executeWhenReadyTimeoutId;
  95416. private _intermediateRendering;
  95417. private _viewUpdateFlag;
  95418. private _projectionUpdateFlag;
  95419. /** @hidden */
  95420. _toBeDisposed: Nullable<IDisposable>[];
  95421. private _activeRequests;
  95422. /** @hidden */
  95423. _pendingData: any[];
  95424. private _isDisposed;
  95425. /**
  95426. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95427. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95428. */
  95429. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95430. private _activeMeshes;
  95431. private _processedMaterials;
  95432. private _renderTargets;
  95433. /** @hidden */
  95434. _activeParticleSystems: SmartArray<IParticleSystem>;
  95435. private _activeSkeletons;
  95436. private _softwareSkinnedMeshes;
  95437. private _renderingManager;
  95438. /** @hidden */
  95439. _activeAnimatables: Animatable[];
  95440. private _transformMatrix;
  95441. private _sceneUbo;
  95442. /** @hidden */
  95443. _viewMatrix: Matrix;
  95444. private _projectionMatrix;
  95445. /** @hidden */
  95446. _forcedViewPosition: Nullable<Vector3>;
  95447. /** @hidden */
  95448. _frustumPlanes: Plane[];
  95449. /**
  95450. * Gets the list of frustum planes (built from the active camera)
  95451. */
  95452. readonly frustumPlanes: Plane[];
  95453. /**
  95454. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95455. * This is useful if there are more lights that the maximum simulteanous authorized
  95456. */
  95457. requireLightSorting: boolean;
  95458. /** @hidden */
  95459. readonly useMaterialMeshMap: boolean;
  95460. /** @hidden */
  95461. readonly useClonedMeshhMap: boolean;
  95462. private _externalData;
  95463. private _uid;
  95464. /**
  95465. * @hidden
  95466. * Backing store of defined scene components.
  95467. */
  95468. _components: ISceneComponent[];
  95469. /**
  95470. * @hidden
  95471. * Backing store of defined scene components.
  95472. */
  95473. _serializableComponents: ISceneSerializableComponent[];
  95474. /**
  95475. * List of components to register on the next registration step.
  95476. */
  95477. private _transientComponents;
  95478. /**
  95479. * Registers the transient components if needed.
  95480. */
  95481. private _registerTransientComponents;
  95482. /**
  95483. * @hidden
  95484. * Add a component to the scene.
  95485. * Note that the ccomponent could be registered on th next frame if this is called after
  95486. * the register component stage.
  95487. * @param component Defines the component to add to the scene
  95488. */
  95489. _addComponent(component: ISceneComponent): void;
  95490. /**
  95491. * @hidden
  95492. * Gets a component from the scene.
  95493. * @param name defines the name of the component to retrieve
  95494. * @returns the component or null if not present
  95495. */
  95496. _getComponent(name: string): Nullable<ISceneComponent>;
  95497. /**
  95498. * @hidden
  95499. * Defines the actions happening before camera updates.
  95500. */
  95501. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95502. /**
  95503. * @hidden
  95504. * Defines the actions happening before clear the canvas.
  95505. */
  95506. _beforeClearStage: Stage<SimpleStageAction>;
  95507. /**
  95508. * @hidden
  95509. * Defines the actions when collecting render targets for the frame.
  95510. */
  95511. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95512. /**
  95513. * @hidden
  95514. * Defines the actions happening for one camera in the frame.
  95515. */
  95516. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95517. /**
  95518. * @hidden
  95519. * Defines the actions happening during the per mesh ready checks.
  95520. */
  95521. _isReadyForMeshStage: Stage<MeshStageAction>;
  95522. /**
  95523. * @hidden
  95524. * Defines the actions happening before evaluate active mesh checks.
  95525. */
  95526. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  95527. /**
  95528. * @hidden
  95529. * Defines the actions happening during the evaluate sub mesh checks.
  95530. */
  95531. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  95532. /**
  95533. * @hidden
  95534. * Defines the actions happening during the active mesh stage.
  95535. */
  95536. _activeMeshStage: Stage<ActiveMeshStageAction>;
  95537. /**
  95538. * @hidden
  95539. * Defines the actions happening during the per camera render target step.
  95540. */
  95541. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  95542. /**
  95543. * @hidden
  95544. * Defines the actions happening just before the active camera is drawing.
  95545. */
  95546. _beforeCameraDrawStage: Stage<CameraStageAction>;
  95547. /**
  95548. * @hidden
  95549. * Defines the actions happening just before a render target is drawing.
  95550. */
  95551. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95552. /**
  95553. * @hidden
  95554. * Defines the actions happening just before a rendering group is drawing.
  95555. */
  95556. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95557. /**
  95558. * @hidden
  95559. * Defines the actions happening just before a mesh is drawing.
  95560. */
  95561. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95562. /**
  95563. * @hidden
  95564. * Defines the actions happening just after a mesh has been drawn.
  95565. */
  95566. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95567. /**
  95568. * @hidden
  95569. * Defines the actions happening just after a rendering group has been drawn.
  95570. */
  95571. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95572. /**
  95573. * @hidden
  95574. * Defines the actions happening just after the active camera has been drawn.
  95575. */
  95576. _afterCameraDrawStage: Stage<CameraStageAction>;
  95577. /**
  95578. * @hidden
  95579. * Defines the actions happening just after a render target has been drawn.
  95580. */
  95581. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95582. /**
  95583. * @hidden
  95584. * Defines the actions happening just after rendering all cameras and computing intersections.
  95585. */
  95586. _afterRenderStage: Stage<SimpleStageAction>;
  95587. /**
  95588. * @hidden
  95589. * Defines the actions happening when a pointer move event happens.
  95590. */
  95591. _pointerMoveStage: Stage<PointerMoveStageAction>;
  95592. /**
  95593. * @hidden
  95594. * Defines the actions happening when a pointer down event happens.
  95595. */
  95596. _pointerDownStage: Stage<PointerUpDownStageAction>;
  95597. /**
  95598. * @hidden
  95599. * Defines the actions happening when a pointer up event happens.
  95600. */
  95601. _pointerUpStage: Stage<PointerUpDownStageAction>;
  95602. /**
  95603. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  95604. */
  95605. private geometriesByUniqueId;
  95606. /**
  95607. * Creates a new Scene
  95608. * @param engine defines the engine to use to render this scene
  95609. * @param options defines the scene options
  95610. */
  95611. constructor(engine: Engine, options?: SceneOptions);
  95612. /**
  95613. * Gets a string idenfifying the name of the class
  95614. * @returns "Scene" string
  95615. */
  95616. getClassName(): string;
  95617. private _defaultMeshCandidates;
  95618. /**
  95619. * @hidden
  95620. */
  95621. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95622. private _defaultSubMeshCandidates;
  95623. /**
  95624. * @hidden
  95625. */
  95626. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95627. /**
  95628. * Sets the default candidate providers for the scene.
  95629. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  95630. * and getCollidingSubMeshCandidates to their default function
  95631. */
  95632. setDefaultCandidateProviders(): void;
  95633. /**
  95634. * Gets the mesh that is currently under the pointer
  95635. */
  95636. readonly meshUnderPointer: Nullable<AbstractMesh>;
  95637. /**
  95638. * Gets or sets the current on-screen X position of the pointer
  95639. */
  95640. pointerX: number;
  95641. /**
  95642. * Gets or sets the current on-screen Y position of the pointer
  95643. */
  95644. pointerY: number;
  95645. /**
  95646. * Gets the cached material (ie. the latest rendered one)
  95647. * @returns the cached material
  95648. */
  95649. getCachedMaterial(): Nullable<Material>;
  95650. /**
  95651. * Gets the cached effect (ie. the latest rendered one)
  95652. * @returns the cached effect
  95653. */
  95654. getCachedEffect(): Nullable<Effect>;
  95655. /**
  95656. * Gets the cached visibility state (ie. the latest rendered one)
  95657. * @returns the cached visibility state
  95658. */
  95659. getCachedVisibility(): Nullable<number>;
  95660. /**
  95661. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  95662. * @param material defines the current material
  95663. * @param effect defines the current effect
  95664. * @param visibility defines the current visibility state
  95665. * @returns true if one parameter is not cached
  95666. */
  95667. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  95668. /**
  95669. * Gets the engine associated with the scene
  95670. * @returns an Engine
  95671. */
  95672. getEngine(): Engine;
  95673. /**
  95674. * Gets the total number of vertices rendered per frame
  95675. * @returns the total number of vertices rendered per frame
  95676. */
  95677. getTotalVertices(): number;
  95678. /**
  95679. * Gets the performance counter for total vertices
  95680. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95681. */
  95682. readonly totalVerticesPerfCounter: PerfCounter;
  95683. /**
  95684. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  95685. * @returns the total number of active indices rendered per frame
  95686. */
  95687. getActiveIndices(): number;
  95688. /**
  95689. * Gets the performance counter for active indices
  95690. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95691. */
  95692. readonly totalActiveIndicesPerfCounter: PerfCounter;
  95693. /**
  95694. * Gets the total number of active particles rendered per frame
  95695. * @returns the total number of active particles rendered per frame
  95696. */
  95697. getActiveParticles(): number;
  95698. /**
  95699. * Gets the performance counter for active particles
  95700. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95701. */
  95702. readonly activeParticlesPerfCounter: PerfCounter;
  95703. /**
  95704. * Gets the total number of active bones rendered per frame
  95705. * @returns the total number of active bones rendered per frame
  95706. */
  95707. getActiveBones(): number;
  95708. /**
  95709. * Gets the performance counter for active bones
  95710. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95711. */
  95712. readonly activeBonesPerfCounter: PerfCounter;
  95713. /**
  95714. * Gets the array of active meshes
  95715. * @returns an array of AbstractMesh
  95716. */
  95717. getActiveMeshes(): SmartArray<AbstractMesh>;
  95718. /**
  95719. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  95720. * @returns a number
  95721. */
  95722. getAnimationRatio(): number;
  95723. /**
  95724. * Gets an unique Id for the current render phase
  95725. * @returns a number
  95726. */
  95727. getRenderId(): number;
  95728. /**
  95729. * Gets an unique Id for the current frame
  95730. * @returns a number
  95731. */
  95732. getFrameId(): number;
  95733. /** Call this function if you want to manually increment the render Id*/
  95734. incrementRenderId(): void;
  95735. private _createUbo;
  95736. /**
  95737. * Use this method to simulate a pointer move on a mesh
  95738. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95739. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95740. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95741. * @returns the current scene
  95742. */
  95743. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95744. /**
  95745. * Use this method to simulate a pointer down on a mesh
  95746. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95747. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95748. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95749. * @returns the current scene
  95750. */
  95751. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95752. /**
  95753. * Use this method to simulate a pointer up on a mesh
  95754. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95755. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95756. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95757. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  95758. * @returns the current scene
  95759. */
  95760. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  95761. /**
  95762. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  95763. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  95764. * @returns true if the pointer was captured
  95765. */
  95766. isPointerCaptured(pointerId?: number): boolean;
  95767. /**
  95768. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  95769. * @param attachUp defines if you want to attach events to pointerup
  95770. * @param attachDown defines if you want to attach events to pointerdown
  95771. * @param attachMove defines if you want to attach events to pointermove
  95772. */
  95773. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  95774. /** Detaches all event handlers*/
  95775. detachControl(): void;
  95776. /**
  95777. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  95778. * Delay loaded resources are not taking in account
  95779. * @return true if all required resources are ready
  95780. */
  95781. isReady(): boolean;
  95782. /** Resets all cached information relative to material (including effect and visibility) */
  95783. resetCachedMaterial(): void;
  95784. /**
  95785. * Registers a function to be called before every frame render
  95786. * @param func defines the function to register
  95787. */
  95788. registerBeforeRender(func: () => void): void;
  95789. /**
  95790. * Unregisters a function called before every frame render
  95791. * @param func defines the function to unregister
  95792. */
  95793. unregisterBeforeRender(func: () => void): void;
  95794. /**
  95795. * Registers a function to be called after every frame render
  95796. * @param func defines the function to register
  95797. */
  95798. registerAfterRender(func: () => void): void;
  95799. /**
  95800. * Unregisters a function called after every frame render
  95801. * @param func defines the function to unregister
  95802. */
  95803. unregisterAfterRender(func: () => void): void;
  95804. private _executeOnceBeforeRender;
  95805. /**
  95806. * The provided function will run before render once and will be disposed afterwards.
  95807. * A timeout delay can be provided so that the function will be executed in N ms.
  95808. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  95809. * @param func The function to be executed.
  95810. * @param timeout optional delay in ms
  95811. */
  95812. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  95813. /** @hidden */
  95814. _addPendingData(data: any): void;
  95815. /** @hidden */
  95816. _removePendingData(data: any): void;
  95817. /**
  95818. * Returns the number of items waiting to be loaded
  95819. * @returns the number of items waiting to be loaded
  95820. */
  95821. getWaitingItemsCount(): number;
  95822. /**
  95823. * Returns a boolean indicating if the scene is still loading data
  95824. */
  95825. readonly isLoading: boolean;
  95826. /**
  95827. * Registers a function to be executed when the scene is ready
  95828. * @param {Function} func - the function to be executed
  95829. */
  95830. executeWhenReady(func: () => void): void;
  95831. /**
  95832. * Returns a promise that resolves when the scene is ready
  95833. * @returns A promise that resolves when the scene is ready
  95834. */
  95835. whenReadyAsync(): Promise<void>;
  95836. /** @hidden */
  95837. _checkIsReady(): void;
  95838. /**
  95839. * Gets all animatable attached to the scene
  95840. */
  95841. readonly animatables: Animatable[];
  95842. /**
  95843. * Resets the last animation time frame.
  95844. * Useful to override when animations start running when loading a scene for the first time.
  95845. */
  95846. resetLastAnimationTimeFrame(): void;
  95847. /**
  95848. * Gets the current view matrix
  95849. * @returns a Matrix
  95850. */
  95851. getViewMatrix(): Matrix;
  95852. /**
  95853. * Gets the current projection matrix
  95854. * @returns a Matrix
  95855. */
  95856. getProjectionMatrix(): Matrix;
  95857. /**
  95858. * Gets the current transform matrix
  95859. * @returns a Matrix made of View * Projection
  95860. */
  95861. getTransformMatrix(): Matrix;
  95862. /**
  95863. * Sets the current transform matrix
  95864. * @param viewL defines the View matrix to use
  95865. * @param projectionL defines the Projection matrix to use
  95866. * @param viewR defines the right View matrix to use (if provided)
  95867. * @param projectionR defines the right Projection matrix to use (if provided)
  95868. */
  95869. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  95870. /**
  95871. * Gets the uniform buffer used to store scene data
  95872. * @returns a UniformBuffer
  95873. */
  95874. getSceneUniformBuffer(): UniformBuffer;
  95875. /**
  95876. * Gets an unique (relatively to the current scene) Id
  95877. * @returns an unique number for the scene
  95878. */
  95879. getUniqueId(): number;
  95880. /**
  95881. * Add a mesh to the list of scene's meshes
  95882. * @param newMesh defines the mesh to add
  95883. * @param recursive if all child meshes should also be added to the scene
  95884. */
  95885. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  95886. /**
  95887. * Remove a mesh for the list of scene's meshes
  95888. * @param toRemove defines the mesh to remove
  95889. * @param recursive if all child meshes should also be removed from the scene
  95890. * @returns the index where the mesh was in the mesh list
  95891. */
  95892. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  95893. /**
  95894. * Add a transform node to the list of scene's transform nodes
  95895. * @param newTransformNode defines the transform node to add
  95896. */
  95897. addTransformNode(newTransformNode: TransformNode): void;
  95898. /**
  95899. * Remove a transform node for the list of scene's transform nodes
  95900. * @param toRemove defines the transform node to remove
  95901. * @returns the index where the transform node was in the transform node list
  95902. */
  95903. removeTransformNode(toRemove: TransformNode): number;
  95904. /**
  95905. * Remove a skeleton for the list of scene's skeletons
  95906. * @param toRemove defines the skeleton to remove
  95907. * @returns the index where the skeleton was in the skeleton list
  95908. */
  95909. removeSkeleton(toRemove: Skeleton): number;
  95910. /**
  95911. * Remove a morph target for the list of scene's morph targets
  95912. * @param toRemove defines the morph target to remove
  95913. * @returns the index where the morph target was in the morph target list
  95914. */
  95915. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  95916. /**
  95917. * Remove a light for the list of scene's lights
  95918. * @param toRemove defines the light to remove
  95919. * @returns the index where the light was in the light list
  95920. */
  95921. removeLight(toRemove: Light): number;
  95922. /**
  95923. * Remove a camera for the list of scene's cameras
  95924. * @param toRemove defines the camera to remove
  95925. * @returns the index where the camera was in the camera list
  95926. */
  95927. removeCamera(toRemove: Camera): number;
  95928. /**
  95929. * Remove a particle system for the list of scene's particle systems
  95930. * @param toRemove defines the particle system to remove
  95931. * @returns the index where the particle system was in the particle system list
  95932. */
  95933. removeParticleSystem(toRemove: IParticleSystem): number;
  95934. /**
  95935. * Remove a animation for the list of scene's animations
  95936. * @param toRemove defines the animation to remove
  95937. * @returns the index where the animation was in the animation list
  95938. */
  95939. removeAnimation(toRemove: Animation): number;
  95940. /**
  95941. * Will stop the animation of the given target
  95942. * @param target - the target
  95943. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  95944. * @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)
  95945. */
  95946. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  95947. /**
  95948. * Removes the given animation group from this scene.
  95949. * @param toRemove The animation group to remove
  95950. * @returns The index of the removed animation group
  95951. */
  95952. removeAnimationGroup(toRemove: AnimationGroup): number;
  95953. /**
  95954. * Removes the given multi-material from this scene.
  95955. * @param toRemove The multi-material to remove
  95956. * @returns The index of the removed multi-material
  95957. */
  95958. removeMultiMaterial(toRemove: MultiMaterial): number;
  95959. /**
  95960. * Removes the given material from this scene.
  95961. * @param toRemove The material to remove
  95962. * @returns The index of the removed material
  95963. */
  95964. removeMaterial(toRemove: Material): number;
  95965. /**
  95966. * Removes the given action manager from this scene.
  95967. * @param toRemove The action manager to remove
  95968. * @returns The index of the removed action manager
  95969. */
  95970. removeActionManager(toRemove: AbstractActionManager): number;
  95971. /**
  95972. * Removes the given texture from this scene.
  95973. * @param toRemove The texture to remove
  95974. * @returns The index of the removed texture
  95975. */
  95976. removeTexture(toRemove: BaseTexture): number;
  95977. /**
  95978. * Adds the given light to this scene
  95979. * @param newLight The light to add
  95980. */
  95981. addLight(newLight: Light): void;
  95982. /**
  95983. * Sorts the list list based on light priorities
  95984. */
  95985. sortLightsByPriority(): void;
  95986. /**
  95987. * Adds the given camera to this scene
  95988. * @param newCamera The camera to add
  95989. */
  95990. addCamera(newCamera: Camera): void;
  95991. /**
  95992. * Adds the given skeleton to this scene
  95993. * @param newSkeleton The skeleton to add
  95994. */
  95995. addSkeleton(newSkeleton: Skeleton): void;
  95996. /**
  95997. * Adds the given particle system to this scene
  95998. * @param newParticleSystem The particle system to add
  95999. */
  96000. addParticleSystem(newParticleSystem: IParticleSystem): void;
  96001. /**
  96002. * Adds the given animation to this scene
  96003. * @param newAnimation The animation to add
  96004. */
  96005. addAnimation(newAnimation: Animation): void;
  96006. /**
  96007. * Adds the given animation group to this scene.
  96008. * @param newAnimationGroup The animation group to add
  96009. */
  96010. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  96011. /**
  96012. * Adds the given multi-material to this scene
  96013. * @param newMultiMaterial The multi-material to add
  96014. */
  96015. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  96016. /**
  96017. * Adds the given material to this scene
  96018. * @param newMaterial The material to add
  96019. */
  96020. addMaterial(newMaterial: Material): void;
  96021. /**
  96022. * Adds the given morph target to this scene
  96023. * @param newMorphTargetManager The morph target to add
  96024. */
  96025. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  96026. /**
  96027. * Adds the given geometry to this scene
  96028. * @param newGeometry The geometry to add
  96029. */
  96030. addGeometry(newGeometry: Geometry): void;
  96031. /**
  96032. * Adds the given action manager to this scene
  96033. * @param newActionManager The action manager to add
  96034. */
  96035. addActionManager(newActionManager: AbstractActionManager): void;
  96036. /**
  96037. * Adds the given texture to this scene.
  96038. * @param newTexture The texture to add
  96039. */
  96040. addTexture(newTexture: BaseTexture): void;
  96041. /**
  96042. * Switch active camera
  96043. * @param newCamera defines the new active camera
  96044. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  96045. */
  96046. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  96047. /**
  96048. * sets the active camera of the scene using its ID
  96049. * @param id defines the camera's ID
  96050. * @return the new active camera or null if none found.
  96051. */
  96052. setActiveCameraByID(id: string): Nullable<Camera>;
  96053. /**
  96054. * sets the active camera of the scene using its name
  96055. * @param name defines the camera's name
  96056. * @returns the new active camera or null if none found.
  96057. */
  96058. setActiveCameraByName(name: string): Nullable<Camera>;
  96059. /**
  96060. * get an animation group using its name
  96061. * @param name defines the material's name
  96062. * @return the animation group or null if none found.
  96063. */
  96064. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  96065. /**
  96066. * Get a material using its unique id
  96067. * @param uniqueId defines the material's unique id
  96068. * @return the material or null if none found.
  96069. */
  96070. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  96071. /**
  96072. * get a material using its id
  96073. * @param id defines the material's ID
  96074. * @return the material or null if none found.
  96075. */
  96076. getMaterialByID(id: string): Nullable<Material>;
  96077. /**
  96078. * Gets a material using its name
  96079. * @param name defines the material's name
  96080. * @return the material or null if none found.
  96081. */
  96082. getMaterialByName(name: string): Nullable<Material>;
  96083. /**
  96084. * Gets a camera using its id
  96085. * @param id defines the id to look for
  96086. * @returns the camera or null if not found
  96087. */
  96088. getCameraByID(id: string): Nullable<Camera>;
  96089. /**
  96090. * Gets a camera using its unique id
  96091. * @param uniqueId defines the unique id to look for
  96092. * @returns the camera or null if not found
  96093. */
  96094. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  96095. /**
  96096. * Gets a camera using its name
  96097. * @param name defines the camera's name
  96098. * @return the camera or null if none found.
  96099. */
  96100. getCameraByName(name: string): Nullable<Camera>;
  96101. /**
  96102. * Gets a bone using its id
  96103. * @param id defines the bone's id
  96104. * @return the bone or null if not found
  96105. */
  96106. getBoneByID(id: string): Nullable<Bone>;
  96107. /**
  96108. * Gets a bone using its id
  96109. * @param name defines the bone's name
  96110. * @return the bone or null if not found
  96111. */
  96112. getBoneByName(name: string): Nullable<Bone>;
  96113. /**
  96114. * Gets a light node using its name
  96115. * @param name defines the the light's name
  96116. * @return the light or null if none found.
  96117. */
  96118. getLightByName(name: string): Nullable<Light>;
  96119. /**
  96120. * Gets a light node using its id
  96121. * @param id defines the light's id
  96122. * @return the light or null if none found.
  96123. */
  96124. getLightByID(id: string): Nullable<Light>;
  96125. /**
  96126. * Gets a light node using its scene-generated unique ID
  96127. * @param uniqueId defines the light's unique id
  96128. * @return the light or null if none found.
  96129. */
  96130. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  96131. /**
  96132. * Gets a particle system by id
  96133. * @param id defines the particle system id
  96134. * @return the corresponding system or null if none found
  96135. */
  96136. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  96137. /**
  96138. * Gets a geometry using its ID
  96139. * @param id defines the geometry's id
  96140. * @return the geometry or null if none found.
  96141. */
  96142. getGeometryByID(id: string): Nullable<Geometry>;
  96143. private _getGeometryByUniqueID;
  96144. /**
  96145. * Add a new geometry to this scene
  96146. * @param geometry defines the geometry to be added to the scene.
  96147. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  96148. * @return a boolean defining if the geometry was added or not
  96149. */
  96150. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  96151. /**
  96152. * Removes an existing geometry
  96153. * @param geometry defines the geometry to be removed from the scene
  96154. * @return a boolean defining if the geometry was removed or not
  96155. */
  96156. removeGeometry(geometry: Geometry): boolean;
  96157. /**
  96158. * Gets the list of geometries attached to the scene
  96159. * @returns an array of Geometry
  96160. */
  96161. getGeometries(): Geometry[];
  96162. /**
  96163. * Gets the first added mesh found of a given ID
  96164. * @param id defines the id to search for
  96165. * @return the mesh found or null if not found at all
  96166. */
  96167. getMeshByID(id: string): Nullable<AbstractMesh>;
  96168. /**
  96169. * Gets a list of meshes using their id
  96170. * @param id defines the id to search for
  96171. * @returns a list of meshes
  96172. */
  96173. getMeshesByID(id: string): Array<AbstractMesh>;
  96174. /**
  96175. * Gets the first added transform node found of a given ID
  96176. * @param id defines the id to search for
  96177. * @return the found transform node or null if not found at all.
  96178. */
  96179. getTransformNodeByID(id: string): Nullable<TransformNode>;
  96180. /**
  96181. * Gets a transform node with its auto-generated unique id
  96182. * @param uniqueId efines the unique id to search for
  96183. * @return the found transform node or null if not found at all.
  96184. */
  96185. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  96186. /**
  96187. * Gets a list of transform nodes using their id
  96188. * @param id defines the id to search for
  96189. * @returns a list of transform nodes
  96190. */
  96191. getTransformNodesByID(id: string): Array<TransformNode>;
  96192. /**
  96193. * Gets a mesh with its auto-generated unique id
  96194. * @param uniqueId defines the unique id to search for
  96195. * @return the found mesh or null if not found at all.
  96196. */
  96197. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  96198. /**
  96199. * Gets a the last added mesh using a given id
  96200. * @param id defines the id to search for
  96201. * @return the found mesh or null if not found at all.
  96202. */
  96203. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  96204. /**
  96205. * Gets a the last added node (Mesh, Camera, Light) using a given id
  96206. * @param id defines the id to search for
  96207. * @return the found node or null if not found at all
  96208. */
  96209. getLastEntryByID(id: string): Nullable<Node>;
  96210. /**
  96211. * Gets a node (Mesh, Camera, Light) using a given id
  96212. * @param id defines the id to search for
  96213. * @return the found node or null if not found at all
  96214. */
  96215. getNodeByID(id: string): Nullable<Node>;
  96216. /**
  96217. * Gets a node (Mesh, Camera, Light) using a given name
  96218. * @param name defines the name to search for
  96219. * @return the found node or null if not found at all.
  96220. */
  96221. getNodeByName(name: string): Nullable<Node>;
  96222. /**
  96223. * Gets a mesh using a given name
  96224. * @param name defines the name to search for
  96225. * @return the found mesh or null if not found at all.
  96226. */
  96227. getMeshByName(name: string): Nullable<AbstractMesh>;
  96228. /**
  96229. * Gets a transform node using a given name
  96230. * @param name defines the name to search for
  96231. * @return the found transform node or null if not found at all.
  96232. */
  96233. getTransformNodeByName(name: string): Nullable<TransformNode>;
  96234. /**
  96235. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  96236. * @param id defines the id to search for
  96237. * @return the found skeleton or null if not found at all.
  96238. */
  96239. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  96240. /**
  96241. * Gets a skeleton using a given auto generated unique id
  96242. * @param uniqueId defines the unique id to search for
  96243. * @return the found skeleton or null if not found at all.
  96244. */
  96245. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  96246. /**
  96247. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  96248. * @param id defines the id to search for
  96249. * @return the found skeleton or null if not found at all.
  96250. */
  96251. getSkeletonById(id: string): Nullable<Skeleton>;
  96252. /**
  96253. * Gets a skeleton using a given name
  96254. * @param name defines the name to search for
  96255. * @return the found skeleton or null if not found at all.
  96256. */
  96257. getSkeletonByName(name: string): Nullable<Skeleton>;
  96258. /**
  96259. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  96260. * @param id defines the id to search for
  96261. * @return the found morph target manager or null if not found at all.
  96262. */
  96263. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  96264. /**
  96265. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  96266. * @param id defines the id to search for
  96267. * @return the found morph target or null if not found at all.
  96268. */
  96269. getMorphTargetById(id: string): Nullable<MorphTarget>;
  96270. /**
  96271. * Gets a boolean indicating if the given mesh is active
  96272. * @param mesh defines the mesh to look for
  96273. * @returns true if the mesh is in the active list
  96274. */
  96275. isActiveMesh(mesh: AbstractMesh): boolean;
  96276. /**
  96277. * Return a unique id as a string which can serve as an identifier for the scene
  96278. */
  96279. readonly uid: string;
  96280. /**
  96281. * Add an externaly attached data from its key.
  96282. * This method call will fail and return false, if such key already exists.
  96283. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96284. * @param key the unique key that identifies the data
  96285. * @param data the data object to associate to the key for this Engine instance
  96286. * @return true if no such key were already present and the data was added successfully, false otherwise
  96287. */
  96288. addExternalData<T>(key: string, data: T): boolean;
  96289. /**
  96290. * Get an externaly attached data from its key
  96291. * @param key the unique key that identifies the data
  96292. * @return the associated data, if present (can be null), or undefined if not present
  96293. */
  96294. getExternalData<T>(key: string): Nullable<T>;
  96295. /**
  96296. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96297. * @param key the unique key that identifies the data
  96298. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96299. * @return the associated data, can be null if the factory returned null.
  96300. */
  96301. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96302. /**
  96303. * Remove an externaly attached data from the Engine instance
  96304. * @param key the unique key that identifies the data
  96305. * @return true if the data was successfully removed, false if it doesn't exist
  96306. */
  96307. removeExternalData(key: string): boolean;
  96308. private _evaluateSubMesh;
  96309. /**
  96310. * Clear the processed materials smart array preventing retention point in material dispose.
  96311. */
  96312. freeProcessedMaterials(): void;
  96313. private _preventFreeActiveMeshesAndRenderingGroups;
  96314. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  96315. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  96316. * when disposing several meshes in a row or a hierarchy of meshes.
  96317. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  96318. */
  96319. blockfreeActiveMeshesAndRenderingGroups: boolean;
  96320. /**
  96321. * Clear the active meshes smart array preventing retention point in mesh dispose.
  96322. */
  96323. freeActiveMeshes(): void;
  96324. /**
  96325. * Clear the info related to rendering groups preventing retention points during dispose.
  96326. */
  96327. freeRenderingGroups(): void;
  96328. /** @hidden */
  96329. _isInIntermediateRendering(): boolean;
  96330. /**
  96331. * Lambda returning the list of potentially active meshes.
  96332. */
  96333. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  96334. /**
  96335. * Lambda returning the list of potentially active sub meshes.
  96336. */
  96337. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  96338. /**
  96339. * Lambda returning the list of potentially intersecting sub meshes.
  96340. */
  96341. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96342. /**
  96343. * Lambda returning the list of potentially colliding sub meshes.
  96344. */
  96345. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96346. private _activeMeshesFrozen;
  96347. /**
  96348. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96349. * @returns the current scene
  96350. */
  96351. freezeActiveMeshes(): Scene;
  96352. /**
  96353. * Use this function to restart evaluating active meshes on every frame
  96354. * @returns the current scene
  96355. */
  96356. unfreezeActiveMeshes(): Scene;
  96357. private _evaluateActiveMeshes;
  96358. private _activeMesh;
  96359. /**
  96360. * Update the transform matrix to update from the current active camera
  96361. * @param force defines a boolean used to force the update even if cache is up to date
  96362. */
  96363. updateTransformMatrix(force?: boolean): void;
  96364. private _bindFrameBuffer;
  96365. /** @hidden */
  96366. _allowPostProcessClearColor: boolean;
  96367. /** @hidden */
  96368. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96369. private _processSubCameras;
  96370. private _checkIntersections;
  96371. /** @hidden */
  96372. _advancePhysicsEngineStep(step: number): void;
  96373. /**
  96374. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96375. */
  96376. getDeterministicFrameTime: () => number;
  96377. /** @hidden */
  96378. _animate(): void;
  96379. /** Execute all animations (for a frame) */
  96380. animate(): void;
  96381. /**
  96382. * Render the scene
  96383. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96384. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96385. */
  96386. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96387. /**
  96388. * Freeze all materials
  96389. * A frozen material will not be updatable but should be faster to render
  96390. */
  96391. freezeMaterials(): void;
  96392. /**
  96393. * Unfreeze all materials
  96394. * A frozen material will not be updatable but should be faster to render
  96395. */
  96396. unfreezeMaterials(): void;
  96397. /**
  96398. * Releases all held ressources
  96399. */
  96400. dispose(): void;
  96401. /**
  96402. * Gets if the scene is already disposed
  96403. */
  96404. readonly isDisposed: boolean;
  96405. /**
  96406. * Call this function to reduce memory footprint of the scene.
  96407. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96408. */
  96409. clearCachedVertexData(): void;
  96410. /**
  96411. * This function will remove the local cached buffer data from texture.
  96412. * It will save memory but will prevent the texture from being rebuilt
  96413. */
  96414. cleanCachedTextureBuffer(): void;
  96415. /**
  96416. * Get the world extend vectors with an optional filter
  96417. *
  96418. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96419. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96420. */
  96421. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96422. min: Vector3;
  96423. max: Vector3;
  96424. };
  96425. /**
  96426. * Creates a ray that can be used to pick in the scene
  96427. * @param x defines the x coordinate of the origin (on-screen)
  96428. * @param y defines the y coordinate of the origin (on-screen)
  96429. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96430. * @param camera defines the camera to use for the picking
  96431. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96432. * @returns a Ray
  96433. */
  96434. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96435. /**
  96436. * Creates a ray that can be used to pick in the scene
  96437. * @param x defines the x coordinate of the origin (on-screen)
  96438. * @param y defines the y coordinate of the origin (on-screen)
  96439. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96440. * @param result defines the ray where to store the picking ray
  96441. * @param camera defines the camera to use for the picking
  96442. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96443. * @returns the current scene
  96444. */
  96445. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96446. /**
  96447. * Creates a ray that can be used to pick in the scene
  96448. * @param x defines the x coordinate of the origin (on-screen)
  96449. * @param y defines the y coordinate of the origin (on-screen)
  96450. * @param camera defines the camera to use for the picking
  96451. * @returns a Ray
  96452. */
  96453. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96454. /**
  96455. * Creates a ray that can be used to pick in the scene
  96456. * @param x defines the x coordinate of the origin (on-screen)
  96457. * @param y defines the y coordinate of the origin (on-screen)
  96458. * @param result defines the ray where to store the picking ray
  96459. * @param camera defines the camera to use for the picking
  96460. * @returns the current scene
  96461. */
  96462. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96463. /** Launch a ray to try to pick a mesh in the scene
  96464. * @param x position on screen
  96465. * @param y position on screen
  96466. * @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
  96467. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96468. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96469. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96470. * @returns a PickingInfo
  96471. */
  96472. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96473. /** Use the given ray to pick a mesh in the scene
  96474. * @param ray The ray to use to pick meshes
  96475. * @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
  96476. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96477. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96478. * @returns a PickingInfo
  96479. */
  96480. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96481. /**
  96482. * Launch a ray to try to pick a mesh in the scene
  96483. * @param x X position on screen
  96484. * @param y Y position on screen
  96485. * @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
  96486. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96487. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96488. * @returns an array of PickingInfo
  96489. */
  96490. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96491. /**
  96492. * Launch a ray to try to pick a mesh in the scene
  96493. * @param ray Ray to use
  96494. * @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
  96495. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96496. * @returns an array of PickingInfo
  96497. */
  96498. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96499. /**
  96500. * Force the value of meshUnderPointer
  96501. * @param mesh defines the mesh to use
  96502. */
  96503. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96504. /**
  96505. * Gets the mesh under the pointer
  96506. * @returns a Mesh or null if no mesh is under the pointer
  96507. */
  96508. getPointerOverMesh(): Nullable<AbstractMesh>;
  96509. /** @hidden */
  96510. _rebuildGeometries(): void;
  96511. /** @hidden */
  96512. _rebuildTextures(): void;
  96513. private _getByTags;
  96514. /**
  96515. * Get a list of meshes by tags
  96516. * @param tagsQuery defines the tags query to use
  96517. * @param forEach defines a predicate used to filter results
  96518. * @returns an array of Mesh
  96519. */
  96520. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  96521. /**
  96522. * Get a list of cameras by tags
  96523. * @param tagsQuery defines the tags query to use
  96524. * @param forEach defines a predicate used to filter results
  96525. * @returns an array of Camera
  96526. */
  96527. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  96528. /**
  96529. * Get a list of lights by tags
  96530. * @param tagsQuery defines the tags query to use
  96531. * @param forEach defines a predicate used to filter results
  96532. * @returns an array of Light
  96533. */
  96534. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  96535. /**
  96536. * Get a list of materials by tags
  96537. * @param tagsQuery defines the tags query to use
  96538. * @param forEach defines a predicate used to filter results
  96539. * @returns an array of Material
  96540. */
  96541. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  96542. /**
  96543. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96544. * This allowed control for front to back rendering or reversly depending of the special needs.
  96545. *
  96546. * @param renderingGroupId The rendering group id corresponding to its index
  96547. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96548. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96549. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96550. */
  96551. 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;
  96552. /**
  96553. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96554. *
  96555. * @param renderingGroupId The rendering group id corresponding to its index
  96556. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96557. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96558. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96559. */
  96560. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96561. /**
  96562. * Gets the current auto clear configuration for one rendering group of the rendering
  96563. * manager.
  96564. * @param index the rendering group index to get the information for
  96565. * @returns The auto clear setup for the requested rendering group
  96566. */
  96567. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96568. private _blockMaterialDirtyMechanism;
  96569. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  96570. blockMaterialDirtyMechanism: boolean;
  96571. /**
  96572. * Will flag all materials as dirty to trigger new shader compilation
  96573. * @param flag defines the flag used to specify which material part must be marked as dirty
  96574. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  96575. */
  96576. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  96577. /** @hidden */
  96578. _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;
  96579. /** @hidden */
  96580. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96581. }
  96582. }
  96583. declare module BABYLON {
  96584. /**
  96585. * Set of assets to keep when moving a scene into an asset container.
  96586. */
  96587. export class KeepAssets extends AbstractScene {
  96588. }
  96589. /**
  96590. * Container with a set of assets that can be added or removed from a scene.
  96591. */
  96592. export class AssetContainer extends AbstractScene {
  96593. /**
  96594. * The scene the AssetContainer belongs to.
  96595. */
  96596. scene: Scene;
  96597. /**
  96598. * Instantiates an AssetContainer.
  96599. * @param scene The scene the AssetContainer belongs to.
  96600. */
  96601. constructor(scene: Scene);
  96602. /**
  96603. * Adds all the assets from the container to the scene.
  96604. */
  96605. addAllToScene(): void;
  96606. /**
  96607. * Removes all the assets in the container from the scene
  96608. */
  96609. removeAllFromScene(): void;
  96610. /**
  96611. * Disposes all the assets in the container
  96612. */
  96613. dispose(): void;
  96614. private _moveAssets;
  96615. /**
  96616. * Removes all the assets contained in the scene and adds them to the container.
  96617. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  96618. */
  96619. moveAllFromScene(keepAssets?: KeepAssets): void;
  96620. /**
  96621. * 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.
  96622. * @returns the root mesh
  96623. */
  96624. createRootMesh(): Mesh;
  96625. }
  96626. }
  96627. declare module BABYLON {
  96628. /**
  96629. * Defines how the parser contract is defined.
  96630. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  96631. */
  96632. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  96633. /**
  96634. * Defines how the individual parser contract is defined.
  96635. * These parser can parse an individual asset
  96636. */
  96637. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  96638. /**
  96639. * Base class of the scene acting as a container for the different elements composing a scene.
  96640. * This class is dynamically extended by the different components of the scene increasing
  96641. * flexibility and reducing coupling
  96642. */
  96643. export abstract class AbstractScene {
  96644. /**
  96645. * Stores the list of available parsers in the application.
  96646. */
  96647. private static _BabylonFileParsers;
  96648. /**
  96649. * Stores the list of available individual parsers in the application.
  96650. */
  96651. private static _IndividualBabylonFileParsers;
  96652. /**
  96653. * Adds a parser in the list of available ones
  96654. * @param name Defines the name of the parser
  96655. * @param parser Defines the parser to add
  96656. */
  96657. static AddParser(name: string, parser: BabylonFileParser): void;
  96658. /**
  96659. * Gets a general parser from the list of avaialble ones
  96660. * @param name Defines the name of the parser
  96661. * @returns the requested parser or null
  96662. */
  96663. static GetParser(name: string): Nullable<BabylonFileParser>;
  96664. /**
  96665. * Adds n individual parser in the list of available ones
  96666. * @param name Defines the name of the parser
  96667. * @param parser Defines the parser to add
  96668. */
  96669. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  96670. /**
  96671. * Gets an individual parser from the list of avaialble ones
  96672. * @param name Defines the name of the parser
  96673. * @returns the requested parser or null
  96674. */
  96675. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  96676. /**
  96677. * Parser json data and populate both a scene and its associated container object
  96678. * @param jsonData Defines the data to parse
  96679. * @param scene Defines the scene to parse the data for
  96680. * @param container Defines the container attached to the parsing sequence
  96681. * @param rootUrl Defines the root url of the data
  96682. */
  96683. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  96684. /**
  96685. * Gets the list of root nodes (ie. nodes with no parent)
  96686. */
  96687. rootNodes: Node[];
  96688. /** All of the cameras added to this scene
  96689. * @see http://doc.babylonjs.com/babylon101/cameras
  96690. */
  96691. cameras: Camera[];
  96692. /**
  96693. * All of the lights added to this scene
  96694. * @see http://doc.babylonjs.com/babylon101/lights
  96695. */
  96696. lights: Light[];
  96697. /**
  96698. * All of the (abstract) meshes added to this scene
  96699. */
  96700. meshes: AbstractMesh[];
  96701. /**
  96702. * The list of skeletons added to the scene
  96703. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96704. */
  96705. skeletons: Skeleton[];
  96706. /**
  96707. * All of the particle systems added to this scene
  96708. * @see http://doc.babylonjs.com/babylon101/particles
  96709. */
  96710. particleSystems: IParticleSystem[];
  96711. /**
  96712. * Gets a list of Animations associated with the scene
  96713. */
  96714. animations: Animation[];
  96715. /**
  96716. * All of the animation groups added to this scene
  96717. * @see http://doc.babylonjs.com/how_to/group
  96718. */
  96719. animationGroups: AnimationGroup[];
  96720. /**
  96721. * All of the multi-materials added to this scene
  96722. * @see http://doc.babylonjs.com/how_to/multi_materials
  96723. */
  96724. multiMaterials: MultiMaterial[];
  96725. /**
  96726. * All of the materials added to this scene
  96727. * In the context of a Scene, it is not supposed to be modified manually.
  96728. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  96729. * Note also that the order of the Material wihin the array is not significant and might change.
  96730. * @see http://doc.babylonjs.com/babylon101/materials
  96731. */
  96732. materials: Material[];
  96733. /**
  96734. * The list of morph target managers added to the scene
  96735. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  96736. */
  96737. morphTargetManagers: MorphTargetManager[];
  96738. /**
  96739. * The list of geometries used in the scene.
  96740. */
  96741. geometries: Geometry[];
  96742. /**
  96743. * All of the tranform nodes added to this scene
  96744. * In the context of a Scene, it is not supposed to be modified manually.
  96745. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  96746. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  96747. * @see http://doc.babylonjs.com/how_to/transformnode
  96748. */
  96749. transformNodes: TransformNode[];
  96750. /**
  96751. * ActionManagers available on the scene.
  96752. */
  96753. actionManagers: AbstractActionManager[];
  96754. /**
  96755. * Textures to keep.
  96756. */
  96757. textures: BaseTexture[];
  96758. /**
  96759. * Environment texture for the scene
  96760. */
  96761. environmentTexture: Nullable<BaseTexture>;
  96762. }
  96763. }
  96764. declare module BABYLON {
  96765. /**
  96766. * Defines a sound that can be played in the application.
  96767. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  96768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96769. */
  96770. export class Sound {
  96771. /**
  96772. * The name of the sound in the scene.
  96773. */
  96774. name: string;
  96775. /**
  96776. * Does the sound autoplay once loaded.
  96777. */
  96778. autoplay: boolean;
  96779. /**
  96780. * Does the sound loop after it finishes playing once.
  96781. */
  96782. loop: boolean;
  96783. /**
  96784. * Does the sound use a custom attenuation curve to simulate the falloff
  96785. * happening when the source gets further away from the camera.
  96786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96787. */
  96788. useCustomAttenuation: boolean;
  96789. /**
  96790. * The sound track id this sound belongs to.
  96791. */
  96792. soundTrackId: number;
  96793. /**
  96794. * Is this sound currently played.
  96795. */
  96796. isPlaying: boolean;
  96797. /**
  96798. * Is this sound currently paused.
  96799. */
  96800. isPaused: boolean;
  96801. /**
  96802. * Does this sound enables spatial sound.
  96803. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96804. */
  96805. spatialSound: boolean;
  96806. /**
  96807. * Define the reference distance the sound should be heard perfectly.
  96808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96809. */
  96810. refDistance: number;
  96811. /**
  96812. * Define the roll off factor of spatial sounds.
  96813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96814. */
  96815. rolloffFactor: number;
  96816. /**
  96817. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  96818. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96819. */
  96820. maxDistance: number;
  96821. /**
  96822. * Define the distance attenuation model the sound will follow.
  96823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96824. */
  96825. distanceModel: string;
  96826. /**
  96827. * @hidden
  96828. * Back Compat
  96829. **/
  96830. onended: () => any;
  96831. /**
  96832. * Observable event when the current playing sound finishes.
  96833. */
  96834. onEndedObservable: Observable<Sound>;
  96835. private _panningModel;
  96836. private _playbackRate;
  96837. private _streaming;
  96838. private _startTime;
  96839. private _startOffset;
  96840. private _position;
  96841. /** @hidden */
  96842. _positionInEmitterSpace: boolean;
  96843. private _localDirection;
  96844. private _volume;
  96845. private _isReadyToPlay;
  96846. private _isDirectional;
  96847. private _readyToPlayCallback;
  96848. private _audioBuffer;
  96849. private _soundSource;
  96850. private _streamingSource;
  96851. private _soundPanner;
  96852. private _soundGain;
  96853. private _inputAudioNode;
  96854. private _outputAudioNode;
  96855. private _coneInnerAngle;
  96856. private _coneOuterAngle;
  96857. private _coneOuterGain;
  96858. private _scene;
  96859. private _connectedTransformNode;
  96860. private _customAttenuationFunction;
  96861. private _registerFunc;
  96862. private _isOutputConnected;
  96863. private _htmlAudioElement;
  96864. private _urlType;
  96865. /** @hidden */
  96866. static _SceneComponentInitialization: (scene: Scene) => void;
  96867. /**
  96868. * Create a sound and attach it to a scene
  96869. * @param name Name of your sound
  96870. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  96871. * @param scene defines the scene the sound belongs to
  96872. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  96873. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  96874. */
  96875. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  96876. /**
  96877. * Release the sound and its associated resources
  96878. */
  96879. dispose(): void;
  96880. /**
  96881. * Gets if the sounds is ready to be played or not.
  96882. * @returns true if ready, otherwise false
  96883. */
  96884. isReady(): boolean;
  96885. private _soundLoaded;
  96886. /**
  96887. * Sets the data of the sound from an audiobuffer
  96888. * @param audioBuffer The audioBuffer containing the data
  96889. */
  96890. setAudioBuffer(audioBuffer: AudioBuffer): void;
  96891. /**
  96892. * Updates the current sounds options such as maxdistance, loop...
  96893. * @param options A JSON object containing values named as the object properties
  96894. */
  96895. updateOptions(options: any): void;
  96896. private _createSpatialParameters;
  96897. private _updateSpatialParameters;
  96898. /**
  96899. * Switch the panning model to HRTF:
  96900. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  96901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96902. */
  96903. switchPanningModelToHRTF(): void;
  96904. /**
  96905. * Switch the panning model to Equal Power:
  96906. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  96907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96908. */
  96909. switchPanningModelToEqualPower(): void;
  96910. private _switchPanningModel;
  96911. /**
  96912. * Connect this sound to a sound track audio node like gain...
  96913. * @param soundTrackAudioNode the sound track audio node to connect to
  96914. */
  96915. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  96916. /**
  96917. * Transform this sound into a directional source
  96918. * @param coneInnerAngle Size of the inner cone in degree
  96919. * @param coneOuterAngle Size of the outer cone in degree
  96920. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  96921. */
  96922. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  96923. /**
  96924. * Gets or sets the inner angle for the directional cone.
  96925. */
  96926. /**
  96927. * Gets or sets the inner angle for the directional cone.
  96928. */
  96929. directionalConeInnerAngle: number;
  96930. /**
  96931. * Gets or sets the outer angle for the directional cone.
  96932. */
  96933. /**
  96934. * Gets or sets the outer angle for the directional cone.
  96935. */
  96936. directionalConeOuterAngle: number;
  96937. /**
  96938. * Sets the position of the emitter if spatial sound is enabled
  96939. * @param newPosition Defines the new posisiton
  96940. */
  96941. setPosition(newPosition: Vector3): void;
  96942. /**
  96943. * Sets the local direction of the emitter if spatial sound is enabled
  96944. * @param newLocalDirection Defines the new local direction
  96945. */
  96946. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  96947. private _updateDirection;
  96948. /** @hidden */
  96949. updateDistanceFromListener(): void;
  96950. /**
  96951. * Sets a new custom attenuation function for the sound.
  96952. * @param callback Defines the function used for the attenuation
  96953. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96954. */
  96955. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  96956. /**
  96957. * Play the sound
  96958. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  96959. * @param offset (optional) Start the sound setting it at a specific time
  96960. */
  96961. play(time?: number, offset?: number): void;
  96962. private _onended;
  96963. /**
  96964. * Stop the sound
  96965. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  96966. */
  96967. stop(time?: number): void;
  96968. /**
  96969. * Put the sound in pause
  96970. */
  96971. pause(): void;
  96972. /**
  96973. * Sets a dedicated volume for this sounds
  96974. * @param newVolume Define the new volume of the sound
  96975. * @param time Define in how long the sound should be at this value
  96976. */
  96977. setVolume(newVolume: number, time?: number): void;
  96978. /**
  96979. * Set the sound play back rate
  96980. * @param newPlaybackRate Define the playback rate the sound should be played at
  96981. */
  96982. setPlaybackRate(newPlaybackRate: number): void;
  96983. /**
  96984. * Gets the volume of the sound.
  96985. * @returns the volume of the sound
  96986. */
  96987. getVolume(): number;
  96988. /**
  96989. * Attach the sound to a dedicated mesh
  96990. * @param transformNode The transform node to connect the sound with
  96991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96992. */
  96993. attachToMesh(transformNode: TransformNode): void;
  96994. /**
  96995. * Detach the sound from the previously attached mesh
  96996. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96997. */
  96998. detachFromMesh(): void;
  96999. private _onRegisterAfterWorldMatrixUpdate;
  97000. /**
  97001. * Clone the current sound in the scene.
  97002. * @returns the new sound clone
  97003. */
  97004. clone(): Nullable<Sound>;
  97005. /**
  97006. * Gets the current underlying audio buffer containing the data
  97007. * @returns the audio buffer
  97008. */
  97009. getAudioBuffer(): Nullable<AudioBuffer>;
  97010. /**
  97011. * Serializes the Sound in a JSON representation
  97012. * @returns the JSON representation of the sound
  97013. */
  97014. serialize(): any;
  97015. /**
  97016. * Parse a JSON representation of a sound to innstantiate in a given scene
  97017. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  97018. * @param scene Define the scene the new parsed sound should be created in
  97019. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  97020. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  97021. * @returns the newly parsed sound
  97022. */
  97023. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  97024. }
  97025. }
  97026. declare module BABYLON {
  97027. /**
  97028. * This defines an action helpful to play a defined sound on a triggered action.
  97029. */
  97030. export class PlaySoundAction extends Action {
  97031. private _sound;
  97032. /**
  97033. * Instantiate the action
  97034. * @param triggerOptions defines the trigger options
  97035. * @param sound defines the sound to play
  97036. * @param condition defines the trigger related conditions
  97037. */
  97038. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97039. /** @hidden */
  97040. _prepare(): void;
  97041. /**
  97042. * Execute the action and play the sound.
  97043. */
  97044. execute(): void;
  97045. /**
  97046. * Serializes the actions and its related information.
  97047. * @param parent defines the object to serialize in
  97048. * @returns the serialized object
  97049. */
  97050. serialize(parent: any): any;
  97051. }
  97052. /**
  97053. * This defines an action helpful to stop a defined sound on a triggered action.
  97054. */
  97055. export class StopSoundAction extends Action {
  97056. private _sound;
  97057. /**
  97058. * Instantiate the action
  97059. * @param triggerOptions defines the trigger options
  97060. * @param sound defines the sound to stop
  97061. * @param condition defines the trigger related conditions
  97062. */
  97063. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97064. /** @hidden */
  97065. _prepare(): void;
  97066. /**
  97067. * Execute the action and stop the sound.
  97068. */
  97069. execute(): void;
  97070. /**
  97071. * Serializes the actions and its related information.
  97072. * @param parent defines the object to serialize in
  97073. * @returns the serialized object
  97074. */
  97075. serialize(parent: any): any;
  97076. }
  97077. }
  97078. declare module BABYLON {
  97079. /**
  97080. * This defines an action responsible to change the value of a property
  97081. * by interpolating between its current value and the newly set one once triggered.
  97082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97083. */
  97084. export class InterpolateValueAction extends Action {
  97085. /**
  97086. * Defines the path of the property where the value should be interpolated
  97087. */
  97088. propertyPath: string;
  97089. /**
  97090. * Defines the target value at the end of the interpolation.
  97091. */
  97092. value: any;
  97093. /**
  97094. * Defines the time it will take for the property to interpolate to the value.
  97095. */
  97096. duration: number;
  97097. /**
  97098. * Defines if the other scene animations should be stopped when the action has been triggered
  97099. */
  97100. stopOtherAnimations?: boolean;
  97101. /**
  97102. * Defines a callback raised once the interpolation animation has been done.
  97103. */
  97104. onInterpolationDone?: () => void;
  97105. /**
  97106. * Observable triggered once the interpolation animation has been done.
  97107. */
  97108. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  97109. private _target;
  97110. private _effectiveTarget;
  97111. private _property;
  97112. /**
  97113. * Instantiate the action
  97114. * @param triggerOptions defines the trigger options
  97115. * @param target defines the object containing the value to interpolate
  97116. * @param propertyPath defines the path to the property in the target object
  97117. * @param value defines the target value at the end of the interpolation
  97118. * @param duration deines the time it will take for the property to interpolate to the value.
  97119. * @param condition defines the trigger related conditions
  97120. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  97121. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  97122. */
  97123. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  97124. /** @hidden */
  97125. _prepare(): void;
  97126. /**
  97127. * Execute the action starts the value interpolation.
  97128. */
  97129. execute(): void;
  97130. /**
  97131. * Serializes the actions and its related information.
  97132. * @param parent defines the object to serialize in
  97133. * @returns the serialized object
  97134. */
  97135. serialize(parent: any): any;
  97136. }
  97137. }
  97138. declare module BABYLON {
  97139. /**
  97140. * Options allowed during the creation of a sound track.
  97141. */
  97142. export interface ISoundTrackOptions {
  97143. /**
  97144. * The volume the sound track should take during creation
  97145. */
  97146. volume?: number;
  97147. /**
  97148. * Define if the sound track is the main sound track of the scene
  97149. */
  97150. mainTrack?: boolean;
  97151. }
  97152. /**
  97153. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  97154. * It will be also used in a future release to apply effects on a specific track.
  97155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97156. */
  97157. export class SoundTrack {
  97158. /**
  97159. * The unique identifier of the sound track in the scene.
  97160. */
  97161. id: number;
  97162. /**
  97163. * The list of sounds included in the sound track.
  97164. */
  97165. soundCollection: Array<Sound>;
  97166. private _outputAudioNode;
  97167. private _scene;
  97168. private _isMainTrack;
  97169. private _connectedAnalyser;
  97170. private _options;
  97171. private _isInitialized;
  97172. /**
  97173. * Creates a new sound track.
  97174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97175. * @param scene Define the scene the sound track belongs to
  97176. * @param options
  97177. */
  97178. constructor(scene: Scene, options?: ISoundTrackOptions);
  97179. private _initializeSoundTrackAudioGraph;
  97180. /**
  97181. * Release the sound track and its associated resources
  97182. */
  97183. dispose(): void;
  97184. /**
  97185. * Adds a sound to this sound track
  97186. * @param sound define the cound to add
  97187. * @ignoreNaming
  97188. */
  97189. AddSound(sound: Sound): void;
  97190. /**
  97191. * Removes a sound to this sound track
  97192. * @param sound define the cound to remove
  97193. * @ignoreNaming
  97194. */
  97195. RemoveSound(sound: Sound): void;
  97196. /**
  97197. * Set a global volume for the full sound track.
  97198. * @param newVolume Define the new volume of the sound track
  97199. */
  97200. setVolume(newVolume: number): void;
  97201. /**
  97202. * Switch the panning model to HRTF:
  97203. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97205. */
  97206. switchPanningModelToHRTF(): void;
  97207. /**
  97208. * Switch the panning model to Equal Power:
  97209. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97211. */
  97212. switchPanningModelToEqualPower(): void;
  97213. /**
  97214. * Connect the sound track to an audio analyser allowing some amazing
  97215. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97217. * @param analyser The analyser to connect to the engine
  97218. */
  97219. connectToAnalyser(analyser: Analyser): void;
  97220. }
  97221. }
  97222. declare module BABYLON {
  97223. interface AbstractScene {
  97224. /**
  97225. * The list of sounds used in the scene.
  97226. */
  97227. sounds: Nullable<Array<Sound>>;
  97228. }
  97229. interface Scene {
  97230. /**
  97231. * @hidden
  97232. * Backing field
  97233. */
  97234. _mainSoundTrack: SoundTrack;
  97235. /**
  97236. * The main sound track played by the scene.
  97237. * It cotains your primary collection of sounds.
  97238. */
  97239. mainSoundTrack: SoundTrack;
  97240. /**
  97241. * The list of sound tracks added to the scene
  97242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97243. */
  97244. soundTracks: Nullable<Array<SoundTrack>>;
  97245. /**
  97246. * Gets a sound using a given name
  97247. * @param name defines the name to search for
  97248. * @return the found sound or null if not found at all.
  97249. */
  97250. getSoundByName(name: string): Nullable<Sound>;
  97251. /**
  97252. * Gets or sets if audio support is enabled
  97253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97254. */
  97255. audioEnabled: boolean;
  97256. /**
  97257. * Gets or sets if audio will be output to headphones
  97258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97259. */
  97260. headphone: boolean;
  97261. }
  97262. /**
  97263. * Defines the sound scene component responsible to manage any sounds
  97264. * in a given scene.
  97265. */
  97266. export class AudioSceneComponent implements ISceneSerializableComponent {
  97267. /**
  97268. * The component name helpfull to identify the component in the list of scene components.
  97269. */
  97270. readonly name: string;
  97271. /**
  97272. * The scene the component belongs to.
  97273. */
  97274. scene: Scene;
  97275. private _audioEnabled;
  97276. /**
  97277. * Gets whether audio is enabled or not.
  97278. * Please use related enable/disable method to switch state.
  97279. */
  97280. readonly audioEnabled: boolean;
  97281. private _headphone;
  97282. /**
  97283. * Gets whether audio is outputing to headphone or not.
  97284. * Please use the according Switch methods to change output.
  97285. */
  97286. readonly headphone: boolean;
  97287. /**
  97288. * Creates a new instance of the component for the given scene
  97289. * @param scene Defines the scene to register the component in
  97290. */
  97291. constructor(scene: Scene);
  97292. /**
  97293. * Registers the component in a given scene
  97294. */
  97295. register(): void;
  97296. /**
  97297. * Rebuilds the elements related to this component in case of
  97298. * context lost for instance.
  97299. */
  97300. rebuild(): void;
  97301. /**
  97302. * Serializes the component data to the specified json object
  97303. * @param serializationObject The object to serialize to
  97304. */
  97305. serialize(serializationObject: any): void;
  97306. /**
  97307. * Adds all the elements from the container to the scene
  97308. * @param container the container holding the elements
  97309. */
  97310. addFromContainer(container: AbstractScene): void;
  97311. /**
  97312. * Removes all the elements in the container from the scene
  97313. * @param container contains the elements to remove
  97314. * @param dispose if the removed element should be disposed (default: false)
  97315. */
  97316. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  97317. /**
  97318. * Disposes the component and the associated ressources.
  97319. */
  97320. dispose(): void;
  97321. /**
  97322. * Disables audio in the associated scene.
  97323. */
  97324. disableAudio(): void;
  97325. /**
  97326. * Enables audio in the associated scene.
  97327. */
  97328. enableAudio(): void;
  97329. /**
  97330. * Switch audio to headphone output.
  97331. */
  97332. switchAudioModeForHeadphones(): void;
  97333. /**
  97334. * Switch audio to normal speakers.
  97335. */
  97336. switchAudioModeForNormalSpeakers(): void;
  97337. private _afterRender;
  97338. }
  97339. }
  97340. declare module BABYLON {
  97341. /**
  97342. * Wraps one or more Sound objects and selects one with random weight for playback.
  97343. */
  97344. export class WeightedSound {
  97345. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97346. loop: boolean;
  97347. private _coneInnerAngle;
  97348. private _coneOuterAngle;
  97349. private _volume;
  97350. /** A Sound is currently playing. */
  97351. isPlaying: boolean;
  97352. /** A Sound is currently paused. */
  97353. isPaused: boolean;
  97354. private _sounds;
  97355. private _weights;
  97356. private _currentIndex?;
  97357. /**
  97358. * Creates a new WeightedSound from the list of sounds given.
  97359. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97360. * @param sounds Array of Sounds that will be selected from.
  97361. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97362. */
  97363. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97364. /**
  97365. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97366. */
  97367. /**
  97368. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97369. */
  97370. directionalConeInnerAngle: number;
  97371. /**
  97372. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97373. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97374. */
  97375. /**
  97376. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97377. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97378. */
  97379. directionalConeOuterAngle: number;
  97380. /**
  97381. * Playback volume.
  97382. */
  97383. /**
  97384. * Playback volume.
  97385. */
  97386. volume: number;
  97387. private _onended;
  97388. /**
  97389. * Suspend playback
  97390. */
  97391. pause(): void;
  97392. /**
  97393. * Stop playback
  97394. */
  97395. stop(): void;
  97396. /**
  97397. * Start playback.
  97398. * @param startOffset Position the clip head at a specific time in seconds.
  97399. */
  97400. play(startOffset?: number): void;
  97401. }
  97402. }
  97403. declare module BABYLON {
  97404. /**
  97405. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97406. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97407. */
  97408. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97409. /**
  97410. * Gets the name of the behavior.
  97411. */
  97412. readonly name: string;
  97413. /**
  97414. * The easing function used by animations
  97415. */
  97416. static EasingFunction: BackEase;
  97417. /**
  97418. * The easing mode used by animations
  97419. */
  97420. static EasingMode: number;
  97421. /**
  97422. * The duration of the animation, in milliseconds
  97423. */
  97424. transitionDuration: number;
  97425. /**
  97426. * Length of the distance animated by the transition when lower radius is reached
  97427. */
  97428. lowerRadiusTransitionRange: number;
  97429. /**
  97430. * Length of the distance animated by the transition when upper radius is reached
  97431. */
  97432. upperRadiusTransitionRange: number;
  97433. private _autoTransitionRange;
  97434. /**
  97435. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97436. */
  97437. /**
  97438. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97439. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97440. */
  97441. autoTransitionRange: boolean;
  97442. private _attachedCamera;
  97443. private _onAfterCheckInputsObserver;
  97444. private _onMeshTargetChangedObserver;
  97445. /**
  97446. * Initializes the behavior.
  97447. */
  97448. init(): void;
  97449. /**
  97450. * Attaches the behavior to its arc rotate camera.
  97451. * @param camera Defines the camera to attach the behavior to
  97452. */
  97453. attach(camera: ArcRotateCamera): void;
  97454. /**
  97455. * Detaches the behavior from its current arc rotate camera.
  97456. */
  97457. detach(): void;
  97458. private _radiusIsAnimating;
  97459. private _radiusBounceTransition;
  97460. private _animatables;
  97461. private _cachedWheelPrecision;
  97462. /**
  97463. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  97464. * @param radiusLimit The limit to check against.
  97465. * @return Bool to indicate if at limit.
  97466. */
  97467. private _isRadiusAtLimit;
  97468. /**
  97469. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  97470. * @param radiusDelta The delta by which to animate to. Can be negative.
  97471. */
  97472. private _applyBoundRadiusAnimation;
  97473. /**
  97474. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  97475. */
  97476. protected _clearAnimationLocks(): void;
  97477. /**
  97478. * Stops and removes all animations that have been applied to the camera
  97479. */
  97480. stopAllAnimations(): void;
  97481. }
  97482. }
  97483. declare module BABYLON {
  97484. /**
  97485. * 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.
  97486. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97487. */
  97488. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  97489. /**
  97490. * Gets the name of the behavior.
  97491. */
  97492. readonly name: string;
  97493. private _mode;
  97494. private _radiusScale;
  97495. private _positionScale;
  97496. private _defaultElevation;
  97497. private _elevationReturnTime;
  97498. private _elevationReturnWaitTime;
  97499. private _zoomStopsAnimation;
  97500. private _framingTime;
  97501. /**
  97502. * The easing function used by animations
  97503. */
  97504. static EasingFunction: ExponentialEase;
  97505. /**
  97506. * The easing mode used by animations
  97507. */
  97508. static EasingMode: number;
  97509. /**
  97510. * Sets the current mode used by the behavior
  97511. */
  97512. /**
  97513. * Gets current mode used by the behavior.
  97514. */
  97515. mode: number;
  97516. /**
  97517. * Sets the scale applied to the radius (1 by default)
  97518. */
  97519. /**
  97520. * Gets the scale applied to the radius
  97521. */
  97522. radiusScale: number;
  97523. /**
  97524. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97525. */
  97526. /**
  97527. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97528. */
  97529. positionScale: number;
  97530. /**
  97531. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97532. * behaviour is triggered, in radians.
  97533. */
  97534. /**
  97535. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97536. * behaviour is triggered, in radians.
  97537. */
  97538. defaultElevation: number;
  97539. /**
  97540. * Sets the time (in milliseconds) taken to return to the default beta position.
  97541. * Negative value indicates camera should not return to default.
  97542. */
  97543. /**
  97544. * Gets the time (in milliseconds) taken to return to the default beta position.
  97545. * Negative value indicates camera should not return to default.
  97546. */
  97547. elevationReturnTime: number;
  97548. /**
  97549. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97550. */
  97551. /**
  97552. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97553. */
  97554. elevationReturnWaitTime: number;
  97555. /**
  97556. * Sets the flag that indicates if user zooming should stop animation.
  97557. */
  97558. /**
  97559. * Gets the flag that indicates if user zooming should stop animation.
  97560. */
  97561. zoomStopsAnimation: boolean;
  97562. /**
  97563. * Sets the transition time when framing the mesh, in milliseconds
  97564. */
  97565. /**
  97566. * Gets the transition time when framing the mesh, in milliseconds
  97567. */
  97568. framingTime: number;
  97569. /**
  97570. * Define if the behavior should automatically change the configured
  97571. * camera limits and sensibilities.
  97572. */
  97573. autoCorrectCameraLimitsAndSensibility: boolean;
  97574. private _onPrePointerObservableObserver;
  97575. private _onAfterCheckInputsObserver;
  97576. private _onMeshTargetChangedObserver;
  97577. private _attachedCamera;
  97578. private _isPointerDown;
  97579. private _lastInteractionTime;
  97580. /**
  97581. * Initializes the behavior.
  97582. */
  97583. init(): void;
  97584. /**
  97585. * Attaches the behavior to its arc rotate camera.
  97586. * @param camera Defines the camera to attach the behavior to
  97587. */
  97588. attach(camera: ArcRotateCamera): void;
  97589. /**
  97590. * Detaches the behavior from its current arc rotate camera.
  97591. */
  97592. detach(): void;
  97593. private _animatables;
  97594. private _betaIsAnimating;
  97595. private _betaTransition;
  97596. private _radiusTransition;
  97597. private _vectorTransition;
  97598. /**
  97599. * Targets the given mesh and updates zoom level accordingly.
  97600. * @param mesh The mesh to target.
  97601. * @param radius Optional. If a cached radius position already exists, overrides default.
  97602. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97603. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97604. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97605. */
  97606. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97607. /**
  97608. * Targets the given mesh with its children and updates zoom level accordingly.
  97609. * @param mesh The mesh to target.
  97610. * @param radius Optional. If a cached radius position already exists, overrides default.
  97611. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97612. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97613. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97614. */
  97615. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97616. /**
  97617. * Targets the given meshes with their children and updates zoom level accordingly.
  97618. * @param meshes The mesh to target.
  97619. * @param radius Optional. If a cached radius position already exists, overrides default.
  97620. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97621. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97622. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97623. */
  97624. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97625. /**
  97626. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  97627. * @param minimumWorld Determines the smaller position of the bounding box extend
  97628. * @param maximumWorld Determines the bigger position of the bounding box extend
  97629. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97630. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97631. */
  97632. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97633. /**
  97634. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  97635. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  97636. * frustum width.
  97637. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  97638. * to fully enclose the mesh in the viewing frustum.
  97639. */
  97640. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  97641. /**
  97642. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  97643. * is automatically returned to its default position (expected to be above ground plane).
  97644. */
  97645. private _maintainCameraAboveGround;
  97646. /**
  97647. * Returns the frustum slope based on the canvas ratio and camera FOV
  97648. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  97649. */
  97650. private _getFrustumSlope;
  97651. /**
  97652. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  97653. */
  97654. private _clearAnimationLocks;
  97655. /**
  97656. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  97657. */
  97658. private _applyUserInteraction;
  97659. /**
  97660. * Stops and removes all animations that have been applied to the camera
  97661. */
  97662. stopAllAnimations(): void;
  97663. /**
  97664. * Gets a value indicating if the user is moving the camera
  97665. */
  97666. readonly isUserIsMoving: boolean;
  97667. /**
  97668. * The camera can move all the way towards the mesh.
  97669. */
  97670. static IgnoreBoundsSizeMode: number;
  97671. /**
  97672. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  97673. */
  97674. static FitFrustumSidesMode: number;
  97675. }
  97676. }
  97677. declare module BABYLON {
  97678. /**
  97679. * Base class for Camera Pointer Inputs.
  97680. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  97681. * for example usage.
  97682. */
  97683. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  97684. /**
  97685. * Defines the camera the input is attached to.
  97686. */
  97687. abstract camera: Camera;
  97688. /**
  97689. * Whether keyboard modifier keys are pressed at time of last mouse event.
  97690. */
  97691. protected _altKey: boolean;
  97692. protected _ctrlKey: boolean;
  97693. protected _metaKey: boolean;
  97694. protected _shiftKey: boolean;
  97695. /**
  97696. * Which mouse buttons were pressed at time of last mouse event.
  97697. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  97698. */
  97699. protected _buttonsPressed: number;
  97700. /**
  97701. * Defines the buttons associated with the input to handle camera move.
  97702. */
  97703. buttons: number[];
  97704. /**
  97705. * Attach the input controls to a specific dom element to get the input from.
  97706. * @param element Defines the element the controls should be listened from
  97707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97708. */
  97709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97710. /**
  97711. * Detach the current controls from the specified dom element.
  97712. * @param element Defines the element to stop listening the inputs from
  97713. */
  97714. detachControl(element: Nullable<HTMLElement>): void;
  97715. /**
  97716. * Gets the class name of the current input.
  97717. * @returns the class name
  97718. */
  97719. getClassName(): string;
  97720. /**
  97721. * Get the friendly name associated with the input class.
  97722. * @returns the input friendly name
  97723. */
  97724. getSimpleName(): string;
  97725. /**
  97726. * Called on pointer POINTERDOUBLETAP event.
  97727. * Override this method to provide functionality on POINTERDOUBLETAP event.
  97728. */
  97729. protected onDoubleTap(type: string): void;
  97730. /**
  97731. * Called on pointer POINTERMOVE event if only a single touch is active.
  97732. * Override this method to provide functionality.
  97733. */
  97734. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97735. /**
  97736. * Called on pointer POINTERMOVE event if multiple touches are active.
  97737. * Override this method to provide functionality.
  97738. */
  97739. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97740. /**
  97741. * Called on JS contextmenu event.
  97742. * Override this method to provide functionality.
  97743. */
  97744. protected onContextMenu(evt: PointerEvent): void;
  97745. /**
  97746. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97747. * press.
  97748. * Override this method to provide functionality.
  97749. */
  97750. protected onButtonDown(evt: PointerEvent): void;
  97751. /**
  97752. * Called each time a new POINTERUP event occurs. Ie, for each button
  97753. * release.
  97754. * Override this method to provide functionality.
  97755. */
  97756. protected onButtonUp(evt: PointerEvent): void;
  97757. /**
  97758. * Called when window becomes inactive.
  97759. * Override this method to provide functionality.
  97760. */
  97761. protected onLostFocus(): void;
  97762. private _pointerInput;
  97763. private _observer;
  97764. private _onLostFocus;
  97765. private pointA;
  97766. private pointB;
  97767. }
  97768. }
  97769. declare module BABYLON {
  97770. /**
  97771. * Manage the pointers inputs to control an arc rotate camera.
  97772. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97773. */
  97774. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  97775. /**
  97776. * Defines the camera the input is attached to.
  97777. */
  97778. camera: ArcRotateCamera;
  97779. /**
  97780. * Gets the class name of the current input.
  97781. * @returns the class name
  97782. */
  97783. getClassName(): string;
  97784. /**
  97785. * Defines the buttons associated with the input to handle camera move.
  97786. */
  97787. buttons: number[];
  97788. /**
  97789. * Defines the pointer angular sensibility along the X axis or how fast is
  97790. * the camera rotating.
  97791. */
  97792. angularSensibilityX: number;
  97793. /**
  97794. * Defines the pointer angular sensibility along the Y axis or how fast is
  97795. * the camera rotating.
  97796. */
  97797. angularSensibilityY: number;
  97798. /**
  97799. * Defines the pointer pinch precision or how fast is the camera zooming.
  97800. */
  97801. pinchPrecision: number;
  97802. /**
  97803. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  97804. * from 0.
  97805. * It defines the percentage of current camera.radius to use as delta when
  97806. * pinch zoom is used.
  97807. */
  97808. pinchDeltaPercentage: number;
  97809. /**
  97810. * Defines the pointer panning sensibility or how fast is the camera moving.
  97811. */
  97812. panningSensibility: number;
  97813. /**
  97814. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  97815. */
  97816. multiTouchPanning: boolean;
  97817. /**
  97818. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  97819. * zoom (pinch) through multitouch.
  97820. */
  97821. multiTouchPanAndZoom: boolean;
  97822. /**
  97823. * Revers pinch action direction.
  97824. */
  97825. pinchInwards: boolean;
  97826. private _isPanClick;
  97827. private _twoFingerActivityCount;
  97828. private _isPinching;
  97829. /**
  97830. * Called on pointer POINTERMOVE event if only a single touch is active.
  97831. */
  97832. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97833. /**
  97834. * Called on pointer POINTERDOUBLETAP event.
  97835. */
  97836. protected onDoubleTap(type: string): void;
  97837. /**
  97838. * Called on pointer POINTERMOVE event if multiple touches are active.
  97839. */
  97840. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97841. /**
  97842. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97843. * press.
  97844. */
  97845. protected onButtonDown(evt: PointerEvent): void;
  97846. /**
  97847. * Called each time a new POINTERUP event occurs. Ie, for each button
  97848. * release.
  97849. */
  97850. protected onButtonUp(evt: PointerEvent): void;
  97851. /**
  97852. * Called when window becomes inactive.
  97853. */
  97854. protected onLostFocus(): void;
  97855. }
  97856. }
  97857. declare module BABYLON {
  97858. /**
  97859. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  97860. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97861. */
  97862. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  97863. /**
  97864. * Defines the camera the input is attached to.
  97865. */
  97866. camera: ArcRotateCamera;
  97867. /**
  97868. * Defines the list of key codes associated with the up action (increase alpha)
  97869. */
  97870. keysUp: number[];
  97871. /**
  97872. * Defines the list of key codes associated with the down action (decrease alpha)
  97873. */
  97874. keysDown: number[];
  97875. /**
  97876. * Defines the list of key codes associated with the left action (increase beta)
  97877. */
  97878. keysLeft: number[];
  97879. /**
  97880. * Defines the list of key codes associated with the right action (decrease beta)
  97881. */
  97882. keysRight: number[];
  97883. /**
  97884. * Defines the list of key codes associated with the reset action.
  97885. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  97886. */
  97887. keysReset: number[];
  97888. /**
  97889. * Defines the panning sensibility of the inputs.
  97890. * (How fast is the camera paning)
  97891. */
  97892. panningSensibility: number;
  97893. /**
  97894. * Defines the zooming sensibility of the inputs.
  97895. * (How fast is the camera zooming)
  97896. */
  97897. zoomingSensibility: number;
  97898. /**
  97899. * Defines wether maintaining the alt key down switch the movement mode from
  97900. * orientation to zoom.
  97901. */
  97902. useAltToZoom: boolean;
  97903. /**
  97904. * Rotation speed of the camera
  97905. */
  97906. angularSpeed: number;
  97907. private _keys;
  97908. private _ctrlPressed;
  97909. private _altPressed;
  97910. private _onCanvasBlurObserver;
  97911. private _onKeyboardObserver;
  97912. private _engine;
  97913. private _scene;
  97914. /**
  97915. * Attach the input controls to a specific dom element to get the input from.
  97916. * @param element Defines the element the controls should be listened from
  97917. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97918. */
  97919. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97920. /**
  97921. * Detach the current controls from the specified dom element.
  97922. * @param element Defines the element to stop listening the inputs from
  97923. */
  97924. detachControl(element: Nullable<HTMLElement>): void;
  97925. /**
  97926. * Update the current camera state depending on the inputs that have been used this frame.
  97927. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97928. */
  97929. checkInputs(): void;
  97930. /**
  97931. * Gets the class name of the current intput.
  97932. * @returns the class name
  97933. */
  97934. getClassName(): string;
  97935. /**
  97936. * Get the friendly name associated with the input class.
  97937. * @returns the input friendly name
  97938. */
  97939. getSimpleName(): string;
  97940. }
  97941. }
  97942. declare module BABYLON {
  97943. /**
  97944. * Manage the mouse wheel inputs to control an arc rotate camera.
  97945. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97946. */
  97947. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  97948. /**
  97949. * Defines the camera the input is attached to.
  97950. */
  97951. camera: ArcRotateCamera;
  97952. /**
  97953. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  97954. */
  97955. wheelPrecision: number;
  97956. /**
  97957. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  97958. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  97959. */
  97960. wheelDeltaPercentage: number;
  97961. private _wheel;
  97962. private _observer;
  97963. private computeDeltaFromMouseWheelLegacyEvent;
  97964. /**
  97965. * Attach the input controls to a specific dom element to get the input from.
  97966. * @param element Defines the element the controls should be listened from
  97967. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97968. */
  97969. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97970. /**
  97971. * Detach the current controls from the specified dom element.
  97972. * @param element Defines the element to stop listening the inputs from
  97973. */
  97974. detachControl(element: Nullable<HTMLElement>): void;
  97975. /**
  97976. * Gets the class name of the current intput.
  97977. * @returns the class name
  97978. */
  97979. getClassName(): string;
  97980. /**
  97981. * Get the friendly name associated with the input class.
  97982. * @returns the input friendly name
  97983. */
  97984. getSimpleName(): string;
  97985. }
  97986. }
  97987. declare module BABYLON {
  97988. /**
  97989. * Default Inputs manager for the ArcRotateCamera.
  97990. * It groups all the default supported inputs for ease of use.
  97991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97992. */
  97993. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  97994. /**
  97995. * Instantiates a new ArcRotateCameraInputsManager.
  97996. * @param camera Defines the camera the inputs belong to
  97997. */
  97998. constructor(camera: ArcRotateCamera);
  97999. /**
  98000. * Add mouse wheel input support to the input manager.
  98001. * @returns the current input manager
  98002. */
  98003. addMouseWheel(): ArcRotateCameraInputsManager;
  98004. /**
  98005. * Add pointers input support to the input manager.
  98006. * @returns the current input manager
  98007. */
  98008. addPointers(): ArcRotateCameraInputsManager;
  98009. /**
  98010. * Add keyboard input support to the input manager.
  98011. * @returns the current input manager
  98012. */
  98013. addKeyboard(): ArcRotateCameraInputsManager;
  98014. }
  98015. }
  98016. declare module BABYLON {
  98017. /**
  98018. * This represents an orbital type of camera.
  98019. *
  98020. * 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.
  98021. * 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.
  98022. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  98023. */
  98024. export class ArcRotateCamera extends TargetCamera {
  98025. /**
  98026. * Defines the rotation angle of the camera along the longitudinal axis.
  98027. */
  98028. alpha: number;
  98029. /**
  98030. * Defines the rotation angle of the camera along the latitudinal axis.
  98031. */
  98032. beta: number;
  98033. /**
  98034. * Defines the radius of the camera from it s target point.
  98035. */
  98036. radius: number;
  98037. protected _target: Vector3;
  98038. protected _targetHost: Nullable<AbstractMesh>;
  98039. /**
  98040. * Defines the target point of the camera.
  98041. * The camera looks towards it form the radius distance.
  98042. */
  98043. target: Vector3;
  98044. /**
  98045. * Define the current local position of the camera in the scene
  98046. */
  98047. position: Vector3;
  98048. protected _upVector: Vector3;
  98049. protected _upToYMatrix: Matrix;
  98050. protected _YToUpMatrix: Matrix;
  98051. /**
  98052. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  98053. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  98054. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  98055. */
  98056. upVector: Vector3;
  98057. /**
  98058. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  98059. */
  98060. setMatUp(): void;
  98061. /**
  98062. * Current inertia value on the longitudinal axis.
  98063. * The bigger this number the longer it will take for the camera to stop.
  98064. */
  98065. inertialAlphaOffset: number;
  98066. /**
  98067. * Current inertia value on the latitudinal axis.
  98068. * The bigger this number the longer it will take for the camera to stop.
  98069. */
  98070. inertialBetaOffset: number;
  98071. /**
  98072. * Current inertia value on the radius axis.
  98073. * The bigger this number the longer it will take for the camera to stop.
  98074. */
  98075. inertialRadiusOffset: number;
  98076. /**
  98077. * Minimum allowed angle on the longitudinal axis.
  98078. * This can help limiting how the Camera is able to move in the scene.
  98079. */
  98080. lowerAlphaLimit: Nullable<number>;
  98081. /**
  98082. * Maximum allowed angle on the longitudinal axis.
  98083. * This can help limiting how the Camera is able to move in the scene.
  98084. */
  98085. upperAlphaLimit: Nullable<number>;
  98086. /**
  98087. * Minimum allowed angle on the latitudinal axis.
  98088. * This can help limiting how the Camera is able to move in the scene.
  98089. */
  98090. lowerBetaLimit: number;
  98091. /**
  98092. * Maximum allowed angle on the latitudinal axis.
  98093. * This can help limiting how the Camera is able to move in the scene.
  98094. */
  98095. upperBetaLimit: number;
  98096. /**
  98097. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  98098. * This can help limiting how the Camera is able to move in the scene.
  98099. */
  98100. lowerRadiusLimit: Nullable<number>;
  98101. /**
  98102. * Maximum allowed distance of the camera to the target (The camera can not get further).
  98103. * This can help limiting how the Camera is able to move in the scene.
  98104. */
  98105. upperRadiusLimit: Nullable<number>;
  98106. /**
  98107. * Defines the current inertia value used during panning of the camera along the X axis.
  98108. */
  98109. inertialPanningX: number;
  98110. /**
  98111. * Defines the current inertia value used during panning of the camera along the Y axis.
  98112. */
  98113. inertialPanningY: number;
  98114. /**
  98115. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  98116. * Basically if your fingers moves away from more than this distance you will be considered
  98117. * in pinch mode.
  98118. */
  98119. pinchToPanMaxDistance: number;
  98120. /**
  98121. * Defines the maximum distance the camera can pan.
  98122. * This could help keeping the cammera always in your scene.
  98123. */
  98124. panningDistanceLimit: Nullable<number>;
  98125. /**
  98126. * Defines the target of the camera before paning.
  98127. */
  98128. panningOriginTarget: Vector3;
  98129. /**
  98130. * Defines the value of the inertia used during panning.
  98131. * 0 would mean stop inertia and one would mean no decelleration at all.
  98132. */
  98133. panningInertia: number;
  98134. /**
  98135. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  98136. */
  98137. angularSensibilityX: number;
  98138. /**
  98139. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  98140. */
  98141. angularSensibilityY: number;
  98142. /**
  98143. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  98144. */
  98145. pinchPrecision: number;
  98146. /**
  98147. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  98148. * It will be used instead of pinchDeltaPrecision if different from 0.
  98149. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98150. */
  98151. pinchDeltaPercentage: number;
  98152. /**
  98153. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  98154. */
  98155. panningSensibility: number;
  98156. /**
  98157. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  98158. */
  98159. keysUp: number[];
  98160. /**
  98161. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  98162. */
  98163. keysDown: number[];
  98164. /**
  98165. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  98166. */
  98167. keysLeft: number[];
  98168. /**
  98169. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  98170. */
  98171. keysRight: number[];
  98172. /**
  98173. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98174. */
  98175. wheelPrecision: number;
  98176. /**
  98177. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  98178. * It will be used instead of pinchDeltaPrecision if different from 0.
  98179. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98180. */
  98181. wheelDeltaPercentage: number;
  98182. /**
  98183. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  98184. */
  98185. zoomOnFactor: number;
  98186. /**
  98187. * Defines a screen offset for the camera position.
  98188. */
  98189. targetScreenOffset: Vector2;
  98190. /**
  98191. * Allows the camera to be completely reversed.
  98192. * If false the camera can not arrive upside down.
  98193. */
  98194. allowUpsideDown: boolean;
  98195. /**
  98196. * Define if double tap/click is used to restore the previously saved state of the camera.
  98197. */
  98198. useInputToRestoreState: boolean;
  98199. /** @hidden */
  98200. _viewMatrix: Matrix;
  98201. /** @hidden */
  98202. _useCtrlForPanning: boolean;
  98203. /** @hidden */
  98204. _panningMouseButton: number;
  98205. /**
  98206. * Defines the input associated to the camera.
  98207. */
  98208. inputs: ArcRotateCameraInputsManager;
  98209. /** @hidden */
  98210. _reset: () => void;
  98211. /**
  98212. * Defines the allowed panning axis.
  98213. */
  98214. panningAxis: Vector3;
  98215. protected _localDirection: Vector3;
  98216. protected _transformedDirection: Vector3;
  98217. private _bouncingBehavior;
  98218. /**
  98219. * Gets the bouncing behavior of the camera if it has been enabled.
  98220. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98221. */
  98222. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  98223. /**
  98224. * Defines if the bouncing behavior of the camera is enabled on the camera.
  98225. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98226. */
  98227. useBouncingBehavior: boolean;
  98228. private _framingBehavior;
  98229. /**
  98230. * Gets the framing behavior of the camera if it has been enabled.
  98231. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98232. */
  98233. readonly framingBehavior: Nullable<FramingBehavior>;
  98234. /**
  98235. * Defines if the framing behavior of the camera is enabled on the camera.
  98236. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98237. */
  98238. useFramingBehavior: boolean;
  98239. private _autoRotationBehavior;
  98240. /**
  98241. * Gets the auto rotation behavior of the camera if it has been enabled.
  98242. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98243. */
  98244. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  98245. /**
  98246. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  98247. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98248. */
  98249. useAutoRotationBehavior: boolean;
  98250. /**
  98251. * Observable triggered when the mesh target has been changed on the camera.
  98252. */
  98253. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  98254. /**
  98255. * Event raised when the camera is colliding with a mesh.
  98256. */
  98257. onCollide: (collidedMesh: AbstractMesh) => void;
  98258. /**
  98259. * Defines whether the camera should check collision with the objects oh the scene.
  98260. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  98261. */
  98262. checkCollisions: boolean;
  98263. /**
  98264. * Defines the collision radius of the camera.
  98265. * This simulates a sphere around the camera.
  98266. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98267. */
  98268. collisionRadius: Vector3;
  98269. protected _collider: Collider;
  98270. protected _previousPosition: Vector3;
  98271. protected _collisionVelocity: Vector3;
  98272. protected _newPosition: Vector3;
  98273. protected _previousAlpha: number;
  98274. protected _previousBeta: number;
  98275. protected _previousRadius: number;
  98276. protected _collisionTriggered: boolean;
  98277. protected _targetBoundingCenter: Nullable<Vector3>;
  98278. private _computationVector;
  98279. /**
  98280. * Instantiates a new ArcRotateCamera in a given scene
  98281. * @param name Defines the name of the camera
  98282. * @param alpha Defines the camera rotation along the logitudinal axis
  98283. * @param beta Defines the camera rotation along the latitudinal axis
  98284. * @param radius Defines the camera distance from its target
  98285. * @param target Defines the camera target
  98286. * @param scene Defines the scene the camera belongs to
  98287. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98288. */
  98289. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98290. /** @hidden */
  98291. _initCache(): void;
  98292. /** @hidden */
  98293. _updateCache(ignoreParentClass?: boolean): void;
  98294. protected _getTargetPosition(): Vector3;
  98295. private _storedAlpha;
  98296. private _storedBeta;
  98297. private _storedRadius;
  98298. private _storedTarget;
  98299. /**
  98300. * Stores the current state of the camera (alpha, beta, radius and target)
  98301. * @returns the camera itself
  98302. */
  98303. storeState(): Camera;
  98304. /**
  98305. * @hidden
  98306. * Restored camera state. You must call storeState() first
  98307. */
  98308. _restoreStateValues(): boolean;
  98309. /** @hidden */
  98310. _isSynchronizedViewMatrix(): boolean;
  98311. /**
  98312. * Attached controls to the current camera.
  98313. * @param element Defines the element the controls should be listened from
  98314. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98315. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  98316. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  98317. */
  98318. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  98319. /**
  98320. * Detach the current controls from the camera.
  98321. * The camera will stop reacting to inputs.
  98322. * @param element Defines the element to stop listening the inputs from
  98323. */
  98324. detachControl(element: HTMLElement): void;
  98325. /** @hidden */
  98326. _checkInputs(): void;
  98327. protected _checkLimits(): void;
  98328. /**
  98329. * Rebuilds angles (alpha, beta) and radius from the give position and target
  98330. */
  98331. rebuildAnglesAndRadius(): void;
  98332. /**
  98333. * Use a position to define the current camera related information like aplha, beta and radius
  98334. * @param position Defines the position to set the camera at
  98335. */
  98336. setPosition(position: Vector3): void;
  98337. /**
  98338. * Defines the target the camera should look at.
  98339. * This will automatically adapt alpha beta and radius to fit within the new target.
  98340. * @param target Defines the new target as a Vector or a mesh
  98341. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98342. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98343. */
  98344. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98345. /** @hidden */
  98346. _getViewMatrix(): Matrix;
  98347. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98348. /**
  98349. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98350. * @param meshes Defines the mesh to zoom on
  98351. * @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)
  98352. */
  98353. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98354. /**
  98355. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98356. * The target will be changed but the radius
  98357. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98358. * @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)
  98359. */
  98360. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98361. min: Vector3;
  98362. max: Vector3;
  98363. distance: number;
  98364. }, doNotUpdateMaxZ?: boolean): void;
  98365. /**
  98366. * @override
  98367. * Override Camera.createRigCamera
  98368. */
  98369. createRigCamera(name: string, cameraIndex: number): Camera;
  98370. /**
  98371. * @hidden
  98372. * @override
  98373. * Override Camera._updateRigCameras
  98374. */
  98375. _updateRigCameras(): void;
  98376. /**
  98377. * Destroy the camera and release the current resources hold by it.
  98378. */
  98379. dispose(): void;
  98380. /**
  98381. * Gets the current object class name.
  98382. * @return the class name
  98383. */
  98384. getClassName(): string;
  98385. }
  98386. }
  98387. declare module BABYLON {
  98388. /**
  98389. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98390. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98391. */
  98392. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98393. /**
  98394. * Gets the name of the behavior.
  98395. */
  98396. readonly name: string;
  98397. private _zoomStopsAnimation;
  98398. private _idleRotationSpeed;
  98399. private _idleRotationWaitTime;
  98400. private _idleRotationSpinupTime;
  98401. /**
  98402. * Sets the flag that indicates if user zooming should stop animation.
  98403. */
  98404. /**
  98405. * Gets the flag that indicates if user zooming should stop animation.
  98406. */
  98407. zoomStopsAnimation: boolean;
  98408. /**
  98409. * Sets the default speed at which the camera rotates around the model.
  98410. */
  98411. /**
  98412. * Gets the default speed at which the camera rotates around the model.
  98413. */
  98414. idleRotationSpeed: number;
  98415. /**
  98416. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98417. */
  98418. /**
  98419. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98420. */
  98421. idleRotationWaitTime: number;
  98422. /**
  98423. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98424. */
  98425. /**
  98426. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98427. */
  98428. idleRotationSpinupTime: number;
  98429. /**
  98430. * Gets a value indicating if the camera is currently rotating because of this behavior
  98431. */
  98432. readonly rotationInProgress: boolean;
  98433. private _onPrePointerObservableObserver;
  98434. private _onAfterCheckInputsObserver;
  98435. private _attachedCamera;
  98436. private _isPointerDown;
  98437. private _lastFrameTime;
  98438. private _lastInteractionTime;
  98439. private _cameraRotationSpeed;
  98440. /**
  98441. * Initializes the behavior.
  98442. */
  98443. init(): void;
  98444. /**
  98445. * Attaches the behavior to its arc rotate camera.
  98446. * @param camera Defines the camera to attach the behavior to
  98447. */
  98448. attach(camera: ArcRotateCamera): void;
  98449. /**
  98450. * Detaches the behavior from its current arc rotate camera.
  98451. */
  98452. detach(): void;
  98453. /**
  98454. * Returns true if user is scrolling.
  98455. * @return true if user is scrolling.
  98456. */
  98457. private _userIsZooming;
  98458. private _lastFrameRadius;
  98459. private _shouldAnimationStopForInteraction;
  98460. /**
  98461. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98462. */
  98463. private _applyUserInteraction;
  98464. private _userIsMoving;
  98465. }
  98466. }
  98467. declare module BABYLON {
  98468. /**
  98469. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  98470. */
  98471. export class AttachToBoxBehavior implements Behavior<Mesh> {
  98472. private ui;
  98473. /**
  98474. * The name of the behavior
  98475. */
  98476. name: string;
  98477. /**
  98478. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  98479. */
  98480. distanceAwayFromFace: number;
  98481. /**
  98482. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  98483. */
  98484. distanceAwayFromBottomOfFace: number;
  98485. private _faceVectors;
  98486. private _target;
  98487. private _scene;
  98488. private _onRenderObserver;
  98489. private _tmpMatrix;
  98490. private _tmpVector;
  98491. /**
  98492. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  98493. * @param ui The transform node that should be attched to the mesh
  98494. */
  98495. constructor(ui: TransformNode);
  98496. /**
  98497. * Initializes the behavior
  98498. */
  98499. init(): void;
  98500. private _closestFace;
  98501. private _zeroVector;
  98502. private _lookAtTmpMatrix;
  98503. private _lookAtToRef;
  98504. /**
  98505. * Attaches the AttachToBoxBehavior to the passed in mesh
  98506. * @param target The mesh that the specified node will be attached to
  98507. */
  98508. attach(target: Mesh): void;
  98509. /**
  98510. * Detaches the behavior from the mesh
  98511. */
  98512. detach(): void;
  98513. }
  98514. }
  98515. declare module BABYLON {
  98516. /**
  98517. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  98518. */
  98519. export class FadeInOutBehavior implements Behavior<Mesh> {
  98520. /**
  98521. * Time in milliseconds to delay before fading in (Default: 0)
  98522. */
  98523. delay: number;
  98524. /**
  98525. * Time in milliseconds for the mesh to fade in (Default: 300)
  98526. */
  98527. fadeInTime: number;
  98528. private _millisecondsPerFrame;
  98529. private _hovered;
  98530. private _hoverValue;
  98531. private _ownerNode;
  98532. /**
  98533. * Instatiates the FadeInOutBehavior
  98534. */
  98535. constructor();
  98536. /**
  98537. * The name of the behavior
  98538. */
  98539. readonly name: string;
  98540. /**
  98541. * Initializes the behavior
  98542. */
  98543. init(): void;
  98544. /**
  98545. * Attaches the fade behavior on the passed in mesh
  98546. * @param ownerNode The mesh that will be faded in/out once attached
  98547. */
  98548. attach(ownerNode: Mesh): void;
  98549. /**
  98550. * Detaches the behavior from the mesh
  98551. */
  98552. detach(): void;
  98553. /**
  98554. * Triggers the mesh to begin fading in or out
  98555. * @param value if the object should fade in or out (true to fade in)
  98556. */
  98557. fadeIn(value: boolean): void;
  98558. private _update;
  98559. private _setAllVisibility;
  98560. }
  98561. }
  98562. declare module BABYLON {
  98563. /**
  98564. * Class containing a set of static utilities functions for managing Pivots
  98565. * @hidden
  98566. */
  98567. export class PivotTools {
  98568. private static _PivotCached;
  98569. private static _OldPivotPoint;
  98570. private static _PivotTranslation;
  98571. private static _PivotTmpVector;
  98572. /** @hidden */
  98573. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  98574. /** @hidden */
  98575. static _RestorePivotPoint(mesh: AbstractMesh): void;
  98576. }
  98577. }
  98578. declare module BABYLON {
  98579. /**
  98580. * Class containing static functions to help procedurally build meshes
  98581. */
  98582. export class PlaneBuilder {
  98583. /**
  98584. * Creates a plane mesh
  98585. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  98586. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  98587. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  98588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98591. * @param name defines the name of the mesh
  98592. * @param options defines the options used to create the mesh
  98593. * @param scene defines the hosting scene
  98594. * @returns the plane mesh
  98595. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  98596. */
  98597. static CreatePlane(name: string, options: {
  98598. size?: number;
  98599. width?: number;
  98600. height?: number;
  98601. sideOrientation?: number;
  98602. frontUVs?: Vector4;
  98603. backUVs?: Vector4;
  98604. updatable?: boolean;
  98605. sourcePlane?: Plane;
  98606. }, scene?: Nullable<Scene>): Mesh;
  98607. }
  98608. }
  98609. declare module BABYLON {
  98610. /**
  98611. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  98612. */
  98613. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  98614. private static _AnyMouseID;
  98615. /**
  98616. * Abstract mesh the behavior is set on
  98617. */
  98618. attachedNode: AbstractMesh;
  98619. private _dragPlane;
  98620. private _scene;
  98621. private _pointerObserver;
  98622. private _beforeRenderObserver;
  98623. private static _planeScene;
  98624. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  98625. /**
  98626. * 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)
  98627. */
  98628. maxDragAngle: number;
  98629. /**
  98630. * @hidden
  98631. */
  98632. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  98633. /**
  98634. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98635. */
  98636. currentDraggingPointerID: number;
  98637. /**
  98638. * The last position where the pointer hit the drag plane in world space
  98639. */
  98640. lastDragPosition: Vector3;
  98641. /**
  98642. * If the behavior is currently in a dragging state
  98643. */
  98644. dragging: boolean;
  98645. /**
  98646. * 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)
  98647. */
  98648. dragDeltaRatio: number;
  98649. /**
  98650. * If the drag plane orientation should be updated during the dragging (Default: true)
  98651. */
  98652. updateDragPlane: boolean;
  98653. private _debugMode;
  98654. private _moving;
  98655. /**
  98656. * Fires each time the attached mesh is dragged with the pointer
  98657. * * delta between last drag position and current drag position in world space
  98658. * * dragDistance along the drag axis
  98659. * * dragPlaneNormal normal of the current drag plane used during the drag
  98660. * * dragPlanePoint in world space where the drag intersects the drag plane
  98661. */
  98662. onDragObservable: Observable<{
  98663. delta: Vector3;
  98664. dragPlanePoint: Vector3;
  98665. dragPlaneNormal: Vector3;
  98666. dragDistance: number;
  98667. pointerId: number;
  98668. }>;
  98669. /**
  98670. * Fires each time a drag begins (eg. mouse down on mesh)
  98671. */
  98672. onDragStartObservable: Observable<{
  98673. dragPlanePoint: Vector3;
  98674. pointerId: number;
  98675. }>;
  98676. /**
  98677. * Fires each time a drag ends (eg. mouse release after drag)
  98678. */
  98679. onDragEndObservable: Observable<{
  98680. dragPlanePoint: Vector3;
  98681. pointerId: number;
  98682. }>;
  98683. /**
  98684. * If the attached mesh should be moved when dragged
  98685. */
  98686. moveAttached: boolean;
  98687. /**
  98688. * If the drag behavior will react to drag events (Default: true)
  98689. */
  98690. enabled: boolean;
  98691. /**
  98692. * If camera controls should be detached during the drag
  98693. */
  98694. detachCameraControls: boolean;
  98695. /**
  98696. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  98697. */
  98698. useObjectOrienationForDragging: boolean;
  98699. private _options;
  98700. /**
  98701. * Creates a pointer drag behavior that can be attached to a mesh
  98702. * @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)
  98703. */
  98704. constructor(options?: {
  98705. dragAxis?: Vector3;
  98706. dragPlaneNormal?: Vector3;
  98707. });
  98708. /**
  98709. * Predicate to determine if it is valid to move the object to a new position when it is moved
  98710. */
  98711. validateDrag: (targetPosition: Vector3) => boolean;
  98712. /**
  98713. * The name of the behavior
  98714. */
  98715. readonly name: string;
  98716. /**
  98717. * Initializes the behavior
  98718. */
  98719. init(): void;
  98720. private _tmpVector;
  98721. private _alternatePickedPoint;
  98722. private _worldDragAxis;
  98723. private _targetPosition;
  98724. private _attachedElement;
  98725. /**
  98726. * Attaches the drag behavior the passed in mesh
  98727. * @param ownerNode The mesh that will be dragged around once attached
  98728. */
  98729. attach(ownerNode: AbstractMesh): void;
  98730. /**
  98731. * Force relase the drag action by code.
  98732. */
  98733. releaseDrag(): void;
  98734. private _startDragRay;
  98735. private _lastPointerRay;
  98736. /**
  98737. * Simulates the start of a pointer drag event on the behavior
  98738. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  98739. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  98740. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  98741. */
  98742. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  98743. private _startDrag;
  98744. private _dragDelta;
  98745. private _moveDrag;
  98746. private _pickWithRayOnDragPlane;
  98747. private _pointA;
  98748. private _pointB;
  98749. private _pointC;
  98750. private _lineA;
  98751. private _lineB;
  98752. private _localAxis;
  98753. private _lookAt;
  98754. private _updateDragPlanePosition;
  98755. /**
  98756. * Detaches the behavior from the mesh
  98757. */
  98758. detach(): void;
  98759. }
  98760. }
  98761. declare module BABYLON {
  98762. /**
  98763. * A behavior that when attached to a mesh will allow the mesh to be scaled
  98764. */
  98765. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  98766. private _dragBehaviorA;
  98767. private _dragBehaviorB;
  98768. private _startDistance;
  98769. private _initialScale;
  98770. private _targetScale;
  98771. private _ownerNode;
  98772. private _sceneRenderObserver;
  98773. /**
  98774. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  98775. */
  98776. constructor();
  98777. /**
  98778. * The name of the behavior
  98779. */
  98780. readonly name: string;
  98781. /**
  98782. * Initializes the behavior
  98783. */
  98784. init(): void;
  98785. private _getCurrentDistance;
  98786. /**
  98787. * Attaches the scale behavior the passed in mesh
  98788. * @param ownerNode The mesh that will be scaled around once attached
  98789. */
  98790. attach(ownerNode: Mesh): void;
  98791. /**
  98792. * Detaches the behavior from the mesh
  98793. */
  98794. detach(): void;
  98795. }
  98796. }
  98797. declare module BABYLON {
  98798. /**
  98799. * 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
  98800. */
  98801. export class SixDofDragBehavior implements Behavior<Mesh> {
  98802. private static _virtualScene;
  98803. private _ownerNode;
  98804. private _sceneRenderObserver;
  98805. private _scene;
  98806. private _targetPosition;
  98807. private _virtualOriginMesh;
  98808. private _virtualDragMesh;
  98809. private _pointerObserver;
  98810. private _moving;
  98811. private _startingOrientation;
  98812. /**
  98813. * 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)
  98814. */
  98815. private zDragFactor;
  98816. /**
  98817. * If the object should rotate to face the drag origin
  98818. */
  98819. rotateDraggedObject: boolean;
  98820. /**
  98821. * If the behavior is currently in a dragging state
  98822. */
  98823. dragging: boolean;
  98824. /**
  98825. * 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)
  98826. */
  98827. dragDeltaRatio: number;
  98828. /**
  98829. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98830. */
  98831. currentDraggingPointerID: number;
  98832. /**
  98833. * If camera controls should be detached during the drag
  98834. */
  98835. detachCameraControls: boolean;
  98836. /**
  98837. * Fires each time a drag starts
  98838. */
  98839. onDragStartObservable: Observable<{}>;
  98840. /**
  98841. * Fires each time a drag ends (eg. mouse release after drag)
  98842. */
  98843. onDragEndObservable: Observable<{}>;
  98844. /**
  98845. * 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
  98846. */
  98847. constructor();
  98848. /**
  98849. * The name of the behavior
  98850. */
  98851. readonly name: string;
  98852. /**
  98853. * Initializes the behavior
  98854. */
  98855. init(): void;
  98856. /**
  98857. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  98858. */
  98859. private readonly _pointerCamera;
  98860. /**
  98861. * Attaches the scale behavior the passed in mesh
  98862. * @param ownerNode The mesh that will be scaled around once attached
  98863. */
  98864. attach(ownerNode: Mesh): void;
  98865. /**
  98866. * Detaches the behavior from the mesh
  98867. */
  98868. detach(): void;
  98869. }
  98870. }
  98871. declare module BABYLON {
  98872. /**
  98873. * Class used to apply inverse kinematics to bones
  98874. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  98875. */
  98876. export class BoneIKController {
  98877. private static _tmpVecs;
  98878. private static _tmpQuat;
  98879. private static _tmpMats;
  98880. /**
  98881. * Gets or sets the target mesh
  98882. */
  98883. targetMesh: AbstractMesh;
  98884. /** Gets or sets the mesh used as pole */
  98885. poleTargetMesh: AbstractMesh;
  98886. /**
  98887. * Gets or sets the bone used as pole
  98888. */
  98889. poleTargetBone: Nullable<Bone>;
  98890. /**
  98891. * Gets or sets the target position
  98892. */
  98893. targetPosition: Vector3;
  98894. /**
  98895. * Gets or sets the pole target position
  98896. */
  98897. poleTargetPosition: Vector3;
  98898. /**
  98899. * Gets or sets the pole target local offset
  98900. */
  98901. poleTargetLocalOffset: Vector3;
  98902. /**
  98903. * Gets or sets the pole angle
  98904. */
  98905. poleAngle: number;
  98906. /**
  98907. * Gets or sets the mesh associated with the controller
  98908. */
  98909. mesh: AbstractMesh;
  98910. /**
  98911. * 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)
  98912. */
  98913. slerpAmount: number;
  98914. private _bone1Quat;
  98915. private _bone1Mat;
  98916. private _bone2Ang;
  98917. private _bone1;
  98918. private _bone2;
  98919. private _bone1Length;
  98920. private _bone2Length;
  98921. private _maxAngle;
  98922. private _maxReach;
  98923. private _rightHandedSystem;
  98924. private _bendAxis;
  98925. private _slerping;
  98926. private _adjustRoll;
  98927. /**
  98928. * Gets or sets maximum allowed angle
  98929. */
  98930. maxAngle: number;
  98931. /**
  98932. * Creates a new BoneIKController
  98933. * @param mesh defines the mesh to control
  98934. * @param bone defines the bone to control
  98935. * @param options defines options to set up the controller
  98936. */
  98937. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  98938. targetMesh?: AbstractMesh;
  98939. poleTargetMesh?: AbstractMesh;
  98940. poleTargetBone?: Bone;
  98941. poleTargetLocalOffset?: Vector3;
  98942. poleAngle?: number;
  98943. bendAxis?: Vector3;
  98944. maxAngle?: number;
  98945. slerpAmount?: number;
  98946. });
  98947. private _setMaxAngle;
  98948. /**
  98949. * Force the controller to update the bones
  98950. */
  98951. update(): void;
  98952. }
  98953. }
  98954. declare module BABYLON {
  98955. /**
  98956. * Class used to make a bone look toward a point in space
  98957. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  98958. */
  98959. export class BoneLookController {
  98960. private static _tmpVecs;
  98961. private static _tmpQuat;
  98962. private static _tmpMats;
  98963. /**
  98964. * The target Vector3 that the bone will look at
  98965. */
  98966. target: Vector3;
  98967. /**
  98968. * The mesh that the bone is attached to
  98969. */
  98970. mesh: AbstractMesh;
  98971. /**
  98972. * The bone that will be looking to the target
  98973. */
  98974. bone: Bone;
  98975. /**
  98976. * The up axis of the coordinate system that is used when the bone is rotated
  98977. */
  98978. upAxis: Vector3;
  98979. /**
  98980. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  98981. */
  98982. upAxisSpace: Space;
  98983. /**
  98984. * Used to make an adjustment to the yaw of the bone
  98985. */
  98986. adjustYaw: number;
  98987. /**
  98988. * Used to make an adjustment to the pitch of the bone
  98989. */
  98990. adjustPitch: number;
  98991. /**
  98992. * Used to make an adjustment to the roll of the bone
  98993. */
  98994. adjustRoll: number;
  98995. /**
  98996. * 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)
  98997. */
  98998. slerpAmount: number;
  98999. private _minYaw;
  99000. private _maxYaw;
  99001. private _minPitch;
  99002. private _maxPitch;
  99003. private _minYawSin;
  99004. private _minYawCos;
  99005. private _maxYawSin;
  99006. private _maxYawCos;
  99007. private _midYawConstraint;
  99008. private _minPitchTan;
  99009. private _maxPitchTan;
  99010. private _boneQuat;
  99011. private _slerping;
  99012. private _transformYawPitch;
  99013. private _transformYawPitchInv;
  99014. private _firstFrameSkipped;
  99015. private _yawRange;
  99016. private _fowardAxis;
  99017. /**
  99018. * Gets or sets the minimum yaw angle that the bone can look to
  99019. */
  99020. minYaw: number;
  99021. /**
  99022. * Gets or sets the maximum yaw angle that the bone can look to
  99023. */
  99024. maxYaw: number;
  99025. /**
  99026. * Gets or sets the minimum pitch angle that the bone can look to
  99027. */
  99028. minPitch: number;
  99029. /**
  99030. * Gets or sets the maximum pitch angle that the bone can look to
  99031. */
  99032. maxPitch: number;
  99033. /**
  99034. * Create a BoneLookController
  99035. * @param mesh the mesh that the bone belongs to
  99036. * @param bone the bone that will be looking to the target
  99037. * @param target the target Vector3 to look at
  99038. * @param options optional settings:
  99039. * * maxYaw: the maximum angle the bone will yaw to
  99040. * * minYaw: the minimum angle the bone will yaw to
  99041. * * maxPitch: the maximum angle the bone will pitch to
  99042. * * minPitch: the minimum angle the bone will yaw to
  99043. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  99044. * * upAxis: the up axis of the coordinate system
  99045. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  99046. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  99047. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  99048. * * adjustYaw: used to make an adjustment to the yaw of the bone
  99049. * * adjustPitch: used to make an adjustment to the pitch of the bone
  99050. * * adjustRoll: used to make an adjustment to the roll of the bone
  99051. **/
  99052. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  99053. maxYaw?: number;
  99054. minYaw?: number;
  99055. maxPitch?: number;
  99056. minPitch?: number;
  99057. slerpAmount?: number;
  99058. upAxis?: Vector3;
  99059. upAxisSpace?: Space;
  99060. yawAxis?: Vector3;
  99061. pitchAxis?: Vector3;
  99062. adjustYaw?: number;
  99063. adjustPitch?: number;
  99064. adjustRoll?: number;
  99065. });
  99066. /**
  99067. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  99068. */
  99069. update(): void;
  99070. private _getAngleDiff;
  99071. private _getAngleBetween;
  99072. private _isAngleBetween;
  99073. }
  99074. }
  99075. declare module BABYLON {
  99076. /**
  99077. * Manage the gamepad inputs to control an arc rotate camera.
  99078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99079. */
  99080. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  99081. /**
  99082. * Defines the camera the input is attached to.
  99083. */
  99084. camera: ArcRotateCamera;
  99085. /**
  99086. * Defines the gamepad the input is gathering event from.
  99087. */
  99088. gamepad: Nullable<Gamepad>;
  99089. /**
  99090. * Defines the gamepad rotation sensiblity.
  99091. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99092. */
  99093. gamepadRotationSensibility: number;
  99094. /**
  99095. * Defines the gamepad move sensiblity.
  99096. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99097. */
  99098. gamepadMoveSensibility: number;
  99099. private _onGamepadConnectedObserver;
  99100. private _onGamepadDisconnectedObserver;
  99101. /**
  99102. * Attach the input controls to a specific dom element to get the input from.
  99103. * @param element Defines the element the controls should be listened from
  99104. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99105. */
  99106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99107. /**
  99108. * Detach the current controls from the specified dom element.
  99109. * @param element Defines the element to stop listening the inputs from
  99110. */
  99111. detachControl(element: Nullable<HTMLElement>): void;
  99112. /**
  99113. * Update the current camera state depending on the inputs that have been used this frame.
  99114. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99115. */
  99116. checkInputs(): void;
  99117. /**
  99118. * Gets the class name of the current intput.
  99119. * @returns the class name
  99120. */
  99121. getClassName(): string;
  99122. /**
  99123. * Get the friendly name associated with the input class.
  99124. * @returns the input friendly name
  99125. */
  99126. getSimpleName(): string;
  99127. }
  99128. }
  99129. declare module BABYLON {
  99130. interface ArcRotateCameraInputsManager {
  99131. /**
  99132. * Add orientation input support to the input manager.
  99133. * @returns the current input manager
  99134. */
  99135. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  99136. }
  99137. /**
  99138. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  99139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99140. */
  99141. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  99142. /**
  99143. * Defines the camera the input is attached to.
  99144. */
  99145. camera: ArcRotateCamera;
  99146. /**
  99147. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  99148. */
  99149. alphaCorrection: number;
  99150. /**
  99151. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  99152. */
  99153. gammaCorrection: number;
  99154. private _alpha;
  99155. private _gamma;
  99156. private _dirty;
  99157. private _deviceOrientationHandler;
  99158. /**
  99159. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  99160. */
  99161. constructor();
  99162. /**
  99163. * Attach the input controls to a specific dom element to get the input from.
  99164. * @param element Defines the element the controls should be listened from
  99165. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99166. */
  99167. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99168. /** @hidden */
  99169. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  99170. /**
  99171. * Update the current camera state depending on the inputs that have been used this frame.
  99172. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99173. */
  99174. checkInputs(): void;
  99175. /**
  99176. * Detach the current controls from the specified dom element.
  99177. * @param element Defines the element to stop listening the inputs from
  99178. */
  99179. detachControl(element: Nullable<HTMLElement>): void;
  99180. /**
  99181. * Gets the class name of the current intput.
  99182. * @returns the class name
  99183. */
  99184. getClassName(): string;
  99185. /**
  99186. * Get the friendly name associated with the input class.
  99187. * @returns the input friendly name
  99188. */
  99189. getSimpleName(): string;
  99190. }
  99191. }
  99192. declare module BABYLON {
  99193. /**
  99194. * Listen to mouse events to control the camera.
  99195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99196. */
  99197. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  99198. /**
  99199. * Defines the camera the input is attached to.
  99200. */
  99201. camera: FlyCamera;
  99202. /**
  99203. * Defines if touch is enabled. (Default is true.)
  99204. */
  99205. touchEnabled: boolean;
  99206. /**
  99207. * Defines the buttons associated with the input to handle camera rotation.
  99208. */
  99209. buttons: number[];
  99210. /**
  99211. * Assign buttons for Yaw control.
  99212. */
  99213. buttonsYaw: number[];
  99214. /**
  99215. * Assign buttons for Pitch control.
  99216. */
  99217. buttonsPitch: number[];
  99218. /**
  99219. * Assign buttons for Roll control.
  99220. */
  99221. buttonsRoll: number[];
  99222. /**
  99223. * Detect if any button is being pressed while mouse is moved.
  99224. * -1 = Mouse locked.
  99225. * 0 = Left button.
  99226. * 1 = Middle Button.
  99227. * 2 = Right Button.
  99228. */
  99229. activeButton: number;
  99230. /**
  99231. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  99232. * Higher values reduce its sensitivity.
  99233. */
  99234. angularSensibility: number;
  99235. private _mousemoveCallback;
  99236. private _observer;
  99237. private _rollObserver;
  99238. private previousPosition;
  99239. private noPreventDefault;
  99240. private element;
  99241. /**
  99242. * Listen to mouse events to control the camera.
  99243. * @param touchEnabled Define if touch is enabled. (Default is true.)
  99244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99245. */
  99246. constructor(touchEnabled?: boolean);
  99247. /**
  99248. * Attach the mouse control to the HTML DOM element.
  99249. * @param element Defines the element that listens to the input events.
  99250. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  99251. */
  99252. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99253. /**
  99254. * Detach the current controls from the specified dom element.
  99255. * @param element Defines the element to stop listening the inputs from
  99256. */
  99257. detachControl(element: Nullable<HTMLElement>): void;
  99258. /**
  99259. * Gets the class name of the current input.
  99260. * @returns the class name.
  99261. */
  99262. getClassName(): string;
  99263. /**
  99264. * Get the friendly name associated with the input class.
  99265. * @returns the input's friendly name.
  99266. */
  99267. getSimpleName(): string;
  99268. private _pointerInput;
  99269. private _onMouseMove;
  99270. /**
  99271. * Rotate camera by mouse offset.
  99272. */
  99273. private rotateCamera;
  99274. }
  99275. }
  99276. declare module BABYLON {
  99277. /**
  99278. * Default Inputs manager for the FlyCamera.
  99279. * It groups all the default supported inputs for ease of use.
  99280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99281. */
  99282. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  99283. /**
  99284. * Instantiates a new FlyCameraInputsManager.
  99285. * @param camera Defines the camera the inputs belong to.
  99286. */
  99287. constructor(camera: FlyCamera);
  99288. /**
  99289. * Add keyboard input support to the input manager.
  99290. * @returns the new FlyCameraKeyboardMoveInput().
  99291. */
  99292. addKeyboard(): FlyCameraInputsManager;
  99293. /**
  99294. * Add mouse input support to the input manager.
  99295. * @param touchEnabled Enable touch screen support.
  99296. * @returns the new FlyCameraMouseInput().
  99297. */
  99298. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  99299. }
  99300. }
  99301. declare module BABYLON {
  99302. /**
  99303. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99304. * such as in a 3D Space Shooter or a Flight Simulator.
  99305. */
  99306. export class FlyCamera extends TargetCamera {
  99307. /**
  99308. * Define the collision ellipsoid of the camera.
  99309. * This is helpful for simulating a camera body, like a player's body.
  99310. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99311. */
  99312. ellipsoid: Vector3;
  99313. /**
  99314. * Define an offset for the position of the ellipsoid around the camera.
  99315. * This can be helpful if the camera is attached away from the player's body center,
  99316. * such as at its head.
  99317. */
  99318. ellipsoidOffset: Vector3;
  99319. /**
  99320. * Enable or disable collisions of the camera with the rest of the scene objects.
  99321. */
  99322. checkCollisions: boolean;
  99323. /**
  99324. * Enable or disable gravity on the camera.
  99325. */
  99326. applyGravity: boolean;
  99327. /**
  99328. * Define the current direction the camera is moving to.
  99329. */
  99330. cameraDirection: Vector3;
  99331. /**
  99332. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  99333. * This overrides and empties cameraRotation.
  99334. */
  99335. rotationQuaternion: Quaternion;
  99336. /**
  99337. * Track Roll to maintain the wanted Rolling when looking around.
  99338. */
  99339. _trackRoll: number;
  99340. /**
  99341. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  99342. */
  99343. rollCorrect: number;
  99344. /**
  99345. * Mimic a banked turn, Rolling the camera when Yawing.
  99346. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99347. */
  99348. bankedTurn: boolean;
  99349. /**
  99350. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99351. */
  99352. bankedTurnLimit: number;
  99353. /**
  99354. * Value of 0 disables the banked Roll.
  99355. * Value of 1 is equal to the Yaw angle in radians.
  99356. */
  99357. bankedTurnMultiplier: number;
  99358. /**
  99359. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99360. */
  99361. inputs: FlyCameraInputsManager;
  99362. /**
  99363. * Gets the input sensibility for mouse input.
  99364. * Higher values reduce sensitivity.
  99365. */
  99366. /**
  99367. * Sets the input sensibility for a mouse input.
  99368. * Higher values reduce sensitivity.
  99369. */
  99370. angularSensibility: number;
  99371. /**
  99372. * Get the keys for camera movement forward.
  99373. */
  99374. /**
  99375. * Set the keys for camera movement forward.
  99376. */
  99377. keysForward: number[];
  99378. /**
  99379. * Get the keys for camera movement backward.
  99380. */
  99381. keysBackward: number[];
  99382. /**
  99383. * Get the keys for camera movement up.
  99384. */
  99385. /**
  99386. * Set the keys for camera movement up.
  99387. */
  99388. keysUp: number[];
  99389. /**
  99390. * Get the keys for camera movement down.
  99391. */
  99392. /**
  99393. * Set the keys for camera movement down.
  99394. */
  99395. keysDown: number[];
  99396. /**
  99397. * Get the keys for camera movement left.
  99398. */
  99399. /**
  99400. * Set the keys for camera movement left.
  99401. */
  99402. keysLeft: number[];
  99403. /**
  99404. * Set the keys for camera movement right.
  99405. */
  99406. /**
  99407. * Set the keys for camera movement right.
  99408. */
  99409. keysRight: number[];
  99410. /**
  99411. * Event raised when the camera collides with a mesh in the scene.
  99412. */
  99413. onCollide: (collidedMesh: AbstractMesh) => void;
  99414. private _collider;
  99415. private _needMoveForGravity;
  99416. private _oldPosition;
  99417. private _diffPosition;
  99418. private _newPosition;
  99419. /** @hidden */
  99420. _localDirection: Vector3;
  99421. /** @hidden */
  99422. _transformedDirection: Vector3;
  99423. /**
  99424. * Instantiates a FlyCamera.
  99425. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99426. * such as in a 3D Space Shooter or a Flight Simulator.
  99427. * @param name Define the name of the camera in the scene.
  99428. * @param position Define the starting position of the camera in the scene.
  99429. * @param scene Define the scene the camera belongs to.
  99430. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99431. */
  99432. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99433. /**
  99434. * Attach a control to the HTML DOM element.
  99435. * @param element Defines the element that listens to the input events.
  99436. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99437. */
  99438. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99439. /**
  99440. * Detach a control from the HTML DOM element.
  99441. * The camera will stop reacting to that input.
  99442. * @param element Defines the element that listens to the input events.
  99443. */
  99444. detachControl(element: HTMLElement): void;
  99445. private _collisionMask;
  99446. /**
  99447. * Get the mask that the camera ignores in collision events.
  99448. */
  99449. /**
  99450. * Set the mask that the camera ignores in collision events.
  99451. */
  99452. collisionMask: number;
  99453. /** @hidden */
  99454. _collideWithWorld(displacement: Vector3): void;
  99455. /** @hidden */
  99456. private _onCollisionPositionChange;
  99457. /** @hidden */
  99458. _checkInputs(): void;
  99459. /** @hidden */
  99460. _decideIfNeedsToMove(): boolean;
  99461. /** @hidden */
  99462. _updatePosition(): void;
  99463. /**
  99464. * Restore the Roll to its target value at the rate specified.
  99465. * @param rate - Higher means slower restoring.
  99466. * @hidden
  99467. */
  99468. restoreRoll(rate: number): void;
  99469. /**
  99470. * Destroy the camera and release the current resources held by it.
  99471. */
  99472. dispose(): void;
  99473. /**
  99474. * Get the current object class name.
  99475. * @returns the class name.
  99476. */
  99477. getClassName(): string;
  99478. }
  99479. }
  99480. declare module BABYLON {
  99481. /**
  99482. * Listen to keyboard events to control the camera.
  99483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99484. */
  99485. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  99486. /**
  99487. * Defines the camera the input is attached to.
  99488. */
  99489. camera: FlyCamera;
  99490. /**
  99491. * The list of keyboard keys used to control the forward move of the camera.
  99492. */
  99493. keysForward: number[];
  99494. /**
  99495. * The list of keyboard keys used to control the backward move of the camera.
  99496. */
  99497. keysBackward: number[];
  99498. /**
  99499. * The list of keyboard keys used to control the forward move of the camera.
  99500. */
  99501. keysUp: number[];
  99502. /**
  99503. * The list of keyboard keys used to control the backward move of the camera.
  99504. */
  99505. keysDown: number[];
  99506. /**
  99507. * The list of keyboard keys used to control the right strafe move of the camera.
  99508. */
  99509. keysRight: number[];
  99510. /**
  99511. * The list of keyboard keys used to control the left strafe move of the camera.
  99512. */
  99513. keysLeft: number[];
  99514. private _keys;
  99515. private _onCanvasBlurObserver;
  99516. private _onKeyboardObserver;
  99517. private _engine;
  99518. private _scene;
  99519. /**
  99520. * Attach the input controls to a specific dom element to get the input from.
  99521. * @param element Defines the element the controls should be listened from
  99522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99523. */
  99524. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99525. /**
  99526. * Detach the current controls from the specified dom element.
  99527. * @param element Defines the element to stop listening the inputs from
  99528. */
  99529. detachControl(element: Nullable<HTMLElement>): void;
  99530. /**
  99531. * Gets the class name of the current intput.
  99532. * @returns the class name
  99533. */
  99534. getClassName(): string;
  99535. /** @hidden */
  99536. _onLostFocus(e: FocusEvent): void;
  99537. /**
  99538. * Get the friendly name associated with the input class.
  99539. * @returns the input friendly name
  99540. */
  99541. getSimpleName(): string;
  99542. /**
  99543. * Update the current camera state depending on the inputs that have been used this frame.
  99544. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99545. */
  99546. checkInputs(): void;
  99547. }
  99548. }
  99549. declare module BABYLON {
  99550. /**
  99551. * Manage the mouse wheel inputs to control a follow camera.
  99552. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99553. */
  99554. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  99555. /**
  99556. * Defines the camera the input is attached to.
  99557. */
  99558. camera: FollowCamera;
  99559. /**
  99560. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  99561. */
  99562. axisControlRadius: boolean;
  99563. /**
  99564. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  99565. */
  99566. axisControlHeight: boolean;
  99567. /**
  99568. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  99569. */
  99570. axisControlRotation: boolean;
  99571. /**
  99572. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  99573. * relation to mouseWheel events.
  99574. */
  99575. wheelPrecision: number;
  99576. /**
  99577. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99578. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99579. */
  99580. wheelDeltaPercentage: number;
  99581. private _wheel;
  99582. private _observer;
  99583. /**
  99584. * Attach the input controls to a specific dom element to get the input from.
  99585. * @param element Defines the element the controls should be listened from
  99586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99587. */
  99588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99589. /**
  99590. * Detach the current controls from the specified dom element.
  99591. * @param element Defines the element to stop listening the inputs from
  99592. */
  99593. detachControl(element: Nullable<HTMLElement>): void;
  99594. /**
  99595. * Gets the class name of the current intput.
  99596. * @returns the class name
  99597. */
  99598. getClassName(): string;
  99599. /**
  99600. * Get the friendly name associated with the input class.
  99601. * @returns the input friendly name
  99602. */
  99603. getSimpleName(): string;
  99604. }
  99605. }
  99606. declare module BABYLON {
  99607. /**
  99608. * Manage the pointers inputs to control an follow camera.
  99609. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99610. */
  99611. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  99612. /**
  99613. * Defines the camera the input is attached to.
  99614. */
  99615. camera: FollowCamera;
  99616. /**
  99617. * Gets the class name of the current input.
  99618. * @returns the class name
  99619. */
  99620. getClassName(): string;
  99621. /**
  99622. * Defines the pointer angular sensibility along the X axis or how fast is
  99623. * the camera rotating.
  99624. * A negative number will reverse the axis direction.
  99625. */
  99626. angularSensibilityX: number;
  99627. /**
  99628. * Defines the pointer angular sensibility along the Y axis or how fast is
  99629. * the camera rotating.
  99630. * A negative number will reverse the axis direction.
  99631. */
  99632. angularSensibilityY: number;
  99633. /**
  99634. * Defines the pointer pinch precision or how fast is the camera zooming.
  99635. * A negative number will reverse the axis direction.
  99636. */
  99637. pinchPrecision: number;
  99638. /**
  99639. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99640. * from 0.
  99641. * It defines the percentage of current camera.radius to use as delta when
  99642. * pinch zoom is used.
  99643. */
  99644. pinchDeltaPercentage: number;
  99645. /**
  99646. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  99647. */
  99648. axisXControlRadius: boolean;
  99649. /**
  99650. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  99651. */
  99652. axisXControlHeight: boolean;
  99653. /**
  99654. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  99655. */
  99656. axisXControlRotation: boolean;
  99657. /**
  99658. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  99659. */
  99660. axisYControlRadius: boolean;
  99661. /**
  99662. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  99663. */
  99664. axisYControlHeight: boolean;
  99665. /**
  99666. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  99667. */
  99668. axisYControlRotation: boolean;
  99669. /**
  99670. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  99671. */
  99672. axisPinchControlRadius: boolean;
  99673. /**
  99674. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  99675. */
  99676. axisPinchControlHeight: boolean;
  99677. /**
  99678. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  99679. */
  99680. axisPinchControlRotation: boolean;
  99681. /**
  99682. * Log error messages if basic misconfiguration has occurred.
  99683. */
  99684. warningEnable: boolean;
  99685. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99686. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99687. private _warningCounter;
  99688. private _warning;
  99689. }
  99690. }
  99691. declare module BABYLON {
  99692. /**
  99693. * Default Inputs manager for the FollowCamera.
  99694. * It groups all the default supported inputs for ease of use.
  99695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99696. */
  99697. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  99698. /**
  99699. * Instantiates a new FollowCameraInputsManager.
  99700. * @param camera Defines the camera the inputs belong to
  99701. */
  99702. constructor(camera: FollowCamera);
  99703. /**
  99704. * Add keyboard input support to the input manager.
  99705. * @returns the current input manager
  99706. */
  99707. addKeyboard(): FollowCameraInputsManager;
  99708. /**
  99709. * Add mouse wheel input support to the input manager.
  99710. * @returns the current input manager
  99711. */
  99712. addMouseWheel(): FollowCameraInputsManager;
  99713. /**
  99714. * Add pointers input support to the input manager.
  99715. * @returns the current input manager
  99716. */
  99717. addPointers(): FollowCameraInputsManager;
  99718. /**
  99719. * Add orientation input support to the input manager.
  99720. * @returns the current input manager
  99721. */
  99722. addVRDeviceOrientation(): FollowCameraInputsManager;
  99723. }
  99724. }
  99725. declare module BABYLON {
  99726. /**
  99727. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  99728. * an arc rotate version arcFollowCamera are available.
  99729. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99730. */
  99731. export class FollowCamera extends TargetCamera {
  99732. /**
  99733. * Distance the follow camera should follow an object at
  99734. */
  99735. radius: number;
  99736. /**
  99737. * Minimum allowed distance of the camera to the axis of rotation
  99738. * (The camera can not get closer).
  99739. * This can help limiting how the Camera is able to move in the scene.
  99740. */
  99741. lowerRadiusLimit: Nullable<number>;
  99742. /**
  99743. * Maximum allowed distance of the camera to the axis of rotation
  99744. * (The camera can not get further).
  99745. * This can help limiting how the Camera is able to move in the scene.
  99746. */
  99747. upperRadiusLimit: Nullable<number>;
  99748. /**
  99749. * Define a rotation offset between the camera and the object it follows
  99750. */
  99751. rotationOffset: number;
  99752. /**
  99753. * Minimum allowed angle to camera position relative to target object.
  99754. * This can help limiting how the Camera is able to move in the scene.
  99755. */
  99756. lowerRotationOffsetLimit: Nullable<number>;
  99757. /**
  99758. * Maximum allowed angle to camera position relative to target object.
  99759. * This can help limiting how the Camera is able to move in the scene.
  99760. */
  99761. upperRotationOffsetLimit: Nullable<number>;
  99762. /**
  99763. * Define a height offset between the camera and the object it follows.
  99764. * It can help following an object from the top (like a car chaing a plane)
  99765. */
  99766. heightOffset: number;
  99767. /**
  99768. * Minimum allowed height of camera position relative to target object.
  99769. * This can help limiting how the Camera is able to move in the scene.
  99770. */
  99771. lowerHeightOffsetLimit: Nullable<number>;
  99772. /**
  99773. * Maximum allowed height of camera position relative to target object.
  99774. * This can help limiting how the Camera is able to move in the scene.
  99775. */
  99776. upperHeightOffsetLimit: Nullable<number>;
  99777. /**
  99778. * Define how fast the camera can accelerate to follow it s target.
  99779. */
  99780. cameraAcceleration: number;
  99781. /**
  99782. * Define the speed limit of the camera following an object.
  99783. */
  99784. maxCameraSpeed: number;
  99785. /**
  99786. * Define the target of the camera.
  99787. */
  99788. lockedTarget: Nullable<AbstractMesh>;
  99789. /**
  99790. * Defines the input associated with the camera.
  99791. */
  99792. inputs: FollowCameraInputsManager;
  99793. /**
  99794. * Instantiates the follow camera.
  99795. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99796. * @param name Define the name of the camera in the scene
  99797. * @param position Define the position of the camera
  99798. * @param scene Define the scene the camera belong to
  99799. * @param lockedTarget Define the target of the camera
  99800. */
  99801. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  99802. private _follow;
  99803. /**
  99804. * Attached controls to the current camera.
  99805. * @param element Defines the element the controls should be listened from
  99806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99807. */
  99808. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99809. /**
  99810. * Detach the current controls from the camera.
  99811. * The camera will stop reacting to inputs.
  99812. * @param element Defines the element to stop listening the inputs from
  99813. */
  99814. detachControl(element: HTMLElement): void;
  99815. /** @hidden */
  99816. _checkInputs(): void;
  99817. private _checkLimits;
  99818. /**
  99819. * Gets the camera class name.
  99820. * @returns the class name
  99821. */
  99822. getClassName(): string;
  99823. }
  99824. /**
  99825. * Arc Rotate version of the follow camera.
  99826. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  99827. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99828. */
  99829. export class ArcFollowCamera extends TargetCamera {
  99830. /** The longitudinal angle of the camera */
  99831. alpha: number;
  99832. /** The latitudinal angle of the camera */
  99833. beta: number;
  99834. /** The radius of the camera from its target */
  99835. radius: number;
  99836. /** Define the camera target (the messh it should follow) */
  99837. target: Nullable<AbstractMesh>;
  99838. private _cartesianCoordinates;
  99839. /**
  99840. * Instantiates a new ArcFollowCamera
  99841. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99842. * @param name Define the name of the camera
  99843. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  99844. * @param beta Define the rotation angle of the camera around the elevation axis
  99845. * @param radius Define the radius of the camera from its target point
  99846. * @param target Define the target of the camera
  99847. * @param scene Define the scene the camera belongs to
  99848. */
  99849. constructor(name: string,
  99850. /** The longitudinal angle of the camera */
  99851. alpha: number,
  99852. /** The latitudinal angle of the camera */
  99853. beta: number,
  99854. /** The radius of the camera from its target */
  99855. radius: number,
  99856. /** Define the camera target (the messh it should follow) */
  99857. target: Nullable<AbstractMesh>, scene: Scene);
  99858. private _follow;
  99859. /** @hidden */
  99860. _checkInputs(): void;
  99861. /**
  99862. * Returns the class name of the object.
  99863. * It is mostly used internally for serialization purposes.
  99864. */
  99865. getClassName(): string;
  99866. }
  99867. }
  99868. declare module BABYLON {
  99869. /**
  99870. * Manage the keyboard inputs to control the movement of a follow camera.
  99871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99872. */
  99873. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  99874. /**
  99875. * Defines the camera the input is attached to.
  99876. */
  99877. camera: FollowCamera;
  99878. /**
  99879. * Defines the list of key codes associated with the up action (increase heightOffset)
  99880. */
  99881. keysHeightOffsetIncr: number[];
  99882. /**
  99883. * Defines the list of key codes associated with the down action (decrease heightOffset)
  99884. */
  99885. keysHeightOffsetDecr: number[];
  99886. /**
  99887. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  99888. */
  99889. keysHeightOffsetModifierAlt: boolean;
  99890. /**
  99891. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  99892. */
  99893. keysHeightOffsetModifierCtrl: boolean;
  99894. /**
  99895. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  99896. */
  99897. keysHeightOffsetModifierShift: boolean;
  99898. /**
  99899. * Defines the list of key codes associated with the left action (increase rotationOffset)
  99900. */
  99901. keysRotationOffsetIncr: number[];
  99902. /**
  99903. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  99904. */
  99905. keysRotationOffsetDecr: number[];
  99906. /**
  99907. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  99908. */
  99909. keysRotationOffsetModifierAlt: boolean;
  99910. /**
  99911. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  99912. */
  99913. keysRotationOffsetModifierCtrl: boolean;
  99914. /**
  99915. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  99916. */
  99917. keysRotationOffsetModifierShift: boolean;
  99918. /**
  99919. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  99920. */
  99921. keysRadiusIncr: number[];
  99922. /**
  99923. * Defines the list of key codes associated with the zoom-out action (increase radius)
  99924. */
  99925. keysRadiusDecr: number[];
  99926. /**
  99927. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  99928. */
  99929. keysRadiusModifierAlt: boolean;
  99930. /**
  99931. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  99932. */
  99933. keysRadiusModifierCtrl: boolean;
  99934. /**
  99935. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  99936. */
  99937. keysRadiusModifierShift: boolean;
  99938. /**
  99939. * Defines the rate of change of heightOffset.
  99940. */
  99941. heightSensibility: number;
  99942. /**
  99943. * Defines the rate of change of rotationOffset.
  99944. */
  99945. rotationSensibility: number;
  99946. /**
  99947. * Defines the rate of change of radius.
  99948. */
  99949. radiusSensibility: number;
  99950. private _keys;
  99951. private _ctrlPressed;
  99952. private _altPressed;
  99953. private _shiftPressed;
  99954. private _onCanvasBlurObserver;
  99955. private _onKeyboardObserver;
  99956. private _engine;
  99957. private _scene;
  99958. /**
  99959. * Attach the input controls to a specific dom element to get the input from.
  99960. * @param element Defines the element the controls should be listened from
  99961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99962. */
  99963. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99964. /**
  99965. * Detach the current controls from the specified dom element.
  99966. * @param element Defines the element to stop listening the inputs from
  99967. */
  99968. detachControl(element: Nullable<HTMLElement>): void;
  99969. /**
  99970. * Update the current camera state depending on the inputs that have been used this frame.
  99971. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99972. */
  99973. checkInputs(): void;
  99974. /**
  99975. * Gets the class name of the current input.
  99976. * @returns the class name
  99977. */
  99978. getClassName(): string;
  99979. /**
  99980. * Get the friendly name associated with the input class.
  99981. * @returns the input friendly name
  99982. */
  99983. getSimpleName(): string;
  99984. /**
  99985. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99986. * allow modification of the heightOffset value.
  99987. */
  99988. private _modifierHeightOffset;
  99989. /**
  99990. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99991. * allow modification of the rotationOffset value.
  99992. */
  99993. private _modifierRotationOffset;
  99994. /**
  99995. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99996. * allow modification of the radius value.
  99997. */
  99998. private _modifierRadius;
  99999. }
  100000. }
  100001. declare module BABYLON {
  100002. interface FreeCameraInputsManager {
  100003. /**
  100004. * @hidden
  100005. */
  100006. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  100007. /**
  100008. * Add orientation input support to the input manager.
  100009. * @returns the current input manager
  100010. */
  100011. addDeviceOrientation(): FreeCameraInputsManager;
  100012. }
  100013. /**
  100014. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  100015. * Screen rotation is taken into account.
  100016. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100017. */
  100018. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  100019. private _camera;
  100020. private _screenOrientationAngle;
  100021. private _constantTranform;
  100022. private _screenQuaternion;
  100023. private _alpha;
  100024. private _beta;
  100025. private _gamma;
  100026. /**
  100027. * Can be used to detect if a device orientation sensor is availible on a device
  100028. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  100029. * @returns a promise that will resolve on orientation change
  100030. */
  100031. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  100032. /**
  100033. * @hidden
  100034. */
  100035. _onDeviceOrientationChangedObservable: Observable<void>;
  100036. /**
  100037. * Instantiates a new input
  100038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100039. */
  100040. constructor();
  100041. /**
  100042. * Define the camera controlled by the input.
  100043. */
  100044. camera: FreeCamera;
  100045. /**
  100046. * Attach the input controls to a specific dom element to get the input from.
  100047. * @param element Defines the element the controls should be listened from
  100048. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100049. */
  100050. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100051. private _orientationChanged;
  100052. private _deviceOrientation;
  100053. /**
  100054. * Detach the current controls from the specified dom element.
  100055. * @param element Defines the element to stop listening the inputs from
  100056. */
  100057. detachControl(element: Nullable<HTMLElement>): void;
  100058. /**
  100059. * Update the current camera state depending on the inputs that have been used this frame.
  100060. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100061. */
  100062. checkInputs(): void;
  100063. /**
  100064. * Gets the class name of the current intput.
  100065. * @returns the class name
  100066. */
  100067. getClassName(): string;
  100068. /**
  100069. * Get the friendly name associated with the input class.
  100070. * @returns the input friendly name
  100071. */
  100072. getSimpleName(): string;
  100073. }
  100074. }
  100075. declare module BABYLON {
  100076. /**
  100077. * Manage the gamepad inputs to control a free camera.
  100078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100079. */
  100080. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  100081. /**
  100082. * Define the camera the input is attached to.
  100083. */
  100084. camera: FreeCamera;
  100085. /**
  100086. * Define the Gamepad controlling the input
  100087. */
  100088. gamepad: Nullable<Gamepad>;
  100089. /**
  100090. * Defines the gamepad rotation sensiblity.
  100091. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100092. */
  100093. gamepadAngularSensibility: number;
  100094. /**
  100095. * Defines the gamepad move sensiblity.
  100096. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100097. */
  100098. gamepadMoveSensibility: number;
  100099. private _onGamepadConnectedObserver;
  100100. private _onGamepadDisconnectedObserver;
  100101. private _cameraTransform;
  100102. private _deltaTransform;
  100103. private _vector3;
  100104. private _vector2;
  100105. /**
  100106. * Attach the input controls to a specific dom element to get the input from.
  100107. * @param element Defines the element the controls should be listened from
  100108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100109. */
  100110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100111. /**
  100112. * Detach the current controls from the specified dom element.
  100113. * @param element Defines the element to stop listening the inputs from
  100114. */
  100115. detachControl(element: Nullable<HTMLElement>): void;
  100116. /**
  100117. * Update the current camera state depending on the inputs that have been used this frame.
  100118. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100119. */
  100120. checkInputs(): void;
  100121. /**
  100122. * Gets the class name of the current intput.
  100123. * @returns the class name
  100124. */
  100125. getClassName(): string;
  100126. /**
  100127. * Get the friendly name associated with the input class.
  100128. * @returns the input friendly name
  100129. */
  100130. getSimpleName(): string;
  100131. }
  100132. }
  100133. declare module BABYLON {
  100134. /**
  100135. * Defines the potential axis of a Joystick
  100136. */
  100137. export enum JoystickAxis {
  100138. /** X axis */
  100139. X = 0,
  100140. /** Y axis */
  100141. Y = 1,
  100142. /** Z axis */
  100143. Z = 2
  100144. }
  100145. /**
  100146. * Class used to define virtual joystick (used in touch mode)
  100147. */
  100148. export class VirtualJoystick {
  100149. /**
  100150. * Gets or sets a boolean indicating that left and right values must be inverted
  100151. */
  100152. reverseLeftRight: boolean;
  100153. /**
  100154. * Gets or sets a boolean indicating that up and down values must be inverted
  100155. */
  100156. reverseUpDown: boolean;
  100157. /**
  100158. * Gets the offset value for the position (ie. the change of the position value)
  100159. */
  100160. deltaPosition: Vector3;
  100161. /**
  100162. * Gets a boolean indicating if the virtual joystick was pressed
  100163. */
  100164. pressed: boolean;
  100165. /**
  100166. * Canvas the virtual joystick will render onto, default z-index of this is 5
  100167. */
  100168. static Canvas: Nullable<HTMLCanvasElement>;
  100169. private static _globalJoystickIndex;
  100170. private static vjCanvasContext;
  100171. private static vjCanvasWidth;
  100172. private static vjCanvasHeight;
  100173. private static halfWidth;
  100174. private _action;
  100175. private _axisTargetedByLeftAndRight;
  100176. private _axisTargetedByUpAndDown;
  100177. private _joystickSensibility;
  100178. private _inversedSensibility;
  100179. private _joystickPointerID;
  100180. private _joystickColor;
  100181. private _joystickPointerPos;
  100182. private _joystickPreviousPointerPos;
  100183. private _joystickPointerStartPos;
  100184. private _deltaJoystickVector;
  100185. private _leftJoystick;
  100186. private _touches;
  100187. private _onPointerDownHandlerRef;
  100188. private _onPointerMoveHandlerRef;
  100189. private _onPointerUpHandlerRef;
  100190. private _onResize;
  100191. /**
  100192. * Creates a new virtual joystick
  100193. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100194. */
  100195. constructor(leftJoystick?: boolean);
  100196. /**
  100197. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100198. * @param newJoystickSensibility defines the new sensibility
  100199. */
  100200. setJoystickSensibility(newJoystickSensibility: number): void;
  100201. private _onPointerDown;
  100202. private _onPointerMove;
  100203. private _onPointerUp;
  100204. /**
  100205. * Change the color of the virtual joystick
  100206. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100207. */
  100208. setJoystickColor(newColor: string): void;
  100209. /**
  100210. * Defines a callback to call when the joystick is touched
  100211. * @param action defines the callback
  100212. */
  100213. setActionOnTouch(action: () => any): void;
  100214. /**
  100215. * Defines which axis you'd like to control for left & right
  100216. * @param axis defines the axis to use
  100217. */
  100218. setAxisForLeftRight(axis: JoystickAxis): void;
  100219. /**
  100220. * Defines which axis you'd like to control for up & down
  100221. * @param axis defines the axis to use
  100222. */
  100223. setAxisForUpDown(axis: JoystickAxis): void;
  100224. private _drawVirtualJoystick;
  100225. /**
  100226. * Release internal HTML canvas
  100227. */
  100228. releaseCanvas(): void;
  100229. }
  100230. }
  100231. declare module BABYLON {
  100232. interface FreeCameraInputsManager {
  100233. /**
  100234. * Add virtual joystick input support to the input manager.
  100235. * @returns the current input manager
  100236. */
  100237. addVirtualJoystick(): FreeCameraInputsManager;
  100238. }
  100239. /**
  100240. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  100241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100242. */
  100243. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  100244. /**
  100245. * Defines the camera the input is attached to.
  100246. */
  100247. camera: FreeCamera;
  100248. private _leftjoystick;
  100249. private _rightjoystick;
  100250. /**
  100251. * Gets the left stick of the virtual joystick.
  100252. * @returns The virtual Joystick
  100253. */
  100254. getLeftJoystick(): VirtualJoystick;
  100255. /**
  100256. * Gets the right stick of the virtual joystick.
  100257. * @returns The virtual Joystick
  100258. */
  100259. getRightJoystick(): VirtualJoystick;
  100260. /**
  100261. * Update the current camera state depending on the inputs that have been used this frame.
  100262. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100263. */
  100264. checkInputs(): void;
  100265. /**
  100266. * Attach the input controls to a specific dom element to get the input from.
  100267. * @param element Defines the element the controls should be listened from
  100268. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100269. */
  100270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100271. /**
  100272. * Detach the current controls from the specified dom element.
  100273. * @param element Defines the element to stop listening the inputs from
  100274. */
  100275. detachControl(element: Nullable<HTMLElement>): void;
  100276. /**
  100277. * Gets the class name of the current intput.
  100278. * @returns the class name
  100279. */
  100280. getClassName(): string;
  100281. /**
  100282. * Get the friendly name associated with the input class.
  100283. * @returns the input friendly name
  100284. */
  100285. getSimpleName(): string;
  100286. }
  100287. }
  100288. declare module BABYLON {
  100289. /**
  100290. * This represents a FPS type of camera controlled by touch.
  100291. * This is like a universal camera minus the Gamepad controls.
  100292. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100293. */
  100294. export class TouchCamera extends FreeCamera {
  100295. /**
  100296. * Defines the touch sensibility for rotation.
  100297. * The higher the faster.
  100298. */
  100299. touchAngularSensibility: number;
  100300. /**
  100301. * Defines the touch sensibility for move.
  100302. * The higher the faster.
  100303. */
  100304. touchMoveSensibility: number;
  100305. /**
  100306. * Instantiates a new touch camera.
  100307. * This represents a FPS type of camera controlled by touch.
  100308. * This is like a universal camera minus the Gamepad controls.
  100309. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100310. * @param name Define the name of the camera in the scene
  100311. * @param position Define the start position of the camera in the scene
  100312. * @param scene Define the scene the camera belongs to
  100313. */
  100314. constructor(name: string, position: Vector3, scene: Scene);
  100315. /**
  100316. * Gets the current object class name.
  100317. * @return the class name
  100318. */
  100319. getClassName(): string;
  100320. /** @hidden */
  100321. _setupInputs(): void;
  100322. }
  100323. }
  100324. declare module BABYLON {
  100325. /**
  100326. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  100327. * being tilted forward or back and left or right.
  100328. */
  100329. export class DeviceOrientationCamera extends FreeCamera {
  100330. private _initialQuaternion;
  100331. private _quaternionCache;
  100332. private _tmpDragQuaternion;
  100333. /**
  100334. * Creates a new device orientation camera
  100335. * @param name The name of the camera
  100336. * @param position The start position camera
  100337. * @param scene The scene the camera belongs to
  100338. */
  100339. constructor(name: string, position: Vector3, scene: Scene);
  100340. /**
  100341. * @hidden
  100342. * Disabled pointer input on first orientation sensor update (Default: true)
  100343. */
  100344. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  100345. private _dragFactor;
  100346. /**
  100347. * Enabled turning on the y axis when the orientation sensor is active
  100348. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  100349. */
  100350. enableHorizontalDragging(dragFactor?: number): void;
  100351. /**
  100352. * Gets the current instance class name ("DeviceOrientationCamera").
  100353. * This helps avoiding instanceof at run time.
  100354. * @returns the class name
  100355. */
  100356. getClassName(): string;
  100357. /**
  100358. * @hidden
  100359. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100360. */
  100361. _checkInputs(): void;
  100362. /**
  100363. * Reset the camera to its default orientation on the specified axis only.
  100364. * @param axis The axis to reset
  100365. */
  100366. resetToCurrentRotation(axis?: Axis): void;
  100367. }
  100368. }
  100369. declare module BABYLON {
  100370. /**
  100371. * Defines supported buttons for XBox360 compatible gamepads
  100372. */
  100373. export enum Xbox360Button {
  100374. /** A */
  100375. A = 0,
  100376. /** B */
  100377. B = 1,
  100378. /** X */
  100379. X = 2,
  100380. /** Y */
  100381. Y = 3,
  100382. /** Start */
  100383. Start = 4,
  100384. /** Back */
  100385. Back = 5,
  100386. /** Left button */
  100387. LB = 6,
  100388. /** Right button */
  100389. RB = 7,
  100390. /** Left stick */
  100391. LeftStick = 8,
  100392. /** Right stick */
  100393. RightStick = 9
  100394. }
  100395. /** Defines values for XBox360 DPad */
  100396. export enum Xbox360Dpad {
  100397. /** Up */
  100398. Up = 0,
  100399. /** Down */
  100400. Down = 1,
  100401. /** Left */
  100402. Left = 2,
  100403. /** Right */
  100404. Right = 3
  100405. }
  100406. /**
  100407. * Defines a XBox360 gamepad
  100408. */
  100409. export class Xbox360Pad extends Gamepad {
  100410. private _leftTrigger;
  100411. private _rightTrigger;
  100412. private _onlefttriggerchanged;
  100413. private _onrighttriggerchanged;
  100414. private _onbuttondown;
  100415. private _onbuttonup;
  100416. private _ondpaddown;
  100417. private _ondpadup;
  100418. /** Observable raised when a button is pressed */
  100419. onButtonDownObservable: Observable<Xbox360Button>;
  100420. /** Observable raised when a button is released */
  100421. onButtonUpObservable: Observable<Xbox360Button>;
  100422. /** Observable raised when a pad is pressed */
  100423. onPadDownObservable: Observable<Xbox360Dpad>;
  100424. /** Observable raised when a pad is released */
  100425. onPadUpObservable: Observable<Xbox360Dpad>;
  100426. private _buttonA;
  100427. private _buttonB;
  100428. private _buttonX;
  100429. private _buttonY;
  100430. private _buttonBack;
  100431. private _buttonStart;
  100432. private _buttonLB;
  100433. private _buttonRB;
  100434. private _buttonLeftStick;
  100435. private _buttonRightStick;
  100436. private _dPadUp;
  100437. private _dPadDown;
  100438. private _dPadLeft;
  100439. private _dPadRight;
  100440. private _isXboxOnePad;
  100441. /**
  100442. * Creates a new XBox360 gamepad object
  100443. * @param id defines the id of this gamepad
  100444. * @param index defines its index
  100445. * @param gamepad defines the internal HTML gamepad object
  100446. * @param xboxOne defines if it is a XBox One gamepad
  100447. */
  100448. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  100449. /**
  100450. * Defines the callback to call when left trigger is pressed
  100451. * @param callback defines the callback to use
  100452. */
  100453. onlefttriggerchanged(callback: (value: number) => void): void;
  100454. /**
  100455. * Defines the callback to call when right trigger is pressed
  100456. * @param callback defines the callback to use
  100457. */
  100458. onrighttriggerchanged(callback: (value: number) => void): void;
  100459. /**
  100460. * Gets the left trigger value
  100461. */
  100462. /**
  100463. * Sets the left trigger value
  100464. */
  100465. leftTrigger: number;
  100466. /**
  100467. * Gets the right trigger value
  100468. */
  100469. /**
  100470. * Sets the right trigger value
  100471. */
  100472. rightTrigger: number;
  100473. /**
  100474. * Defines the callback to call when a button is pressed
  100475. * @param callback defines the callback to use
  100476. */
  100477. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  100478. /**
  100479. * Defines the callback to call when a button is released
  100480. * @param callback defines the callback to use
  100481. */
  100482. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  100483. /**
  100484. * Defines the callback to call when a pad is pressed
  100485. * @param callback defines the callback to use
  100486. */
  100487. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  100488. /**
  100489. * Defines the callback to call when a pad is released
  100490. * @param callback defines the callback to use
  100491. */
  100492. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  100493. private _setButtonValue;
  100494. private _setDPadValue;
  100495. /**
  100496. * Gets the value of the `A` button
  100497. */
  100498. /**
  100499. * Sets the value of the `A` button
  100500. */
  100501. buttonA: number;
  100502. /**
  100503. * Gets the value of the `B` button
  100504. */
  100505. /**
  100506. * Sets the value of the `B` button
  100507. */
  100508. buttonB: number;
  100509. /**
  100510. * Gets the value of the `X` button
  100511. */
  100512. /**
  100513. * Sets the value of the `X` button
  100514. */
  100515. buttonX: number;
  100516. /**
  100517. * Gets the value of the `Y` button
  100518. */
  100519. /**
  100520. * Sets the value of the `Y` button
  100521. */
  100522. buttonY: number;
  100523. /**
  100524. * Gets the value of the `Start` button
  100525. */
  100526. /**
  100527. * Sets the value of the `Start` button
  100528. */
  100529. buttonStart: number;
  100530. /**
  100531. * Gets the value of the `Back` button
  100532. */
  100533. /**
  100534. * Sets the value of the `Back` button
  100535. */
  100536. buttonBack: number;
  100537. /**
  100538. * Gets the value of the `Left` button
  100539. */
  100540. /**
  100541. * Sets the value of the `Left` button
  100542. */
  100543. buttonLB: number;
  100544. /**
  100545. * Gets the value of the `Right` button
  100546. */
  100547. /**
  100548. * Sets the value of the `Right` button
  100549. */
  100550. buttonRB: number;
  100551. /**
  100552. * Gets the value of the Left joystick
  100553. */
  100554. /**
  100555. * Sets the value of the Left joystick
  100556. */
  100557. buttonLeftStick: number;
  100558. /**
  100559. * Gets the value of the Right joystick
  100560. */
  100561. /**
  100562. * Sets the value of the Right joystick
  100563. */
  100564. buttonRightStick: number;
  100565. /**
  100566. * Gets the value of D-pad up
  100567. */
  100568. /**
  100569. * Sets the value of D-pad up
  100570. */
  100571. dPadUp: number;
  100572. /**
  100573. * Gets the value of D-pad down
  100574. */
  100575. /**
  100576. * Sets the value of D-pad down
  100577. */
  100578. dPadDown: number;
  100579. /**
  100580. * Gets the value of D-pad left
  100581. */
  100582. /**
  100583. * Sets the value of D-pad left
  100584. */
  100585. dPadLeft: number;
  100586. /**
  100587. * Gets the value of D-pad right
  100588. */
  100589. /**
  100590. * Sets the value of D-pad right
  100591. */
  100592. dPadRight: number;
  100593. /**
  100594. * Force the gamepad to synchronize with device values
  100595. */
  100596. update(): void;
  100597. /**
  100598. * Disposes the gamepad
  100599. */
  100600. dispose(): void;
  100601. }
  100602. }
  100603. declare module BABYLON {
  100604. /**
  100605. * Manager for handling gamepads
  100606. */
  100607. export class GamepadManager {
  100608. private _scene?;
  100609. private _babylonGamepads;
  100610. private _oneGamepadConnected;
  100611. /** @hidden */
  100612. _isMonitoring: boolean;
  100613. private _gamepadEventSupported;
  100614. private _gamepadSupport;
  100615. /**
  100616. * observable to be triggered when the gamepad controller has been connected
  100617. */
  100618. onGamepadConnectedObservable: Observable<Gamepad>;
  100619. /**
  100620. * observable to be triggered when the gamepad controller has been disconnected
  100621. */
  100622. onGamepadDisconnectedObservable: Observable<Gamepad>;
  100623. private _onGamepadConnectedEvent;
  100624. private _onGamepadDisconnectedEvent;
  100625. /**
  100626. * Initializes the gamepad manager
  100627. * @param _scene BabylonJS scene
  100628. */
  100629. constructor(_scene?: Scene | undefined);
  100630. /**
  100631. * The gamepads in the game pad manager
  100632. */
  100633. readonly gamepads: Gamepad[];
  100634. /**
  100635. * Get the gamepad controllers based on type
  100636. * @param type The type of gamepad controller
  100637. * @returns Nullable gamepad
  100638. */
  100639. getGamepadByType(type?: number): Nullable<Gamepad>;
  100640. /**
  100641. * Disposes the gamepad manager
  100642. */
  100643. dispose(): void;
  100644. private _addNewGamepad;
  100645. private _startMonitoringGamepads;
  100646. private _stopMonitoringGamepads;
  100647. /** @hidden */
  100648. _checkGamepadsStatus(): void;
  100649. private _updateGamepadObjects;
  100650. }
  100651. }
  100652. declare module BABYLON {
  100653. interface Scene {
  100654. /** @hidden */
  100655. _gamepadManager: Nullable<GamepadManager>;
  100656. /**
  100657. * Gets the gamepad manager associated with the scene
  100658. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  100659. */
  100660. gamepadManager: GamepadManager;
  100661. }
  100662. /**
  100663. * Interface representing a free camera inputs manager
  100664. */
  100665. interface FreeCameraInputsManager {
  100666. /**
  100667. * Adds gamepad input support to the FreeCameraInputsManager.
  100668. * @returns the FreeCameraInputsManager
  100669. */
  100670. addGamepad(): FreeCameraInputsManager;
  100671. }
  100672. /**
  100673. * Interface representing an arc rotate camera inputs manager
  100674. */
  100675. interface ArcRotateCameraInputsManager {
  100676. /**
  100677. * Adds gamepad input support to the ArcRotateCamera InputManager.
  100678. * @returns the camera inputs manager
  100679. */
  100680. addGamepad(): ArcRotateCameraInputsManager;
  100681. }
  100682. /**
  100683. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  100684. */
  100685. export class GamepadSystemSceneComponent implements ISceneComponent {
  100686. /**
  100687. * The component name helpfull to identify the component in the list of scene components.
  100688. */
  100689. readonly name: string;
  100690. /**
  100691. * The scene the component belongs to.
  100692. */
  100693. scene: Scene;
  100694. /**
  100695. * Creates a new instance of the component for the given scene
  100696. * @param scene Defines the scene to register the component in
  100697. */
  100698. constructor(scene: Scene);
  100699. /**
  100700. * Registers the component in a given scene
  100701. */
  100702. register(): void;
  100703. /**
  100704. * Rebuilds the elements related to this component in case of
  100705. * context lost for instance.
  100706. */
  100707. rebuild(): void;
  100708. /**
  100709. * Disposes the component and the associated ressources
  100710. */
  100711. dispose(): void;
  100712. private _beforeCameraUpdate;
  100713. }
  100714. }
  100715. declare module BABYLON {
  100716. /**
  100717. * 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,
  100718. * which still works and will still be found in many Playgrounds.
  100719. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100720. */
  100721. export class UniversalCamera extends TouchCamera {
  100722. /**
  100723. * Defines the gamepad rotation sensiblity.
  100724. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100725. */
  100726. gamepadAngularSensibility: number;
  100727. /**
  100728. * Defines the gamepad move sensiblity.
  100729. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100730. */
  100731. gamepadMoveSensibility: number;
  100732. /**
  100733. * 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,
  100734. * which still works and will still be found in many Playgrounds.
  100735. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100736. * @param name Define the name of the camera in the scene
  100737. * @param position Define the start position of the camera in the scene
  100738. * @param scene Define the scene the camera belongs to
  100739. */
  100740. constructor(name: string, position: Vector3, scene: Scene);
  100741. /**
  100742. * Gets the current object class name.
  100743. * @return the class name
  100744. */
  100745. getClassName(): string;
  100746. }
  100747. }
  100748. declare module BABYLON {
  100749. /**
  100750. * This represents a FPS type of camera. This is only here for back compat purpose.
  100751. * Please use the UniversalCamera instead as both are identical.
  100752. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100753. */
  100754. export class GamepadCamera extends UniversalCamera {
  100755. /**
  100756. * Instantiates a new Gamepad Camera
  100757. * This represents a FPS type of camera. This is only here for back compat purpose.
  100758. * Please use the UniversalCamera instead as both are identical.
  100759. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100760. * @param name Define the name of the camera in the scene
  100761. * @param position Define the start position of the camera in the scene
  100762. * @param scene Define the scene the camera belongs to
  100763. */
  100764. constructor(name: string, position: Vector3, scene: Scene);
  100765. /**
  100766. * Gets the current object class name.
  100767. * @return the class name
  100768. */
  100769. getClassName(): string;
  100770. }
  100771. }
  100772. declare module BABYLON {
  100773. /** @hidden */
  100774. export var passPixelShader: {
  100775. name: string;
  100776. shader: string;
  100777. };
  100778. }
  100779. declare module BABYLON {
  100780. /** @hidden */
  100781. export var passCubePixelShader: {
  100782. name: string;
  100783. shader: string;
  100784. };
  100785. }
  100786. declare module BABYLON {
  100787. /**
  100788. * PassPostProcess which produces an output the same as it's input
  100789. */
  100790. export class PassPostProcess extends PostProcess {
  100791. /**
  100792. * Creates the PassPostProcess
  100793. * @param name The name of the effect.
  100794. * @param options The required width/height ratio to downsize to before computing the render pass.
  100795. * @param camera The camera to apply the render pass to.
  100796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100797. * @param engine The engine which the post process will be applied. (default: current engine)
  100798. * @param reusable If the post process can be reused on the same frame. (default: false)
  100799. * @param textureType The type of texture to be used when performing the post processing.
  100800. * @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)
  100801. */
  100802. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100803. }
  100804. /**
  100805. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  100806. */
  100807. export class PassCubePostProcess extends PostProcess {
  100808. private _face;
  100809. /**
  100810. * Gets or sets the cube face to display.
  100811. * * 0 is +X
  100812. * * 1 is -X
  100813. * * 2 is +Y
  100814. * * 3 is -Y
  100815. * * 4 is +Z
  100816. * * 5 is -Z
  100817. */
  100818. face: number;
  100819. /**
  100820. * Creates the PassCubePostProcess
  100821. * @param name The name of the effect.
  100822. * @param options The required width/height ratio to downsize to before computing the render pass.
  100823. * @param camera The camera to apply the render pass to.
  100824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100825. * @param engine The engine which the post process will be applied. (default: current engine)
  100826. * @param reusable If the post process can be reused on the same frame. (default: false)
  100827. * @param textureType The type of texture to be used when performing the post processing.
  100828. * @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)
  100829. */
  100830. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100831. }
  100832. }
  100833. declare module BABYLON {
  100834. /** @hidden */
  100835. export var anaglyphPixelShader: {
  100836. name: string;
  100837. shader: string;
  100838. };
  100839. }
  100840. declare module BABYLON {
  100841. /**
  100842. * Postprocess used to generate anaglyphic rendering
  100843. */
  100844. export class AnaglyphPostProcess extends PostProcess {
  100845. private _passedProcess;
  100846. /**
  100847. * Creates a new AnaglyphPostProcess
  100848. * @param name defines postprocess name
  100849. * @param options defines creation options or target ratio scale
  100850. * @param rigCameras defines cameras using this postprocess
  100851. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  100852. * @param engine defines hosting engine
  100853. * @param reusable defines if the postprocess will be reused multiple times per frame
  100854. */
  100855. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  100856. }
  100857. }
  100858. declare module BABYLON {
  100859. /**
  100860. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  100861. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100862. */
  100863. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  100864. /**
  100865. * Creates a new AnaglyphArcRotateCamera
  100866. * @param name defines camera name
  100867. * @param alpha defines alpha angle (in radians)
  100868. * @param beta defines beta angle (in radians)
  100869. * @param radius defines radius
  100870. * @param target defines camera target
  100871. * @param interaxialDistance defines distance between each color axis
  100872. * @param scene defines the hosting scene
  100873. */
  100874. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  100875. /**
  100876. * Gets camera class name
  100877. * @returns AnaglyphArcRotateCamera
  100878. */
  100879. getClassName(): string;
  100880. }
  100881. }
  100882. declare module BABYLON {
  100883. /**
  100884. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  100885. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100886. */
  100887. export class AnaglyphFreeCamera extends FreeCamera {
  100888. /**
  100889. * Creates a new AnaglyphFreeCamera
  100890. * @param name defines camera name
  100891. * @param position defines initial position
  100892. * @param interaxialDistance defines distance between each color axis
  100893. * @param scene defines the hosting scene
  100894. */
  100895. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100896. /**
  100897. * Gets camera class name
  100898. * @returns AnaglyphFreeCamera
  100899. */
  100900. getClassName(): string;
  100901. }
  100902. }
  100903. declare module BABYLON {
  100904. /**
  100905. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  100906. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100907. */
  100908. export class AnaglyphGamepadCamera extends GamepadCamera {
  100909. /**
  100910. * Creates a new AnaglyphGamepadCamera
  100911. * @param name defines camera name
  100912. * @param position defines initial position
  100913. * @param interaxialDistance defines distance between each color axis
  100914. * @param scene defines the hosting scene
  100915. */
  100916. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100917. /**
  100918. * Gets camera class name
  100919. * @returns AnaglyphGamepadCamera
  100920. */
  100921. getClassName(): string;
  100922. }
  100923. }
  100924. declare module BABYLON {
  100925. /**
  100926. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  100927. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100928. */
  100929. export class AnaglyphUniversalCamera extends UniversalCamera {
  100930. /**
  100931. * Creates a new AnaglyphUniversalCamera
  100932. * @param name defines camera name
  100933. * @param position defines initial position
  100934. * @param interaxialDistance defines distance between each color axis
  100935. * @param scene defines the hosting scene
  100936. */
  100937. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100938. /**
  100939. * Gets camera class name
  100940. * @returns AnaglyphUniversalCamera
  100941. */
  100942. getClassName(): string;
  100943. }
  100944. }
  100945. declare module BABYLON {
  100946. /** @hidden */
  100947. export var stereoscopicInterlacePixelShader: {
  100948. name: string;
  100949. shader: string;
  100950. };
  100951. }
  100952. declare module BABYLON {
  100953. /**
  100954. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  100955. */
  100956. export class StereoscopicInterlacePostProcess extends PostProcess {
  100957. private _stepSize;
  100958. private _passedProcess;
  100959. /**
  100960. * Initializes a StereoscopicInterlacePostProcess
  100961. * @param name The name of the effect.
  100962. * @param rigCameras The rig cameras to be appled to the post process
  100963. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  100964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100965. * @param engine The engine which the post process will be applied. (default: current engine)
  100966. * @param reusable If the post process can be reused on the same frame. (default: false)
  100967. */
  100968. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  100969. }
  100970. }
  100971. declare module BABYLON {
  100972. /**
  100973. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  100974. * @see http://doc.babylonjs.com/features/cameras
  100975. */
  100976. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  100977. /**
  100978. * Creates a new StereoscopicArcRotateCamera
  100979. * @param name defines camera name
  100980. * @param alpha defines alpha angle (in radians)
  100981. * @param beta defines beta angle (in radians)
  100982. * @param radius defines radius
  100983. * @param target defines camera target
  100984. * @param interaxialDistance defines distance between each color axis
  100985. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100986. * @param scene defines the hosting scene
  100987. */
  100988. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100989. /**
  100990. * Gets camera class name
  100991. * @returns StereoscopicArcRotateCamera
  100992. */
  100993. getClassName(): string;
  100994. }
  100995. }
  100996. declare module BABYLON {
  100997. /**
  100998. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  100999. * @see http://doc.babylonjs.com/features/cameras
  101000. */
  101001. export class StereoscopicFreeCamera extends FreeCamera {
  101002. /**
  101003. * Creates a new StereoscopicFreeCamera
  101004. * @param name defines camera name
  101005. * @param position defines initial position
  101006. * @param interaxialDistance defines distance between each color axis
  101007. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101008. * @param scene defines the hosting scene
  101009. */
  101010. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101011. /**
  101012. * Gets camera class name
  101013. * @returns StereoscopicFreeCamera
  101014. */
  101015. getClassName(): string;
  101016. }
  101017. }
  101018. declare module BABYLON {
  101019. /**
  101020. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  101021. * @see http://doc.babylonjs.com/features/cameras
  101022. */
  101023. export class StereoscopicGamepadCamera extends GamepadCamera {
  101024. /**
  101025. * Creates a new StereoscopicGamepadCamera
  101026. * @param name defines camera name
  101027. * @param position defines initial position
  101028. * @param interaxialDistance defines distance between each color axis
  101029. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101030. * @param scene defines the hosting scene
  101031. */
  101032. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101033. /**
  101034. * Gets camera class name
  101035. * @returns StereoscopicGamepadCamera
  101036. */
  101037. getClassName(): string;
  101038. }
  101039. }
  101040. declare module BABYLON {
  101041. /**
  101042. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  101043. * @see http://doc.babylonjs.com/features/cameras
  101044. */
  101045. export class StereoscopicUniversalCamera extends UniversalCamera {
  101046. /**
  101047. * Creates a new StereoscopicUniversalCamera
  101048. * @param name defines camera name
  101049. * @param position defines initial position
  101050. * @param interaxialDistance defines distance between each color axis
  101051. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101052. * @param scene defines the hosting scene
  101053. */
  101054. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101055. /**
  101056. * Gets camera class name
  101057. * @returns StereoscopicUniversalCamera
  101058. */
  101059. getClassName(): string;
  101060. }
  101061. }
  101062. declare module BABYLON {
  101063. /**
  101064. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  101065. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101066. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101067. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101068. */
  101069. export class VirtualJoysticksCamera extends FreeCamera {
  101070. /**
  101071. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  101072. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101073. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101074. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101075. * @param name Define the name of the camera in the scene
  101076. * @param position Define the start position of the camera in the scene
  101077. * @param scene Define the scene the camera belongs to
  101078. */
  101079. constructor(name: string, position: Vector3, scene: Scene);
  101080. /**
  101081. * Gets the current object class name.
  101082. * @return the class name
  101083. */
  101084. getClassName(): string;
  101085. }
  101086. }
  101087. declare module BABYLON {
  101088. /**
  101089. * This represents all the required metrics to create a VR camera.
  101090. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  101091. */
  101092. export class VRCameraMetrics {
  101093. /**
  101094. * Define the horizontal resolution off the screen.
  101095. */
  101096. hResolution: number;
  101097. /**
  101098. * Define the vertical resolution off the screen.
  101099. */
  101100. vResolution: number;
  101101. /**
  101102. * Define the horizontal screen size.
  101103. */
  101104. hScreenSize: number;
  101105. /**
  101106. * Define the vertical screen size.
  101107. */
  101108. vScreenSize: number;
  101109. /**
  101110. * Define the vertical screen center position.
  101111. */
  101112. vScreenCenter: number;
  101113. /**
  101114. * Define the distance of the eyes to the screen.
  101115. */
  101116. eyeToScreenDistance: number;
  101117. /**
  101118. * Define the distance between both lenses
  101119. */
  101120. lensSeparationDistance: number;
  101121. /**
  101122. * Define the distance between both viewer's eyes.
  101123. */
  101124. interpupillaryDistance: number;
  101125. /**
  101126. * Define the distortion factor of the VR postprocess.
  101127. * Please, touch with care.
  101128. */
  101129. distortionK: number[];
  101130. /**
  101131. * Define the chromatic aberration correction factors for the VR post process.
  101132. */
  101133. chromaAbCorrection: number[];
  101134. /**
  101135. * Define the scale factor of the post process.
  101136. * The smaller the better but the slower.
  101137. */
  101138. postProcessScaleFactor: number;
  101139. /**
  101140. * Define an offset for the lens center.
  101141. */
  101142. lensCenterOffset: number;
  101143. /**
  101144. * Define if the current vr camera should compensate the distortion of the lense or not.
  101145. */
  101146. compensateDistortion: boolean;
  101147. /**
  101148. * Defines if multiview should be enabled when rendering (Default: false)
  101149. */
  101150. multiviewEnabled: boolean;
  101151. /**
  101152. * Gets the rendering aspect ratio based on the provided resolutions.
  101153. */
  101154. readonly aspectRatio: number;
  101155. /**
  101156. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  101157. */
  101158. readonly aspectRatioFov: number;
  101159. /**
  101160. * @hidden
  101161. */
  101162. readonly leftHMatrix: Matrix;
  101163. /**
  101164. * @hidden
  101165. */
  101166. readonly rightHMatrix: Matrix;
  101167. /**
  101168. * @hidden
  101169. */
  101170. readonly leftPreViewMatrix: Matrix;
  101171. /**
  101172. * @hidden
  101173. */
  101174. readonly rightPreViewMatrix: Matrix;
  101175. /**
  101176. * Get the default VRMetrics based on the most generic setup.
  101177. * @returns the default vr metrics
  101178. */
  101179. static GetDefault(): VRCameraMetrics;
  101180. }
  101181. }
  101182. declare module BABYLON {
  101183. /** @hidden */
  101184. export var vrDistortionCorrectionPixelShader: {
  101185. name: string;
  101186. shader: string;
  101187. };
  101188. }
  101189. declare module BABYLON {
  101190. /**
  101191. * VRDistortionCorrectionPostProcess used for mobile VR
  101192. */
  101193. export class VRDistortionCorrectionPostProcess extends PostProcess {
  101194. private _isRightEye;
  101195. private _distortionFactors;
  101196. private _postProcessScaleFactor;
  101197. private _lensCenterOffset;
  101198. private _scaleIn;
  101199. private _scaleFactor;
  101200. private _lensCenter;
  101201. /**
  101202. * Initializes the VRDistortionCorrectionPostProcess
  101203. * @param name The name of the effect.
  101204. * @param camera The camera to apply the render pass to.
  101205. * @param isRightEye If this is for the right eye distortion
  101206. * @param vrMetrics All the required metrics for the VR camera
  101207. */
  101208. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  101209. }
  101210. }
  101211. declare module BABYLON {
  101212. /**
  101213. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  101214. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101215. */
  101216. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  101217. /**
  101218. * Creates a new VRDeviceOrientationArcRotateCamera
  101219. * @param name defines camera name
  101220. * @param alpha defines the camera rotation along the logitudinal axis
  101221. * @param beta defines the camera rotation along the latitudinal axis
  101222. * @param radius defines the camera distance from its target
  101223. * @param target defines the camera target
  101224. * @param scene defines the scene the camera belongs to
  101225. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101226. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101227. */
  101228. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101229. /**
  101230. * Gets camera class name
  101231. * @returns VRDeviceOrientationArcRotateCamera
  101232. */
  101233. getClassName(): string;
  101234. }
  101235. }
  101236. declare module BABYLON {
  101237. /**
  101238. * Camera used to simulate VR rendering (based on FreeCamera)
  101239. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101240. */
  101241. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  101242. /**
  101243. * Creates a new VRDeviceOrientationFreeCamera
  101244. * @param name defines camera name
  101245. * @param position defines the start position of the camera
  101246. * @param scene defines the scene the camera belongs to
  101247. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101248. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101249. */
  101250. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101251. /**
  101252. * Gets camera class name
  101253. * @returns VRDeviceOrientationFreeCamera
  101254. */
  101255. getClassName(): string;
  101256. }
  101257. }
  101258. declare module BABYLON {
  101259. /**
  101260. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  101261. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101262. */
  101263. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  101264. /**
  101265. * Creates a new VRDeviceOrientationGamepadCamera
  101266. * @param name defines camera name
  101267. * @param position defines the start position of the camera
  101268. * @param scene defines the scene the camera belongs to
  101269. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101270. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101271. */
  101272. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101273. /**
  101274. * Gets camera class name
  101275. * @returns VRDeviceOrientationGamepadCamera
  101276. */
  101277. getClassName(): string;
  101278. }
  101279. }
  101280. declare module BABYLON {
  101281. /**
  101282. * Base class of materials working in push mode in babylon JS
  101283. * @hidden
  101284. */
  101285. export class PushMaterial extends Material {
  101286. protected _activeEffect: Effect;
  101287. protected _normalMatrix: Matrix;
  101288. /**
  101289. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  101290. * This means that the material can keep using a previous shader while a new one is being compiled.
  101291. * This is mostly used when shader parallel compilation is supported (true by default)
  101292. */
  101293. allowShaderHotSwapping: boolean;
  101294. constructor(name: string, scene: Scene);
  101295. getEffect(): Effect;
  101296. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101297. /**
  101298. * Binds the given world matrix to the active effect
  101299. *
  101300. * @param world the matrix to bind
  101301. */
  101302. bindOnlyWorldMatrix(world: Matrix): void;
  101303. /**
  101304. * Binds the given normal matrix to the active effect
  101305. *
  101306. * @param normalMatrix the matrix to bind
  101307. */
  101308. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101309. bind(world: Matrix, mesh?: Mesh): void;
  101310. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101311. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101312. }
  101313. }
  101314. declare module BABYLON {
  101315. /**
  101316. * This groups all the flags used to control the materials channel.
  101317. */
  101318. export class MaterialFlags {
  101319. private static _DiffuseTextureEnabled;
  101320. /**
  101321. * Are diffuse textures enabled in the application.
  101322. */
  101323. static DiffuseTextureEnabled: boolean;
  101324. private static _AmbientTextureEnabled;
  101325. /**
  101326. * Are ambient textures enabled in the application.
  101327. */
  101328. static AmbientTextureEnabled: boolean;
  101329. private static _OpacityTextureEnabled;
  101330. /**
  101331. * Are opacity textures enabled in the application.
  101332. */
  101333. static OpacityTextureEnabled: boolean;
  101334. private static _ReflectionTextureEnabled;
  101335. /**
  101336. * Are reflection textures enabled in the application.
  101337. */
  101338. static ReflectionTextureEnabled: boolean;
  101339. private static _EmissiveTextureEnabled;
  101340. /**
  101341. * Are emissive textures enabled in the application.
  101342. */
  101343. static EmissiveTextureEnabled: boolean;
  101344. private static _SpecularTextureEnabled;
  101345. /**
  101346. * Are specular textures enabled in the application.
  101347. */
  101348. static SpecularTextureEnabled: boolean;
  101349. private static _BumpTextureEnabled;
  101350. /**
  101351. * Are bump textures enabled in the application.
  101352. */
  101353. static BumpTextureEnabled: boolean;
  101354. private static _LightmapTextureEnabled;
  101355. /**
  101356. * Are lightmap textures enabled in the application.
  101357. */
  101358. static LightmapTextureEnabled: boolean;
  101359. private static _RefractionTextureEnabled;
  101360. /**
  101361. * Are refraction textures enabled in the application.
  101362. */
  101363. static RefractionTextureEnabled: boolean;
  101364. private static _ColorGradingTextureEnabled;
  101365. /**
  101366. * Are color grading textures enabled in the application.
  101367. */
  101368. static ColorGradingTextureEnabled: boolean;
  101369. private static _FresnelEnabled;
  101370. /**
  101371. * Are fresnels enabled in the application.
  101372. */
  101373. static FresnelEnabled: boolean;
  101374. private static _ClearCoatTextureEnabled;
  101375. /**
  101376. * Are clear coat textures enabled in the application.
  101377. */
  101378. static ClearCoatTextureEnabled: boolean;
  101379. private static _ClearCoatBumpTextureEnabled;
  101380. /**
  101381. * Are clear coat bump textures enabled in the application.
  101382. */
  101383. static ClearCoatBumpTextureEnabled: boolean;
  101384. private static _ClearCoatTintTextureEnabled;
  101385. /**
  101386. * Are clear coat tint textures enabled in the application.
  101387. */
  101388. static ClearCoatTintTextureEnabled: boolean;
  101389. private static _SheenTextureEnabled;
  101390. /**
  101391. * Are sheen textures enabled in the application.
  101392. */
  101393. static SheenTextureEnabled: boolean;
  101394. private static _AnisotropicTextureEnabled;
  101395. /**
  101396. * Are anisotropic textures enabled in the application.
  101397. */
  101398. static AnisotropicTextureEnabled: boolean;
  101399. private static _ThicknessTextureEnabled;
  101400. /**
  101401. * Are thickness textures enabled in the application.
  101402. */
  101403. static ThicknessTextureEnabled: boolean;
  101404. }
  101405. }
  101406. declare module BABYLON {
  101407. /** @hidden */
  101408. export var defaultFragmentDeclaration: {
  101409. name: string;
  101410. shader: string;
  101411. };
  101412. }
  101413. declare module BABYLON {
  101414. /** @hidden */
  101415. export var defaultUboDeclaration: {
  101416. name: string;
  101417. shader: string;
  101418. };
  101419. }
  101420. declare module BABYLON {
  101421. /** @hidden */
  101422. export var lightFragmentDeclaration: {
  101423. name: string;
  101424. shader: string;
  101425. };
  101426. }
  101427. declare module BABYLON {
  101428. /** @hidden */
  101429. export var lightUboDeclaration: {
  101430. name: string;
  101431. shader: string;
  101432. };
  101433. }
  101434. declare module BABYLON {
  101435. /** @hidden */
  101436. export var lightsFragmentFunctions: {
  101437. name: string;
  101438. shader: string;
  101439. };
  101440. }
  101441. declare module BABYLON {
  101442. /** @hidden */
  101443. export var shadowsFragmentFunctions: {
  101444. name: string;
  101445. shader: string;
  101446. };
  101447. }
  101448. declare module BABYLON {
  101449. /** @hidden */
  101450. export var fresnelFunction: {
  101451. name: string;
  101452. shader: string;
  101453. };
  101454. }
  101455. declare module BABYLON {
  101456. /** @hidden */
  101457. export var reflectionFunction: {
  101458. name: string;
  101459. shader: string;
  101460. };
  101461. }
  101462. declare module BABYLON {
  101463. /** @hidden */
  101464. export var bumpFragmentFunctions: {
  101465. name: string;
  101466. shader: string;
  101467. };
  101468. }
  101469. declare module BABYLON {
  101470. /** @hidden */
  101471. export var logDepthDeclaration: {
  101472. name: string;
  101473. shader: string;
  101474. };
  101475. }
  101476. declare module BABYLON {
  101477. /** @hidden */
  101478. export var bumpFragment: {
  101479. name: string;
  101480. shader: string;
  101481. };
  101482. }
  101483. declare module BABYLON {
  101484. /** @hidden */
  101485. export var depthPrePass: {
  101486. name: string;
  101487. shader: string;
  101488. };
  101489. }
  101490. declare module BABYLON {
  101491. /** @hidden */
  101492. export var lightFragment: {
  101493. name: string;
  101494. shader: string;
  101495. };
  101496. }
  101497. declare module BABYLON {
  101498. /** @hidden */
  101499. export var logDepthFragment: {
  101500. name: string;
  101501. shader: string;
  101502. };
  101503. }
  101504. declare module BABYLON {
  101505. /** @hidden */
  101506. export var defaultPixelShader: {
  101507. name: string;
  101508. shader: string;
  101509. };
  101510. }
  101511. declare module BABYLON {
  101512. /** @hidden */
  101513. export var defaultVertexDeclaration: {
  101514. name: string;
  101515. shader: string;
  101516. };
  101517. }
  101518. declare module BABYLON {
  101519. /** @hidden */
  101520. export var bumpVertexDeclaration: {
  101521. name: string;
  101522. shader: string;
  101523. };
  101524. }
  101525. declare module BABYLON {
  101526. /** @hidden */
  101527. export var bumpVertex: {
  101528. name: string;
  101529. shader: string;
  101530. };
  101531. }
  101532. declare module BABYLON {
  101533. /** @hidden */
  101534. export var fogVertex: {
  101535. name: string;
  101536. shader: string;
  101537. };
  101538. }
  101539. declare module BABYLON {
  101540. /** @hidden */
  101541. export var shadowsVertex: {
  101542. name: string;
  101543. shader: string;
  101544. };
  101545. }
  101546. declare module BABYLON {
  101547. /** @hidden */
  101548. export var pointCloudVertex: {
  101549. name: string;
  101550. shader: string;
  101551. };
  101552. }
  101553. declare module BABYLON {
  101554. /** @hidden */
  101555. export var logDepthVertex: {
  101556. name: string;
  101557. shader: string;
  101558. };
  101559. }
  101560. declare module BABYLON {
  101561. /** @hidden */
  101562. export var defaultVertexShader: {
  101563. name: string;
  101564. shader: string;
  101565. };
  101566. }
  101567. declare module BABYLON {
  101568. /** @hidden */
  101569. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101570. MAINUV1: boolean;
  101571. MAINUV2: boolean;
  101572. DIFFUSE: boolean;
  101573. DIFFUSEDIRECTUV: number;
  101574. AMBIENT: boolean;
  101575. AMBIENTDIRECTUV: number;
  101576. OPACITY: boolean;
  101577. OPACITYDIRECTUV: number;
  101578. OPACITYRGB: boolean;
  101579. REFLECTION: boolean;
  101580. EMISSIVE: boolean;
  101581. EMISSIVEDIRECTUV: number;
  101582. SPECULAR: boolean;
  101583. SPECULARDIRECTUV: number;
  101584. BUMP: boolean;
  101585. BUMPDIRECTUV: number;
  101586. PARALLAX: boolean;
  101587. PARALLAXOCCLUSION: boolean;
  101588. SPECULAROVERALPHA: boolean;
  101589. CLIPPLANE: boolean;
  101590. CLIPPLANE2: boolean;
  101591. CLIPPLANE3: boolean;
  101592. CLIPPLANE4: boolean;
  101593. ALPHATEST: boolean;
  101594. DEPTHPREPASS: boolean;
  101595. ALPHAFROMDIFFUSE: boolean;
  101596. POINTSIZE: boolean;
  101597. FOG: boolean;
  101598. SPECULARTERM: boolean;
  101599. DIFFUSEFRESNEL: boolean;
  101600. OPACITYFRESNEL: boolean;
  101601. REFLECTIONFRESNEL: boolean;
  101602. REFRACTIONFRESNEL: boolean;
  101603. EMISSIVEFRESNEL: boolean;
  101604. FRESNEL: boolean;
  101605. NORMAL: boolean;
  101606. UV1: boolean;
  101607. UV2: boolean;
  101608. VERTEXCOLOR: boolean;
  101609. VERTEXALPHA: boolean;
  101610. NUM_BONE_INFLUENCERS: number;
  101611. BonesPerMesh: number;
  101612. BONETEXTURE: boolean;
  101613. INSTANCES: boolean;
  101614. GLOSSINESS: boolean;
  101615. ROUGHNESS: boolean;
  101616. EMISSIVEASILLUMINATION: boolean;
  101617. LINKEMISSIVEWITHDIFFUSE: boolean;
  101618. REFLECTIONFRESNELFROMSPECULAR: boolean;
  101619. LIGHTMAP: boolean;
  101620. LIGHTMAPDIRECTUV: number;
  101621. OBJECTSPACE_NORMALMAP: boolean;
  101622. USELIGHTMAPASSHADOWMAP: boolean;
  101623. REFLECTIONMAP_3D: boolean;
  101624. REFLECTIONMAP_SPHERICAL: boolean;
  101625. REFLECTIONMAP_PLANAR: boolean;
  101626. REFLECTIONMAP_CUBIC: boolean;
  101627. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  101628. REFLECTIONMAP_PROJECTION: boolean;
  101629. REFLECTIONMAP_SKYBOX: boolean;
  101630. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  101631. REFLECTIONMAP_EXPLICIT: boolean;
  101632. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  101633. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  101634. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  101635. INVERTCUBICMAP: boolean;
  101636. LOGARITHMICDEPTH: boolean;
  101637. REFRACTION: boolean;
  101638. REFRACTIONMAP_3D: boolean;
  101639. REFLECTIONOVERALPHA: boolean;
  101640. TWOSIDEDLIGHTING: boolean;
  101641. SHADOWFLOAT: boolean;
  101642. MORPHTARGETS: boolean;
  101643. MORPHTARGETS_NORMAL: boolean;
  101644. MORPHTARGETS_TANGENT: boolean;
  101645. NUM_MORPH_INFLUENCERS: number;
  101646. NONUNIFORMSCALING: boolean;
  101647. PREMULTIPLYALPHA: boolean;
  101648. IMAGEPROCESSING: boolean;
  101649. VIGNETTE: boolean;
  101650. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101651. VIGNETTEBLENDMODEOPAQUE: boolean;
  101652. TONEMAPPING: boolean;
  101653. TONEMAPPING_ACES: boolean;
  101654. CONTRAST: boolean;
  101655. COLORCURVES: boolean;
  101656. COLORGRADING: boolean;
  101657. COLORGRADING3D: boolean;
  101658. SAMPLER3DGREENDEPTH: boolean;
  101659. SAMPLER3DBGRMAP: boolean;
  101660. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101661. MULTIVIEW: boolean;
  101662. /**
  101663. * If the reflection texture on this material is in linear color space
  101664. * @hidden
  101665. */
  101666. IS_REFLECTION_LINEAR: boolean;
  101667. /**
  101668. * If the refraction texture on this material is in linear color space
  101669. * @hidden
  101670. */
  101671. IS_REFRACTION_LINEAR: boolean;
  101672. EXPOSURE: boolean;
  101673. constructor();
  101674. setReflectionMode(modeToEnable: string): void;
  101675. }
  101676. /**
  101677. * This is the default material used in Babylon. It is the best trade off between quality
  101678. * and performances.
  101679. * @see http://doc.babylonjs.com/babylon101/materials
  101680. */
  101681. export class StandardMaterial extends PushMaterial {
  101682. private _diffuseTexture;
  101683. /**
  101684. * The basic texture of the material as viewed under a light.
  101685. */
  101686. diffuseTexture: Nullable<BaseTexture>;
  101687. private _ambientTexture;
  101688. /**
  101689. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  101690. */
  101691. ambientTexture: Nullable<BaseTexture>;
  101692. private _opacityTexture;
  101693. /**
  101694. * Define the transparency of the material from a texture.
  101695. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  101696. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  101697. */
  101698. opacityTexture: Nullable<BaseTexture>;
  101699. private _reflectionTexture;
  101700. /**
  101701. * Define the texture used to display the reflection.
  101702. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101703. */
  101704. reflectionTexture: Nullable<BaseTexture>;
  101705. private _emissiveTexture;
  101706. /**
  101707. * Define texture of the material as if self lit.
  101708. * This will be mixed in the final result even in the absence of light.
  101709. */
  101710. emissiveTexture: Nullable<BaseTexture>;
  101711. private _specularTexture;
  101712. /**
  101713. * Define how the color and intensity of the highlight given by the light in the material.
  101714. */
  101715. specularTexture: Nullable<BaseTexture>;
  101716. private _bumpTexture;
  101717. /**
  101718. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101719. * 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.
  101720. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101721. */
  101722. bumpTexture: Nullable<BaseTexture>;
  101723. private _lightmapTexture;
  101724. /**
  101725. * Complex lighting can be computationally expensive to compute at runtime.
  101726. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101727. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101728. */
  101729. lightmapTexture: Nullable<BaseTexture>;
  101730. private _refractionTexture;
  101731. /**
  101732. * Define the texture used to display the refraction.
  101733. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101734. */
  101735. refractionTexture: Nullable<BaseTexture>;
  101736. /**
  101737. * The color of the material lit by the environmental background lighting.
  101738. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101739. */
  101740. ambientColor: Color3;
  101741. /**
  101742. * The basic color of the material as viewed under a light.
  101743. */
  101744. diffuseColor: Color3;
  101745. /**
  101746. * Define how the color and intensity of the highlight given by the light in the material.
  101747. */
  101748. specularColor: Color3;
  101749. /**
  101750. * Define the color of the material as if self lit.
  101751. * This will be mixed in the final result even in the absence of light.
  101752. */
  101753. emissiveColor: Color3;
  101754. /**
  101755. * Defines how sharp are the highlights in the material.
  101756. * The bigger the value the sharper giving a more glossy feeling to the result.
  101757. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101758. */
  101759. specularPower: number;
  101760. private _useAlphaFromDiffuseTexture;
  101761. /**
  101762. * Does the transparency come from the diffuse texture alpha channel.
  101763. */
  101764. useAlphaFromDiffuseTexture: boolean;
  101765. private _useEmissiveAsIllumination;
  101766. /**
  101767. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101768. */
  101769. useEmissiveAsIllumination: boolean;
  101770. private _linkEmissiveWithDiffuse;
  101771. /**
  101772. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101773. * the emissive level when the final color is close to one.
  101774. */
  101775. linkEmissiveWithDiffuse: boolean;
  101776. private _useSpecularOverAlpha;
  101777. /**
  101778. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101779. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101780. */
  101781. useSpecularOverAlpha: boolean;
  101782. private _useReflectionOverAlpha;
  101783. /**
  101784. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101785. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101786. */
  101787. useReflectionOverAlpha: boolean;
  101788. private _disableLighting;
  101789. /**
  101790. * Does lights from the scene impacts this material.
  101791. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101792. */
  101793. disableLighting: boolean;
  101794. private _useObjectSpaceNormalMap;
  101795. /**
  101796. * Allows using an object space normal map (instead of tangent space).
  101797. */
  101798. useObjectSpaceNormalMap: boolean;
  101799. private _useParallax;
  101800. /**
  101801. * Is parallax enabled or not.
  101802. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101803. */
  101804. useParallax: boolean;
  101805. private _useParallaxOcclusion;
  101806. /**
  101807. * Is parallax occlusion enabled or not.
  101808. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101809. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101810. */
  101811. useParallaxOcclusion: boolean;
  101812. /**
  101813. * 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.
  101814. */
  101815. parallaxScaleBias: number;
  101816. private _roughness;
  101817. /**
  101818. * Helps to define how blurry the reflections should appears in the material.
  101819. */
  101820. roughness: number;
  101821. /**
  101822. * In case of refraction, define the value of the index of refraction.
  101823. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101824. */
  101825. indexOfRefraction: number;
  101826. /**
  101827. * Invert the refraction texture alongside the y axis.
  101828. * It can be useful with procedural textures or probe for instance.
  101829. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101830. */
  101831. invertRefractionY: boolean;
  101832. /**
  101833. * Defines the alpha limits in alpha test mode.
  101834. */
  101835. alphaCutOff: number;
  101836. private _useLightmapAsShadowmap;
  101837. /**
  101838. * In case of light mapping, define whether the map contains light or shadow informations.
  101839. */
  101840. useLightmapAsShadowmap: boolean;
  101841. private _diffuseFresnelParameters;
  101842. /**
  101843. * Define the diffuse fresnel parameters of the material.
  101844. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101845. */
  101846. diffuseFresnelParameters: FresnelParameters;
  101847. private _opacityFresnelParameters;
  101848. /**
  101849. * Define the opacity fresnel parameters of the material.
  101850. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101851. */
  101852. opacityFresnelParameters: FresnelParameters;
  101853. private _reflectionFresnelParameters;
  101854. /**
  101855. * Define the reflection fresnel parameters of the material.
  101856. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101857. */
  101858. reflectionFresnelParameters: FresnelParameters;
  101859. private _refractionFresnelParameters;
  101860. /**
  101861. * Define the refraction fresnel parameters of the material.
  101862. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101863. */
  101864. refractionFresnelParameters: FresnelParameters;
  101865. private _emissiveFresnelParameters;
  101866. /**
  101867. * Define the emissive fresnel parameters of the material.
  101868. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101869. */
  101870. emissiveFresnelParameters: FresnelParameters;
  101871. private _useReflectionFresnelFromSpecular;
  101872. /**
  101873. * If true automatically deducts the fresnels values from the material specularity.
  101874. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101875. */
  101876. useReflectionFresnelFromSpecular: boolean;
  101877. private _useGlossinessFromSpecularMapAlpha;
  101878. /**
  101879. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101880. */
  101881. useGlossinessFromSpecularMapAlpha: boolean;
  101882. private _maxSimultaneousLights;
  101883. /**
  101884. * Defines the maximum number of lights that can be used in the material
  101885. */
  101886. maxSimultaneousLights: number;
  101887. private _invertNormalMapX;
  101888. /**
  101889. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101890. */
  101891. invertNormalMapX: boolean;
  101892. private _invertNormalMapY;
  101893. /**
  101894. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101895. */
  101896. invertNormalMapY: boolean;
  101897. private _twoSidedLighting;
  101898. /**
  101899. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101900. */
  101901. twoSidedLighting: boolean;
  101902. /**
  101903. * Default configuration related to image processing available in the standard Material.
  101904. */
  101905. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101906. /**
  101907. * Gets the image processing configuration used either in this material.
  101908. */
  101909. /**
  101910. * Sets the Default image processing configuration used either in the this material.
  101911. *
  101912. * If sets to null, the scene one is in use.
  101913. */
  101914. imageProcessingConfiguration: ImageProcessingConfiguration;
  101915. /**
  101916. * Keep track of the image processing observer to allow dispose and replace.
  101917. */
  101918. private _imageProcessingObserver;
  101919. /**
  101920. * Attaches a new image processing configuration to the Standard Material.
  101921. * @param configuration
  101922. */
  101923. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101924. /**
  101925. * Gets wether the color curves effect is enabled.
  101926. */
  101927. /**
  101928. * Sets wether the color curves effect is enabled.
  101929. */
  101930. cameraColorCurvesEnabled: boolean;
  101931. /**
  101932. * Gets wether the color grading effect is enabled.
  101933. */
  101934. /**
  101935. * Gets wether the color grading effect is enabled.
  101936. */
  101937. cameraColorGradingEnabled: boolean;
  101938. /**
  101939. * Gets wether tonemapping is enabled or not.
  101940. */
  101941. /**
  101942. * Sets wether tonemapping is enabled or not
  101943. */
  101944. cameraToneMappingEnabled: boolean;
  101945. /**
  101946. * The camera exposure used on this material.
  101947. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101948. * This corresponds to a photographic exposure.
  101949. */
  101950. /**
  101951. * The camera exposure used on this material.
  101952. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101953. * This corresponds to a photographic exposure.
  101954. */
  101955. cameraExposure: number;
  101956. /**
  101957. * Gets The camera contrast used on this material.
  101958. */
  101959. /**
  101960. * Sets The camera contrast used on this material.
  101961. */
  101962. cameraContrast: number;
  101963. /**
  101964. * Gets the Color Grading 2D Lookup Texture.
  101965. */
  101966. /**
  101967. * Sets the Color Grading 2D Lookup Texture.
  101968. */
  101969. cameraColorGradingTexture: Nullable<BaseTexture>;
  101970. /**
  101971. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101972. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101973. * 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;
  101974. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101975. */
  101976. /**
  101977. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101978. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101979. * 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;
  101980. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101981. */
  101982. cameraColorCurves: Nullable<ColorCurves>;
  101983. /**
  101984. * Custom callback helping to override the default shader used in the material.
  101985. */
  101986. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  101987. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101988. protected _worldViewProjectionMatrix: Matrix;
  101989. protected _globalAmbientColor: Color3;
  101990. protected _useLogarithmicDepth: boolean;
  101991. /**
  101992. * Instantiates a new standard material.
  101993. * This is the default material used in Babylon. It is the best trade off between quality
  101994. * and performances.
  101995. * @see http://doc.babylonjs.com/babylon101/materials
  101996. * @param name Define the name of the material in the scene
  101997. * @param scene Define the scene the material belong to
  101998. */
  101999. constructor(name: string, scene: Scene);
  102000. /**
  102001. * Gets a boolean indicating that current material needs to register RTT
  102002. */
  102003. readonly hasRenderTargetTextures: boolean;
  102004. /**
  102005. * Gets the current class name of the material e.g. "StandardMaterial"
  102006. * Mainly use in serialization.
  102007. * @returns the class name
  102008. */
  102009. getClassName(): string;
  102010. /**
  102011. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  102012. * You can try switching to logarithmic depth.
  102013. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  102014. */
  102015. useLogarithmicDepth: boolean;
  102016. /**
  102017. * Specifies if the material will require alpha blending
  102018. * @returns a boolean specifying if alpha blending is needed
  102019. */
  102020. needAlphaBlending(): boolean;
  102021. /**
  102022. * Specifies if this material should be rendered in alpha test mode
  102023. * @returns a boolean specifying if an alpha test is needed.
  102024. */
  102025. needAlphaTesting(): boolean;
  102026. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  102027. /**
  102028. * Get the texture used for alpha test purpose.
  102029. * @returns the diffuse texture in case of the standard material.
  102030. */
  102031. getAlphaTestTexture(): Nullable<BaseTexture>;
  102032. /**
  102033. * Get if the submesh is ready to be used and all its information available.
  102034. * Child classes can use it to update shaders
  102035. * @param mesh defines the mesh to check
  102036. * @param subMesh defines which submesh to check
  102037. * @param useInstances specifies that instances should be used
  102038. * @returns a boolean indicating that the submesh is ready or not
  102039. */
  102040. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102041. /**
  102042. * Builds the material UBO layouts.
  102043. * Used internally during the effect preparation.
  102044. */
  102045. buildUniformLayout(): void;
  102046. /**
  102047. * Unbinds the material from the mesh
  102048. */
  102049. unbind(): void;
  102050. /**
  102051. * Binds the submesh to this material by preparing the effect and shader to draw
  102052. * @param world defines the world transformation matrix
  102053. * @param mesh defines the mesh containing the submesh
  102054. * @param subMesh defines the submesh to bind the material to
  102055. */
  102056. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102057. /**
  102058. * Get the list of animatables in the material.
  102059. * @returns the list of animatables object used in the material
  102060. */
  102061. getAnimatables(): IAnimatable[];
  102062. /**
  102063. * Gets the active textures from the material
  102064. * @returns an array of textures
  102065. */
  102066. getActiveTextures(): BaseTexture[];
  102067. /**
  102068. * Specifies if the material uses a texture
  102069. * @param texture defines the texture to check against the material
  102070. * @returns a boolean specifying if the material uses the texture
  102071. */
  102072. hasTexture(texture: BaseTexture): boolean;
  102073. /**
  102074. * Disposes the material
  102075. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102076. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102077. */
  102078. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102079. /**
  102080. * Makes a duplicate of the material, and gives it a new name
  102081. * @param name defines the new name for the duplicated material
  102082. * @returns the cloned material
  102083. */
  102084. clone(name: string): StandardMaterial;
  102085. /**
  102086. * Serializes this material in a JSON representation
  102087. * @returns the serialized material object
  102088. */
  102089. serialize(): any;
  102090. /**
  102091. * Creates a standard material from parsed material data
  102092. * @param source defines the JSON representation of the material
  102093. * @param scene defines the hosting scene
  102094. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102095. * @returns a new standard material
  102096. */
  102097. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  102098. /**
  102099. * Are diffuse textures enabled in the application.
  102100. */
  102101. static DiffuseTextureEnabled: boolean;
  102102. /**
  102103. * Are ambient textures enabled in the application.
  102104. */
  102105. static AmbientTextureEnabled: boolean;
  102106. /**
  102107. * Are opacity textures enabled in the application.
  102108. */
  102109. static OpacityTextureEnabled: boolean;
  102110. /**
  102111. * Are reflection textures enabled in the application.
  102112. */
  102113. static ReflectionTextureEnabled: boolean;
  102114. /**
  102115. * Are emissive textures enabled in the application.
  102116. */
  102117. static EmissiveTextureEnabled: boolean;
  102118. /**
  102119. * Are specular textures enabled in the application.
  102120. */
  102121. static SpecularTextureEnabled: boolean;
  102122. /**
  102123. * Are bump textures enabled in the application.
  102124. */
  102125. static BumpTextureEnabled: boolean;
  102126. /**
  102127. * Are lightmap textures enabled in the application.
  102128. */
  102129. static LightmapTextureEnabled: boolean;
  102130. /**
  102131. * Are refraction textures enabled in the application.
  102132. */
  102133. static RefractionTextureEnabled: boolean;
  102134. /**
  102135. * Are color grading textures enabled in the application.
  102136. */
  102137. static ColorGradingTextureEnabled: boolean;
  102138. /**
  102139. * Are fresnels enabled in the application.
  102140. */
  102141. static FresnelEnabled: boolean;
  102142. }
  102143. }
  102144. declare module BABYLON {
  102145. /**
  102146. * A class extending Texture allowing drawing on a texture
  102147. * @see http://doc.babylonjs.com/how_to/dynamictexture
  102148. */
  102149. export class DynamicTexture extends Texture {
  102150. private _generateMipMaps;
  102151. private _canvas;
  102152. private _context;
  102153. private _engine;
  102154. /**
  102155. * Creates a DynamicTexture
  102156. * @param name defines the name of the texture
  102157. * @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
  102158. * @param scene defines the scene where you want the texture
  102159. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  102160. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  102161. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  102162. */
  102163. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  102164. /**
  102165. * Get the current class name of the texture useful for serialization or dynamic coding.
  102166. * @returns "DynamicTexture"
  102167. */
  102168. getClassName(): string;
  102169. /**
  102170. * Gets the current state of canRescale
  102171. */
  102172. readonly canRescale: boolean;
  102173. private _recreate;
  102174. /**
  102175. * Scales the texture
  102176. * @param ratio the scale factor to apply to both width and height
  102177. */
  102178. scale(ratio: number): void;
  102179. /**
  102180. * Resizes the texture
  102181. * @param width the new width
  102182. * @param height the new height
  102183. */
  102184. scaleTo(width: number, height: number): void;
  102185. /**
  102186. * Gets the context of the canvas used by the texture
  102187. * @returns the canvas context of the dynamic texture
  102188. */
  102189. getContext(): CanvasRenderingContext2D;
  102190. /**
  102191. * Clears the texture
  102192. */
  102193. clear(): void;
  102194. /**
  102195. * Updates the texture
  102196. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102197. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  102198. */
  102199. update(invertY?: boolean, premulAlpha?: boolean): void;
  102200. /**
  102201. * Draws text onto the texture
  102202. * @param text defines the text to be drawn
  102203. * @param x defines the placement of the text from the left
  102204. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  102205. * @param font defines the font to be used with font-style, font-size, font-name
  102206. * @param color defines the color used for the text
  102207. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  102208. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102209. * @param update defines whether texture is immediately update (default is true)
  102210. */
  102211. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  102212. /**
  102213. * Clones the texture
  102214. * @returns the clone of the texture.
  102215. */
  102216. clone(): DynamicTexture;
  102217. /**
  102218. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  102219. * @returns a serialized dynamic texture object
  102220. */
  102221. serialize(): any;
  102222. /** @hidden */
  102223. _rebuild(): void;
  102224. }
  102225. }
  102226. declare module BABYLON {
  102227. /** @hidden */
  102228. export var imageProcessingPixelShader: {
  102229. name: string;
  102230. shader: string;
  102231. };
  102232. }
  102233. declare module BABYLON {
  102234. /**
  102235. * ImageProcessingPostProcess
  102236. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102237. */
  102238. export class ImageProcessingPostProcess extends PostProcess {
  102239. /**
  102240. * Default configuration related to image processing available in the PBR Material.
  102241. */
  102242. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102243. /**
  102244. * Gets the image processing configuration used either in this material.
  102245. */
  102246. /**
  102247. * Sets the Default image processing configuration used either in the this material.
  102248. *
  102249. * If sets to null, the scene one is in use.
  102250. */
  102251. imageProcessingConfiguration: ImageProcessingConfiguration;
  102252. /**
  102253. * Keep track of the image processing observer to allow dispose and replace.
  102254. */
  102255. private _imageProcessingObserver;
  102256. /**
  102257. * Attaches a new image processing configuration to the PBR Material.
  102258. * @param configuration
  102259. */
  102260. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102261. /**
  102262. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102263. */
  102264. /**
  102265. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102266. */
  102267. colorCurves: Nullable<ColorCurves>;
  102268. /**
  102269. * Gets wether the color curves effect is enabled.
  102270. */
  102271. /**
  102272. * Sets wether the color curves effect is enabled.
  102273. */
  102274. colorCurvesEnabled: boolean;
  102275. /**
  102276. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102277. */
  102278. /**
  102279. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102280. */
  102281. colorGradingTexture: Nullable<BaseTexture>;
  102282. /**
  102283. * Gets wether the color grading effect is enabled.
  102284. */
  102285. /**
  102286. * Gets wether the color grading effect is enabled.
  102287. */
  102288. colorGradingEnabled: boolean;
  102289. /**
  102290. * Gets exposure used in the effect.
  102291. */
  102292. /**
  102293. * Sets exposure used in the effect.
  102294. */
  102295. exposure: number;
  102296. /**
  102297. * Gets wether tonemapping is enabled or not.
  102298. */
  102299. /**
  102300. * Sets wether tonemapping is enabled or not
  102301. */
  102302. toneMappingEnabled: boolean;
  102303. /**
  102304. * Gets the type of tone mapping effect.
  102305. */
  102306. /**
  102307. * Sets the type of tone mapping effect.
  102308. */
  102309. toneMappingType: number;
  102310. /**
  102311. * Gets contrast used in the effect.
  102312. */
  102313. /**
  102314. * Sets contrast used in the effect.
  102315. */
  102316. contrast: number;
  102317. /**
  102318. * Gets Vignette stretch size.
  102319. */
  102320. /**
  102321. * Sets Vignette stretch size.
  102322. */
  102323. vignetteStretch: number;
  102324. /**
  102325. * Gets Vignette centre X Offset.
  102326. */
  102327. /**
  102328. * Sets Vignette centre X Offset.
  102329. */
  102330. vignetteCentreX: number;
  102331. /**
  102332. * Gets Vignette centre Y Offset.
  102333. */
  102334. /**
  102335. * Sets Vignette centre Y Offset.
  102336. */
  102337. vignetteCentreY: number;
  102338. /**
  102339. * Gets Vignette weight or intensity of the vignette effect.
  102340. */
  102341. /**
  102342. * Sets Vignette weight or intensity of the vignette effect.
  102343. */
  102344. vignetteWeight: number;
  102345. /**
  102346. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102347. * if vignetteEnabled is set to true.
  102348. */
  102349. /**
  102350. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102351. * if vignetteEnabled is set to true.
  102352. */
  102353. vignetteColor: Color4;
  102354. /**
  102355. * Gets Camera field of view used by the Vignette effect.
  102356. */
  102357. /**
  102358. * Sets Camera field of view used by the Vignette effect.
  102359. */
  102360. vignetteCameraFov: number;
  102361. /**
  102362. * Gets the vignette blend mode allowing different kind of effect.
  102363. */
  102364. /**
  102365. * Sets the vignette blend mode allowing different kind of effect.
  102366. */
  102367. vignetteBlendMode: number;
  102368. /**
  102369. * Gets wether the vignette effect is enabled.
  102370. */
  102371. /**
  102372. * Sets wether the vignette effect is enabled.
  102373. */
  102374. vignetteEnabled: boolean;
  102375. private _fromLinearSpace;
  102376. /**
  102377. * Gets wether the input of the processing is in Gamma or Linear Space.
  102378. */
  102379. /**
  102380. * Sets wether the input of the processing is in Gamma or Linear Space.
  102381. */
  102382. fromLinearSpace: boolean;
  102383. /**
  102384. * Defines cache preventing GC.
  102385. */
  102386. private _defines;
  102387. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102388. /**
  102389. * "ImageProcessingPostProcess"
  102390. * @returns "ImageProcessingPostProcess"
  102391. */
  102392. getClassName(): string;
  102393. protected _updateParameters(): void;
  102394. dispose(camera?: Camera): void;
  102395. }
  102396. }
  102397. declare module BABYLON {
  102398. /**
  102399. * Class containing static functions to help procedurally build meshes
  102400. */
  102401. export class GroundBuilder {
  102402. /**
  102403. * Creates a ground mesh
  102404. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102405. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102407. * @param name defines the name of the mesh
  102408. * @param options defines the options used to create the mesh
  102409. * @param scene defines the hosting scene
  102410. * @returns the ground mesh
  102411. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102412. */
  102413. static CreateGround(name: string, options: {
  102414. width?: number;
  102415. height?: number;
  102416. subdivisions?: number;
  102417. subdivisionsX?: number;
  102418. subdivisionsY?: number;
  102419. updatable?: boolean;
  102420. }, scene: any): Mesh;
  102421. /**
  102422. * Creates a tiled ground mesh
  102423. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102424. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102425. * * 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
  102426. * * 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
  102427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102428. * @param name defines the name of the mesh
  102429. * @param options defines the options used to create the mesh
  102430. * @param scene defines the hosting scene
  102431. * @returns the tiled ground mesh
  102432. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102433. */
  102434. static CreateTiledGround(name: string, options: {
  102435. xmin: number;
  102436. zmin: number;
  102437. xmax: number;
  102438. zmax: number;
  102439. subdivisions?: {
  102440. w: number;
  102441. h: number;
  102442. };
  102443. precision?: {
  102444. w: number;
  102445. h: number;
  102446. };
  102447. updatable?: boolean;
  102448. }, scene?: Nullable<Scene>): Mesh;
  102449. /**
  102450. * Creates a ground mesh from a height map
  102451. * * The parameter `url` sets the URL of the height map image resource.
  102452. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  102453. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  102454. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  102455. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  102456. * * 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.
  102457. * * 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).
  102458. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  102459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102460. * @param name defines the name of the mesh
  102461. * @param url defines the url to the height map
  102462. * @param options defines the options used to create the mesh
  102463. * @param scene defines the hosting scene
  102464. * @returns the ground mesh
  102465. * @see https://doc.babylonjs.com/babylon101/height_map
  102466. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  102467. */
  102468. static CreateGroundFromHeightMap(name: string, url: string, options: {
  102469. width?: number;
  102470. height?: number;
  102471. subdivisions?: number;
  102472. minHeight?: number;
  102473. maxHeight?: number;
  102474. colorFilter?: Color3;
  102475. alphaFilter?: number;
  102476. updatable?: boolean;
  102477. onReady?: (mesh: GroundMesh) => void;
  102478. }, scene?: Nullable<Scene>): GroundMesh;
  102479. }
  102480. }
  102481. declare module BABYLON {
  102482. /**
  102483. * Class containing static functions to help procedurally build meshes
  102484. */
  102485. export class TorusBuilder {
  102486. /**
  102487. * Creates a torus mesh
  102488. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  102489. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  102490. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  102491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102494. * @param name defines the name of the mesh
  102495. * @param options defines the options used to create the mesh
  102496. * @param scene defines the hosting scene
  102497. * @returns the torus mesh
  102498. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  102499. */
  102500. static CreateTorus(name: string, options: {
  102501. diameter?: number;
  102502. thickness?: number;
  102503. tessellation?: number;
  102504. updatable?: boolean;
  102505. sideOrientation?: number;
  102506. frontUVs?: Vector4;
  102507. backUVs?: Vector4;
  102508. }, scene: any): Mesh;
  102509. }
  102510. }
  102511. declare module BABYLON {
  102512. /**
  102513. * Class containing static functions to help procedurally build meshes
  102514. */
  102515. export class CylinderBuilder {
  102516. /**
  102517. * Creates a cylinder or a cone mesh
  102518. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  102519. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  102520. * * 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.
  102521. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  102522. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  102523. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  102524. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  102525. * * 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).
  102526. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  102527. * * 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).
  102528. * * 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
  102529. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  102530. * * 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
  102531. * * 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.
  102532. * * If `enclose` is false, a ring surface is one element.
  102533. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  102534. * * 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
  102535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102536. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102538. * @param name defines the name of the mesh
  102539. * @param options defines the options used to create the mesh
  102540. * @param scene defines the hosting scene
  102541. * @returns the cylinder mesh
  102542. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  102543. */
  102544. static CreateCylinder(name: string, options: {
  102545. height?: number;
  102546. diameterTop?: number;
  102547. diameterBottom?: number;
  102548. diameter?: number;
  102549. tessellation?: number;
  102550. subdivisions?: number;
  102551. arc?: number;
  102552. faceColors?: Color4[];
  102553. faceUV?: Vector4[];
  102554. updatable?: boolean;
  102555. hasRings?: boolean;
  102556. enclose?: boolean;
  102557. cap?: number;
  102558. sideOrientation?: number;
  102559. frontUVs?: Vector4;
  102560. backUVs?: Vector4;
  102561. }, scene: any): Mesh;
  102562. }
  102563. }
  102564. declare module BABYLON {
  102565. /**
  102566. * Options to modify the vr teleportation behavior.
  102567. */
  102568. export interface VRTeleportationOptions {
  102569. /**
  102570. * The name of the mesh which should be used as the teleportation floor. (default: null)
  102571. */
  102572. floorMeshName?: string;
  102573. /**
  102574. * A list of meshes to be used as the teleportation floor. (default: empty)
  102575. */
  102576. floorMeshes?: Mesh[];
  102577. }
  102578. /**
  102579. * Options to modify the vr experience helper's behavior.
  102580. */
  102581. export interface VRExperienceHelperOptions extends WebVROptions {
  102582. /**
  102583. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  102584. */
  102585. createDeviceOrientationCamera?: boolean;
  102586. /**
  102587. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  102588. */
  102589. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  102590. /**
  102591. * Uses the main button on the controller to toggle the laser casted. (default: true)
  102592. */
  102593. laserToggle?: boolean;
  102594. /**
  102595. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  102596. */
  102597. floorMeshes?: Mesh[];
  102598. /**
  102599. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  102600. */
  102601. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  102602. }
  102603. /**
  102604. * Event containing information after VR has been entered
  102605. */
  102606. export class OnAfterEnteringVRObservableEvent {
  102607. /**
  102608. * If entering vr was successful
  102609. */
  102610. success: boolean;
  102611. }
  102612. /**
  102613. * Helps to quickly add VR support to an existing scene.
  102614. * See http://doc.babylonjs.com/how_to/webvr_helper
  102615. */
  102616. export class VRExperienceHelper {
  102617. /** Options to modify the vr experience helper's behavior. */
  102618. webVROptions: VRExperienceHelperOptions;
  102619. private _scene;
  102620. private _position;
  102621. private _btnVR;
  102622. private _btnVRDisplayed;
  102623. private _webVRsupported;
  102624. private _webVRready;
  102625. private _webVRrequesting;
  102626. private _webVRpresenting;
  102627. private _hasEnteredVR;
  102628. private _fullscreenVRpresenting;
  102629. private _canvas;
  102630. private _webVRCamera;
  102631. private _vrDeviceOrientationCamera;
  102632. private _deviceOrientationCamera;
  102633. private _existingCamera;
  102634. private _onKeyDown;
  102635. private _onVrDisplayPresentChange;
  102636. private _onVRDisplayChanged;
  102637. private _onVRRequestPresentStart;
  102638. private _onVRRequestPresentComplete;
  102639. /**
  102640. * Observable raised right before entering VR.
  102641. */
  102642. onEnteringVRObservable: Observable<VRExperienceHelper>;
  102643. /**
  102644. * Observable raised when entering VR has completed.
  102645. */
  102646. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  102647. /**
  102648. * Observable raised when exiting VR.
  102649. */
  102650. onExitingVRObservable: Observable<VRExperienceHelper>;
  102651. /**
  102652. * Observable raised when controller mesh is loaded.
  102653. */
  102654. onControllerMeshLoadedObservable: Observable<WebVRController>;
  102655. /** Return this.onEnteringVRObservable
  102656. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  102657. */
  102658. readonly onEnteringVR: Observable<VRExperienceHelper>;
  102659. /** Return this.onExitingVRObservable
  102660. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  102661. */
  102662. readonly onExitingVR: Observable<VRExperienceHelper>;
  102663. /** Return this.onControllerMeshLoadedObservable
  102664. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  102665. */
  102666. readonly onControllerMeshLoaded: Observable<WebVRController>;
  102667. private _rayLength;
  102668. private _useCustomVRButton;
  102669. private _teleportationRequested;
  102670. private _teleportActive;
  102671. private _floorMeshName;
  102672. private _floorMeshesCollection;
  102673. private _rotationAllowed;
  102674. private _teleportBackwardsVector;
  102675. private _teleportationTarget;
  102676. private _isDefaultTeleportationTarget;
  102677. private _postProcessMove;
  102678. private _teleportationFillColor;
  102679. private _teleportationBorderColor;
  102680. private _rotationAngle;
  102681. private _haloCenter;
  102682. private _cameraGazer;
  102683. private _padSensibilityUp;
  102684. private _padSensibilityDown;
  102685. private _leftController;
  102686. private _rightController;
  102687. /**
  102688. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  102689. */
  102690. onNewMeshSelected: Observable<AbstractMesh>;
  102691. /**
  102692. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  102693. */
  102694. onNewMeshPicked: Observable<PickingInfo>;
  102695. private _circleEase;
  102696. /**
  102697. * Observable raised before camera teleportation
  102698. */
  102699. onBeforeCameraTeleport: Observable<Vector3>;
  102700. /**
  102701. * Observable raised after camera teleportation
  102702. */
  102703. onAfterCameraTeleport: Observable<Vector3>;
  102704. /**
  102705. * Observable raised when current selected mesh gets unselected
  102706. */
  102707. onSelectedMeshUnselected: Observable<AbstractMesh>;
  102708. private _raySelectionPredicate;
  102709. /**
  102710. * To be optionaly changed by user to define custom ray selection
  102711. */
  102712. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  102713. /**
  102714. * To be optionaly changed by user to define custom selection logic (after ray selection)
  102715. */
  102716. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  102717. /**
  102718. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  102719. */
  102720. teleportationEnabled: boolean;
  102721. private _defaultHeight;
  102722. private _teleportationInitialized;
  102723. private _interactionsEnabled;
  102724. private _interactionsRequested;
  102725. private _displayGaze;
  102726. private _displayLaserPointer;
  102727. /**
  102728. * The mesh used to display where the user is going to teleport.
  102729. */
  102730. /**
  102731. * Sets the mesh to be used to display where the user is going to teleport.
  102732. */
  102733. teleportationTarget: Mesh;
  102734. /**
  102735. * 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
  102736. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  102737. * See http://doc.babylonjs.com/resources/baking_transformations
  102738. */
  102739. gazeTrackerMesh: Mesh;
  102740. /**
  102741. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  102742. */
  102743. updateGazeTrackerScale: boolean;
  102744. /**
  102745. * If the gaze trackers color should be updated when selecting meshes
  102746. */
  102747. updateGazeTrackerColor: boolean;
  102748. /**
  102749. * The gaze tracking mesh corresponding to the left controller
  102750. */
  102751. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  102752. /**
  102753. * The gaze tracking mesh corresponding to the right controller
  102754. */
  102755. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  102756. /**
  102757. * If the ray of the gaze should be displayed.
  102758. */
  102759. /**
  102760. * Sets if the ray of the gaze should be displayed.
  102761. */
  102762. displayGaze: boolean;
  102763. /**
  102764. * If the ray of the LaserPointer should be displayed.
  102765. */
  102766. /**
  102767. * Sets if the ray of the LaserPointer should be displayed.
  102768. */
  102769. displayLaserPointer: boolean;
  102770. /**
  102771. * The deviceOrientationCamera used as the camera when not in VR.
  102772. */
  102773. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  102774. /**
  102775. * Based on the current WebVR support, returns the current VR camera used.
  102776. */
  102777. readonly currentVRCamera: Nullable<Camera>;
  102778. /**
  102779. * The webVRCamera which is used when in VR.
  102780. */
  102781. readonly webVRCamera: WebVRFreeCamera;
  102782. /**
  102783. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  102784. */
  102785. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  102786. private readonly _teleportationRequestInitiated;
  102787. /**
  102788. * Defines wether or not Pointer lock should be requested when switching to
  102789. * full screen.
  102790. */
  102791. requestPointerLockOnFullScreen: boolean;
  102792. /**
  102793. * Instantiates a VRExperienceHelper.
  102794. * Helps to quickly add VR support to an existing scene.
  102795. * @param scene The scene the VRExperienceHelper belongs to.
  102796. * @param webVROptions Options to modify the vr experience helper's behavior.
  102797. */
  102798. constructor(scene: Scene,
  102799. /** Options to modify the vr experience helper's behavior. */
  102800. webVROptions?: VRExperienceHelperOptions);
  102801. private _onDefaultMeshLoaded;
  102802. private _onResize;
  102803. private _onFullscreenChange;
  102804. /**
  102805. * Gets a value indicating if we are currently in VR mode.
  102806. */
  102807. readonly isInVRMode: boolean;
  102808. private onVrDisplayPresentChange;
  102809. private onVRDisplayChanged;
  102810. private moveButtonToBottomRight;
  102811. private displayVRButton;
  102812. private updateButtonVisibility;
  102813. private _cachedAngularSensibility;
  102814. /**
  102815. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  102816. * Otherwise, will use the fullscreen API.
  102817. */
  102818. enterVR(): void;
  102819. /**
  102820. * Attempt to exit VR, or fullscreen.
  102821. */
  102822. exitVR(): void;
  102823. /**
  102824. * The position of the vr experience helper.
  102825. */
  102826. /**
  102827. * Sets the position of the vr experience helper.
  102828. */
  102829. position: Vector3;
  102830. /**
  102831. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  102832. */
  102833. enableInteractions(): void;
  102834. private readonly _noControllerIsActive;
  102835. private beforeRender;
  102836. private _isTeleportationFloor;
  102837. /**
  102838. * Adds a floor mesh to be used for teleportation.
  102839. * @param floorMesh the mesh to be used for teleportation.
  102840. */
  102841. addFloorMesh(floorMesh: Mesh): void;
  102842. /**
  102843. * Removes a floor mesh from being used for teleportation.
  102844. * @param floorMesh the mesh to be removed.
  102845. */
  102846. removeFloorMesh(floorMesh: Mesh): void;
  102847. /**
  102848. * Enables interactions and teleportation using the VR controllers and gaze.
  102849. * @param vrTeleportationOptions options to modify teleportation behavior.
  102850. */
  102851. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  102852. private _onNewGamepadConnected;
  102853. private _tryEnableInteractionOnController;
  102854. private _onNewGamepadDisconnected;
  102855. private _enableInteractionOnController;
  102856. private _checkTeleportWithRay;
  102857. private _checkRotate;
  102858. private _checkTeleportBackwards;
  102859. private _enableTeleportationOnController;
  102860. private _createTeleportationCircles;
  102861. private _displayTeleportationTarget;
  102862. private _hideTeleportationTarget;
  102863. private _rotateCamera;
  102864. private _moveTeleportationSelectorTo;
  102865. private _workingVector;
  102866. private _workingQuaternion;
  102867. private _workingMatrix;
  102868. /**
  102869. * Teleports the users feet to the desired location
  102870. * @param location The location where the user's feet should be placed
  102871. */
  102872. teleportCamera(location: Vector3): void;
  102873. private _convertNormalToDirectionOfRay;
  102874. private _castRayAndSelectObject;
  102875. private _notifySelectedMeshUnselected;
  102876. /**
  102877. * Sets the color of the laser ray from the vr controllers.
  102878. * @param color new color for the ray.
  102879. */
  102880. changeLaserColor(color: Color3): void;
  102881. /**
  102882. * Sets the color of the ray from the vr headsets gaze.
  102883. * @param color new color for the ray.
  102884. */
  102885. changeGazeColor(color: Color3): void;
  102886. /**
  102887. * Exits VR and disposes of the vr experience helper
  102888. */
  102889. dispose(): void;
  102890. /**
  102891. * Gets the name of the VRExperienceHelper class
  102892. * @returns "VRExperienceHelper"
  102893. */
  102894. getClassName(): string;
  102895. }
  102896. }
  102897. declare module BABYLON {
  102898. /**
  102899. * Manages an XRSession
  102900. * @see https://doc.babylonjs.com/how_to/webxr
  102901. */
  102902. export class WebXRSessionManager implements IDisposable {
  102903. private scene;
  102904. /**
  102905. * Fires every time a new xrFrame arrives which can be used to update the camera
  102906. */
  102907. onXRFrameObservable: Observable<any>;
  102908. /**
  102909. * Fires when the xr session is ended either by the device or manually done
  102910. */
  102911. onXRSessionEnded: Observable<any>;
  102912. /** @hidden */
  102913. _xrSession: XRSession;
  102914. /** @hidden */
  102915. _frameOfReference: XRFrameOfReference;
  102916. /** @hidden */
  102917. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  102918. /** @hidden */
  102919. _currentXRFrame: Nullable<XRFrame>;
  102920. private _xrNavigator;
  102921. private _xrDevice;
  102922. private _tmpMatrix;
  102923. /**
  102924. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  102925. * @param scene The scene which the session should be created for
  102926. */
  102927. constructor(scene: Scene);
  102928. /**
  102929. * Initializes the manager
  102930. * After initialization enterXR can be called to start an XR session
  102931. * @returns Promise which resolves after it is initialized
  102932. */
  102933. initializeAsync(): Promise<void>;
  102934. /**
  102935. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  102936. * @param sessionCreationOptions xr options to create the session with
  102937. * @param frameOfReferenceType option to configure how the xr pose is expressed
  102938. * @returns Promise which resolves after it enters XR
  102939. */
  102940. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  102941. /**
  102942. * Stops the xrSession and restores the renderloop
  102943. * @returns Promise which resolves after it exits XR
  102944. */
  102945. exitXRAsync(): Promise<void>;
  102946. /**
  102947. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  102948. * @param ray ray to cast into the environment
  102949. * @returns Promise which resolves with a collision point in the environment if it exists
  102950. */
  102951. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  102952. /**
  102953. * Checks if a session would be supported for the creation options specified
  102954. * @param options creation options to check if they are supported
  102955. * @returns true if supported
  102956. */
  102957. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  102958. /**
  102959. * @hidden
  102960. * Converts the render layer of xrSession to a render target
  102961. * @param session session to create render target for
  102962. * @param scene scene the new render target should be created for
  102963. */
  102964. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  102965. /**
  102966. * Disposes of the session manager
  102967. */
  102968. dispose(): void;
  102969. }
  102970. }
  102971. declare module BABYLON {
  102972. /**
  102973. * WebXR Camera which holds the views for the xrSession
  102974. * @see https://doc.babylonjs.com/how_to/webxr
  102975. */
  102976. export class WebXRCamera extends FreeCamera {
  102977. private static _TmpMatrix;
  102978. /**
  102979. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  102980. * @param name the name of the camera
  102981. * @param scene the scene to add the camera to
  102982. */
  102983. constructor(name: string, scene: Scene);
  102984. private _updateNumberOfRigCameras;
  102985. /** @hidden */
  102986. _updateForDualEyeDebugging(pupilDistance?: number): void;
  102987. /**
  102988. * Updates the cameras position from the current pose information of the XR session
  102989. * @param xrSessionManager the session containing pose information
  102990. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  102991. */
  102992. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  102993. }
  102994. }
  102995. declare module BABYLON {
  102996. /**
  102997. * States of the webXR experience
  102998. */
  102999. export enum WebXRState {
  103000. /**
  103001. * Transitioning to being in XR mode
  103002. */
  103003. ENTERING_XR = 0,
  103004. /**
  103005. * Transitioning to non XR mode
  103006. */
  103007. EXITING_XR = 1,
  103008. /**
  103009. * In XR mode and presenting
  103010. */
  103011. IN_XR = 2,
  103012. /**
  103013. * Not entered XR mode
  103014. */
  103015. NOT_IN_XR = 3
  103016. }
  103017. /**
  103018. * Helper class used to enable XR
  103019. * @see https://doc.babylonjs.com/how_to/webxr
  103020. */
  103021. export class WebXRExperienceHelper implements IDisposable {
  103022. private scene;
  103023. /**
  103024. * 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
  103025. */
  103026. container: AbstractMesh;
  103027. /**
  103028. * Camera used to render xr content
  103029. */
  103030. camera: WebXRCamera;
  103031. /**
  103032. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  103033. */
  103034. state: WebXRState;
  103035. private _setState;
  103036. private static _TmpVector;
  103037. /**
  103038. * Fires when the state of the experience helper has changed
  103039. */
  103040. onStateChangedObservable: Observable<WebXRState>;
  103041. /** @hidden */
  103042. _sessionManager: WebXRSessionManager;
  103043. private _nonVRCamera;
  103044. private _originalSceneAutoClear;
  103045. private _supported;
  103046. /**
  103047. * Creates the experience helper
  103048. * @param scene the scene to attach the experience helper to
  103049. * @returns a promise for the experience helper
  103050. */
  103051. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  103052. /**
  103053. * Creates a WebXRExperienceHelper
  103054. * @param scene The scene the helper should be created in
  103055. */
  103056. private constructor();
  103057. /**
  103058. * Exits XR mode and returns the scene to its original state
  103059. * @returns promise that resolves after xr mode has exited
  103060. */
  103061. exitXRAsync(): Promise<void>;
  103062. /**
  103063. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  103064. * @param sessionCreationOptions options for the XR session
  103065. * @param frameOfReference frame of reference of the XR session
  103066. * @returns promise that resolves after xr mode has entered
  103067. */
  103068. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  103069. /**
  103070. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  103071. * @param ray ray to cast into the environment
  103072. * @returns Promise which resolves with a collision point in the environment if it exists
  103073. */
  103074. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  103075. /**
  103076. * Updates the global position of the camera by moving the camera's container
  103077. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  103078. * @param position The desired global position of the camera
  103079. */
  103080. setPositionOfCameraUsingContainer(position: Vector3): void;
  103081. /**
  103082. * Rotates the xr camera by rotating the camera's container around the camera's position
  103083. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  103084. * @param rotation the desired quaternion rotation to apply to the camera
  103085. */
  103086. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  103087. /**
  103088. * Checks if the creation options are supported by the xr session
  103089. * @param options creation options
  103090. * @returns true if supported
  103091. */
  103092. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  103093. /**
  103094. * Disposes of the experience helper
  103095. */
  103096. dispose(): void;
  103097. }
  103098. }
  103099. declare module BABYLON {
  103100. /**
  103101. * Button which can be used to enter a different mode of XR
  103102. */
  103103. export class WebXREnterExitUIButton {
  103104. /** button element */
  103105. element: HTMLElement;
  103106. /** XR initialization options for the button */
  103107. initializationOptions: XRSessionCreationOptions;
  103108. /**
  103109. * Creates a WebXREnterExitUIButton
  103110. * @param element button element
  103111. * @param initializationOptions XR initialization options for the button
  103112. */
  103113. constructor(
  103114. /** button element */
  103115. element: HTMLElement,
  103116. /** XR initialization options for the button */
  103117. initializationOptions: XRSessionCreationOptions);
  103118. /**
  103119. * Overwritable function which can be used to update the button's visuals when the state changes
  103120. * @param activeButton the current active button in the UI
  103121. */
  103122. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  103123. }
  103124. /**
  103125. * Options to create the webXR UI
  103126. */
  103127. export class WebXREnterExitUIOptions {
  103128. /**
  103129. * Context to enter xr with
  103130. */
  103131. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  103132. /**
  103133. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  103134. */
  103135. customButtons?: Array<WebXREnterExitUIButton>;
  103136. }
  103137. /**
  103138. * UI to allow the user to enter/exit XR mode
  103139. */
  103140. export class WebXREnterExitUI implements IDisposable {
  103141. private scene;
  103142. private _overlay;
  103143. private _buttons;
  103144. private _activeButton;
  103145. /**
  103146. * Fired every time the active button is changed.
  103147. *
  103148. * When xr is entered via a button that launches xr that button will be the callback parameter
  103149. *
  103150. * When exiting xr the callback parameter will be null)
  103151. */
  103152. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  103153. /**
  103154. * Creates UI to allow the user to enter/exit XR mode
  103155. * @param scene the scene to add the ui to
  103156. * @param helper the xr experience helper to enter/exit xr with
  103157. * @param options options to configure the UI
  103158. * @returns the created ui
  103159. */
  103160. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  103161. private constructor();
  103162. private _updateButtons;
  103163. /**
  103164. * Disposes of the object
  103165. */
  103166. dispose(): void;
  103167. }
  103168. }
  103169. declare module BABYLON {
  103170. /**
  103171. * Represents an XR input
  103172. */
  103173. export class WebXRController {
  103174. /**
  103175. * 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
  103176. */
  103177. grip?: AbstractMesh;
  103178. /**
  103179. * Pointer which can be used to select objects or attach a visible laser to
  103180. */
  103181. pointer: AbstractMesh;
  103182. /**
  103183. * Creates the controller
  103184. * @see https://doc.babylonjs.com/how_to/webxr
  103185. * @param scene the scene which the controller should be associated to
  103186. */
  103187. constructor(scene: Scene);
  103188. /**
  103189. * Disposes of the object
  103190. */
  103191. dispose(): void;
  103192. }
  103193. /**
  103194. * XR input used to track XR inputs such as controllers/rays
  103195. */
  103196. export class WebXRInput implements IDisposable {
  103197. private helper;
  103198. /**
  103199. * XR controllers being tracked
  103200. */
  103201. controllers: Array<WebXRController>;
  103202. private _tmpMatrix;
  103203. private _frameObserver;
  103204. /**
  103205. * Initializes the WebXRInput
  103206. * @param helper experience helper which the input should be created for
  103207. */
  103208. constructor(helper: WebXRExperienceHelper);
  103209. /**
  103210. * Disposes of the object
  103211. */
  103212. dispose(): void;
  103213. }
  103214. }
  103215. declare module BABYLON {
  103216. /**
  103217. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  103218. */
  103219. export class WebXRManagedOutputCanvas implements IDisposable {
  103220. private _canvas;
  103221. /**
  103222. * xrpresent context of the canvas which can be used to display/mirror xr content
  103223. */
  103224. canvasContext: Nullable<WebGLRenderingContext>;
  103225. /**
  103226. * Initializes the canvas to be added/removed upon entering/exiting xr
  103227. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  103228. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  103229. */
  103230. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  103231. /**
  103232. * Disposes of the object
  103233. */
  103234. dispose(): void;
  103235. private _setManagedOutputCanvas;
  103236. private _addCanvas;
  103237. private _removeCanvas;
  103238. }
  103239. }
  103240. declare module BABYLON {
  103241. /**
  103242. * Contains an array of blocks representing the octree
  103243. */
  103244. export interface IOctreeContainer<T> {
  103245. /**
  103246. * Blocks within the octree
  103247. */
  103248. blocks: Array<OctreeBlock<T>>;
  103249. }
  103250. /**
  103251. * Class used to store a cell in an octree
  103252. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103253. */
  103254. export class OctreeBlock<T> {
  103255. /**
  103256. * Gets the content of the current block
  103257. */
  103258. entries: T[];
  103259. /**
  103260. * Gets the list of block children
  103261. */
  103262. blocks: Array<OctreeBlock<T>>;
  103263. private _depth;
  103264. private _maxDepth;
  103265. private _capacity;
  103266. private _minPoint;
  103267. private _maxPoint;
  103268. private _boundingVectors;
  103269. private _creationFunc;
  103270. /**
  103271. * Creates a new block
  103272. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  103273. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  103274. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103275. * @param depth defines the current depth of this block in the octree
  103276. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  103277. * @param creationFunc defines a callback to call when an element is added to the block
  103278. */
  103279. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  103280. /**
  103281. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103282. */
  103283. readonly capacity: number;
  103284. /**
  103285. * Gets the minimum vector (in world space) of the block's bounding box
  103286. */
  103287. readonly minPoint: Vector3;
  103288. /**
  103289. * Gets the maximum vector (in world space) of the block's bounding box
  103290. */
  103291. readonly maxPoint: Vector3;
  103292. /**
  103293. * Add a new element to this block
  103294. * @param entry defines the element to add
  103295. */
  103296. addEntry(entry: T): void;
  103297. /**
  103298. * Remove an element from this block
  103299. * @param entry defines the element to remove
  103300. */
  103301. removeEntry(entry: T): void;
  103302. /**
  103303. * Add an array of elements to this block
  103304. * @param entries defines the array of elements to add
  103305. */
  103306. addEntries(entries: T[]): void;
  103307. /**
  103308. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  103309. * @param frustumPlanes defines the frustum planes to test
  103310. * @param selection defines the array to store current content if selection is positive
  103311. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103312. */
  103313. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103314. /**
  103315. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  103316. * @param sphereCenter defines the bounding sphere center
  103317. * @param sphereRadius defines the bounding sphere radius
  103318. * @param selection defines the array to store current content if selection is positive
  103319. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103320. */
  103321. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103322. /**
  103323. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  103324. * @param ray defines the ray to test with
  103325. * @param selection defines the array to store current content if selection is positive
  103326. */
  103327. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  103328. /**
  103329. * Subdivide the content into child blocks (this block will then be empty)
  103330. */
  103331. createInnerBlocks(): void;
  103332. /**
  103333. * @hidden
  103334. */
  103335. 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;
  103336. }
  103337. }
  103338. declare module BABYLON {
  103339. /**
  103340. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  103341. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103342. */
  103343. export class Octree<T> {
  103344. /** 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.) */
  103345. maxDepth: number;
  103346. /**
  103347. * Blocks within the octree containing objects
  103348. */
  103349. blocks: Array<OctreeBlock<T>>;
  103350. /**
  103351. * Content stored in the octree
  103352. */
  103353. dynamicContent: T[];
  103354. private _maxBlockCapacity;
  103355. private _selectionContent;
  103356. private _creationFunc;
  103357. /**
  103358. * Creates a octree
  103359. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103360. * @param creationFunc function to be used to instatiate the octree
  103361. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  103362. * @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.)
  103363. */
  103364. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  103365. /** 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.) */
  103366. maxDepth?: number);
  103367. /**
  103368. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  103369. * @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);
  103370. * @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);
  103371. * @param entries meshes to be added to the octree blocks
  103372. */
  103373. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  103374. /**
  103375. * Adds a mesh to the octree
  103376. * @param entry Mesh to add to the octree
  103377. */
  103378. addMesh(entry: T): void;
  103379. /**
  103380. * Remove an element from the octree
  103381. * @param entry defines the element to remove
  103382. */
  103383. removeMesh(entry: T): void;
  103384. /**
  103385. * Selects an array of meshes within the frustum
  103386. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  103387. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  103388. * @returns array of meshes within the frustum
  103389. */
  103390. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  103391. /**
  103392. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  103393. * @param sphereCenter defines the bounding sphere center
  103394. * @param sphereRadius defines the bounding sphere radius
  103395. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103396. * @returns an array of objects that intersect the sphere
  103397. */
  103398. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  103399. /**
  103400. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  103401. * @param ray defines the ray to test with
  103402. * @returns array of intersected objects
  103403. */
  103404. intersectsRay(ray: Ray): SmartArray<T>;
  103405. /**
  103406. * Adds a mesh into the octree block if it intersects the block
  103407. */
  103408. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  103409. /**
  103410. * Adds a submesh into the octree block if it intersects the block
  103411. */
  103412. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  103413. }
  103414. }
  103415. declare module BABYLON {
  103416. interface Scene {
  103417. /**
  103418. * @hidden
  103419. * Backing Filed
  103420. */
  103421. _selectionOctree: Octree<AbstractMesh>;
  103422. /**
  103423. * Gets the octree used to boost mesh selection (picking)
  103424. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103425. */
  103426. selectionOctree: Octree<AbstractMesh>;
  103427. /**
  103428. * Creates or updates the octree used to boost selection (picking)
  103429. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103430. * @param maxCapacity defines the maximum capacity per leaf
  103431. * @param maxDepth defines the maximum depth of the octree
  103432. * @returns an octree of AbstractMesh
  103433. */
  103434. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  103435. }
  103436. interface AbstractMesh {
  103437. /**
  103438. * @hidden
  103439. * Backing Field
  103440. */
  103441. _submeshesOctree: Octree<SubMesh>;
  103442. /**
  103443. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  103444. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103445. * @param maxCapacity defines the maximum size of each block (64 by default)
  103446. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  103447. * @returns the new octree
  103448. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  103449. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103450. */
  103451. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  103452. }
  103453. /**
  103454. * Defines the octree scene component responsible to manage any octrees
  103455. * in a given scene.
  103456. */
  103457. export class OctreeSceneComponent {
  103458. /**
  103459. * The component name help to identify the component in the list of scene components.
  103460. */
  103461. readonly name: string;
  103462. /**
  103463. * The scene the component belongs to.
  103464. */
  103465. scene: Scene;
  103466. /**
  103467. * Indicates if the meshes have been checked to make sure they are isEnabled()
  103468. */
  103469. readonly checksIsEnabled: boolean;
  103470. /**
  103471. * Creates a new instance of the component for the given scene
  103472. * @param scene Defines the scene to register the component in
  103473. */
  103474. constructor(scene: Scene);
  103475. /**
  103476. * Registers the component in a given scene
  103477. */
  103478. register(): void;
  103479. /**
  103480. * Return the list of active meshes
  103481. * @returns the list of active meshes
  103482. */
  103483. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  103484. /**
  103485. * Return the list of active sub meshes
  103486. * @param mesh The mesh to get the candidates sub meshes from
  103487. * @returns the list of active sub meshes
  103488. */
  103489. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  103490. private _tempRay;
  103491. /**
  103492. * Return the list of sub meshes intersecting with a given local ray
  103493. * @param mesh defines the mesh to find the submesh for
  103494. * @param localRay defines the ray in local space
  103495. * @returns the list of intersecting sub meshes
  103496. */
  103497. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  103498. /**
  103499. * Return the list of sub meshes colliding with a collider
  103500. * @param mesh defines the mesh to find the submesh for
  103501. * @param collider defines the collider to evaluate the collision against
  103502. * @returns the list of colliding sub meshes
  103503. */
  103504. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  103505. /**
  103506. * Rebuilds the elements related to this component in case of
  103507. * context lost for instance.
  103508. */
  103509. rebuild(): void;
  103510. /**
  103511. * Disposes the component and the associated ressources.
  103512. */
  103513. dispose(): void;
  103514. }
  103515. }
  103516. declare module BABYLON {
  103517. /**
  103518. * Renders a layer on top of an existing scene
  103519. */
  103520. export class UtilityLayerRenderer implements IDisposable {
  103521. /** the original scene that will be rendered on top of */
  103522. originalScene: Scene;
  103523. private _pointerCaptures;
  103524. private _lastPointerEvents;
  103525. private static _DefaultUtilityLayer;
  103526. private static _DefaultKeepDepthUtilityLayer;
  103527. private _sharedGizmoLight;
  103528. private _renderCamera;
  103529. /**
  103530. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  103531. * @returns the camera that is used when rendering the utility layer
  103532. */
  103533. getRenderCamera(): Nullable<Camera>;
  103534. /**
  103535. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  103536. * @param cam the camera that should be used when rendering the utility layer
  103537. */
  103538. setRenderCamera(cam: Nullable<Camera>): void;
  103539. /**
  103540. * @hidden
  103541. * Light which used by gizmos to get light shading
  103542. */
  103543. _getSharedGizmoLight(): HemisphericLight;
  103544. /**
  103545. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  103546. */
  103547. pickUtilitySceneFirst: boolean;
  103548. /**
  103549. * 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)
  103550. */
  103551. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  103552. /**
  103553. * 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)
  103554. */
  103555. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  103556. /**
  103557. * The scene that is rendered on top of the original scene
  103558. */
  103559. utilityLayerScene: Scene;
  103560. /**
  103561. * If the utility layer should automatically be rendered on top of existing scene
  103562. */
  103563. shouldRender: boolean;
  103564. /**
  103565. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  103566. */
  103567. onlyCheckPointerDownEvents: boolean;
  103568. /**
  103569. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  103570. */
  103571. processAllEvents: boolean;
  103572. /**
  103573. * Observable raised when the pointer move from the utility layer scene to the main scene
  103574. */
  103575. onPointerOutObservable: Observable<number>;
  103576. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  103577. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  103578. private _afterRenderObserver;
  103579. private _sceneDisposeObserver;
  103580. private _originalPointerObserver;
  103581. /**
  103582. * Instantiates a UtilityLayerRenderer
  103583. * @param originalScene the original scene that will be rendered on top of
  103584. * @param handleEvents boolean indicating if the utility layer should handle events
  103585. */
  103586. constructor(
  103587. /** the original scene that will be rendered on top of */
  103588. originalScene: Scene, handleEvents?: boolean);
  103589. private _notifyObservers;
  103590. /**
  103591. * Renders the utility layers scene on top of the original scene
  103592. */
  103593. render(): void;
  103594. /**
  103595. * Disposes of the renderer
  103596. */
  103597. dispose(): void;
  103598. private _updateCamera;
  103599. }
  103600. }
  103601. declare module BABYLON {
  103602. /**
  103603. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  103604. */
  103605. export class Gizmo implements IDisposable {
  103606. /** The utility layer the gizmo will be added to */
  103607. gizmoLayer: UtilityLayerRenderer;
  103608. /**
  103609. * The root mesh of the gizmo
  103610. */
  103611. _rootMesh: Mesh;
  103612. private _attachedMesh;
  103613. /**
  103614. * Ratio for the scale of the gizmo (Default: 1)
  103615. */
  103616. scaleRatio: number;
  103617. /**
  103618. * If a custom mesh has been set (Default: false)
  103619. */
  103620. protected _customMeshSet: boolean;
  103621. /**
  103622. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  103623. * * When set, interactions will be enabled
  103624. */
  103625. attachedMesh: Nullable<AbstractMesh>;
  103626. /**
  103627. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  103628. * @param mesh The mesh to replace the default mesh of the gizmo
  103629. */
  103630. setCustomMesh(mesh: Mesh): void;
  103631. /**
  103632. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  103633. */
  103634. updateGizmoRotationToMatchAttachedMesh: boolean;
  103635. /**
  103636. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  103637. */
  103638. updateGizmoPositionToMatchAttachedMesh: boolean;
  103639. /**
  103640. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  103641. */
  103642. protected _updateScale: boolean;
  103643. protected _interactionsEnabled: boolean;
  103644. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103645. private _beforeRenderObserver;
  103646. private _tempVector;
  103647. /**
  103648. * Creates a gizmo
  103649. * @param gizmoLayer The utility layer the gizmo will be added to
  103650. */
  103651. constructor(
  103652. /** The utility layer the gizmo will be added to */
  103653. gizmoLayer?: UtilityLayerRenderer);
  103654. /**
  103655. * Updates the gizmo to match the attached mesh's position/rotation
  103656. */
  103657. protected _update(): void;
  103658. /**
  103659. * Disposes of the gizmo
  103660. */
  103661. dispose(): void;
  103662. }
  103663. }
  103664. declare module BABYLON {
  103665. /**
  103666. * Single plane drag gizmo
  103667. */
  103668. export class PlaneDragGizmo extends Gizmo {
  103669. /**
  103670. * Drag behavior responsible for the gizmos dragging interactions
  103671. */
  103672. dragBehavior: PointerDragBehavior;
  103673. private _pointerObserver;
  103674. /**
  103675. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103676. */
  103677. snapDistance: number;
  103678. /**
  103679. * Event that fires each time the gizmo snaps to a new location.
  103680. * * snapDistance is the the change in distance
  103681. */
  103682. onSnapObservable: Observable<{
  103683. snapDistance: number;
  103684. }>;
  103685. private _plane;
  103686. private _coloredMaterial;
  103687. private _hoverMaterial;
  103688. private _isEnabled;
  103689. private _parent;
  103690. /** @hidden */
  103691. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  103692. /** @hidden */
  103693. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103694. /**
  103695. * Creates a PlaneDragGizmo
  103696. * @param gizmoLayer The utility layer the gizmo will be added to
  103697. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  103698. * @param color The color of the gizmo
  103699. */
  103700. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103701. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103702. /**
  103703. * If the gizmo is enabled
  103704. */
  103705. isEnabled: boolean;
  103706. /**
  103707. * Disposes of the gizmo
  103708. */
  103709. dispose(): void;
  103710. }
  103711. }
  103712. declare module BABYLON {
  103713. /**
  103714. * Gizmo that enables dragging a mesh along 3 axis
  103715. */
  103716. export class PositionGizmo extends Gizmo {
  103717. /**
  103718. * Internal gizmo used for interactions on the x axis
  103719. */
  103720. xGizmo: AxisDragGizmo;
  103721. /**
  103722. * Internal gizmo used for interactions on the y axis
  103723. */
  103724. yGizmo: AxisDragGizmo;
  103725. /**
  103726. * Internal gizmo used for interactions on the z axis
  103727. */
  103728. zGizmo: AxisDragGizmo;
  103729. /**
  103730. * Internal gizmo used for interactions on the yz plane
  103731. */
  103732. xPlaneGizmo: PlaneDragGizmo;
  103733. /**
  103734. * Internal gizmo used for interactions on the xz plane
  103735. */
  103736. yPlaneGizmo: PlaneDragGizmo;
  103737. /**
  103738. * Internal gizmo used for interactions on the xy plane
  103739. */
  103740. zPlaneGizmo: PlaneDragGizmo;
  103741. /**
  103742. * private variables
  103743. */
  103744. private _meshAttached;
  103745. private _updateGizmoRotationToMatchAttachedMesh;
  103746. private _snapDistance;
  103747. private _scaleRatio;
  103748. /** Fires an event when any of it's sub gizmos are dragged */
  103749. onDragStartObservable: Observable<unknown>;
  103750. /** Fires an event when any of it's sub gizmos are released from dragging */
  103751. onDragEndObservable: Observable<unknown>;
  103752. /**
  103753. * If set to true, planar drag is enabled
  103754. */
  103755. private _planarGizmoEnabled;
  103756. attachedMesh: Nullable<AbstractMesh>;
  103757. /**
  103758. * Creates a PositionGizmo
  103759. * @param gizmoLayer The utility layer the gizmo will be added to
  103760. */
  103761. constructor(gizmoLayer?: UtilityLayerRenderer);
  103762. /**
  103763. * If the planar drag gizmo is enabled
  103764. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  103765. */
  103766. planarGizmoEnabled: boolean;
  103767. updateGizmoRotationToMatchAttachedMesh: boolean;
  103768. /**
  103769. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103770. */
  103771. snapDistance: number;
  103772. /**
  103773. * Ratio for the scale of the gizmo (Default: 1)
  103774. */
  103775. scaleRatio: number;
  103776. /**
  103777. * Disposes of the gizmo
  103778. */
  103779. dispose(): void;
  103780. /**
  103781. * CustomMeshes are not supported by this gizmo
  103782. * @param mesh The mesh to replace the default mesh of the gizmo
  103783. */
  103784. setCustomMesh(mesh: Mesh): void;
  103785. }
  103786. }
  103787. declare module BABYLON {
  103788. /**
  103789. * Single axis drag gizmo
  103790. */
  103791. export class AxisDragGizmo extends Gizmo {
  103792. /**
  103793. * Drag behavior responsible for the gizmos dragging interactions
  103794. */
  103795. dragBehavior: PointerDragBehavior;
  103796. private _pointerObserver;
  103797. /**
  103798. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103799. */
  103800. snapDistance: number;
  103801. /**
  103802. * Event that fires each time the gizmo snaps to a new location.
  103803. * * snapDistance is the the change in distance
  103804. */
  103805. onSnapObservable: Observable<{
  103806. snapDistance: number;
  103807. }>;
  103808. private _isEnabled;
  103809. private _parent;
  103810. private _arrow;
  103811. private _coloredMaterial;
  103812. private _hoverMaterial;
  103813. /** @hidden */
  103814. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  103815. /** @hidden */
  103816. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103817. /**
  103818. * Creates an AxisDragGizmo
  103819. * @param gizmoLayer The utility layer the gizmo will be added to
  103820. * @param dragAxis The axis which the gizmo will be able to drag on
  103821. * @param color The color of the gizmo
  103822. */
  103823. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103824. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103825. /**
  103826. * If the gizmo is enabled
  103827. */
  103828. isEnabled: boolean;
  103829. /**
  103830. * Disposes of the gizmo
  103831. */
  103832. dispose(): void;
  103833. }
  103834. }
  103835. declare module BABYLON.Debug {
  103836. /**
  103837. * The Axes viewer will show 3 axes in a specific point in space
  103838. */
  103839. export class AxesViewer {
  103840. private _xAxis;
  103841. private _yAxis;
  103842. private _zAxis;
  103843. private _scaleLinesFactor;
  103844. private _instanced;
  103845. /**
  103846. * Gets the hosting scene
  103847. */
  103848. scene: Scene;
  103849. /**
  103850. * Gets or sets a number used to scale line length
  103851. */
  103852. scaleLines: number;
  103853. /** Gets the node hierarchy used to render x-axis */
  103854. readonly xAxis: TransformNode;
  103855. /** Gets the node hierarchy used to render y-axis */
  103856. readonly yAxis: TransformNode;
  103857. /** Gets the node hierarchy used to render z-axis */
  103858. readonly zAxis: TransformNode;
  103859. /**
  103860. * Creates a new AxesViewer
  103861. * @param scene defines the hosting scene
  103862. * @param scaleLines defines a number used to scale line length (1 by default)
  103863. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  103864. * @param xAxis defines the node hierarchy used to render the x-axis
  103865. * @param yAxis defines the node hierarchy used to render the y-axis
  103866. * @param zAxis defines the node hierarchy used to render the z-axis
  103867. */
  103868. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  103869. /**
  103870. * Force the viewer to update
  103871. * @param position defines the position of the viewer
  103872. * @param xaxis defines the x axis of the viewer
  103873. * @param yaxis defines the y axis of the viewer
  103874. * @param zaxis defines the z axis of the viewer
  103875. */
  103876. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  103877. /**
  103878. * Creates an instance of this axes viewer.
  103879. * @returns a new axes viewer with instanced meshes
  103880. */
  103881. createInstance(): AxesViewer;
  103882. /** Releases resources */
  103883. dispose(): void;
  103884. private static _SetRenderingGroupId;
  103885. }
  103886. }
  103887. declare module BABYLON.Debug {
  103888. /**
  103889. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  103890. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  103891. */
  103892. export class BoneAxesViewer extends AxesViewer {
  103893. /**
  103894. * Gets or sets the target mesh where to display the axes viewer
  103895. */
  103896. mesh: Nullable<Mesh>;
  103897. /**
  103898. * Gets or sets the target bone where to display the axes viewer
  103899. */
  103900. bone: Nullable<Bone>;
  103901. /** Gets current position */
  103902. pos: Vector3;
  103903. /** Gets direction of X axis */
  103904. xaxis: Vector3;
  103905. /** Gets direction of Y axis */
  103906. yaxis: Vector3;
  103907. /** Gets direction of Z axis */
  103908. zaxis: Vector3;
  103909. /**
  103910. * Creates a new BoneAxesViewer
  103911. * @param scene defines the hosting scene
  103912. * @param bone defines the target bone
  103913. * @param mesh defines the target mesh
  103914. * @param scaleLines defines a scaling factor for line length (1 by default)
  103915. */
  103916. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  103917. /**
  103918. * Force the viewer to update
  103919. */
  103920. update(): void;
  103921. /** Releases resources */
  103922. dispose(): void;
  103923. }
  103924. }
  103925. declare module BABYLON {
  103926. /**
  103927. * Interface used to define scene explorer extensibility option
  103928. */
  103929. export interface IExplorerExtensibilityOption {
  103930. /**
  103931. * Define the option label
  103932. */
  103933. label: string;
  103934. /**
  103935. * Defines the action to execute on click
  103936. */
  103937. action: (entity: any) => void;
  103938. }
  103939. /**
  103940. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  103941. */
  103942. export interface IExplorerExtensibilityGroup {
  103943. /**
  103944. * Defines a predicate to test if a given type mut be extended
  103945. */
  103946. predicate: (entity: any) => boolean;
  103947. /**
  103948. * Gets the list of options added to a type
  103949. */
  103950. entries: IExplorerExtensibilityOption[];
  103951. }
  103952. /**
  103953. * Interface used to define the options to use to create the Inspector
  103954. */
  103955. export interface IInspectorOptions {
  103956. /**
  103957. * Display in overlay mode (default: false)
  103958. */
  103959. overlay?: boolean;
  103960. /**
  103961. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  103962. */
  103963. globalRoot?: HTMLElement;
  103964. /**
  103965. * Display the Scene explorer
  103966. */
  103967. showExplorer?: boolean;
  103968. /**
  103969. * Display the property inspector
  103970. */
  103971. showInspector?: boolean;
  103972. /**
  103973. * Display in embed mode (both panes on the right)
  103974. */
  103975. embedMode?: boolean;
  103976. /**
  103977. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  103978. */
  103979. handleResize?: boolean;
  103980. /**
  103981. * Allow the panes to popup (default: true)
  103982. */
  103983. enablePopup?: boolean;
  103984. /**
  103985. * Allow the panes to be closed by users (default: true)
  103986. */
  103987. enableClose?: boolean;
  103988. /**
  103989. * Optional list of extensibility entries
  103990. */
  103991. explorerExtensibility?: IExplorerExtensibilityGroup[];
  103992. /**
  103993. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  103994. */
  103995. inspectorURL?: string;
  103996. }
  103997. interface Scene {
  103998. /**
  103999. * @hidden
  104000. * Backing field
  104001. */
  104002. _debugLayer: DebugLayer;
  104003. /**
  104004. * Gets the debug layer (aka Inspector) associated with the scene
  104005. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104006. */
  104007. debugLayer: DebugLayer;
  104008. }
  104009. /**
  104010. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104011. * what is happening in your scene
  104012. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104013. */
  104014. export class DebugLayer {
  104015. /**
  104016. * Define the url to get the inspector script from.
  104017. * By default it uses the babylonjs CDN.
  104018. * @ignoreNaming
  104019. */
  104020. static InspectorURL: string;
  104021. private _scene;
  104022. private BJSINSPECTOR;
  104023. /**
  104024. * Observable triggered when a property is changed through the inspector.
  104025. */
  104026. onPropertyChangedObservable: Observable<{
  104027. object: any;
  104028. property: string;
  104029. value: any;
  104030. initialValue: any;
  104031. }>;
  104032. /**
  104033. * Instantiates a new debug layer.
  104034. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104035. * what is happening in your scene
  104036. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104037. * @param scene Defines the scene to inspect
  104038. */
  104039. constructor(scene: Scene);
  104040. /** Creates the inspector window. */
  104041. private _createInspector;
  104042. /**
  104043. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  104044. * @param entity defines the entity to select
  104045. * @param lineContainerTitle defines the specific block to highlight
  104046. */
  104047. select(entity: any, lineContainerTitle?: string): void;
  104048. /** Get the inspector from bundle or global */
  104049. private _getGlobalInspector;
  104050. /**
  104051. * Get if the inspector is visible or not.
  104052. * @returns true if visible otherwise, false
  104053. */
  104054. isVisible(): boolean;
  104055. /**
  104056. * Hide the inspector and close its window.
  104057. */
  104058. hide(): void;
  104059. /**
  104060. * Launch the debugLayer.
  104061. * @param config Define the configuration of the inspector
  104062. * @return a promise fulfilled when the debug layer is visible
  104063. */
  104064. show(config?: IInspectorOptions): Promise<DebugLayer>;
  104065. }
  104066. }
  104067. declare module BABYLON {
  104068. /**
  104069. * Class containing static functions to help procedurally build meshes
  104070. */
  104071. export class BoxBuilder {
  104072. /**
  104073. * Creates a box mesh
  104074. * * The parameter `size` sets the size (float) of each box side (default 1)
  104075. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  104076. * * 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)
  104077. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104081. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  104082. * @param name defines the name of the mesh
  104083. * @param options defines the options used to create the mesh
  104084. * @param scene defines the hosting scene
  104085. * @returns the box mesh
  104086. */
  104087. static CreateBox(name: string, options: {
  104088. size?: number;
  104089. width?: number;
  104090. height?: number;
  104091. depth?: number;
  104092. faceUV?: Vector4[];
  104093. faceColors?: Color4[];
  104094. sideOrientation?: number;
  104095. frontUVs?: Vector4;
  104096. backUVs?: Vector4;
  104097. wrap?: boolean;
  104098. topBaseAt?: number;
  104099. bottomBaseAt?: number;
  104100. updatable?: boolean;
  104101. }, scene?: Nullable<Scene>): Mesh;
  104102. }
  104103. }
  104104. declare module BABYLON {
  104105. /**
  104106. * Class containing static functions to help procedurally build meshes
  104107. */
  104108. export class SphereBuilder {
  104109. /**
  104110. * Creates a sphere mesh
  104111. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  104112. * * 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`)
  104113. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  104114. * * 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
  104115. * * 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)
  104116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104119. * @param name defines the name of the mesh
  104120. * @param options defines the options used to create the mesh
  104121. * @param scene defines the hosting scene
  104122. * @returns the sphere mesh
  104123. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  104124. */
  104125. static CreateSphere(name: string, options: {
  104126. segments?: number;
  104127. diameter?: number;
  104128. diameterX?: number;
  104129. diameterY?: number;
  104130. diameterZ?: number;
  104131. arc?: number;
  104132. slice?: number;
  104133. sideOrientation?: number;
  104134. frontUVs?: Vector4;
  104135. backUVs?: Vector4;
  104136. updatable?: boolean;
  104137. }, scene: any): Mesh;
  104138. }
  104139. }
  104140. declare module BABYLON.Debug {
  104141. /**
  104142. * Used to show the physics impostor around the specific mesh
  104143. */
  104144. export class PhysicsViewer {
  104145. /** @hidden */
  104146. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  104147. /** @hidden */
  104148. protected _meshes: Array<Nullable<AbstractMesh>>;
  104149. /** @hidden */
  104150. protected _scene: Nullable<Scene>;
  104151. /** @hidden */
  104152. protected _numMeshes: number;
  104153. /** @hidden */
  104154. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  104155. private _renderFunction;
  104156. private _utilityLayer;
  104157. private _debugBoxMesh;
  104158. private _debugSphereMesh;
  104159. private _debugCylinderMesh;
  104160. private _debugMaterial;
  104161. private _debugMeshMeshes;
  104162. /**
  104163. * Creates a new PhysicsViewer
  104164. * @param scene defines the hosting scene
  104165. */
  104166. constructor(scene: Scene);
  104167. /** @hidden */
  104168. protected _updateDebugMeshes(): void;
  104169. /**
  104170. * Renders a specified physic impostor
  104171. * @param impostor defines the impostor to render
  104172. * @param targetMesh defines the mesh represented by the impostor
  104173. * @returns the new debug mesh used to render the impostor
  104174. */
  104175. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  104176. /**
  104177. * Hides a specified physic impostor
  104178. * @param impostor defines the impostor to hide
  104179. */
  104180. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  104181. private _getDebugMaterial;
  104182. private _getDebugBoxMesh;
  104183. private _getDebugSphereMesh;
  104184. private _getDebugCylinderMesh;
  104185. private _getDebugMeshMesh;
  104186. private _getDebugMesh;
  104187. /** Releases all resources */
  104188. dispose(): void;
  104189. }
  104190. }
  104191. declare module BABYLON {
  104192. /**
  104193. * Class containing static functions to help procedurally build meshes
  104194. */
  104195. export class LinesBuilder {
  104196. /**
  104197. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  104198. * * 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
  104199. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  104200. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  104201. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  104202. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  104203. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  104204. * * 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
  104205. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  104206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104207. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  104208. * @param name defines the name of the new line system
  104209. * @param options defines the options used to create the line system
  104210. * @param scene defines the hosting scene
  104211. * @returns a new line system mesh
  104212. */
  104213. static CreateLineSystem(name: string, options: {
  104214. lines: Vector3[][];
  104215. updatable?: boolean;
  104216. instance?: Nullable<LinesMesh>;
  104217. colors?: Nullable<Color4[][]>;
  104218. useVertexAlpha?: boolean;
  104219. }, scene: Nullable<Scene>): LinesMesh;
  104220. /**
  104221. * Creates a line mesh
  104222. * 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
  104223. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104224. * * The parameter `points` is an array successive Vector3
  104225. * * 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
  104226. * * The optional parameter `colors` is an array of successive Color4, one per line point
  104227. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  104228. * * When updating an instance, remember that only point positions can change, not the number of points
  104229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104230. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  104231. * @param name defines the name of the new line system
  104232. * @param options defines the options used to create the line system
  104233. * @param scene defines the hosting scene
  104234. * @returns a new line mesh
  104235. */
  104236. static CreateLines(name: string, options: {
  104237. points: Vector3[];
  104238. updatable?: boolean;
  104239. instance?: Nullable<LinesMesh>;
  104240. colors?: Color4[];
  104241. useVertexAlpha?: boolean;
  104242. }, scene?: Nullable<Scene>): LinesMesh;
  104243. /**
  104244. * Creates a dashed line mesh
  104245. * * 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
  104246. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104247. * * The parameter `points` is an array successive Vector3
  104248. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  104249. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  104250. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104251. * * 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
  104252. * * When updating an instance, remember that only point positions can change, not the number of points
  104253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104254. * @param name defines the name of the mesh
  104255. * @param options defines the options used to create the mesh
  104256. * @param scene defines the hosting scene
  104257. * @returns the dashed line mesh
  104258. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104259. */
  104260. static CreateDashedLines(name: string, options: {
  104261. points: Vector3[];
  104262. dashSize?: number;
  104263. gapSize?: number;
  104264. dashNb?: number;
  104265. updatable?: boolean;
  104266. instance?: LinesMesh;
  104267. }, scene?: Nullable<Scene>): LinesMesh;
  104268. }
  104269. }
  104270. declare module BABYLON {
  104271. /**
  104272. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104273. * in order to better appreciate the issue one might have.
  104274. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104275. */
  104276. export class RayHelper {
  104277. /**
  104278. * Defines the ray we are currently tryin to visualize.
  104279. */
  104280. ray: Nullable<Ray>;
  104281. private _renderPoints;
  104282. private _renderLine;
  104283. private _renderFunction;
  104284. private _scene;
  104285. private _updateToMeshFunction;
  104286. private _attachedToMesh;
  104287. private _meshSpaceDirection;
  104288. private _meshSpaceOrigin;
  104289. /**
  104290. * Helper function to create a colored helper in a scene in one line.
  104291. * @param ray Defines the ray we are currently tryin to visualize
  104292. * @param scene Defines the scene the ray is used in
  104293. * @param color Defines the color we want to see the ray in
  104294. * @returns The newly created ray helper.
  104295. */
  104296. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  104297. /**
  104298. * Instantiate a new ray helper.
  104299. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104300. * in order to better appreciate the issue one might have.
  104301. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104302. * @param ray Defines the ray we are currently tryin to visualize
  104303. */
  104304. constructor(ray: Ray);
  104305. /**
  104306. * Shows the ray we are willing to debug.
  104307. * @param scene Defines the scene the ray needs to be rendered in
  104308. * @param color Defines the color the ray needs to be rendered in
  104309. */
  104310. show(scene: Scene, color?: Color3): void;
  104311. /**
  104312. * Hides the ray we are debugging.
  104313. */
  104314. hide(): void;
  104315. private _render;
  104316. /**
  104317. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  104318. * @param mesh Defines the mesh we want the helper attached to
  104319. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  104320. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  104321. * @param length Defines the length of the ray
  104322. */
  104323. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  104324. /**
  104325. * Detach the ray helper from the mesh it has previously been attached to.
  104326. */
  104327. detachFromMesh(): void;
  104328. private _updateToMesh;
  104329. /**
  104330. * Dispose the helper and release its associated resources.
  104331. */
  104332. dispose(): void;
  104333. }
  104334. }
  104335. declare module BABYLON.Debug {
  104336. /**
  104337. * Class used to render a debug view of a given skeleton
  104338. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  104339. */
  104340. export class SkeletonViewer {
  104341. /** defines the skeleton to render */
  104342. skeleton: Skeleton;
  104343. /** defines the mesh attached to the skeleton */
  104344. mesh: AbstractMesh;
  104345. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104346. autoUpdateBonesMatrices: boolean;
  104347. /** defines the rendering group id to use with the viewer */
  104348. renderingGroupId: number;
  104349. /** Gets or sets the color used to render the skeleton */
  104350. color: Color3;
  104351. private _scene;
  104352. private _debugLines;
  104353. private _debugMesh;
  104354. private _isEnabled;
  104355. private _renderFunction;
  104356. private _utilityLayer;
  104357. /**
  104358. * Returns the mesh used to render the bones
  104359. */
  104360. readonly debugMesh: Nullable<LinesMesh>;
  104361. /**
  104362. * Creates a new SkeletonViewer
  104363. * @param skeleton defines the skeleton to render
  104364. * @param mesh defines the mesh attached to the skeleton
  104365. * @param scene defines the hosting scene
  104366. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  104367. * @param renderingGroupId defines the rendering group id to use with the viewer
  104368. */
  104369. constructor(
  104370. /** defines the skeleton to render */
  104371. skeleton: Skeleton,
  104372. /** defines the mesh attached to the skeleton */
  104373. mesh: AbstractMesh, scene: Scene,
  104374. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104375. autoUpdateBonesMatrices?: boolean,
  104376. /** defines the rendering group id to use with the viewer */
  104377. renderingGroupId?: number);
  104378. /** Gets or sets a boolean indicating if the viewer is enabled */
  104379. isEnabled: boolean;
  104380. private _getBonePosition;
  104381. private _getLinesForBonesWithLength;
  104382. private _getLinesForBonesNoLength;
  104383. /** Update the viewer to sync with current skeleton state */
  104384. update(): void;
  104385. /** Release associated resources */
  104386. dispose(): void;
  104387. }
  104388. }
  104389. declare module BABYLON {
  104390. /**
  104391. * Options to create the null engine
  104392. */
  104393. export class NullEngineOptions {
  104394. /**
  104395. * Render width (Default: 512)
  104396. */
  104397. renderWidth: number;
  104398. /**
  104399. * Render height (Default: 256)
  104400. */
  104401. renderHeight: number;
  104402. /**
  104403. * Texture size (Default: 512)
  104404. */
  104405. textureSize: number;
  104406. /**
  104407. * If delta time between frames should be constant
  104408. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104409. */
  104410. deterministicLockstep: boolean;
  104411. /**
  104412. * Maximum about of steps between frames (Default: 4)
  104413. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104414. */
  104415. lockstepMaxSteps: number;
  104416. }
  104417. /**
  104418. * The null engine class provides support for headless version of babylon.js.
  104419. * This can be used in server side scenario or for testing purposes
  104420. */
  104421. export class NullEngine extends Engine {
  104422. private _options;
  104423. /**
  104424. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104425. */
  104426. isDeterministicLockStep(): boolean;
  104427. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  104428. getLockstepMaxSteps(): number;
  104429. /**
  104430. * Sets hardware scaling, used to save performance if needed
  104431. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  104432. */
  104433. getHardwareScalingLevel(): number;
  104434. constructor(options?: NullEngineOptions);
  104435. createVertexBuffer(vertices: FloatArray): DataBuffer;
  104436. createIndexBuffer(indices: IndicesArray): DataBuffer;
  104437. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104438. getRenderWidth(useScreen?: boolean): number;
  104439. getRenderHeight(useScreen?: boolean): number;
  104440. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  104441. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  104442. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104443. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104444. bindSamplers(effect: Effect): void;
  104445. enableEffect(effect: Effect): void;
  104446. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104447. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  104448. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  104449. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  104450. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  104451. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  104452. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  104453. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  104454. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  104455. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  104456. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  104457. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  104458. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  104459. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  104460. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  104461. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104462. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104463. setFloat(uniform: WebGLUniformLocation, value: number): void;
  104464. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  104465. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  104466. setBool(uniform: WebGLUniformLocation, bool: number): void;
  104467. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  104468. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  104469. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  104470. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104471. bindBuffers(vertexBuffers: {
  104472. [key: string]: VertexBuffer;
  104473. }, indexBuffer: DataBuffer, effect: Effect): void;
  104474. wipeCaches(bruteForce?: boolean): void;
  104475. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104476. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104477. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104478. /** @hidden */
  104479. _createTexture(): WebGLTexture;
  104480. /** @hidden */
  104481. _releaseTexture(texture: InternalTexture): void;
  104482. 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;
  104483. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  104484. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  104485. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  104486. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104487. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  104488. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  104489. areAllEffectsReady(): boolean;
  104490. /**
  104491. * @hidden
  104492. * Get the current error code of the webGL context
  104493. * @returns the error code
  104494. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104495. */
  104496. getError(): number;
  104497. /** @hidden */
  104498. _getUnpackAlignement(): number;
  104499. /** @hidden */
  104500. _unpackFlipY(value: boolean): void;
  104501. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  104502. /**
  104503. * Updates a dynamic vertex buffer.
  104504. * @param vertexBuffer the vertex buffer to update
  104505. * @param data the data used to update the vertex buffer
  104506. * @param byteOffset the byte offset of the data (optional)
  104507. * @param byteLength the byte length of the data (optional)
  104508. */
  104509. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  104510. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  104511. /** @hidden */
  104512. _bindTexture(channel: number, texture: InternalTexture): void;
  104513. /** @hidden */
  104514. _releaseBuffer(buffer: DataBuffer): boolean;
  104515. releaseEffects(): void;
  104516. displayLoadingUI(): void;
  104517. hideLoadingUI(): void;
  104518. /** @hidden */
  104519. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104520. /** @hidden */
  104521. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104522. /** @hidden */
  104523. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104524. /** @hidden */
  104525. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  104526. }
  104527. }
  104528. declare module BABYLON {
  104529. /** @hidden */
  104530. export class _OcclusionDataStorage {
  104531. /** @hidden */
  104532. occlusionInternalRetryCounter: number;
  104533. /** @hidden */
  104534. isOcclusionQueryInProgress: boolean;
  104535. /** @hidden */
  104536. isOccluded: boolean;
  104537. /** @hidden */
  104538. occlusionRetryCount: number;
  104539. /** @hidden */
  104540. occlusionType: number;
  104541. /** @hidden */
  104542. occlusionQueryAlgorithmType: number;
  104543. }
  104544. interface Engine {
  104545. /**
  104546. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  104547. * @return the new query
  104548. */
  104549. createQuery(): WebGLQuery;
  104550. /**
  104551. * Delete and release a webGL query
  104552. * @param query defines the query to delete
  104553. * @return the current engine
  104554. */
  104555. deleteQuery(query: WebGLQuery): Engine;
  104556. /**
  104557. * Check if a given query has resolved and got its value
  104558. * @param query defines the query to check
  104559. * @returns true if the query got its value
  104560. */
  104561. isQueryResultAvailable(query: WebGLQuery): boolean;
  104562. /**
  104563. * Gets the value of a given query
  104564. * @param query defines the query to check
  104565. * @returns the value of the query
  104566. */
  104567. getQueryResult(query: WebGLQuery): number;
  104568. /**
  104569. * Initiates an occlusion query
  104570. * @param algorithmType defines the algorithm to use
  104571. * @param query defines the query to use
  104572. * @returns the current engine
  104573. * @see http://doc.babylonjs.com/features/occlusionquery
  104574. */
  104575. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  104576. /**
  104577. * Ends an occlusion query
  104578. * @see http://doc.babylonjs.com/features/occlusionquery
  104579. * @param algorithmType defines the algorithm to use
  104580. * @returns the current engine
  104581. */
  104582. endOcclusionQuery(algorithmType: number): Engine;
  104583. /**
  104584. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  104585. * Please note that only one query can be issued at a time
  104586. * @returns a time token used to track the time span
  104587. */
  104588. startTimeQuery(): Nullable<_TimeToken>;
  104589. /**
  104590. * Ends a time query
  104591. * @param token defines the token used to measure the time span
  104592. * @returns the time spent (in ns)
  104593. */
  104594. endTimeQuery(token: _TimeToken): int;
  104595. /** @hidden */
  104596. _currentNonTimestampToken: Nullable<_TimeToken>;
  104597. /** @hidden */
  104598. _createTimeQuery(): WebGLQuery;
  104599. /** @hidden */
  104600. _deleteTimeQuery(query: WebGLQuery): void;
  104601. /** @hidden */
  104602. _getGlAlgorithmType(algorithmType: number): number;
  104603. /** @hidden */
  104604. _getTimeQueryResult(query: WebGLQuery): any;
  104605. /** @hidden */
  104606. _getTimeQueryAvailability(query: WebGLQuery): any;
  104607. }
  104608. interface AbstractMesh {
  104609. /**
  104610. * Backing filed
  104611. * @hidden
  104612. */
  104613. __occlusionDataStorage: _OcclusionDataStorage;
  104614. /**
  104615. * Access property
  104616. * @hidden
  104617. */
  104618. _occlusionDataStorage: _OcclusionDataStorage;
  104619. /**
  104620. * 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.
  104621. * The default value is -1 which means don't break the query and wait till the result
  104622. * @see http://doc.babylonjs.com/features/occlusionquery
  104623. */
  104624. occlusionRetryCount: number;
  104625. /**
  104626. * 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:
  104627. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  104628. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  104629. * * 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.
  104630. * @see http://doc.babylonjs.com/features/occlusionquery
  104631. */
  104632. occlusionType: number;
  104633. /**
  104634. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  104635. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  104636. * * 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.
  104637. * @see http://doc.babylonjs.com/features/occlusionquery
  104638. */
  104639. occlusionQueryAlgorithmType: number;
  104640. /**
  104641. * 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
  104642. * @see http://doc.babylonjs.com/features/occlusionquery
  104643. */
  104644. isOccluded: boolean;
  104645. /**
  104646. * Flag to check the progress status of the query
  104647. * @see http://doc.babylonjs.com/features/occlusionquery
  104648. */
  104649. isOcclusionQueryInProgress: boolean;
  104650. }
  104651. }
  104652. declare module BABYLON {
  104653. /** @hidden */
  104654. export var _forceTransformFeedbackToBundle: boolean;
  104655. interface Engine {
  104656. /**
  104657. * Creates a webGL transform feedback object
  104658. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  104659. * @returns the webGL transform feedback object
  104660. */
  104661. createTransformFeedback(): WebGLTransformFeedback;
  104662. /**
  104663. * Delete a webGL transform feedback object
  104664. * @param value defines the webGL transform feedback object to delete
  104665. */
  104666. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  104667. /**
  104668. * Bind a webGL transform feedback object to the webgl context
  104669. * @param value defines the webGL transform feedback object to bind
  104670. */
  104671. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  104672. /**
  104673. * Begins a transform feedback operation
  104674. * @param usePoints defines if points or triangles must be used
  104675. */
  104676. beginTransformFeedback(usePoints: boolean): void;
  104677. /**
  104678. * Ends a transform feedback operation
  104679. */
  104680. endTransformFeedback(): void;
  104681. /**
  104682. * Specify the varyings to use with transform feedback
  104683. * @param program defines the associated webGL program
  104684. * @param value defines the list of strings representing the varying names
  104685. */
  104686. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  104687. /**
  104688. * Bind a webGL buffer for a transform feedback operation
  104689. * @param value defines the webGL buffer to bind
  104690. */
  104691. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  104692. }
  104693. }
  104694. declare module BABYLON {
  104695. /**
  104696. * Creation options of the multi render target texture.
  104697. */
  104698. export interface IMultiRenderTargetOptions {
  104699. /**
  104700. * Define if the texture needs to create mip maps after render.
  104701. */
  104702. generateMipMaps?: boolean;
  104703. /**
  104704. * Define the types of all the draw buffers we want to create
  104705. */
  104706. types?: number[];
  104707. /**
  104708. * Define the sampling modes of all the draw buffers we want to create
  104709. */
  104710. samplingModes?: number[];
  104711. /**
  104712. * Define if a depth buffer is required
  104713. */
  104714. generateDepthBuffer?: boolean;
  104715. /**
  104716. * Define if a stencil buffer is required
  104717. */
  104718. generateStencilBuffer?: boolean;
  104719. /**
  104720. * Define if a depth texture is required instead of a depth buffer
  104721. */
  104722. generateDepthTexture?: boolean;
  104723. /**
  104724. * Define the number of desired draw buffers
  104725. */
  104726. textureCount?: number;
  104727. /**
  104728. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104729. */
  104730. doNotChangeAspectRatio?: boolean;
  104731. /**
  104732. * Define the default type of the buffers we are creating
  104733. */
  104734. defaultType?: number;
  104735. }
  104736. /**
  104737. * A multi render target, like a render target provides the ability to render to a texture.
  104738. * Unlike the render target, it can render to several draw buffers in one draw.
  104739. * This is specially interesting in deferred rendering or for any effects requiring more than
  104740. * just one color from a single pass.
  104741. */
  104742. export class MultiRenderTarget extends RenderTargetTexture {
  104743. private _internalTextures;
  104744. private _textures;
  104745. private _multiRenderTargetOptions;
  104746. /**
  104747. * Get if draw buffers are currently supported by the used hardware and browser.
  104748. */
  104749. readonly isSupported: boolean;
  104750. /**
  104751. * Get the list of textures generated by the multi render target.
  104752. */
  104753. readonly textures: Texture[];
  104754. /**
  104755. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104756. */
  104757. readonly depthTexture: Texture;
  104758. /**
  104759. * Set the wrapping mode on U of all the textures we are rendering to.
  104760. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104761. */
  104762. wrapU: number;
  104763. /**
  104764. * Set the wrapping mode on V of all the textures we are rendering to.
  104765. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104766. */
  104767. wrapV: number;
  104768. /**
  104769. * Instantiate a new multi render target texture.
  104770. * A multi render target, like a render target provides the ability to render to a texture.
  104771. * Unlike the render target, it can render to several draw buffers in one draw.
  104772. * This is specially interesting in deferred rendering or for any effects requiring more than
  104773. * just one color from a single pass.
  104774. * @param name Define the name of the texture
  104775. * @param size Define the size of the buffers to render to
  104776. * @param count Define the number of target we are rendering into
  104777. * @param scene Define the scene the texture belongs to
  104778. * @param options Define the options used to create the multi render target
  104779. */
  104780. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104781. /** @hidden */
  104782. _rebuild(): void;
  104783. private _createInternalTextures;
  104784. private _createTextures;
  104785. /**
  104786. * Define the number of samples used if MSAA is enabled.
  104787. */
  104788. samples: number;
  104789. /**
  104790. * Resize all the textures in the multi render target.
  104791. * Be carrefull as it will recreate all the data in the new texture.
  104792. * @param size Define the new size
  104793. */
  104794. resize(size: any): void;
  104795. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104796. /**
  104797. * Dispose the render targets and their associated resources
  104798. */
  104799. dispose(): void;
  104800. /**
  104801. * Release all the underlying texture used as draw buffers.
  104802. */
  104803. releaseInternalTextures(): void;
  104804. }
  104805. }
  104806. declare module BABYLON {
  104807. interface Engine {
  104808. /**
  104809. * Unbind a list of render target textures from the webGL context
  104810. * This is used only when drawBuffer extension or webGL2 are active
  104811. * @param textures defines the render target textures to unbind
  104812. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104813. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104814. */
  104815. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104816. /**
  104817. * Create a multi render target texture
  104818. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  104819. * @param size defines the size of the texture
  104820. * @param options defines the creation options
  104821. * @returns the cube texture as an InternalTexture
  104822. */
  104823. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104824. /**
  104825. * Update the sample count for a given multiple render target texture
  104826. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104827. * @param textures defines the textures to update
  104828. * @param samples defines the sample count to set
  104829. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104830. */
  104831. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104832. }
  104833. }
  104834. declare module BABYLON {
  104835. /**
  104836. * Gather the list of clipboard event types as constants.
  104837. */
  104838. export class ClipboardEventTypes {
  104839. /**
  104840. * The clipboard event is fired when a copy command is active (pressed).
  104841. */
  104842. static readonly COPY: number;
  104843. /**
  104844. * The clipboard event is fired when a cut command is active (pressed).
  104845. */
  104846. static readonly CUT: number;
  104847. /**
  104848. * The clipboard event is fired when a paste command is active (pressed).
  104849. */
  104850. static readonly PASTE: number;
  104851. }
  104852. /**
  104853. * This class is used to store clipboard related info for the onClipboardObservable event.
  104854. */
  104855. export class ClipboardInfo {
  104856. /**
  104857. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104858. */
  104859. type: number;
  104860. /**
  104861. * Defines the related dom event
  104862. */
  104863. event: ClipboardEvent;
  104864. /**
  104865. *Creates an instance of ClipboardInfo.
  104866. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  104867. * @param event Defines the related dom event
  104868. */
  104869. constructor(
  104870. /**
  104871. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104872. */
  104873. type: number,
  104874. /**
  104875. * Defines the related dom event
  104876. */
  104877. event: ClipboardEvent);
  104878. /**
  104879. * Get the clipboard event's type from the keycode.
  104880. * @param keyCode Defines the keyCode for the current keyboard event.
  104881. * @return {number}
  104882. */
  104883. static GetTypeFromCharacter(keyCode: number): number;
  104884. }
  104885. }
  104886. declare module BABYLON {
  104887. /**
  104888. * Class used to represent data loading progression
  104889. */
  104890. export class SceneLoaderProgressEvent {
  104891. /** defines if data length to load can be evaluated */
  104892. readonly lengthComputable: boolean;
  104893. /** defines the loaded data length */
  104894. readonly loaded: number;
  104895. /** defines the data length to load */
  104896. readonly total: number;
  104897. /**
  104898. * Create a new progress event
  104899. * @param lengthComputable defines if data length to load can be evaluated
  104900. * @param loaded defines the loaded data length
  104901. * @param total defines the data length to load
  104902. */
  104903. constructor(
  104904. /** defines if data length to load can be evaluated */
  104905. lengthComputable: boolean,
  104906. /** defines the loaded data length */
  104907. loaded: number,
  104908. /** defines the data length to load */
  104909. total: number);
  104910. /**
  104911. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  104912. * @param event defines the source event
  104913. * @returns a new SceneLoaderProgressEvent
  104914. */
  104915. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  104916. }
  104917. /**
  104918. * Interface used by SceneLoader plugins to define supported file extensions
  104919. */
  104920. export interface ISceneLoaderPluginExtensions {
  104921. /**
  104922. * Defines the list of supported extensions
  104923. */
  104924. [extension: string]: {
  104925. isBinary: boolean;
  104926. };
  104927. }
  104928. /**
  104929. * Interface used by SceneLoader plugin factory
  104930. */
  104931. export interface ISceneLoaderPluginFactory {
  104932. /**
  104933. * Defines the name of the factory
  104934. */
  104935. name: string;
  104936. /**
  104937. * Function called to create a new plugin
  104938. * @return the new plugin
  104939. */
  104940. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  104941. /**
  104942. * Boolean indicating if the plugin can direct load specific data
  104943. */
  104944. canDirectLoad?: (data: string) => boolean;
  104945. }
  104946. /**
  104947. * Interface used to define a SceneLoader plugin
  104948. */
  104949. export interface ISceneLoaderPlugin {
  104950. /**
  104951. * The friendly name of this plugin.
  104952. */
  104953. name: string;
  104954. /**
  104955. * The file extensions supported by this plugin.
  104956. */
  104957. extensions: string | ISceneLoaderPluginExtensions;
  104958. /**
  104959. * Import meshes into a scene.
  104960. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104961. * @param scene The scene to import into
  104962. * @param data The data to import
  104963. * @param rootUrl The root url for scene and resources
  104964. * @param meshes The meshes array to import into
  104965. * @param particleSystems The particle systems array to import into
  104966. * @param skeletons The skeletons array to import into
  104967. * @param onError The callback when import fails
  104968. * @returns True if successful or false otherwise
  104969. */
  104970. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  104971. /**
  104972. * Load into a scene.
  104973. * @param scene The scene to load into
  104974. * @param data The data to import
  104975. * @param rootUrl The root url for scene and resources
  104976. * @param onError The callback when import fails
  104977. * @returns true if successful or false otherwise
  104978. */
  104979. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  104980. /**
  104981. * The callback that returns true if the data can be directly loaded.
  104982. */
  104983. canDirectLoad?: (data: string) => boolean;
  104984. /**
  104985. * The callback that allows custom handling of the root url based on the response url.
  104986. */
  104987. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104988. /**
  104989. * Load into an asset container.
  104990. * @param scene The scene to load into
  104991. * @param data The data to import
  104992. * @param rootUrl The root url for scene and resources
  104993. * @param onError The callback when import fails
  104994. * @returns The loaded asset container
  104995. */
  104996. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  104997. }
  104998. /**
  104999. * Interface used to define an async SceneLoader plugin
  105000. */
  105001. export interface ISceneLoaderPluginAsync {
  105002. /**
  105003. * The friendly name of this plugin.
  105004. */
  105005. name: string;
  105006. /**
  105007. * The file extensions supported by this plugin.
  105008. */
  105009. extensions: string | ISceneLoaderPluginExtensions;
  105010. /**
  105011. * Import meshes into a scene.
  105012. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105013. * @param scene The scene to import into
  105014. * @param data The data to import
  105015. * @param rootUrl The root url for scene and resources
  105016. * @param onProgress The callback when the load progresses
  105017. * @param fileName Defines the name of the file to load
  105018. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105019. */
  105020. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105021. meshes: AbstractMesh[];
  105022. particleSystems: IParticleSystem[];
  105023. skeletons: Skeleton[];
  105024. animationGroups: AnimationGroup[];
  105025. }>;
  105026. /**
  105027. * Load into a scene.
  105028. * @param scene The scene to load into
  105029. * @param data The data to import
  105030. * @param rootUrl The root url for scene and resources
  105031. * @param onProgress The callback when the load progresses
  105032. * @param fileName Defines the name of the file to load
  105033. * @returns Nothing
  105034. */
  105035. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105036. /**
  105037. * The callback that returns true if the data can be directly loaded.
  105038. */
  105039. canDirectLoad?: (data: string) => boolean;
  105040. /**
  105041. * The callback that allows custom handling of the root url based on the response url.
  105042. */
  105043. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105044. /**
  105045. * Load into an asset container.
  105046. * @param scene The scene to load into
  105047. * @param data The data to import
  105048. * @param rootUrl The root url for scene and resources
  105049. * @param onProgress The callback when the load progresses
  105050. * @param fileName Defines the name of the file to load
  105051. * @returns The loaded asset container
  105052. */
  105053. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105054. }
  105055. /**
  105056. * Class used to load scene from various file formats using registered plugins
  105057. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105058. */
  105059. export class SceneLoader {
  105060. /**
  105061. * No logging while loading
  105062. */
  105063. static readonly NO_LOGGING: number;
  105064. /**
  105065. * Minimal logging while loading
  105066. */
  105067. static readonly MINIMAL_LOGGING: number;
  105068. /**
  105069. * Summary logging while loading
  105070. */
  105071. static readonly SUMMARY_LOGGING: number;
  105072. /**
  105073. * Detailled logging while loading
  105074. */
  105075. static readonly DETAILED_LOGGING: number;
  105076. /**
  105077. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105078. */
  105079. static ForceFullSceneLoadingForIncremental: boolean;
  105080. /**
  105081. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105082. */
  105083. static ShowLoadingScreen: boolean;
  105084. /**
  105085. * Defines the current logging level (while loading the scene)
  105086. * @ignorenaming
  105087. */
  105088. static loggingLevel: number;
  105089. /**
  105090. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105091. */
  105092. static CleanBoneMatrixWeights: boolean;
  105093. /**
  105094. * Event raised when a plugin is used to load a scene
  105095. */
  105096. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105097. private static _registeredPlugins;
  105098. private static _getDefaultPlugin;
  105099. private static _getPluginForExtension;
  105100. private static _getPluginForDirectLoad;
  105101. private static _getPluginForFilename;
  105102. private static _getDirectLoad;
  105103. private static _loadData;
  105104. private static _getFileInfo;
  105105. /**
  105106. * Gets a plugin that can load the given extension
  105107. * @param extension defines the extension to load
  105108. * @returns a plugin or null if none works
  105109. */
  105110. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105111. /**
  105112. * Gets a boolean indicating that the given extension can be loaded
  105113. * @param extension defines the extension to load
  105114. * @returns true if the extension is supported
  105115. */
  105116. static IsPluginForExtensionAvailable(extension: string): boolean;
  105117. /**
  105118. * Adds a new plugin to the list of registered plugins
  105119. * @param plugin defines the plugin to add
  105120. */
  105121. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105122. /**
  105123. * Import meshes into a scene
  105124. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105125. * @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)
  105126. * @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)
  105127. * @param scene the instance of BABYLON.Scene to append to
  105128. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105129. * @param onProgress a callback with a progress event for each file being loaded
  105130. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105131. * @param pluginExtension the extension used to determine the plugin
  105132. * @returns The loaded plugin
  105133. */
  105134. 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>;
  105135. /**
  105136. * Import meshes into a scene
  105137. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105138. * @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)
  105139. * @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)
  105140. * @param scene the instance of BABYLON.Scene to append to
  105141. * @param onProgress a callback with a progress event for each file being loaded
  105142. * @param pluginExtension the extension used to determine the plugin
  105143. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105144. */
  105145. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105146. meshes: AbstractMesh[];
  105147. particleSystems: IParticleSystem[];
  105148. skeletons: Skeleton[];
  105149. animationGroups: AnimationGroup[];
  105150. }>;
  105151. /**
  105152. * Load a scene
  105153. * @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)
  105154. * @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)
  105155. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105156. * @param onSuccess a callback with the scene when import succeeds
  105157. * @param onProgress a callback with a progress event for each file being loaded
  105158. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105159. * @param pluginExtension the extension used to determine the plugin
  105160. * @returns The loaded plugin
  105161. */
  105162. 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>;
  105163. /**
  105164. * Load a scene
  105165. * @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)
  105166. * @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)
  105167. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105168. * @param onProgress a callback with a progress event for each file being loaded
  105169. * @param pluginExtension the extension used to determine the plugin
  105170. * @returns The loaded scene
  105171. */
  105172. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105173. /**
  105174. * Append a scene
  105175. * @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)
  105176. * @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)
  105177. * @param scene is the instance of BABYLON.Scene to append to
  105178. * @param onSuccess a callback with the scene when import succeeds
  105179. * @param onProgress a callback with a progress event for each file being loaded
  105180. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105181. * @param pluginExtension the extension used to determine the plugin
  105182. * @returns The loaded plugin
  105183. */
  105184. 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>;
  105185. /**
  105186. * Append a scene
  105187. * @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)
  105188. * @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)
  105189. * @param scene is the instance of BABYLON.Scene to append to
  105190. * @param onProgress a callback with a progress event for each file being loaded
  105191. * @param pluginExtension the extension used to determine the plugin
  105192. * @returns The given scene
  105193. */
  105194. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105195. /**
  105196. * Load a scene into an asset container
  105197. * @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)
  105198. * @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)
  105199. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105200. * @param onSuccess a callback with the scene when import succeeds
  105201. * @param onProgress a callback with a progress event for each file being loaded
  105202. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105203. * @param pluginExtension the extension used to determine the plugin
  105204. * @returns The loaded plugin
  105205. */
  105206. 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>;
  105207. /**
  105208. * Load a scene into an asset container
  105209. * @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)
  105210. * @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)
  105211. * @param scene is the instance of Scene to append to
  105212. * @param onProgress a callback with a progress event for each file being loaded
  105213. * @param pluginExtension the extension used to determine the plugin
  105214. * @returns The loaded asset container
  105215. */
  105216. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105217. }
  105218. }
  105219. declare module BABYLON {
  105220. /**
  105221. * Google Daydream controller
  105222. */
  105223. export class DaydreamController extends WebVRController {
  105224. /**
  105225. * Base Url for the controller model.
  105226. */
  105227. static MODEL_BASE_URL: string;
  105228. /**
  105229. * File name for the controller model.
  105230. */
  105231. static MODEL_FILENAME: string;
  105232. /**
  105233. * Gamepad Id prefix used to identify Daydream Controller.
  105234. */
  105235. static readonly GAMEPAD_ID_PREFIX: string;
  105236. /**
  105237. * Creates a new DaydreamController from a gamepad
  105238. * @param vrGamepad the gamepad that the controller should be created from
  105239. */
  105240. constructor(vrGamepad: any);
  105241. /**
  105242. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105243. * @param scene scene in which to add meshes
  105244. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105245. */
  105246. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105247. /**
  105248. * Called once for each button that changed state since the last frame
  105249. * @param buttonIdx Which button index changed
  105250. * @param state New state of the button
  105251. * @param changes Which properties on the state changed since last frame
  105252. */
  105253. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105254. }
  105255. }
  105256. declare module BABYLON {
  105257. /**
  105258. * Gear VR Controller
  105259. */
  105260. export class GearVRController extends WebVRController {
  105261. /**
  105262. * Base Url for the controller model.
  105263. */
  105264. static MODEL_BASE_URL: string;
  105265. /**
  105266. * File name for the controller model.
  105267. */
  105268. static MODEL_FILENAME: string;
  105269. /**
  105270. * Gamepad Id prefix used to identify this controller.
  105271. */
  105272. static readonly GAMEPAD_ID_PREFIX: string;
  105273. private readonly _buttonIndexToObservableNameMap;
  105274. /**
  105275. * Creates a new GearVRController from a gamepad
  105276. * @param vrGamepad the gamepad that the controller should be created from
  105277. */
  105278. constructor(vrGamepad: any);
  105279. /**
  105280. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105281. * @param scene scene in which to add meshes
  105282. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105283. */
  105284. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105285. /**
  105286. * Called once for each button that changed state since the last frame
  105287. * @param buttonIdx Which button index changed
  105288. * @param state New state of the button
  105289. * @param changes Which properties on the state changed since last frame
  105290. */
  105291. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105292. }
  105293. }
  105294. declare module BABYLON {
  105295. /**
  105296. * Generic Controller
  105297. */
  105298. export class GenericController extends WebVRController {
  105299. /**
  105300. * Base Url for the controller model.
  105301. */
  105302. static readonly MODEL_BASE_URL: string;
  105303. /**
  105304. * File name for the controller model.
  105305. */
  105306. static readonly MODEL_FILENAME: string;
  105307. /**
  105308. * Creates a new GenericController from a gamepad
  105309. * @param vrGamepad the gamepad that the controller should be created from
  105310. */
  105311. constructor(vrGamepad: any);
  105312. /**
  105313. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105314. * @param scene scene in which to add meshes
  105315. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105316. */
  105317. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105318. /**
  105319. * Called once for each button that changed state since the last frame
  105320. * @param buttonIdx Which button index changed
  105321. * @param state New state of the button
  105322. * @param changes Which properties on the state changed since last frame
  105323. */
  105324. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105325. }
  105326. }
  105327. declare module BABYLON {
  105328. /**
  105329. * Oculus Touch Controller
  105330. */
  105331. export class OculusTouchController extends WebVRController {
  105332. /**
  105333. * Base Url for the controller model.
  105334. */
  105335. static MODEL_BASE_URL: string;
  105336. /**
  105337. * File name for the left controller model.
  105338. */
  105339. static MODEL_LEFT_FILENAME: string;
  105340. /**
  105341. * File name for the right controller model.
  105342. */
  105343. static MODEL_RIGHT_FILENAME: string;
  105344. /**
  105345. * Fired when the secondary trigger on this controller is modified
  105346. */
  105347. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105348. /**
  105349. * Fired when the thumb rest on this controller is modified
  105350. */
  105351. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105352. /**
  105353. * Creates a new OculusTouchController from a gamepad
  105354. * @param vrGamepad the gamepad that the controller should be created from
  105355. */
  105356. constructor(vrGamepad: any);
  105357. /**
  105358. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105359. * @param scene scene in which to add meshes
  105360. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105361. */
  105362. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105363. /**
  105364. * Fired when the A button on this controller is modified
  105365. */
  105366. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105367. /**
  105368. * Fired when the B button on this controller is modified
  105369. */
  105370. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105371. /**
  105372. * Fired when the X button on this controller is modified
  105373. */
  105374. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105375. /**
  105376. * Fired when the Y button on this controller is modified
  105377. */
  105378. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105379. /**
  105380. * Called once for each button that changed state since the last frame
  105381. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105382. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105383. * 2) secondary trigger (same)
  105384. * 3) A (right) X (left), touch, pressed = value
  105385. * 4) B / Y
  105386. * 5) thumb rest
  105387. * @param buttonIdx Which button index changed
  105388. * @param state New state of the button
  105389. * @param changes Which properties on the state changed since last frame
  105390. */
  105391. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105392. }
  105393. }
  105394. declare module BABYLON {
  105395. /**
  105396. * Vive Controller
  105397. */
  105398. export class ViveController extends WebVRController {
  105399. /**
  105400. * Base Url for the controller model.
  105401. */
  105402. static MODEL_BASE_URL: string;
  105403. /**
  105404. * File name for the controller model.
  105405. */
  105406. static MODEL_FILENAME: string;
  105407. /**
  105408. * Creates a new ViveController from a gamepad
  105409. * @param vrGamepad the gamepad that the controller should be created from
  105410. */
  105411. constructor(vrGamepad: any);
  105412. /**
  105413. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105414. * @param scene scene in which to add meshes
  105415. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105416. */
  105417. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105418. /**
  105419. * Fired when the left button on this controller is modified
  105420. */
  105421. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105422. /**
  105423. * Fired when the right button on this controller is modified
  105424. */
  105425. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105426. /**
  105427. * Fired when the menu button on this controller is modified
  105428. */
  105429. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105430. /**
  105431. * Called once for each button that changed state since the last frame
  105432. * Vive mapping:
  105433. * 0: touchpad
  105434. * 1: trigger
  105435. * 2: left AND right buttons
  105436. * 3: menu button
  105437. * @param buttonIdx Which button index changed
  105438. * @param state New state of the button
  105439. * @param changes Which properties on the state changed since last frame
  105440. */
  105441. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105442. }
  105443. }
  105444. declare module BABYLON {
  105445. /**
  105446. * Defines the WindowsMotionController object that the state of the windows motion controller
  105447. */
  105448. export class WindowsMotionController extends WebVRController {
  105449. /**
  105450. * The base url used to load the left and right controller models
  105451. */
  105452. static MODEL_BASE_URL: string;
  105453. /**
  105454. * The name of the left controller model file
  105455. */
  105456. static MODEL_LEFT_FILENAME: string;
  105457. /**
  105458. * The name of the right controller model file
  105459. */
  105460. static MODEL_RIGHT_FILENAME: string;
  105461. /**
  105462. * The controller name prefix for this controller type
  105463. */
  105464. static readonly GAMEPAD_ID_PREFIX: string;
  105465. /**
  105466. * The controller id pattern for this controller type
  105467. */
  105468. private static readonly GAMEPAD_ID_PATTERN;
  105469. private _loadedMeshInfo;
  105470. private readonly _mapping;
  105471. /**
  105472. * Fired when the trackpad on this controller is clicked
  105473. */
  105474. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105475. /**
  105476. * Fired when the trackpad on this controller is modified
  105477. */
  105478. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105479. /**
  105480. * The current x and y values of this controller's trackpad
  105481. */
  105482. trackpad: StickValues;
  105483. /**
  105484. * Creates a new WindowsMotionController from a gamepad
  105485. * @param vrGamepad the gamepad that the controller should be created from
  105486. */
  105487. constructor(vrGamepad: any);
  105488. /**
  105489. * Fired when the trigger on this controller is modified
  105490. */
  105491. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105492. /**
  105493. * Fired when the menu button on this controller is modified
  105494. */
  105495. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105496. /**
  105497. * Fired when the grip button on this controller is modified
  105498. */
  105499. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105500. /**
  105501. * Fired when the thumbstick button on this controller is modified
  105502. */
  105503. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105504. /**
  105505. * Fired when the touchpad button on this controller is modified
  105506. */
  105507. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105508. /**
  105509. * Fired when the touchpad values on this controller are modified
  105510. */
  105511. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105512. private _updateTrackpad;
  105513. /**
  105514. * Called once per frame by the engine.
  105515. */
  105516. update(): void;
  105517. /**
  105518. * Called once for each button that changed state since the last frame
  105519. * @param buttonIdx Which button index changed
  105520. * @param state New state of the button
  105521. * @param changes Which properties on the state changed since last frame
  105522. */
  105523. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105524. /**
  105525. * Moves the buttons on the controller mesh based on their current state
  105526. * @param buttonName the name of the button to move
  105527. * @param buttonValue the value of the button which determines the buttons new position
  105528. */
  105529. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105530. /**
  105531. * Moves the axis on the controller mesh based on its current state
  105532. * @param axis the index of the axis
  105533. * @param axisValue the value of the axis which determines the meshes new position
  105534. * @hidden
  105535. */
  105536. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105537. /**
  105538. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105539. * @param scene scene in which to add meshes
  105540. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105541. */
  105542. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105543. /**
  105544. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105545. * can be transformed by button presses and axes values, based on this._mapping.
  105546. *
  105547. * @param scene scene in which the meshes exist
  105548. * @param meshes list of meshes that make up the controller model to process
  105549. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105550. */
  105551. private processModel;
  105552. private createMeshInfo;
  105553. /**
  105554. * Gets the ray of the controller in the direction the controller is pointing
  105555. * @param length the length the resulting ray should be
  105556. * @returns a ray in the direction the controller is pointing
  105557. */
  105558. getForwardRay(length?: number): Ray;
  105559. /**
  105560. * Disposes of the controller
  105561. */
  105562. dispose(): void;
  105563. }
  105564. }
  105565. declare module BABYLON {
  105566. /**
  105567. * Class containing static functions to help procedurally build meshes
  105568. */
  105569. export class PolyhedronBuilder {
  105570. /**
  105571. * Creates a polyhedron mesh
  105572. * * 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
  105573. * * The parameter `size` (positive float, default 1) sets the polygon size
  105574. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105575. * * 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`
  105576. * * 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
  105577. * * 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)`)
  105578. * * 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
  105579. * * 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
  105580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105581. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105583. * @param name defines the name of the mesh
  105584. * @param options defines the options used to create the mesh
  105585. * @param scene defines the hosting scene
  105586. * @returns the polyhedron mesh
  105587. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  105588. */
  105589. static CreatePolyhedron(name: string, options: {
  105590. type?: number;
  105591. size?: number;
  105592. sizeX?: number;
  105593. sizeY?: number;
  105594. sizeZ?: number;
  105595. custom?: any;
  105596. faceUV?: Vector4[];
  105597. faceColors?: Color4[];
  105598. flat?: boolean;
  105599. updatable?: boolean;
  105600. sideOrientation?: number;
  105601. frontUVs?: Vector4;
  105602. backUVs?: Vector4;
  105603. }, scene?: Nullable<Scene>): Mesh;
  105604. }
  105605. }
  105606. declare module BABYLON {
  105607. /**
  105608. * Gizmo that enables scaling a mesh along 3 axis
  105609. */
  105610. export class ScaleGizmo extends Gizmo {
  105611. /**
  105612. * Internal gizmo used for interactions on the x axis
  105613. */
  105614. xGizmo: AxisScaleGizmo;
  105615. /**
  105616. * Internal gizmo used for interactions on the y axis
  105617. */
  105618. yGizmo: AxisScaleGizmo;
  105619. /**
  105620. * Internal gizmo used for interactions on the z axis
  105621. */
  105622. zGizmo: AxisScaleGizmo;
  105623. /**
  105624. * Internal gizmo used to scale all axis equally
  105625. */
  105626. uniformScaleGizmo: AxisScaleGizmo;
  105627. private _meshAttached;
  105628. private _updateGizmoRotationToMatchAttachedMesh;
  105629. private _snapDistance;
  105630. private _scaleRatio;
  105631. private _uniformScalingMesh;
  105632. private _octahedron;
  105633. /** Fires an event when any of it's sub gizmos are dragged */
  105634. onDragStartObservable: Observable<unknown>;
  105635. /** Fires an event when any of it's sub gizmos are released from dragging */
  105636. onDragEndObservable: Observable<unknown>;
  105637. attachedMesh: Nullable<AbstractMesh>;
  105638. /**
  105639. * Creates a ScaleGizmo
  105640. * @param gizmoLayer The utility layer the gizmo will be added to
  105641. */
  105642. constructor(gizmoLayer?: UtilityLayerRenderer);
  105643. updateGizmoRotationToMatchAttachedMesh: boolean;
  105644. /**
  105645. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105646. */
  105647. snapDistance: number;
  105648. /**
  105649. * Ratio for the scale of the gizmo (Default: 1)
  105650. */
  105651. scaleRatio: number;
  105652. /**
  105653. * Disposes of the gizmo
  105654. */
  105655. dispose(): void;
  105656. }
  105657. }
  105658. declare module BABYLON {
  105659. /**
  105660. * Single axis scale gizmo
  105661. */
  105662. export class AxisScaleGizmo extends Gizmo {
  105663. /**
  105664. * Drag behavior responsible for the gizmos dragging interactions
  105665. */
  105666. dragBehavior: PointerDragBehavior;
  105667. private _pointerObserver;
  105668. /**
  105669. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105670. */
  105671. snapDistance: number;
  105672. /**
  105673. * Event that fires each time the gizmo snaps to a new location.
  105674. * * snapDistance is the the change in distance
  105675. */
  105676. onSnapObservable: Observable<{
  105677. snapDistance: number;
  105678. }>;
  105679. /**
  105680. * If the scaling operation should be done on all axis (default: false)
  105681. */
  105682. uniformScaling: boolean;
  105683. private _isEnabled;
  105684. private _parent;
  105685. private _arrow;
  105686. private _coloredMaterial;
  105687. private _hoverMaterial;
  105688. /**
  105689. * Creates an AxisScaleGizmo
  105690. * @param gizmoLayer The utility layer the gizmo will be added to
  105691. * @param dragAxis The axis which the gizmo will be able to scale on
  105692. * @param color The color of the gizmo
  105693. */
  105694. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  105695. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105696. /**
  105697. * If the gizmo is enabled
  105698. */
  105699. isEnabled: boolean;
  105700. /**
  105701. * Disposes of the gizmo
  105702. */
  105703. dispose(): void;
  105704. /**
  105705. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  105706. * @param mesh The mesh to replace the default mesh of the gizmo
  105707. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  105708. */
  105709. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  105710. }
  105711. }
  105712. declare module BABYLON {
  105713. /**
  105714. * Bounding box gizmo
  105715. */
  105716. export class BoundingBoxGizmo extends Gizmo {
  105717. private _lineBoundingBox;
  105718. private _rotateSpheresParent;
  105719. private _scaleBoxesParent;
  105720. private _boundingDimensions;
  105721. private _renderObserver;
  105722. private _pointerObserver;
  105723. private _scaleDragSpeed;
  105724. private _tmpQuaternion;
  105725. private _tmpVector;
  105726. private _tmpRotationMatrix;
  105727. /**
  105728. * 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)
  105729. */
  105730. ignoreChildren: boolean;
  105731. /**
  105732. * 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)
  105733. */
  105734. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  105735. /**
  105736. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  105737. */
  105738. rotationSphereSize: number;
  105739. /**
  105740. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  105741. */
  105742. scaleBoxSize: number;
  105743. /**
  105744. * 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)
  105745. */
  105746. fixedDragMeshScreenSize: boolean;
  105747. /**
  105748. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  105749. */
  105750. fixedDragMeshScreenSizeDistanceFactor: number;
  105751. /**
  105752. * Fired when a rotation sphere or scale box is dragged
  105753. */
  105754. onDragStartObservable: Observable<{}>;
  105755. /**
  105756. * Fired when a scale box is dragged
  105757. */
  105758. onScaleBoxDragObservable: Observable<{}>;
  105759. /**
  105760. * Fired when a scale box drag is ended
  105761. */
  105762. onScaleBoxDragEndObservable: Observable<{}>;
  105763. /**
  105764. * Fired when a rotation sphere is dragged
  105765. */
  105766. onRotationSphereDragObservable: Observable<{}>;
  105767. /**
  105768. * Fired when a rotation sphere drag is ended
  105769. */
  105770. onRotationSphereDragEndObservable: Observable<{}>;
  105771. /**
  105772. * 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)
  105773. */
  105774. scalePivot: Nullable<Vector3>;
  105775. /**
  105776. * Mesh used as a pivot to rotate the attached mesh
  105777. */
  105778. private _anchorMesh;
  105779. private _existingMeshScale;
  105780. private _dragMesh;
  105781. private pointerDragBehavior;
  105782. private coloredMaterial;
  105783. private hoverColoredMaterial;
  105784. /**
  105785. * Sets the color of the bounding box gizmo
  105786. * @param color the color to set
  105787. */
  105788. setColor(color: Color3): void;
  105789. /**
  105790. * Creates an BoundingBoxGizmo
  105791. * @param gizmoLayer The utility layer the gizmo will be added to
  105792. * @param color The color of the gizmo
  105793. */
  105794. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  105795. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105796. private _selectNode;
  105797. /**
  105798. * Updates the bounding box information for the Gizmo
  105799. */
  105800. updateBoundingBox(): void;
  105801. private _updateRotationSpheres;
  105802. private _updateScaleBoxes;
  105803. /**
  105804. * Enables rotation on the specified axis and disables rotation on the others
  105805. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  105806. */
  105807. setEnabledRotationAxis(axis: string): void;
  105808. /**
  105809. * Enables/disables scaling
  105810. * @param enable if scaling should be enabled
  105811. */
  105812. setEnabledScaling(enable: boolean): void;
  105813. private _updateDummy;
  105814. /**
  105815. * Enables a pointer drag behavior on the bounding box of the gizmo
  105816. */
  105817. enableDragBehavior(): void;
  105818. /**
  105819. * Disposes of the gizmo
  105820. */
  105821. dispose(): void;
  105822. /**
  105823. * 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)
  105824. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  105825. * @returns the bounding box mesh with the passed in mesh as a child
  105826. */
  105827. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  105828. /**
  105829. * CustomMeshes are not supported by this gizmo
  105830. * @param mesh The mesh to replace the default mesh of the gizmo
  105831. */
  105832. setCustomMesh(mesh: Mesh): void;
  105833. }
  105834. }
  105835. declare module BABYLON {
  105836. /**
  105837. * Single plane rotation gizmo
  105838. */
  105839. export class PlaneRotationGizmo extends Gizmo {
  105840. /**
  105841. * Drag behavior responsible for the gizmos dragging interactions
  105842. */
  105843. dragBehavior: PointerDragBehavior;
  105844. private _pointerObserver;
  105845. /**
  105846. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  105847. */
  105848. snapDistance: number;
  105849. /**
  105850. * Event that fires each time the gizmo snaps to a new location.
  105851. * * snapDistance is the the change in distance
  105852. */
  105853. onSnapObservable: Observable<{
  105854. snapDistance: number;
  105855. }>;
  105856. private _isEnabled;
  105857. private _parent;
  105858. /**
  105859. * Creates a PlaneRotationGizmo
  105860. * @param gizmoLayer The utility layer the gizmo will be added to
  105861. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  105862. * @param color The color of the gizmo
  105863. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105864. */
  105865. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  105866. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105867. /**
  105868. * If the gizmo is enabled
  105869. */
  105870. isEnabled: boolean;
  105871. /**
  105872. * Disposes of the gizmo
  105873. */
  105874. dispose(): void;
  105875. }
  105876. }
  105877. declare module BABYLON {
  105878. /**
  105879. * Gizmo that enables rotating a mesh along 3 axis
  105880. */
  105881. export class RotationGizmo extends Gizmo {
  105882. /**
  105883. * Internal gizmo used for interactions on the x axis
  105884. */
  105885. xGizmo: PlaneRotationGizmo;
  105886. /**
  105887. * Internal gizmo used for interactions on the y axis
  105888. */
  105889. yGizmo: PlaneRotationGizmo;
  105890. /**
  105891. * Internal gizmo used for interactions on the z axis
  105892. */
  105893. zGizmo: PlaneRotationGizmo;
  105894. /** Fires an event when any of it's sub gizmos are dragged */
  105895. onDragStartObservable: Observable<unknown>;
  105896. /** Fires an event when any of it's sub gizmos are released from dragging */
  105897. onDragEndObservable: Observable<unknown>;
  105898. private _meshAttached;
  105899. attachedMesh: Nullable<AbstractMesh>;
  105900. /**
  105901. * Creates a RotationGizmo
  105902. * @param gizmoLayer The utility layer the gizmo will be added to
  105903. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105904. */
  105905. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  105906. updateGizmoRotationToMatchAttachedMesh: boolean;
  105907. /**
  105908. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105909. */
  105910. snapDistance: number;
  105911. /**
  105912. * Ratio for the scale of the gizmo (Default: 1)
  105913. */
  105914. scaleRatio: number;
  105915. /**
  105916. * Disposes of the gizmo
  105917. */
  105918. dispose(): void;
  105919. /**
  105920. * CustomMeshes are not supported by this gizmo
  105921. * @param mesh The mesh to replace the default mesh of the gizmo
  105922. */
  105923. setCustomMesh(mesh: Mesh): void;
  105924. }
  105925. }
  105926. declare module BABYLON {
  105927. /**
  105928. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  105929. */
  105930. export class GizmoManager implements IDisposable {
  105931. private scene;
  105932. /**
  105933. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  105934. */
  105935. gizmos: {
  105936. positionGizmo: Nullable<PositionGizmo>;
  105937. rotationGizmo: Nullable<RotationGizmo>;
  105938. scaleGizmo: Nullable<ScaleGizmo>;
  105939. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  105940. };
  105941. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  105942. clearGizmoOnEmptyPointerEvent: boolean;
  105943. /** Fires an event when the manager is attached to a mesh */
  105944. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  105945. private _gizmosEnabled;
  105946. private _pointerObserver;
  105947. private _attachedMesh;
  105948. private _boundingBoxColor;
  105949. private _defaultUtilityLayer;
  105950. private _defaultKeepDepthUtilityLayer;
  105951. /**
  105952. * When bounding box gizmo is enabled, this can be used to track drag/end events
  105953. */
  105954. boundingBoxDragBehavior: SixDofDragBehavior;
  105955. /**
  105956. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  105957. */
  105958. attachableMeshes: Nullable<Array<AbstractMesh>>;
  105959. /**
  105960. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  105961. */
  105962. usePointerToAttachGizmos: boolean;
  105963. /**
  105964. * Utility layer that the bounding box gizmo belongs to
  105965. */
  105966. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  105967. /**
  105968. * Utility layer that all gizmos besides bounding box belong to
  105969. */
  105970. readonly utilityLayer: UtilityLayerRenderer;
  105971. /**
  105972. * Instatiates a gizmo manager
  105973. * @param scene the scene to overlay the gizmos on top of
  105974. */
  105975. constructor(scene: Scene);
  105976. /**
  105977. * Attaches a set of gizmos to the specified mesh
  105978. * @param mesh The mesh the gizmo's should be attached to
  105979. */
  105980. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  105981. /**
  105982. * If the position gizmo is enabled
  105983. */
  105984. positionGizmoEnabled: boolean;
  105985. /**
  105986. * If the rotation gizmo is enabled
  105987. */
  105988. rotationGizmoEnabled: boolean;
  105989. /**
  105990. * If the scale gizmo is enabled
  105991. */
  105992. scaleGizmoEnabled: boolean;
  105993. /**
  105994. * If the boundingBox gizmo is enabled
  105995. */
  105996. boundingBoxGizmoEnabled: boolean;
  105997. /**
  105998. * Disposes of the gizmo manager
  105999. */
  106000. dispose(): void;
  106001. }
  106002. }
  106003. declare module BABYLON {
  106004. /**
  106005. * A directional light is defined by a direction (what a surprise!).
  106006. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  106007. * 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.
  106008. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106009. */
  106010. export class DirectionalLight extends ShadowLight {
  106011. private _shadowFrustumSize;
  106012. /**
  106013. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  106014. */
  106015. /**
  106016. * Specifies a fix frustum size for the shadow generation.
  106017. */
  106018. shadowFrustumSize: number;
  106019. private _shadowOrthoScale;
  106020. /**
  106021. * Gets the shadow projection scale against the optimal computed one.
  106022. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106023. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106024. */
  106025. /**
  106026. * Sets the shadow projection scale against the optimal computed one.
  106027. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106028. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106029. */
  106030. shadowOrthoScale: number;
  106031. /**
  106032. * Automatically compute the projection matrix to best fit (including all the casters)
  106033. * on each frame.
  106034. */
  106035. autoUpdateExtends: boolean;
  106036. private _orthoLeft;
  106037. private _orthoRight;
  106038. private _orthoTop;
  106039. private _orthoBottom;
  106040. /**
  106041. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  106042. * The directional light is emitted from everywhere in the given direction.
  106043. * It can cast shadows.
  106044. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106045. * @param name The friendly name of the light
  106046. * @param direction The direction of the light
  106047. * @param scene The scene the light belongs to
  106048. */
  106049. constructor(name: string, direction: Vector3, scene: Scene);
  106050. /**
  106051. * Returns the string "DirectionalLight".
  106052. * @return The class name
  106053. */
  106054. getClassName(): string;
  106055. /**
  106056. * Returns the integer 1.
  106057. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106058. */
  106059. getTypeID(): number;
  106060. /**
  106061. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  106062. * Returns the DirectionalLight Shadow projection matrix.
  106063. */
  106064. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106065. /**
  106066. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  106067. * Returns the DirectionalLight Shadow projection matrix.
  106068. */
  106069. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  106070. /**
  106071. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  106072. * Returns the DirectionalLight Shadow projection matrix.
  106073. */
  106074. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106075. protected _buildUniformLayout(): void;
  106076. /**
  106077. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  106078. * @param effect The effect to update
  106079. * @param lightIndex The index of the light in the effect to update
  106080. * @returns The directional light
  106081. */
  106082. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  106083. /**
  106084. * Gets the minZ used for shadow according to both the scene and the light.
  106085. *
  106086. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106087. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106088. * @param activeCamera The camera we are returning the min for
  106089. * @returns the depth min z
  106090. */
  106091. getDepthMinZ(activeCamera: Camera): number;
  106092. /**
  106093. * Gets the maxZ used for shadow according to both the scene and the light.
  106094. *
  106095. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106096. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106097. * @param activeCamera The camera we are returning the max for
  106098. * @returns the depth max z
  106099. */
  106100. getDepthMaxZ(activeCamera: Camera): number;
  106101. /**
  106102. * Prepares the list of defines specific to the light type.
  106103. * @param defines the list of defines
  106104. * @param lightIndex defines the index of the light for the effect
  106105. */
  106106. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106107. }
  106108. }
  106109. declare module BABYLON {
  106110. /**
  106111. * Class containing static functions to help procedurally build meshes
  106112. */
  106113. export class HemisphereBuilder {
  106114. /**
  106115. * Creates a hemisphere mesh
  106116. * @param name defines the name of the mesh
  106117. * @param options defines the options used to create the mesh
  106118. * @param scene defines the hosting scene
  106119. * @returns the hemisphere mesh
  106120. */
  106121. static CreateHemisphere(name: string, options: {
  106122. segments?: number;
  106123. diameter?: number;
  106124. sideOrientation?: number;
  106125. }, scene: any): Mesh;
  106126. }
  106127. }
  106128. declare module BABYLON {
  106129. /**
  106130. * A spot light is defined by a position, a direction, an angle, and an exponent.
  106131. * These values define a cone of light starting from the position, emitting toward the direction.
  106132. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  106133. * and the exponent defines the speed of the decay of the light with distance (reach).
  106134. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106135. */
  106136. export class SpotLight extends ShadowLight {
  106137. private _angle;
  106138. private _innerAngle;
  106139. private _cosHalfAngle;
  106140. private _lightAngleScale;
  106141. private _lightAngleOffset;
  106142. /**
  106143. * Gets the cone angle of the spot light in Radians.
  106144. */
  106145. /**
  106146. * Sets the cone angle of the spot light in Radians.
  106147. */
  106148. angle: number;
  106149. /**
  106150. * Only used in gltf falloff mode, this defines the angle where
  106151. * the directional falloff will start before cutting at angle which could be seen
  106152. * as outer angle.
  106153. */
  106154. /**
  106155. * Only used in gltf falloff mode, this defines the angle where
  106156. * the directional falloff will start before cutting at angle which could be seen
  106157. * as outer angle.
  106158. */
  106159. innerAngle: number;
  106160. private _shadowAngleScale;
  106161. /**
  106162. * Allows scaling the angle of the light for shadow generation only.
  106163. */
  106164. /**
  106165. * Allows scaling the angle of the light for shadow generation only.
  106166. */
  106167. shadowAngleScale: number;
  106168. /**
  106169. * The light decay speed with the distance from the emission spot.
  106170. */
  106171. exponent: number;
  106172. private _projectionTextureMatrix;
  106173. /**
  106174. * Allows reading the projecton texture
  106175. */
  106176. readonly projectionTextureMatrix: Matrix;
  106177. protected _projectionTextureLightNear: number;
  106178. /**
  106179. * Gets the near clip of the Spotlight for texture projection.
  106180. */
  106181. /**
  106182. * Sets the near clip of the Spotlight for texture projection.
  106183. */
  106184. projectionTextureLightNear: number;
  106185. protected _projectionTextureLightFar: number;
  106186. /**
  106187. * Gets the far clip of the Spotlight for texture projection.
  106188. */
  106189. /**
  106190. * Sets the far clip of the Spotlight for texture projection.
  106191. */
  106192. projectionTextureLightFar: number;
  106193. protected _projectionTextureUpDirection: Vector3;
  106194. /**
  106195. * Gets the Up vector of the Spotlight for texture projection.
  106196. */
  106197. /**
  106198. * Sets the Up vector of the Spotlight for texture projection.
  106199. */
  106200. projectionTextureUpDirection: Vector3;
  106201. private _projectionTexture;
  106202. /**
  106203. * Gets the projection texture of the light.
  106204. */
  106205. /**
  106206. * Sets the projection texture of the light.
  106207. */
  106208. projectionTexture: Nullable<BaseTexture>;
  106209. private _projectionTextureViewLightDirty;
  106210. private _projectionTextureProjectionLightDirty;
  106211. private _projectionTextureDirty;
  106212. private _projectionTextureViewTargetVector;
  106213. private _projectionTextureViewLightMatrix;
  106214. private _projectionTextureProjectionLightMatrix;
  106215. private _projectionTextureScalingMatrix;
  106216. /**
  106217. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  106218. * It can cast shadows.
  106219. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106220. * @param name The light friendly name
  106221. * @param position The position of the spot light in the scene
  106222. * @param direction The direction of the light in the scene
  106223. * @param angle The cone angle of the light in Radians
  106224. * @param exponent The light decay speed with the distance from the emission spot
  106225. * @param scene The scene the lights belongs to
  106226. */
  106227. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  106228. /**
  106229. * Returns the string "SpotLight".
  106230. * @returns the class name
  106231. */
  106232. getClassName(): string;
  106233. /**
  106234. * Returns the integer 2.
  106235. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106236. */
  106237. getTypeID(): number;
  106238. /**
  106239. * Overrides the direction setter to recompute the projection texture view light Matrix.
  106240. */
  106241. protected _setDirection(value: Vector3): void;
  106242. /**
  106243. * Overrides the position setter to recompute the projection texture view light Matrix.
  106244. */
  106245. protected _setPosition(value: Vector3): void;
  106246. /**
  106247. * 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.
  106248. * Returns the SpotLight.
  106249. */
  106250. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106251. protected _computeProjectionTextureViewLightMatrix(): void;
  106252. protected _computeProjectionTextureProjectionLightMatrix(): void;
  106253. /**
  106254. * Main function for light texture projection matrix computing.
  106255. */
  106256. protected _computeProjectionTextureMatrix(): void;
  106257. protected _buildUniformLayout(): void;
  106258. private _computeAngleValues;
  106259. /**
  106260. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  106261. * @param effect The effect to update
  106262. * @param lightIndex The index of the light in the effect to update
  106263. * @returns The spot light
  106264. */
  106265. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  106266. /**
  106267. * Disposes the light and the associated resources.
  106268. */
  106269. dispose(): void;
  106270. /**
  106271. * Prepares the list of defines specific to the light type.
  106272. * @param defines the list of defines
  106273. * @param lightIndex defines the index of the light for the effect
  106274. */
  106275. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106276. }
  106277. }
  106278. declare module BABYLON {
  106279. /**
  106280. * Gizmo that enables viewing a light
  106281. */
  106282. export class LightGizmo extends Gizmo {
  106283. private _lightMesh;
  106284. private _material;
  106285. private cachedPosition;
  106286. private cachedForward;
  106287. /**
  106288. * Creates a LightGizmo
  106289. * @param gizmoLayer The utility layer the gizmo will be added to
  106290. */
  106291. constructor(gizmoLayer?: UtilityLayerRenderer);
  106292. private _light;
  106293. /**
  106294. * The light that the gizmo is attached to
  106295. */
  106296. light: Nullable<Light>;
  106297. /**
  106298. * @hidden
  106299. * Updates the gizmo to match the attached mesh's position/rotation
  106300. */
  106301. protected _update(): void;
  106302. private static _Scale;
  106303. /**
  106304. * Creates the lines for a light mesh
  106305. */
  106306. private static _createLightLines;
  106307. /**
  106308. * Disposes of the light gizmo
  106309. */
  106310. dispose(): void;
  106311. private static _CreateHemisphericLightMesh;
  106312. private static _CreatePointLightMesh;
  106313. private static _CreateSpotLightMesh;
  106314. private static _CreateDirectionalLightMesh;
  106315. }
  106316. }
  106317. declare module BABYLON {
  106318. /** @hidden */
  106319. export var backgroundFragmentDeclaration: {
  106320. name: string;
  106321. shader: string;
  106322. };
  106323. }
  106324. declare module BABYLON {
  106325. /** @hidden */
  106326. export var backgroundUboDeclaration: {
  106327. name: string;
  106328. shader: string;
  106329. };
  106330. }
  106331. declare module BABYLON {
  106332. /** @hidden */
  106333. export var backgroundPixelShader: {
  106334. name: string;
  106335. shader: string;
  106336. };
  106337. }
  106338. declare module BABYLON {
  106339. /** @hidden */
  106340. export var backgroundVertexDeclaration: {
  106341. name: string;
  106342. shader: string;
  106343. };
  106344. }
  106345. declare module BABYLON {
  106346. /** @hidden */
  106347. export var backgroundVertexShader: {
  106348. name: string;
  106349. shader: string;
  106350. };
  106351. }
  106352. declare module BABYLON {
  106353. /**
  106354. * Background material used to create an efficient environement around your scene.
  106355. */
  106356. export class BackgroundMaterial extends PushMaterial {
  106357. /**
  106358. * Standard reflectance value at parallel view angle.
  106359. */
  106360. static StandardReflectance0: number;
  106361. /**
  106362. * Standard reflectance value at grazing angle.
  106363. */
  106364. static StandardReflectance90: number;
  106365. protected _primaryColor: Color3;
  106366. /**
  106367. * Key light Color (multiply against the environement texture)
  106368. */
  106369. primaryColor: Color3;
  106370. protected __perceptualColor: Nullable<Color3>;
  106371. /**
  106372. * Experimental Internal Use Only.
  106373. *
  106374. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106375. * This acts as a helper to set the primary color to a more "human friendly" value.
  106376. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106377. * output color as close as possible from the chosen value.
  106378. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106379. * part of lighting setup.)
  106380. */
  106381. _perceptualColor: Nullable<Color3>;
  106382. protected _primaryColorShadowLevel: float;
  106383. /**
  106384. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106385. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106386. */
  106387. primaryColorShadowLevel: float;
  106388. protected _primaryColorHighlightLevel: float;
  106389. /**
  106390. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106391. * The primary color is used at the level chosen to define what the white area would look.
  106392. */
  106393. primaryColorHighlightLevel: float;
  106394. protected _reflectionTexture: Nullable<BaseTexture>;
  106395. /**
  106396. * Reflection Texture used in the material.
  106397. * Should be author in a specific way for the best result (refer to the documentation).
  106398. */
  106399. reflectionTexture: Nullable<BaseTexture>;
  106400. protected _reflectionBlur: float;
  106401. /**
  106402. * Reflection Texture level of blur.
  106403. *
  106404. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106405. * texture twice.
  106406. */
  106407. reflectionBlur: float;
  106408. protected _diffuseTexture: Nullable<BaseTexture>;
  106409. /**
  106410. * Diffuse Texture used in the material.
  106411. * Should be author in a specific way for the best result (refer to the documentation).
  106412. */
  106413. diffuseTexture: Nullable<BaseTexture>;
  106414. protected _shadowLights: Nullable<IShadowLight[]>;
  106415. /**
  106416. * Specify the list of lights casting shadow on the material.
  106417. * All scene shadow lights will be included if null.
  106418. */
  106419. shadowLights: Nullable<IShadowLight[]>;
  106420. protected _shadowLevel: float;
  106421. /**
  106422. * Helps adjusting the shadow to a softer level if required.
  106423. * 0 means black shadows and 1 means no shadows.
  106424. */
  106425. shadowLevel: float;
  106426. protected _sceneCenter: Vector3;
  106427. /**
  106428. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106429. * It is usually zero but might be interesting to modify according to your setup.
  106430. */
  106431. sceneCenter: Vector3;
  106432. protected _opacityFresnel: boolean;
  106433. /**
  106434. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106435. * This helps ensuring a nice transition when the camera goes under the ground.
  106436. */
  106437. opacityFresnel: boolean;
  106438. protected _reflectionFresnel: boolean;
  106439. /**
  106440. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  106441. * This helps adding a mirror texture on the ground.
  106442. */
  106443. reflectionFresnel: boolean;
  106444. protected _reflectionFalloffDistance: number;
  106445. /**
  106446. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  106447. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  106448. */
  106449. reflectionFalloffDistance: number;
  106450. protected _reflectionAmount: number;
  106451. /**
  106452. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  106453. */
  106454. reflectionAmount: number;
  106455. protected _reflectionReflectance0: number;
  106456. /**
  106457. * This specifies the weight of the reflection at grazing angle.
  106458. */
  106459. reflectionReflectance0: number;
  106460. protected _reflectionReflectance90: number;
  106461. /**
  106462. * This specifies the weight of the reflection at a perpendicular point of view.
  106463. */
  106464. reflectionReflectance90: number;
  106465. /**
  106466. * Sets the reflection reflectance fresnel values according to the default standard
  106467. * empirically know to work well :-)
  106468. */
  106469. reflectionStandardFresnelWeight: number;
  106470. protected _useRGBColor: boolean;
  106471. /**
  106472. * Helps to directly use the maps channels instead of their level.
  106473. */
  106474. useRGBColor: boolean;
  106475. protected _enableNoise: boolean;
  106476. /**
  106477. * This helps reducing the banding effect that could occur on the background.
  106478. */
  106479. enableNoise: boolean;
  106480. /**
  106481. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106482. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  106483. * Recommended to be keep at 1.0 except for special cases.
  106484. */
  106485. fovMultiplier: number;
  106486. private _fovMultiplier;
  106487. /**
  106488. * Enable the FOV adjustment feature controlled by fovMultiplier.
  106489. */
  106490. useEquirectangularFOV: boolean;
  106491. private _maxSimultaneousLights;
  106492. /**
  106493. * Number of Simultaneous lights allowed on the material.
  106494. */
  106495. maxSimultaneousLights: int;
  106496. /**
  106497. * Default configuration related to image processing available in the Background Material.
  106498. */
  106499. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106500. /**
  106501. * Keep track of the image processing observer to allow dispose and replace.
  106502. */
  106503. private _imageProcessingObserver;
  106504. /**
  106505. * Attaches a new image processing configuration to the PBR Material.
  106506. * @param configuration (if null the scene configuration will be use)
  106507. */
  106508. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106509. /**
  106510. * Gets the image processing configuration used either in this material.
  106511. */
  106512. /**
  106513. * Sets the Default image processing configuration used either in the this material.
  106514. *
  106515. * If sets to null, the scene one is in use.
  106516. */
  106517. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  106518. /**
  106519. * Gets wether the color curves effect is enabled.
  106520. */
  106521. /**
  106522. * Sets wether the color curves effect is enabled.
  106523. */
  106524. cameraColorCurvesEnabled: boolean;
  106525. /**
  106526. * Gets wether the color grading effect is enabled.
  106527. */
  106528. /**
  106529. * Gets wether the color grading effect is enabled.
  106530. */
  106531. cameraColorGradingEnabled: boolean;
  106532. /**
  106533. * Gets wether tonemapping is enabled or not.
  106534. */
  106535. /**
  106536. * Sets wether tonemapping is enabled or not
  106537. */
  106538. cameraToneMappingEnabled: boolean;
  106539. /**
  106540. * The camera exposure used on this material.
  106541. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106542. * This corresponds to a photographic exposure.
  106543. */
  106544. /**
  106545. * The camera exposure used on this material.
  106546. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106547. * This corresponds to a photographic exposure.
  106548. */
  106549. cameraExposure: float;
  106550. /**
  106551. * Gets The camera contrast used on this material.
  106552. */
  106553. /**
  106554. * Sets The camera contrast used on this material.
  106555. */
  106556. cameraContrast: float;
  106557. /**
  106558. * Gets the Color Grading 2D Lookup Texture.
  106559. */
  106560. /**
  106561. * Sets the Color Grading 2D Lookup Texture.
  106562. */
  106563. cameraColorGradingTexture: Nullable<BaseTexture>;
  106564. /**
  106565. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106566. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106567. * 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;
  106568. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106569. */
  106570. /**
  106571. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106572. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106573. * 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;
  106574. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106575. */
  106576. cameraColorCurves: Nullable<ColorCurves>;
  106577. /**
  106578. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  106579. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  106580. */
  106581. switchToBGR: boolean;
  106582. private _renderTargets;
  106583. private _reflectionControls;
  106584. private _white;
  106585. private _primaryShadowColor;
  106586. private _primaryHighlightColor;
  106587. /**
  106588. * Instantiates a Background Material in the given scene
  106589. * @param name The friendly name of the material
  106590. * @param scene The scene to add the material to
  106591. */
  106592. constructor(name: string, scene: Scene);
  106593. /**
  106594. * Gets a boolean indicating that current material needs to register RTT
  106595. */
  106596. readonly hasRenderTargetTextures: boolean;
  106597. /**
  106598. * The entire material has been created in order to prevent overdraw.
  106599. * @returns false
  106600. */
  106601. needAlphaTesting(): boolean;
  106602. /**
  106603. * The entire material has been created in order to prevent overdraw.
  106604. * @returns true if blending is enable
  106605. */
  106606. needAlphaBlending(): boolean;
  106607. /**
  106608. * Checks wether the material is ready to be rendered for a given mesh.
  106609. * @param mesh The mesh to render
  106610. * @param subMesh The submesh to check against
  106611. * @param useInstances Specify wether or not the material is used with instances
  106612. * @returns true if all the dependencies are ready (Textures, Effects...)
  106613. */
  106614. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106615. /**
  106616. * Compute the primary color according to the chosen perceptual color.
  106617. */
  106618. private _computePrimaryColorFromPerceptualColor;
  106619. /**
  106620. * Compute the highlights and shadow colors according to their chosen levels.
  106621. */
  106622. private _computePrimaryColors;
  106623. /**
  106624. * Build the uniform buffer used in the material.
  106625. */
  106626. buildUniformLayout(): void;
  106627. /**
  106628. * Unbind the material.
  106629. */
  106630. unbind(): void;
  106631. /**
  106632. * Bind only the world matrix to the material.
  106633. * @param world The world matrix to bind.
  106634. */
  106635. bindOnlyWorldMatrix(world: Matrix): void;
  106636. /**
  106637. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  106638. * @param world The world matrix to bind.
  106639. * @param subMesh The submesh to bind for.
  106640. */
  106641. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106642. /**
  106643. * Dispose the material.
  106644. * @param forceDisposeEffect Force disposal of the associated effect.
  106645. * @param forceDisposeTextures Force disposal of the associated textures.
  106646. */
  106647. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106648. /**
  106649. * Clones the material.
  106650. * @param name The cloned name.
  106651. * @returns The cloned material.
  106652. */
  106653. clone(name: string): BackgroundMaterial;
  106654. /**
  106655. * Serializes the current material to its JSON representation.
  106656. * @returns The JSON representation.
  106657. */
  106658. serialize(): any;
  106659. /**
  106660. * Gets the class name of the material
  106661. * @returns "BackgroundMaterial"
  106662. */
  106663. getClassName(): string;
  106664. /**
  106665. * Parse a JSON input to create back a background material.
  106666. * @param source The JSON data to parse
  106667. * @param scene The scene to create the parsed material in
  106668. * @param rootUrl The root url of the assets the material depends upon
  106669. * @returns the instantiated BackgroundMaterial.
  106670. */
  106671. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  106672. }
  106673. }
  106674. declare module BABYLON {
  106675. /**
  106676. * Represents the different options available during the creation of
  106677. * a Environment helper.
  106678. *
  106679. * This can control the default ground, skybox and image processing setup of your scene.
  106680. */
  106681. export interface IEnvironmentHelperOptions {
  106682. /**
  106683. * Specifies wether or not to create a ground.
  106684. * True by default.
  106685. */
  106686. createGround: boolean;
  106687. /**
  106688. * Specifies the ground size.
  106689. * 15 by default.
  106690. */
  106691. groundSize: number;
  106692. /**
  106693. * The texture used on the ground for the main color.
  106694. * Comes from the BabylonJS CDN by default.
  106695. *
  106696. * Remarks: Can be either a texture or a url.
  106697. */
  106698. groundTexture: string | BaseTexture;
  106699. /**
  106700. * The color mixed in the ground texture by default.
  106701. * BabylonJS clearColor by default.
  106702. */
  106703. groundColor: Color3;
  106704. /**
  106705. * Specifies the ground opacity.
  106706. * 1 by default.
  106707. */
  106708. groundOpacity: number;
  106709. /**
  106710. * Enables the ground to receive shadows.
  106711. * True by default.
  106712. */
  106713. enableGroundShadow: boolean;
  106714. /**
  106715. * Helps preventing the shadow to be fully black on the ground.
  106716. * 0.5 by default.
  106717. */
  106718. groundShadowLevel: number;
  106719. /**
  106720. * Creates a mirror texture attach to the ground.
  106721. * false by default.
  106722. */
  106723. enableGroundMirror: boolean;
  106724. /**
  106725. * Specifies the ground mirror size ratio.
  106726. * 0.3 by default as the default kernel is 64.
  106727. */
  106728. groundMirrorSizeRatio: number;
  106729. /**
  106730. * Specifies the ground mirror blur kernel size.
  106731. * 64 by default.
  106732. */
  106733. groundMirrorBlurKernel: number;
  106734. /**
  106735. * Specifies the ground mirror visibility amount.
  106736. * 1 by default
  106737. */
  106738. groundMirrorAmount: number;
  106739. /**
  106740. * Specifies the ground mirror reflectance weight.
  106741. * This uses the standard weight of the background material to setup the fresnel effect
  106742. * of the mirror.
  106743. * 1 by default.
  106744. */
  106745. groundMirrorFresnelWeight: number;
  106746. /**
  106747. * Specifies the ground mirror Falloff distance.
  106748. * This can helps reducing the size of the reflection.
  106749. * 0 by Default.
  106750. */
  106751. groundMirrorFallOffDistance: number;
  106752. /**
  106753. * Specifies the ground mirror texture type.
  106754. * Unsigned Int by Default.
  106755. */
  106756. groundMirrorTextureType: number;
  106757. /**
  106758. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  106759. * the shown objects.
  106760. */
  106761. groundYBias: number;
  106762. /**
  106763. * Specifies wether or not to create a skybox.
  106764. * True by default.
  106765. */
  106766. createSkybox: boolean;
  106767. /**
  106768. * Specifies the skybox size.
  106769. * 20 by default.
  106770. */
  106771. skyboxSize: number;
  106772. /**
  106773. * The texture used on the skybox for the main color.
  106774. * Comes from the BabylonJS CDN by default.
  106775. *
  106776. * Remarks: Can be either a texture or a url.
  106777. */
  106778. skyboxTexture: string | BaseTexture;
  106779. /**
  106780. * The color mixed in the skybox texture by default.
  106781. * BabylonJS clearColor by default.
  106782. */
  106783. skyboxColor: Color3;
  106784. /**
  106785. * The background rotation around the Y axis of the scene.
  106786. * This helps aligning the key lights of your scene with the background.
  106787. * 0 by default.
  106788. */
  106789. backgroundYRotation: number;
  106790. /**
  106791. * Compute automatically the size of the elements to best fit with the scene.
  106792. */
  106793. sizeAuto: boolean;
  106794. /**
  106795. * Default position of the rootMesh if autoSize is not true.
  106796. */
  106797. rootPosition: Vector3;
  106798. /**
  106799. * Sets up the image processing in the scene.
  106800. * true by default.
  106801. */
  106802. setupImageProcessing: boolean;
  106803. /**
  106804. * The texture used as your environment texture in the scene.
  106805. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  106806. *
  106807. * Remarks: Can be either a texture or a url.
  106808. */
  106809. environmentTexture: string | BaseTexture;
  106810. /**
  106811. * The value of the exposure to apply to the scene.
  106812. * 0.6 by default if setupImageProcessing is true.
  106813. */
  106814. cameraExposure: number;
  106815. /**
  106816. * The value of the contrast to apply to the scene.
  106817. * 1.6 by default if setupImageProcessing is true.
  106818. */
  106819. cameraContrast: number;
  106820. /**
  106821. * Specifies wether or not tonemapping should be enabled in the scene.
  106822. * true by default if setupImageProcessing is true.
  106823. */
  106824. toneMappingEnabled: boolean;
  106825. }
  106826. /**
  106827. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  106828. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  106829. * It also helps with the default setup of your imageProcessing configuration.
  106830. */
  106831. export class EnvironmentHelper {
  106832. /**
  106833. * Default ground texture URL.
  106834. */
  106835. private static _groundTextureCDNUrl;
  106836. /**
  106837. * Default skybox texture URL.
  106838. */
  106839. private static _skyboxTextureCDNUrl;
  106840. /**
  106841. * Default environment texture URL.
  106842. */
  106843. private static _environmentTextureCDNUrl;
  106844. /**
  106845. * Creates the default options for the helper.
  106846. */
  106847. private static _getDefaultOptions;
  106848. private _rootMesh;
  106849. /**
  106850. * Gets the root mesh created by the helper.
  106851. */
  106852. readonly rootMesh: Mesh;
  106853. private _skybox;
  106854. /**
  106855. * Gets the skybox created by the helper.
  106856. */
  106857. readonly skybox: Nullable<Mesh>;
  106858. private _skyboxTexture;
  106859. /**
  106860. * Gets the skybox texture created by the helper.
  106861. */
  106862. readonly skyboxTexture: Nullable<BaseTexture>;
  106863. private _skyboxMaterial;
  106864. /**
  106865. * Gets the skybox material created by the helper.
  106866. */
  106867. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  106868. private _ground;
  106869. /**
  106870. * Gets the ground mesh created by the helper.
  106871. */
  106872. readonly ground: Nullable<Mesh>;
  106873. private _groundTexture;
  106874. /**
  106875. * Gets the ground texture created by the helper.
  106876. */
  106877. readonly groundTexture: Nullable<BaseTexture>;
  106878. private _groundMirror;
  106879. /**
  106880. * Gets the ground mirror created by the helper.
  106881. */
  106882. readonly groundMirror: Nullable<MirrorTexture>;
  106883. /**
  106884. * Gets the ground mirror render list to helps pushing the meshes
  106885. * you wish in the ground reflection.
  106886. */
  106887. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  106888. private _groundMaterial;
  106889. /**
  106890. * Gets the ground material created by the helper.
  106891. */
  106892. readonly groundMaterial: Nullable<BackgroundMaterial>;
  106893. /**
  106894. * Stores the creation options.
  106895. */
  106896. private readonly _scene;
  106897. private _options;
  106898. /**
  106899. * This observable will be notified with any error during the creation of the environment,
  106900. * mainly texture creation errors.
  106901. */
  106902. onErrorObservable: Observable<{
  106903. message?: string;
  106904. exception?: any;
  106905. }>;
  106906. /**
  106907. * constructor
  106908. * @param options Defines the options we want to customize the helper
  106909. * @param scene The scene to add the material to
  106910. */
  106911. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  106912. /**
  106913. * Updates the background according to the new options
  106914. * @param options
  106915. */
  106916. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  106917. /**
  106918. * Sets the primary color of all the available elements.
  106919. * @param color the main color to affect to the ground and the background
  106920. */
  106921. setMainColor(color: Color3): void;
  106922. /**
  106923. * Setup the image processing according to the specified options.
  106924. */
  106925. private _setupImageProcessing;
  106926. /**
  106927. * Setup the environment texture according to the specified options.
  106928. */
  106929. private _setupEnvironmentTexture;
  106930. /**
  106931. * Setup the background according to the specified options.
  106932. */
  106933. private _setupBackground;
  106934. /**
  106935. * Get the scene sizes according to the setup.
  106936. */
  106937. private _getSceneSize;
  106938. /**
  106939. * Setup the ground according to the specified options.
  106940. */
  106941. private _setupGround;
  106942. /**
  106943. * Setup the ground material according to the specified options.
  106944. */
  106945. private _setupGroundMaterial;
  106946. /**
  106947. * Setup the ground diffuse texture according to the specified options.
  106948. */
  106949. private _setupGroundDiffuseTexture;
  106950. /**
  106951. * Setup the ground mirror texture according to the specified options.
  106952. */
  106953. private _setupGroundMirrorTexture;
  106954. /**
  106955. * Setup the ground to receive the mirror texture.
  106956. */
  106957. private _setupMirrorInGroundMaterial;
  106958. /**
  106959. * Setup the skybox according to the specified options.
  106960. */
  106961. private _setupSkybox;
  106962. /**
  106963. * Setup the skybox material according to the specified options.
  106964. */
  106965. private _setupSkyboxMaterial;
  106966. /**
  106967. * Setup the skybox reflection texture according to the specified options.
  106968. */
  106969. private _setupSkyboxReflectionTexture;
  106970. private _errorHandler;
  106971. /**
  106972. * Dispose all the elements created by the Helper.
  106973. */
  106974. dispose(): void;
  106975. }
  106976. }
  106977. declare module BABYLON {
  106978. /**
  106979. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  106980. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  106981. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  106982. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106983. */
  106984. export class PhotoDome extends TransformNode {
  106985. /**
  106986. * Define the image as a Monoscopic panoramic 360 image.
  106987. */
  106988. static readonly MODE_MONOSCOPIC: number;
  106989. /**
  106990. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  106991. */
  106992. static readonly MODE_TOPBOTTOM: number;
  106993. /**
  106994. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  106995. */
  106996. static readonly MODE_SIDEBYSIDE: number;
  106997. private _useDirectMapping;
  106998. /**
  106999. * The texture being displayed on the sphere
  107000. */
  107001. protected _photoTexture: Texture;
  107002. /**
  107003. * Gets or sets the texture being displayed on the sphere
  107004. */
  107005. photoTexture: Texture;
  107006. /**
  107007. * Observable raised when an error occured while loading the 360 image
  107008. */
  107009. onLoadErrorObservable: Observable<string>;
  107010. /**
  107011. * The skybox material
  107012. */
  107013. protected _material: BackgroundMaterial;
  107014. /**
  107015. * The surface used for the skybox
  107016. */
  107017. protected _mesh: Mesh;
  107018. /**
  107019. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  107020. * Also see the options.resolution property.
  107021. */
  107022. fovMultiplier: number;
  107023. private _imageMode;
  107024. /**
  107025. * Gets or set the current video mode for the video. It can be:
  107026. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  107027. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107028. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107029. */
  107030. imageMode: number;
  107031. /**
  107032. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  107033. * @param name Element's name, child elements will append suffixes for their own names.
  107034. * @param urlsOfPhoto defines the url of the photo to display
  107035. * @param options defines an object containing optional or exposed sub element properties
  107036. * @param onError defines a callback called when an error occured while loading the texture
  107037. */
  107038. constructor(name: string, urlOfPhoto: string, options: {
  107039. resolution?: number;
  107040. size?: number;
  107041. useDirectMapping?: boolean;
  107042. faceForward?: boolean;
  107043. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  107044. private _onBeforeCameraRenderObserver;
  107045. private _changeImageMode;
  107046. /**
  107047. * Releases resources associated with this node.
  107048. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107049. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107050. */
  107051. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107052. }
  107053. }
  107054. declare module BABYLON {
  107055. /** @hidden */
  107056. export var rgbdDecodePixelShader: {
  107057. name: string;
  107058. shader: string;
  107059. };
  107060. }
  107061. declare module BABYLON {
  107062. /**
  107063. * Class used to host texture specific utilities
  107064. */
  107065. export class BRDFTextureTools {
  107066. /**
  107067. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  107068. * @param texture the texture to expand.
  107069. */
  107070. private static _ExpandDefaultBRDFTexture;
  107071. /**
  107072. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  107073. * @param scene defines the hosting scene
  107074. * @returns the environment BRDF texture
  107075. */
  107076. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  107077. private static _environmentBRDFBase64Texture;
  107078. }
  107079. }
  107080. declare module BABYLON {
  107081. /**
  107082. * @hidden
  107083. */
  107084. export interface IMaterialClearCoatDefines {
  107085. CLEARCOAT: boolean;
  107086. CLEARCOAT_DEFAULTIOR: boolean;
  107087. CLEARCOAT_TEXTURE: boolean;
  107088. CLEARCOAT_TEXTUREDIRECTUV: number;
  107089. CLEARCOAT_BUMP: boolean;
  107090. CLEARCOAT_BUMPDIRECTUV: number;
  107091. CLEARCOAT_TINT: boolean;
  107092. CLEARCOAT_TINT_TEXTURE: boolean;
  107093. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107094. /** @hidden */
  107095. _areTexturesDirty: boolean;
  107096. }
  107097. /**
  107098. * Define the code related to the clear coat parameters of the pbr material.
  107099. */
  107100. export class PBRClearCoatConfiguration {
  107101. /**
  107102. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107103. * The default fits with a polyurethane material.
  107104. */
  107105. private static readonly _DefaultIndexOfRefraction;
  107106. private _isEnabled;
  107107. /**
  107108. * Defines if the clear coat is enabled in the material.
  107109. */
  107110. isEnabled: boolean;
  107111. /**
  107112. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  107113. */
  107114. intensity: number;
  107115. /**
  107116. * Defines the clear coat layer roughness.
  107117. */
  107118. roughness: number;
  107119. private _indexOfRefraction;
  107120. /**
  107121. * Defines the index of refraction of the clear coat.
  107122. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107123. * The default fits with a polyurethane material.
  107124. * Changing the default value is more performance intensive.
  107125. */
  107126. indexOfRefraction: number;
  107127. private _texture;
  107128. /**
  107129. * Stores the clear coat values in a texture.
  107130. */
  107131. texture: Nullable<BaseTexture>;
  107132. private _bumpTexture;
  107133. /**
  107134. * Define the clear coat specific bump texture.
  107135. */
  107136. bumpTexture: Nullable<BaseTexture>;
  107137. private _isTintEnabled;
  107138. /**
  107139. * Defines if the clear coat tint is enabled in the material.
  107140. */
  107141. isTintEnabled: boolean;
  107142. /**
  107143. * Defines the clear coat tint of the material.
  107144. * This is only use if tint is enabled
  107145. */
  107146. tintColor: Color3;
  107147. /**
  107148. * Defines the distance at which the tint color should be found in the
  107149. * clear coat media.
  107150. * This is only use if tint is enabled
  107151. */
  107152. tintColorAtDistance: number;
  107153. /**
  107154. * Defines the clear coat layer thickness.
  107155. * This is only use if tint is enabled
  107156. */
  107157. tintThickness: number;
  107158. private _tintTexture;
  107159. /**
  107160. * Stores the clear tint values in a texture.
  107161. * rgb is tint
  107162. * a is a thickness factor
  107163. */
  107164. tintTexture: Nullable<BaseTexture>;
  107165. /** @hidden */
  107166. private _internalMarkAllSubMeshesAsTexturesDirty;
  107167. /** @hidden */
  107168. _markAllSubMeshesAsTexturesDirty(): void;
  107169. /**
  107170. * Instantiate a new istance of clear coat configuration.
  107171. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107172. */
  107173. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107174. /**
  107175. * Gets wehter the submesh is ready to be used or not.
  107176. * @param defines the list of "defines" to update.
  107177. * @param scene defines the scene the material belongs to.
  107178. * @param engine defines the engine the material belongs to.
  107179. * @param disableBumpMap defines wether the material disables bump or not.
  107180. * @returns - boolean indicating that the submesh is ready or not.
  107181. */
  107182. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  107183. /**
  107184. * Checks to see if a texture is used in the material.
  107185. * @param defines the list of "defines" to update.
  107186. * @param scene defines the scene to the material belongs to.
  107187. */
  107188. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  107189. /**
  107190. * Binds the material data.
  107191. * @param uniformBuffer defines the Uniform buffer to fill in.
  107192. * @param scene defines the scene the material belongs to.
  107193. * @param engine defines the engine the material belongs to.
  107194. * @param disableBumpMap defines wether the material disables bump or not.
  107195. * @param isFrozen defines wether the material is frozen or not.
  107196. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107197. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107198. */
  107199. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  107200. /**
  107201. * Checks to see if a texture is used in the material.
  107202. * @param texture - Base texture to use.
  107203. * @returns - Boolean specifying if a texture is used in the material.
  107204. */
  107205. hasTexture(texture: BaseTexture): boolean;
  107206. /**
  107207. * Returns an array of the actively used textures.
  107208. * @param activeTextures Array of BaseTextures
  107209. */
  107210. getActiveTextures(activeTextures: BaseTexture[]): void;
  107211. /**
  107212. * Returns the animatable textures.
  107213. * @param animatables Array of animatable textures.
  107214. */
  107215. getAnimatables(animatables: IAnimatable[]): void;
  107216. /**
  107217. * Disposes the resources of the material.
  107218. * @param forceDisposeTextures - Forces the disposal of all textures.
  107219. */
  107220. dispose(forceDisposeTextures?: boolean): void;
  107221. /**
  107222. * Get the current class name of the texture useful for serialization or dynamic coding.
  107223. * @returns "PBRClearCoatConfiguration"
  107224. */
  107225. getClassName(): string;
  107226. /**
  107227. * Add fallbacks to the effect fallbacks list.
  107228. * @param defines defines the Base texture to use.
  107229. * @param fallbacks defines the current fallback list.
  107230. * @param currentRank defines the current fallback rank.
  107231. * @returns the new fallback rank.
  107232. */
  107233. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107234. /**
  107235. * Add the required uniforms to the current list.
  107236. * @param uniforms defines the current uniform list.
  107237. */
  107238. static AddUniforms(uniforms: string[]): void;
  107239. /**
  107240. * Add the required samplers to the current list.
  107241. * @param samplers defines the current sampler list.
  107242. */
  107243. static AddSamplers(samplers: string[]): void;
  107244. /**
  107245. * Add the required uniforms to the current buffer.
  107246. * @param uniformBuffer defines the current uniform buffer.
  107247. */
  107248. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107249. /**
  107250. * Makes a duplicate of the current configuration into another one.
  107251. * @param clearCoatConfiguration define the config where to copy the info
  107252. */
  107253. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  107254. /**
  107255. * Serializes this clear coat configuration.
  107256. * @returns - An object with the serialized config.
  107257. */
  107258. serialize(): any;
  107259. /**
  107260. * Parses a Clear Coat Configuration from a serialized object.
  107261. * @param source - Serialized object.
  107262. */
  107263. parse(source: any): void;
  107264. }
  107265. }
  107266. declare module BABYLON {
  107267. /**
  107268. * @hidden
  107269. */
  107270. export interface IMaterialAnisotropicDefines {
  107271. ANISOTROPIC: boolean;
  107272. ANISOTROPIC_TEXTURE: boolean;
  107273. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107274. MAINUV1: boolean;
  107275. _areTexturesDirty: boolean;
  107276. _needUVs: boolean;
  107277. }
  107278. /**
  107279. * Define the code related to the anisotropic parameters of the pbr material.
  107280. */
  107281. export class PBRAnisotropicConfiguration {
  107282. private _isEnabled;
  107283. /**
  107284. * Defines if the anisotropy is enabled in the material.
  107285. */
  107286. isEnabled: boolean;
  107287. /**
  107288. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  107289. */
  107290. intensity: number;
  107291. /**
  107292. * Defines if the effect is along the tangents, bitangents or in between.
  107293. * By default, the effect is "strectching" the highlights along the tangents.
  107294. */
  107295. direction: Vector2;
  107296. private _texture;
  107297. /**
  107298. * Stores the anisotropy values in a texture.
  107299. * rg is direction (like normal from -1 to 1)
  107300. * b is a intensity
  107301. */
  107302. texture: Nullable<BaseTexture>;
  107303. /** @hidden */
  107304. private _internalMarkAllSubMeshesAsTexturesDirty;
  107305. /** @hidden */
  107306. _markAllSubMeshesAsTexturesDirty(): void;
  107307. /**
  107308. * Instantiate a new istance of anisotropy configuration.
  107309. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107310. */
  107311. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107312. /**
  107313. * Specifies that the submesh is ready to be used.
  107314. * @param defines the list of "defines" to update.
  107315. * @param scene defines the scene the material belongs to.
  107316. * @returns - boolean indicating that the submesh is ready or not.
  107317. */
  107318. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  107319. /**
  107320. * Checks to see if a texture is used in the material.
  107321. * @param defines the list of "defines" to update.
  107322. * @param mesh the mesh we are preparing the defines for.
  107323. * @param scene defines the scene the material belongs to.
  107324. */
  107325. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  107326. /**
  107327. * Binds the material data.
  107328. * @param uniformBuffer defines the Uniform buffer to fill in.
  107329. * @param scene defines the scene the material belongs to.
  107330. * @param isFrozen defines wether the material is frozen or not.
  107331. */
  107332. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107333. /**
  107334. * Checks to see if a texture is used in the material.
  107335. * @param texture - Base texture to use.
  107336. * @returns - Boolean specifying if a texture is used in the material.
  107337. */
  107338. hasTexture(texture: BaseTexture): boolean;
  107339. /**
  107340. * Returns an array of the actively used textures.
  107341. * @param activeTextures Array of BaseTextures
  107342. */
  107343. getActiveTextures(activeTextures: BaseTexture[]): void;
  107344. /**
  107345. * Returns the animatable textures.
  107346. * @param animatables Array of animatable textures.
  107347. */
  107348. getAnimatables(animatables: IAnimatable[]): void;
  107349. /**
  107350. * Disposes the resources of the material.
  107351. * @param forceDisposeTextures - Forces the disposal of all textures.
  107352. */
  107353. dispose(forceDisposeTextures?: boolean): void;
  107354. /**
  107355. * Get the current class name of the texture useful for serialization or dynamic coding.
  107356. * @returns "PBRAnisotropicConfiguration"
  107357. */
  107358. getClassName(): string;
  107359. /**
  107360. * Add fallbacks to the effect fallbacks list.
  107361. * @param defines defines the Base texture to use.
  107362. * @param fallbacks defines the current fallback list.
  107363. * @param currentRank defines the current fallback rank.
  107364. * @returns the new fallback rank.
  107365. */
  107366. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107367. /**
  107368. * Add the required uniforms to the current list.
  107369. * @param uniforms defines the current uniform list.
  107370. */
  107371. static AddUniforms(uniforms: string[]): void;
  107372. /**
  107373. * Add the required uniforms to the current buffer.
  107374. * @param uniformBuffer defines the current uniform buffer.
  107375. */
  107376. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107377. /**
  107378. * Add the required samplers to the current list.
  107379. * @param samplers defines the current sampler list.
  107380. */
  107381. static AddSamplers(samplers: string[]): void;
  107382. /**
  107383. * Makes a duplicate of the current configuration into another one.
  107384. * @param anisotropicConfiguration define the config where to copy the info
  107385. */
  107386. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107387. /**
  107388. * Serializes this anisotropy configuration.
  107389. * @returns - An object with the serialized config.
  107390. */
  107391. serialize(): any;
  107392. /**
  107393. * Parses a anisotropy Configuration from a serialized object.
  107394. * @param source - Serialized object.
  107395. */
  107396. parse(source: any): void;
  107397. }
  107398. }
  107399. declare module BABYLON {
  107400. /**
  107401. * @hidden
  107402. */
  107403. export interface IMaterialBRDFDefines {
  107404. BRDF_V_HEIGHT_CORRELATED: boolean;
  107405. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107406. SPHERICAL_HARMONICS: boolean;
  107407. /** @hidden */
  107408. _areMiscDirty: boolean;
  107409. }
  107410. /**
  107411. * Define the code related to the BRDF parameters of the pbr material.
  107412. */
  107413. export class PBRBRDFConfiguration {
  107414. /**
  107415. * Default value used for the energy conservation.
  107416. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107417. */
  107418. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107419. /**
  107420. * Default value used for the Smith Visibility Height Correlated mode.
  107421. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107422. */
  107423. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107424. /**
  107425. * Default value used for the IBL diffuse part.
  107426. * This can help switching back to the polynomials mode globally which is a tiny bit
  107427. * less GPU intensive at the drawback of a lower quality.
  107428. */
  107429. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107430. private _useEnergyConservation;
  107431. /**
  107432. * Defines if the material uses energy conservation.
  107433. */
  107434. useEnergyConservation: boolean;
  107435. private _useSmithVisibilityHeightCorrelated;
  107436. /**
  107437. * LEGACY Mode set to false
  107438. * Defines if the material uses height smith correlated visibility term.
  107439. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  107440. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107441. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  107442. * Not relying on height correlated will also disable energy conservation.
  107443. */
  107444. useSmithVisibilityHeightCorrelated: boolean;
  107445. private _useSphericalHarmonics;
  107446. /**
  107447. * LEGACY Mode set to false
  107448. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  107449. * diffuse part of the IBL.
  107450. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  107451. * to the ground truth.
  107452. */
  107453. useSphericalHarmonics: boolean;
  107454. /** @hidden */
  107455. private _internalMarkAllSubMeshesAsMiscDirty;
  107456. /** @hidden */
  107457. _markAllSubMeshesAsMiscDirty(): void;
  107458. /**
  107459. * Instantiate a new istance of clear coat configuration.
  107460. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  107461. */
  107462. constructor(markAllSubMeshesAsMiscDirty: () => void);
  107463. /**
  107464. * Checks to see if a texture is used in the material.
  107465. * @param defines the list of "defines" to update.
  107466. */
  107467. prepareDefines(defines: IMaterialBRDFDefines): void;
  107468. /**
  107469. * Get the current class name of the texture useful for serialization or dynamic coding.
  107470. * @returns "PBRClearCoatConfiguration"
  107471. */
  107472. getClassName(): string;
  107473. /**
  107474. * Makes a duplicate of the current configuration into another one.
  107475. * @param brdfConfiguration define the config where to copy the info
  107476. */
  107477. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  107478. /**
  107479. * Serializes this BRDF configuration.
  107480. * @returns - An object with the serialized config.
  107481. */
  107482. serialize(): any;
  107483. /**
  107484. * Parses a BRDF Configuration from a serialized object.
  107485. * @param source - Serialized object.
  107486. */
  107487. parse(source: any): void;
  107488. }
  107489. }
  107490. declare module BABYLON {
  107491. /**
  107492. * @hidden
  107493. */
  107494. export interface IMaterialSheenDefines {
  107495. SHEEN: boolean;
  107496. SHEEN_TEXTURE: boolean;
  107497. SHEEN_TEXTUREDIRECTUV: number;
  107498. SHEEN_LINKWITHALBEDO: boolean;
  107499. /** @hidden */
  107500. _areTexturesDirty: boolean;
  107501. }
  107502. /**
  107503. * Define the code related to the Sheen parameters of the pbr material.
  107504. */
  107505. export class PBRSheenConfiguration {
  107506. private _isEnabled;
  107507. /**
  107508. * Defines if the material uses sheen.
  107509. */
  107510. isEnabled: boolean;
  107511. private _linkSheenWithAlbedo;
  107512. /**
  107513. * Defines if the sheen is linked to the sheen color.
  107514. */
  107515. linkSheenWithAlbedo: boolean;
  107516. /**
  107517. * Defines the sheen intensity.
  107518. */
  107519. intensity: number;
  107520. /**
  107521. * Defines the sheen color.
  107522. */
  107523. color: Color3;
  107524. private _texture;
  107525. /**
  107526. * Stores the sheen tint values in a texture.
  107527. * rgb is tint
  107528. * a is a intensity
  107529. */
  107530. texture: Nullable<BaseTexture>;
  107531. /** @hidden */
  107532. private _internalMarkAllSubMeshesAsTexturesDirty;
  107533. /** @hidden */
  107534. _markAllSubMeshesAsTexturesDirty(): void;
  107535. /**
  107536. * Instantiate a new istance of clear coat configuration.
  107537. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107538. */
  107539. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107540. /**
  107541. * Specifies that the submesh is ready to be used.
  107542. * @param defines the list of "defines" to update.
  107543. * @param scene defines the scene the material belongs to.
  107544. * @returns - boolean indicating that the submesh is ready or not.
  107545. */
  107546. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  107547. /**
  107548. * Checks to see if a texture is used in the material.
  107549. * @param defines the list of "defines" to update.
  107550. * @param scene defines the scene the material belongs to.
  107551. */
  107552. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  107553. /**
  107554. * Binds the material data.
  107555. * @param uniformBuffer defines the Uniform buffer to fill in.
  107556. * @param scene defines the scene the material belongs to.
  107557. * @param isFrozen defines wether the material is frozen or not.
  107558. */
  107559. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107560. /**
  107561. * Checks to see if a texture is used in the material.
  107562. * @param texture - Base texture to use.
  107563. * @returns - Boolean specifying if a texture is used in the material.
  107564. */
  107565. hasTexture(texture: BaseTexture): boolean;
  107566. /**
  107567. * Returns an array of the actively used textures.
  107568. * @param activeTextures Array of BaseTextures
  107569. */
  107570. getActiveTextures(activeTextures: BaseTexture[]): void;
  107571. /**
  107572. * Returns the animatable textures.
  107573. * @param animatables Array of animatable textures.
  107574. */
  107575. getAnimatables(animatables: IAnimatable[]): void;
  107576. /**
  107577. * Disposes the resources of the material.
  107578. * @param forceDisposeTextures - Forces the disposal of all textures.
  107579. */
  107580. dispose(forceDisposeTextures?: boolean): void;
  107581. /**
  107582. * Get the current class name of the texture useful for serialization or dynamic coding.
  107583. * @returns "PBRSheenConfiguration"
  107584. */
  107585. getClassName(): string;
  107586. /**
  107587. * Add fallbacks to the effect fallbacks list.
  107588. * @param defines defines the Base texture to use.
  107589. * @param fallbacks defines the current fallback list.
  107590. * @param currentRank defines the current fallback rank.
  107591. * @returns the new fallback rank.
  107592. */
  107593. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107594. /**
  107595. * Add the required uniforms to the current list.
  107596. * @param uniforms defines the current uniform list.
  107597. */
  107598. static AddUniforms(uniforms: string[]): void;
  107599. /**
  107600. * Add the required uniforms to the current buffer.
  107601. * @param uniformBuffer defines the current uniform buffer.
  107602. */
  107603. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107604. /**
  107605. * Add the required samplers to the current list.
  107606. * @param samplers defines the current sampler list.
  107607. */
  107608. static AddSamplers(samplers: string[]): void;
  107609. /**
  107610. * Makes a duplicate of the current configuration into another one.
  107611. * @param sheenConfiguration define the config where to copy the info
  107612. */
  107613. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  107614. /**
  107615. * Serializes this BRDF configuration.
  107616. * @returns - An object with the serialized config.
  107617. */
  107618. serialize(): any;
  107619. /**
  107620. * Parses a Sheen Configuration from a serialized object.
  107621. * @param source - Serialized object.
  107622. */
  107623. parse(source: any): void;
  107624. }
  107625. }
  107626. declare module BABYLON {
  107627. /**
  107628. * @hidden
  107629. */
  107630. export interface IMaterialSubSurfaceDefines {
  107631. SUBSURFACE: boolean;
  107632. SS_REFRACTION: boolean;
  107633. SS_TRANSLUCENCY: boolean;
  107634. SS_SCATERRING: boolean;
  107635. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107636. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107637. SS_REFRACTIONMAP_3D: boolean;
  107638. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107639. SS_LODINREFRACTIONALPHA: boolean;
  107640. SS_GAMMAREFRACTION: boolean;
  107641. SS_RGBDREFRACTION: boolean;
  107642. SS_LINEARSPECULARREFRACTION: boolean;
  107643. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107644. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107645. /** @hidden */
  107646. _areTexturesDirty: boolean;
  107647. }
  107648. /**
  107649. * Define the code related to the sub surface parameters of the pbr material.
  107650. */
  107651. export class PBRSubSurfaceConfiguration {
  107652. private _isRefractionEnabled;
  107653. /**
  107654. * Defines if the refraction is enabled in the material.
  107655. */
  107656. isRefractionEnabled: boolean;
  107657. private _isTranslucencyEnabled;
  107658. /**
  107659. * Defines if the translucency is enabled in the material.
  107660. */
  107661. isTranslucencyEnabled: boolean;
  107662. private _isScatteringEnabled;
  107663. /**
  107664. * Defines the refraction intensity of the material.
  107665. * The refraction when enabled replaces the Diffuse part of the material.
  107666. * The intensity helps transitionning between diffuse and refraction.
  107667. */
  107668. refractionIntensity: number;
  107669. /**
  107670. * Defines the translucency intensity of the material.
  107671. * When translucency has been enabled, this defines how much of the "translucency"
  107672. * is addded to the diffuse part of the material.
  107673. */
  107674. translucencyIntensity: number;
  107675. /**
  107676. * Defines the scattering intensity of the material.
  107677. * When scattering has been enabled, this defines how much of the "scattered light"
  107678. * is addded to the diffuse part of the material.
  107679. */
  107680. scatteringIntensity: number;
  107681. private _thicknessTexture;
  107682. /**
  107683. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  107684. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  107685. * 0 would mean minimumThickness
  107686. * 1 would mean maximumThickness
  107687. * The other channels might be use as a mask to vary the different effects intensity.
  107688. */
  107689. thicknessTexture: Nullable<BaseTexture>;
  107690. private _refractionTexture;
  107691. /**
  107692. * Defines the texture to use for refraction.
  107693. */
  107694. refractionTexture: Nullable<BaseTexture>;
  107695. private _indexOfRefraction;
  107696. /**
  107697. * Defines the index of refraction used in the material.
  107698. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107699. */
  107700. indexOfRefraction: number;
  107701. private _invertRefractionY;
  107702. /**
  107703. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107704. */
  107705. invertRefractionY: boolean;
  107706. private _linkRefractionWithTransparency;
  107707. /**
  107708. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107709. * Materials half opaque for instance using refraction could benefit from this control.
  107710. */
  107711. linkRefractionWithTransparency: boolean;
  107712. /**
  107713. * Defines the minimum thickness stored in the thickness map.
  107714. * If no thickness map is defined, this value will be used to simulate thickness.
  107715. */
  107716. minimumThickness: number;
  107717. /**
  107718. * Defines the maximum thickness stored in the thickness map.
  107719. */
  107720. maximumThickness: number;
  107721. /**
  107722. * Defines the volume tint of the material.
  107723. * This is used for both translucency and scattering.
  107724. */
  107725. tintColor: Color3;
  107726. /**
  107727. * Defines the distance at which the tint color should be found in the media.
  107728. * This is used for refraction only.
  107729. */
  107730. tintColorAtDistance: number;
  107731. /**
  107732. * Defines how far each channel transmit through the media.
  107733. * It is defined as a color to simplify it selection.
  107734. */
  107735. diffusionDistance: Color3;
  107736. private _useMaskFromThicknessTexture;
  107737. /**
  107738. * Stores the intensity of the different subsurface effects in the thickness texture.
  107739. * * the green channel is the translucency intensity.
  107740. * * the blue channel is the scattering intensity.
  107741. * * the alpha channel is the refraction intensity.
  107742. */
  107743. useMaskFromThicknessTexture: boolean;
  107744. /** @hidden */
  107745. private _internalMarkAllSubMeshesAsTexturesDirty;
  107746. /** @hidden */
  107747. _markAllSubMeshesAsTexturesDirty(): void;
  107748. /**
  107749. * Instantiate a new istance of sub surface configuration.
  107750. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107751. */
  107752. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107753. /**
  107754. * Gets wehter the submesh is ready to be used or not.
  107755. * @param defines the list of "defines" to update.
  107756. * @param scene defines the scene the material belongs to.
  107757. * @returns - boolean indicating that the submesh is ready or not.
  107758. */
  107759. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  107760. /**
  107761. * Checks to see if a texture is used in the material.
  107762. * @param defines the list of "defines" to update.
  107763. * @param scene defines the scene to the material belongs to.
  107764. */
  107765. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  107766. /**
  107767. * Binds the material data.
  107768. * @param uniformBuffer defines the Uniform buffer to fill in.
  107769. * @param scene defines the scene the material belongs to.
  107770. * @param engine defines the engine the material belongs to.
  107771. * @param isFrozen defines wether the material is frozen or not.
  107772. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  107773. */
  107774. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  107775. /**
  107776. * Unbinds the material from the mesh.
  107777. * @param activeEffect defines the effect that should be unbound from.
  107778. * @returns true if unbound, otherwise false
  107779. */
  107780. unbind(activeEffect: Effect): boolean;
  107781. /**
  107782. * Returns the texture used for refraction or null if none is used.
  107783. * @param scene defines the scene the material belongs to.
  107784. * @returns - Refraction texture if present. If no refraction texture and refraction
  107785. * is linked with transparency, returns environment texture. Otherwise, returns null.
  107786. */
  107787. private _getRefractionTexture;
  107788. /**
  107789. * Returns true if alpha blending should be disabled.
  107790. */
  107791. readonly disableAlphaBlending: boolean;
  107792. /**
  107793. * Fills the list of render target textures.
  107794. * @param renderTargets the list of render targets to update
  107795. */
  107796. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  107797. /**
  107798. * Checks to see if a texture is used in the material.
  107799. * @param texture - Base texture to use.
  107800. * @returns - Boolean specifying if a texture is used in the material.
  107801. */
  107802. hasTexture(texture: BaseTexture): boolean;
  107803. /**
  107804. * Gets a boolean indicating that current material needs to register RTT
  107805. * @returns true if this uses a render target otherwise false.
  107806. */
  107807. hasRenderTargetTextures(): boolean;
  107808. /**
  107809. * Returns an array of the actively used textures.
  107810. * @param activeTextures Array of BaseTextures
  107811. */
  107812. getActiveTextures(activeTextures: BaseTexture[]): void;
  107813. /**
  107814. * Returns the animatable textures.
  107815. * @param animatables Array of animatable textures.
  107816. */
  107817. getAnimatables(animatables: IAnimatable[]): void;
  107818. /**
  107819. * Disposes the resources of the material.
  107820. * @param forceDisposeTextures - Forces the disposal of all textures.
  107821. */
  107822. dispose(forceDisposeTextures?: boolean): void;
  107823. /**
  107824. * Get the current class name of the texture useful for serialization or dynamic coding.
  107825. * @returns "PBRSubSurfaceConfiguration"
  107826. */
  107827. getClassName(): string;
  107828. /**
  107829. * Add fallbacks to the effect fallbacks list.
  107830. * @param defines defines the Base texture to use.
  107831. * @param fallbacks defines the current fallback list.
  107832. * @param currentRank defines the current fallback rank.
  107833. * @returns the new fallback rank.
  107834. */
  107835. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107836. /**
  107837. * Add the required uniforms to the current list.
  107838. * @param uniforms defines the current uniform list.
  107839. */
  107840. static AddUniforms(uniforms: string[]): void;
  107841. /**
  107842. * Add the required samplers to the current list.
  107843. * @param samplers defines the current sampler list.
  107844. */
  107845. static AddSamplers(samplers: string[]): void;
  107846. /**
  107847. * Add the required uniforms to the current buffer.
  107848. * @param uniformBuffer defines the current uniform buffer.
  107849. */
  107850. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107851. /**
  107852. * Makes a duplicate of the current configuration into another one.
  107853. * @param configuration define the config where to copy the info
  107854. */
  107855. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  107856. /**
  107857. * Serializes this Sub Surface configuration.
  107858. * @returns - An object with the serialized config.
  107859. */
  107860. serialize(): any;
  107861. /**
  107862. * Parses a Sub Surface Configuration from a serialized object.
  107863. * @param source - Serialized object.
  107864. */
  107865. parse(source: any): void;
  107866. }
  107867. }
  107868. declare module BABYLON {
  107869. /** @hidden */
  107870. export var pbrFragmentDeclaration: {
  107871. name: string;
  107872. shader: string;
  107873. };
  107874. }
  107875. declare module BABYLON {
  107876. /** @hidden */
  107877. export var pbrUboDeclaration: {
  107878. name: string;
  107879. shader: string;
  107880. };
  107881. }
  107882. declare module BABYLON {
  107883. /** @hidden */
  107884. export var pbrFragmentExtraDeclaration: {
  107885. name: string;
  107886. shader: string;
  107887. };
  107888. }
  107889. declare module BABYLON {
  107890. /** @hidden */
  107891. export var pbrFragmentSamplersDeclaration: {
  107892. name: string;
  107893. shader: string;
  107894. };
  107895. }
  107896. declare module BABYLON {
  107897. /** @hidden */
  107898. export var pbrHelperFunctions: {
  107899. name: string;
  107900. shader: string;
  107901. };
  107902. }
  107903. declare module BABYLON {
  107904. /** @hidden */
  107905. export var harmonicsFunctions: {
  107906. name: string;
  107907. shader: string;
  107908. };
  107909. }
  107910. declare module BABYLON {
  107911. /** @hidden */
  107912. export var pbrDirectLightingSetupFunctions: {
  107913. name: string;
  107914. shader: string;
  107915. };
  107916. }
  107917. declare module BABYLON {
  107918. /** @hidden */
  107919. export var pbrDirectLightingFalloffFunctions: {
  107920. name: string;
  107921. shader: string;
  107922. };
  107923. }
  107924. declare module BABYLON {
  107925. /** @hidden */
  107926. export var pbrBRDFFunctions: {
  107927. name: string;
  107928. shader: string;
  107929. };
  107930. }
  107931. declare module BABYLON {
  107932. /** @hidden */
  107933. export var pbrDirectLightingFunctions: {
  107934. name: string;
  107935. shader: string;
  107936. };
  107937. }
  107938. declare module BABYLON {
  107939. /** @hidden */
  107940. export var pbrIBLFunctions: {
  107941. name: string;
  107942. shader: string;
  107943. };
  107944. }
  107945. declare module BABYLON {
  107946. /** @hidden */
  107947. export var pbrDebug: {
  107948. name: string;
  107949. shader: string;
  107950. };
  107951. }
  107952. declare module BABYLON {
  107953. /** @hidden */
  107954. export var pbrPixelShader: {
  107955. name: string;
  107956. shader: string;
  107957. };
  107958. }
  107959. declare module BABYLON {
  107960. /** @hidden */
  107961. export var pbrVertexDeclaration: {
  107962. name: string;
  107963. shader: string;
  107964. };
  107965. }
  107966. declare module BABYLON {
  107967. /** @hidden */
  107968. export var pbrVertexShader: {
  107969. name: string;
  107970. shader: string;
  107971. };
  107972. }
  107973. declare module BABYLON {
  107974. /**
  107975. * Manages the defines for the PBR Material.
  107976. * @hidden
  107977. */
  107978. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  107979. PBR: boolean;
  107980. MAINUV1: boolean;
  107981. MAINUV2: boolean;
  107982. UV1: boolean;
  107983. UV2: boolean;
  107984. ALBEDO: boolean;
  107985. ALBEDODIRECTUV: number;
  107986. VERTEXCOLOR: boolean;
  107987. AMBIENT: boolean;
  107988. AMBIENTDIRECTUV: number;
  107989. AMBIENTINGRAYSCALE: boolean;
  107990. OPACITY: boolean;
  107991. VERTEXALPHA: boolean;
  107992. OPACITYDIRECTUV: number;
  107993. OPACITYRGB: boolean;
  107994. ALPHATEST: boolean;
  107995. DEPTHPREPASS: boolean;
  107996. ALPHABLEND: boolean;
  107997. ALPHAFROMALBEDO: boolean;
  107998. ALPHATESTVALUE: string;
  107999. SPECULAROVERALPHA: boolean;
  108000. RADIANCEOVERALPHA: boolean;
  108001. ALPHAFRESNEL: boolean;
  108002. LINEARALPHAFRESNEL: boolean;
  108003. PREMULTIPLYALPHA: boolean;
  108004. EMISSIVE: boolean;
  108005. EMISSIVEDIRECTUV: number;
  108006. REFLECTIVITY: boolean;
  108007. REFLECTIVITYDIRECTUV: number;
  108008. SPECULARTERM: boolean;
  108009. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  108010. MICROSURFACEAUTOMATIC: boolean;
  108011. LODBASEDMICROSFURACE: boolean;
  108012. MICROSURFACEMAP: boolean;
  108013. MICROSURFACEMAPDIRECTUV: number;
  108014. METALLICWORKFLOW: boolean;
  108015. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  108016. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  108017. METALLNESSSTOREINMETALMAPBLUE: boolean;
  108018. AOSTOREINMETALMAPRED: boolean;
  108019. ENVIRONMENTBRDF: boolean;
  108020. ENVIRONMENTBRDF_RGBD: boolean;
  108021. NORMAL: boolean;
  108022. TANGENT: boolean;
  108023. BUMP: boolean;
  108024. BUMPDIRECTUV: number;
  108025. OBJECTSPACE_NORMALMAP: boolean;
  108026. PARALLAX: boolean;
  108027. PARALLAXOCCLUSION: boolean;
  108028. NORMALXYSCALE: boolean;
  108029. LIGHTMAP: boolean;
  108030. LIGHTMAPDIRECTUV: number;
  108031. USELIGHTMAPASSHADOWMAP: boolean;
  108032. GAMMALIGHTMAP: boolean;
  108033. REFLECTION: boolean;
  108034. REFLECTIONMAP_3D: boolean;
  108035. REFLECTIONMAP_SPHERICAL: boolean;
  108036. REFLECTIONMAP_PLANAR: boolean;
  108037. REFLECTIONMAP_CUBIC: boolean;
  108038. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108039. REFLECTIONMAP_PROJECTION: boolean;
  108040. REFLECTIONMAP_SKYBOX: boolean;
  108041. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108042. REFLECTIONMAP_EXPLICIT: boolean;
  108043. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108044. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108045. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108046. INVERTCUBICMAP: boolean;
  108047. USESPHERICALFROMREFLECTIONMAP: boolean;
  108048. USEIRRADIANCEMAP: boolean;
  108049. SPHERICAL_HARMONICS: boolean;
  108050. USESPHERICALINVERTEX: boolean;
  108051. REFLECTIONMAP_OPPOSITEZ: boolean;
  108052. LODINREFLECTIONALPHA: boolean;
  108053. GAMMAREFLECTION: boolean;
  108054. RGBDREFLECTION: boolean;
  108055. LINEARSPECULARREFLECTION: boolean;
  108056. RADIANCEOCCLUSION: boolean;
  108057. HORIZONOCCLUSION: boolean;
  108058. INSTANCES: boolean;
  108059. NUM_BONE_INFLUENCERS: number;
  108060. BonesPerMesh: number;
  108061. BONETEXTURE: boolean;
  108062. NONUNIFORMSCALING: boolean;
  108063. MORPHTARGETS: boolean;
  108064. MORPHTARGETS_NORMAL: boolean;
  108065. MORPHTARGETS_TANGENT: boolean;
  108066. NUM_MORPH_INFLUENCERS: number;
  108067. IMAGEPROCESSING: boolean;
  108068. VIGNETTE: boolean;
  108069. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108070. VIGNETTEBLENDMODEOPAQUE: boolean;
  108071. TONEMAPPING: boolean;
  108072. TONEMAPPING_ACES: boolean;
  108073. CONTRAST: boolean;
  108074. COLORCURVES: boolean;
  108075. COLORGRADING: boolean;
  108076. COLORGRADING3D: boolean;
  108077. SAMPLER3DGREENDEPTH: boolean;
  108078. SAMPLER3DBGRMAP: boolean;
  108079. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108080. EXPOSURE: boolean;
  108081. MULTIVIEW: boolean;
  108082. USEPHYSICALLIGHTFALLOFF: boolean;
  108083. USEGLTFLIGHTFALLOFF: boolean;
  108084. TWOSIDEDLIGHTING: boolean;
  108085. SHADOWFLOAT: boolean;
  108086. CLIPPLANE: boolean;
  108087. CLIPPLANE2: boolean;
  108088. CLIPPLANE3: boolean;
  108089. CLIPPLANE4: boolean;
  108090. POINTSIZE: boolean;
  108091. FOG: boolean;
  108092. LOGARITHMICDEPTH: boolean;
  108093. FORCENORMALFORWARD: boolean;
  108094. SPECULARAA: boolean;
  108095. CLEARCOAT: boolean;
  108096. CLEARCOAT_DEFAULTIOR: boolean;
  108097. CLEARCOAT_TEXTURE: boolean;
  108098. CLEARCOAT_TEXTUREDIRECTUV: number;
  108099. CLEARCOAT_BUMP: boolean;
  108100. CLEARCOAT_BUMPDIRECTUV: number;
  108101. CLEARCOAT_TINT: boolean;
  108102. CLEARCOAT_TINT_TEXTURE: boolean;
  108103. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108104. ANISOTROPIC: boolean;
  108105. ANISOTROPIC_TEXTURE: boolean;
  108106. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108107. BRDF_V_HEIGHT_CORRELATED: boolean;
  108108. MS_BRDF_ENERGY_CONSERVATION: boolean;
  108109. SHEEN: boolean;
  108110. SHEEN_TEXTURE: boolean;
  108111. SHEEN_TEXTUREDIRECTUV: number;
  108112. SHEEN_LINKWITHALBEDO: boolean;
  108113. SUBSURFACE: boolean;
  108114. SS_REFRACTION: boolean;
  108115. SS_TRANSLUCENCY: boolean;
  108116. SS_SCATERRING: boolean;
  108117. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108118. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108119. SS_REFRACTIONMAP_3D: boolean;
  108120. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108121. SS_LODINREFRACTIONALPHA: boolean;
  108122. SS_GAMMAREFRACTION: boolean;
  108123. SS_RGBDREFRACTION: boolean;
  108124. SS_LINEARSPECULARREFRACTION: boolean;
  108125. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108126. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108127. UNLIT: boolean;
  108128. DEBUGMODE: number;
  108129. /**
  108130. * Initializes the PBR Material defines.
  108131. */
  108132. constructor();
  108133. /**
  108134. * Resets the PBR Material defines.
  108135. */
  108136. reset(): void;
  108137. }
  108138. /**
  108139. * The Physically based material base class of BJS.
  108140. *
  108141. * This offers the main features of a standard PBR material.
  108142. * For more information, please refer to the documentation :
  108143. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108144. */
  108145. export abstract class PBRBaseMaterial extends PushMaterial {
  108146. /**
  108147. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108148. */
  108149. static readonly PBRMATERIAL_OPAQUE: number;
  108150. /**
  108151. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108152. */
  108153. static readonly PBRMATERIAL_ALPHATEST: number;
  108154. /**
  108155. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108156. */
  108157. static readonly PBRMATERIAL_ALPHABLEND: number;
  108158. /**
  108159. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108160. * They are also discarded below the alpha cutoff threshold to improve performances.
  108161. */
  108162. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108163. /**
  108164. * Defines the default value of how much AO map is occluding the analytical lights
  108165. * (point spot...).
  108166. */
  108167. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108168. /**
  108169. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  108170. */
  108171. static readonly LIGHTFALLOFF_PHYSICAL: number;
  108172. /**
  108173. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  108174. * to enhance interoperability with other engines.
  108175. */
  108176. static readonly LIGHTFALLOFF_GLTF: number;
  108177. /**
  108178. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  108179. * to enhance interoperability with other materials.
  108180. */
  108181. static readonly LIGHTFALLOFF_STANDARD: number;
  108182. /**
  108183. * Intensity of the direct lights e.g. the four lights available in your scene.
  108184. * This impacts both the direct diffuse and specular highlights.
  108185. */
  108186. protected _directIntensity: number;
  108187. /**
  108188. * Intensity of the emissive part of the material.
  108189. * This helps controlling the emissive effect without modifying the emissive color.
  108190. */
  108191. protected _emissiveIntensity: number;
  108192. /**
  108193. * Intensity of the environment e.g. how much the environment will light the object
  108194. * either through harmonics for rough material or through the refelction for shiny ones.
  108195. */
  108196. protected _environmentIntensity: number;
  108197. /**
  108198. * This is a special control allowing the reduction of the specular highlights coming from the
  108199. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108200. */
  108201. protected _specularIntensity: number;
  108202. /**
  108203. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  108204. */
  108205. private _lightingInfos;
  108206. /**
  108207. * Debug Control allowing disabling the bump map on this material.
  108208. */
  108209. protected _disableBumpMap: boolean;
  108210. /**
  108211. * AKA Diffuse Texture in standard nomenclature.
  108212. */
  108213. protected _albedoTexture: Nullable<BaseTexture>;
  108214. /**
  108215. * AKA Occlusion Texture in other nomenclature.
  108216. */
  108217. protected _ambientTexture: Nullable<BaseTexture>;
  108218. /**
  108219. * AKA Occlusion Texture Intensity in other nomenclature.
  108220. */
  108221. protected _ambientTextureStrength: number;
  108222. /**
  108223. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108224. * 1 means it completely occludes it
  108225. * 0 mean it has no impact
  108226. */
  108227. protected _ambientTextureImpactOnAnalyticalLights: number;
  108228. /**
  108229. * Stores the alpha values in a texture.
  108230. */
  108231. protected _opacityTexture: Nullable<BaseTexture>;
  108232. /**
  108233. * Stores the reflection values in a texture.
  108234. */
  108235. protected _reflectionTexture: Nullable<BaseTexture>;
  108236. /**
  108237. * Stores the emissive values in a texture.
  108238. */
  108239. protected _emissiveTexture: Nullable<BaseTexture>;
  108240. /**
  108241. * AKA Specular texture in other nomenclature.
  108242. */
  108243. protected _reflectivityTexture: Nullable<BaseTexture>;
  108244. /**
  108245. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108246. */
  108247. protected _metallicTexture: Nullable<BaseTexture>;
  108248. /**
  108249. * Specifies the metallic scalar of the metallic/roughness workflow.
  108250. * Can also be used to scale the metalness values of the metallic texture.
  108251. */
  108252. protected _metallic: Nullable<number>;
  108253. /**
  108254. * Specifies the roughness scalar of the metallic/roughness workflow.
  108255. * Can also be used to scale the roughness values of the metallic texture.
  108256. */
  108257. protected _roughness: Nullable<number>;
  108258. /**
  108259. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108260. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108261. */
  108262. protected _microSurfaceTexture: Nullable<BaseTexture>;
  108263. /**
  108264. * Stores surface normal data used to displace a mesh in a texture.
  108265. */
  108266. protected _bumpTexture: Nullable<BaseTexture>;
  108267. /**
  108268. * Stores the pre-calculated light information of a mesh in a texture.
  108269. */
  108270. protected _lightmapTexture: Nullable<BaseTexture>;
  108271. /**
  108272. * The color of a material in ambient lighting.
  108273. */
  108274. protected _ambientColor: Color3;
  108275. /**
  108276. * AKA Diffuse Color in other nomenclature.
  108277. */
  108278. protected _albedoColor: Color3;
  108279. /**
  108280. * AKA Specular Color in other nomenclature.
  108281. */
  108282. protected _reflectivityColor: Color3;
  108283. /**
  108284. * The color applied when light is reflected from a material.
  108285. */
  108286. protected _reflectionColor: Color3;
  108287. /**
  108288. * The color applied when light is emitted from a material.
  108289. */
  108290. protected _emissiveColor: Color3;
  108291. /**
  108292. * AKA Glossiness in other nomenclature.
  108293. */
  108294. protected _microSurface: number;
  108295. /**
  108296. * Specifies that the material will use the light map as a show map.
  108297. */
  108298. protected _useLightmapAsShadowmap: boolean;
  108299. /**
  108300. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108301. * makes the reflect vector face the model (under horizon).
  108302. */
  108303. protected _useHorizonOcclusion: boolean;
  108304. /**
  108305. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108306. * too much the area relying on ambient texture to define their ambient occlusion.
  108307. */
  108308. protected _useRadianceOcclusion: boolean;
  108309. /**
  108310. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108311. */
  108312. protected _useAlphaFromAlbedoTexture: boolean;
  108313. /**
  108314. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  108315. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108316. */
  108317. protected _useSpecularOverAlpha: boolean;
  108318. /**
  108319. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108320. */
  108321. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108322. /**
  108323. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108324. */
  108325. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  108326. /**
  108327. * Specifies if the metallic texture contains the roughness information in its green channel.
  108328. */
  108329. protected _useRoughnessFromMetallicTextureGreen: boolean;
  108330. /**
  108331. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108332. */
  108333. protected _useMetallnessFromMetallicTextureBlue: boolean;
  108334. /**
  108335. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108336. */
  108337. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  108338. /**
  108339. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108340. */
  108341. protected _useAmbientInGrayScale: boolean;
  108342. /**
  108343. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108344. * The material will try to infer what glossiness each pixel should be.
  108345. */
  108346. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  108347. /**
  108348. * Defines the falloff type used in this material.
  108349. * It by default is Physical.
  108350. */
  108351. protected _lightFalloff: number;
  108352. /**
  108353. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108354. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108355. */
  108356. protected _useRadianceOverAlpha: boolean;
  108357. /**
  108358. * Allows using an object space normal map (instead of tangent space).
  108359. */
  108360. protected _useObjectSpaceNormalMap: boolean;
  108361. /**
  108362. * Allows using the bump map in parallax mode.
  108363. */
  108364. protected _useParallax: boolean;
  108365. /**
  108366. * Allows using the bump map in parallax occlusion mode.
  108367. */
  108368. protected _useParallaxOcclusion: boolean;
  108369. /**
  108370. * Controls the scale bias of the parallax mode.
  108371. */
  108372. protected _parallaxScaleBias: number;
  108373. /**
  108374. * If sets to true, disables all the lights affecting the material.
  108375. */
  108376. protected _disableLighting: boolean;
  108377. /**
  108378. * Number of Simultaneous lights allowed on the material.
  108379. */
  108380. protected _maxSimultaneousLights: number;
  108381. /**
  108382. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108383. */
  108384. protected _invertNormalMapX: boolean;
  108385. /**
  108386. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108387. */
  108388. protected _invertNormalMapY: boolean;
  108389. /**
  108390. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108391. */
  108392. protected _twoSidedLighting: boolean;
  108393. /**
  108394. * Defines the alpha limits in alpha test mode.
  108395. */
  108396. protected _alphaCutOff: number;
  108397. /**
  108398. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108399. */
  108400. protected _forceAlphaTest: boolean;
  108401. /**
  108402. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108403. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108404. */
  108405. protected _useAlphaFresnel: boolean;
  108406. /**
  108407. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108408. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108409. */
  108410. protected _useLinearAlphaFresnel: boolean;
  108411. /**
  108412. * The transparency mode of the material.
  108413. */
  108414. protected _transparencyMode: Nullable<number>;
  108415. /**
  108416. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108417. * from cos thetav and roughness:
  108418. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108419. */
  108420. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108421. /**
  108422. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108423. */
  108424. protected _forceIrradianceInFragment: boolean;
  108425. /**
  108426. * Force normal to face away from face.
  108427. */
  108428. protected _forceNormalForward: boolean;
  108429. /**
  108430. * Enables specular anti aliasing in the PBR shader.
  108431. * It will both interacts on the Geometry for analytical and IBL lighting.
  108432. * It also prefilter the roughness map based on the bump values.
  108433. */
  108434. protected _enableSpecularAntiAliasing: boolean;
  108435. /**
  108436. * Default configuration related to image processing available in the PBR Material.
  108437. */
  108438. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108439. /**
  108440. * Keep track of the image processing observer to allow dispose and replace.
  108441. */
  108442. private _imageProcessingObserver;
  108443. /**
  108444. * Attaches a new image processing configuration to the PBR Material.
  108445. * @param configuration
  108446. */
  108447. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108448. /**
  108449. * Stores the available render targets.
  108450. */
  108451. private _renderTargets;
  108452. /**
  108453. * Sets the global ambient color for the material used in lighting calculations.
  108454. */
  108455. private _globalAmbientColor;
  108456. /**
  108457. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  108458. */
  108459. private _useLogarithmicDepth;
  108460. /**
  108461. * If set to true, no lighting calculations will be applied.
  108462. */
  108463. private _unlit;
  108464. private _debugMode;
  108465. /**
  108466. * @hidden
  108467. * This is reserved for the inspector.
  108468. * Defines the material debug mode.
  108469. * It helps seeing only some components of the material while troubleshooting.
  108470. */
  108471. debugMode: number;
  108472. /**
  108473. * @hidden
  108474. * This is reserved for the inspector.
  108475. * Specify from where on screen the debug mode should start.
  108476. * The value goes from -1 (full screen) to 1 (not visible)
  108477. * It helps with side by side comparison against the final render
  108478. * This defaults to -1
  108479. */
  108480. private debugLimit;
  108481. /**
  108482. * @hidden
  108483. * This is reserved for the inspector.
  108484. * As the default viewing range might not be enough (if the ambient is really small for instance)
  108485. * You can use the factor to better multiply the final value.
  108486. */
  108487. private debugFactor;
  108488. /**
  108489. * Defines the clear coat layer parameters for the material.
  108490. */
  108491. readonly clearCoat: PBRClearCoatConfiguration;
  108492. /**
  108493. * Defines the anisotropic parameters for the material.
  108494. */
  108495. readonly anisotropy: PBRAnisotropicConfiguration;
  108496. /**
  108497. * Defines the BRDF parameters for the material.
  108498. */
  108499. readonly brdf: PBRBRDFConfiguration;
  108500. /**
  108501. * Defines the Sheen parameters for the material.
  108502. */
  108503. readonly sheen: PBRSheenConfiguration;
  108504. /**
  108505. * Defines the SubSurface parameters for the material.
  108506. */
  108507. readonly subSurface: PBRSubSurfaceConfiguration;
  108508. /**
  108509. * Custom callback helping to override the default shader used in the material.
  108510. */
  108511. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  108512. /**
  108513. * Instantiates a new PBRMaterial instance.
  108514. *
  108515. * @param name The material name
  108516. * @param scene The scene the material will be use in.
  108517. */
  108518. constructor(name: string, scene: Scene);
  108519. /**
  108520. * Gets a boolean indicating that current material needs to register RTT
  108521. */
  108522. readonly hasRenderTargetTextures: boolean;
  108523. /**
  108524. * Gets the name of the material class.
  108525. */
  108526. getClassName(): string;
  108527. /**
  108528. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108529. */
  108530. /**
  108531. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108532. */
  108533. useLogarithmicDepth: boolean;
  108534. /**
  108535. * Gets the current transparency mode.
  108536. */
  108537. /**
  108538. * Sets the transparency mode of the material.
  108539. *
  108540. * | Value | Type | Description |
  108541. * | ----- | ----------------------------------- | ----------- |
  108542. * | 0 | OPAQUE | |
  108543. * | 1 | ALPHATEST | |
  108544. * | 2 | ALPHABLEND | |
  108545. * | 3 | ALPHATESTANDBLEND | |
  108546. *
  108547. */
  108548. transparencyMode: Nullable<number>;
  108549. /**
  108550. * Returns true if alpha blending should be disabled.
  108551. */
  108552. private readonly _disableAlphaBlending;
  108553. /**
  108554. * Specifies whether or not this material should be rendered in alpha blend mode.
  108555. */
  108556. needAlphaBlending(): boolean;
  108557. /**
  108558. * Specifies if the mesh will require alpha blending.
  108559. * @param mesh - BJS mesh.
  108560. */
  108561. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  108562. /**
  108563. * Specifies whether or not this material should be rendered in alpha test mode.
  108564. */
  108565. needAlphaTesting(): boolean;
  108566. /**
  108567. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  108568. */
  108569. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  108570. /**
  108571. * Gets the texture used for the alpha test.
  108572. */
  108573. getAlphaTestTexture(): Nullable<BaseTexture>;
  108574. /**
  108575. * Specifies that the submesh is ready to be used.
  108576. * @param mesh - BJS mesh.
  108577. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  108578. * @param useInstances - Specifies that instances should be used.
  108579. * @returns - boolean indicating that the submesh is ready or not.
  108580. */
  108581. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108582. /**
  108583. * Specifies if the material uses metallic roughness workflow.
  108584. * @returns boolean specifiying if the material uses metallic roughness workflow.
  108585. */
  108586. isMetallicWorkflow(): boolean;
  108587. private _prepareEffect;
  108588. private _prepareDefines;
  108589. /**
  108590. * Force shader compilation
  108591. */
  108592. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  108593. clipPlane: boolean;
  108594. }>): void;
  108595. /**
  108596. * Initializes the uniform buffer layout for the shader.
  108597. */
  108598. buildUniformLayout(): void;
  108599. /**
  108600. * Unbinds the material from the mesh
  108601. */
  108602. unbind(): void;
  108603. /**
  108604. * Binds the submesh data.
  108605. * @param world - The world matrix.
  108606. * @param mesh - The BJS mesh.
  108607. * @param subMesh - A submesh of the BJS mesh.
  108608. */
  108609. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108610. /**
  108611. * Returns the animatable textures.
  108612. * @returns - Array of animatable textures.
  108613. */
  108614. getAnimatables(): IAnimatable[];
  108615. /**
  108616. * Returns the texture used for reflections.
  108617. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  108618. */
  108619. private _getReflectionTexture;
  108620. /**
  108621. * Returns an array of the actively used textures.
  108622. * @returns - Array of BaseTextures
  108623. */
  108624. getActiveTextures(): BaseTexture[];
  108625. /**
  108626. * Checks to see if a texture is used in the material.
  108627. * @param texture - Base texture to use.
  108628. * @returns - Boolean specifying if a texture is used in the material.
  108629. */
  108630. hasTexture(texture: BaseTexture): boolean;
  108631. /**
  108632. * Disposes the resources of the material.
  108633. * @param forceDisposeEffect - Forces the disposal of effects.
  108634. * @param forceDisposeTextures - Forces the disposal of all textures.
  108635. */
  108636. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108637. }
  108638. }
  108639. declare module BABYLON {
  108640. /**
  108641. * The Physically based material of BJS.
  108642. *
  108643. * This offers the main features of a standard PBR material.
  108644. * For more information, please refer to the documentation :
  108645. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108646. */
  108647. export class PBRMaterial extends PBRBaseMaterial {
  108648. /**
  108649. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108650. */
  108651. static readonly PBRMATERIAL_OPAQUE: number;
  108652. /**
  108653. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108654. */
  108655. static readonly PBRMATERIAL_ALPHATEST: number;
  108656. /**
  108657. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108658. */
  108659. static readonly PBRMATERIAL_ALPHABLEND: number;
  108660. /**
  108661. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108662. * They are also discarded below the alpha cutoff threshold to improve performances.
  108663. */
  108664. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108665. /**
  108666. * Defines the default value of how much AO map is occluding the analytical lights
  108667. * (point spot...).
  108668. */
  108669. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108670. /**
  108671. * Intensity of the direct lights e.g. the four lights available in your scene.
  108672. * This impacts both the direct diffuse and specular highlights.
  108673. */
  108674. directIntensity: number;
  108675. /**
  108676. * Intensity of the emissive part of the material.
  108677. * This helps controlling the emissive effect without modifying the emissive color.
  108678. */
  108679. emissiveIntensity: number;
  108680. /**
  108681. * Intensity of the environment e.g. how much the environment will light the object
  108682. * either through harmonics for rough material or through the refelction for shiny ones.
  108683. */
  108684. environmentIntensity: number;
  108685. /**
  108686. * This is a special control allowing the reduction of the specular highlights coming from the
  108687. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108688. */
  108689. specularIntensity: number;
  108690. /**
  108691. * Debug Control allowing disabling the bump map on this material.
  108692. */
  108693. disableBumpMap: boolean;
  108694. /**
  108695. * AKA Diffuse Texture in standard nomenclature.
  108696. */
  108697. albedoTexture: BaseTexture;
  108698. /**
  108699. * AKA Occlusion Texture in other nomenclature.
  108700. */
  108701. ambientTexture: BaseTexture;
  108702. /**
  108703. * AKA Occlusion Texture Intensity in other nomenclature.
  108704. */
  108705. ambientTextureStrength: number;
  108706. /**
  108707. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108708. * 1 means it completely occludes it
  108709. * 0 mean it has no impact
  108710. */
  108711. ambientTextureImpactOnAnalyticalLights: number;
  108712. /**
  108713. * Stores the alpha values in a texture.
  108714. */
  108715. opacityTexture: BaseTexture;
  108716. /**
  108717. * Stores the reflection values in a texture.
  108718. */
  108719. reflectionTexture: Nullable<BaseTexture>;
  108720. /**
  108721. * Stores the emissive values in a texture.
  108722. */
  108723. emissiveTexture: BaseTexture;
  108724. /**
  108725. * AKA Specular texture in other nomenclature.
  108726. */
  108727. reflectivityTexture: BaseTexture;
  108728. /**
  108729. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108730. */
  108731. metallicTexture: BaseTexture;
  108732. /**
  108733. * Specifies the metallic scalar of the metallic/roughness workflow.
  108734. * Can also be used to scale the metalness values of the metallic texture.
  108735. */
  108736. metallic: Nullable<number>;
  108737. /**
  108738. * Specifies the roughness scalar of the metallic/roughness workflow.
  108739. * Can also be used to scale the roughness values of the metallic texture.
  108740. */
  108741. roughness: Nullable<number>;
  108742. /**
  108743. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108744. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108745. */
  108746. microSurfaceTexture: BaseTexture;
  108747. /**
  108748. * Stores surface normal data used to displace a mesh in a texture.
  108749. */
  108750. bumpTexture: BaseTexture;
  108751. /**
  108752. * Stores the pre-calculated light information of a mesh in a texture.
  108753. */
  108754. lightmapTexture: BaseTexture;
  108755. /**
  108756. * Stores the refracted light information in a texture.
  108757. */
  108758. refractionTexture: Nullable<BaseTexture>;
  108759. /**
  108760. * The color of a material in ambient lighting.
  108761. */
  108762. ambientColor: Color3;
  108763. /**
  108764. * AKA Diffuse Color in other nomenclature.
  108765. */
  108766. albedoColor: Color3;
  108767. /**
  108768. * AKA Specular Color in other nomenclature.
  108769. */
  108770. reflectivityColor: Color3;
  108771. /**
  108772. * The color reflected from the material.
  108773. */
  108774. reflectionColor: Color3;
  108775. /**
  108776. * The color emitted from the material.
  108777. */
  108778. emissiveColor: Color3;
  108779. /**
  108780. * AKA Glossiness in other nomenclature.
  108781. */
  108782. microSurface: number;
  108783. /**
  108784. * source material index of refraction (IOR)' / 'destination material IOR.
  108785. */
  108786. indexOfRefraction: number;
  108787. /**
  108788. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108789. */
  108790. invertRefractionY: boolean;
  108791. /**
  108792. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108793. * Materials half opaque for instance using refraction could benefit from this control.
  108794. */
  108795. linkRefractionWithTransparency: boolean;
  108796. /**
  108797. * If true, the light map contains occlusion information instead of lighting info.
  108798. */
  108799. useLightmapAsShadowmap: boolean;
  108800. /**
  108801. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108802. */
  108803. useAlphaFromAlbedoTexture: boolean;
  108804. /**
  108805. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108806. */
  108807. forceAlphaTest: boolean;
  108808. /**
  108809. * Defines the alpha limits in alpha test mode.
  108810. */
  108811. alphaCutOff: number;
  108812. /**
  108813. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108814. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108815. */
  108816. useSpecularOverAlpha: boolean;
  108817. /**
  108818. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108819. */
  108820. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108821. /**
  108822. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108823. */
  108824. useRoughnessFromMetallicTextureAlpha: boolean;
  108825. /**
  108826. * Specifies if the metallic texture contains the roughness information in its green channel.
  108827. */
  108828. useRoughnessFromMetallicTextureGreen: boolean;
  108829. /**
  108830. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108831. */
  108832. useMetallnessFromMetallicTextureBlue: boolean;
  108833. /**
  108834. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108835. */
  108836. useAmbientOcclusionFromMetallicTextureRed: boolean;
  108837. /**
  108838. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108839. */
  108840. useAmbientInGrayScale: boolean;
  108841. /**
  108842. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108843. * The material will try to infer what glossiness each pixel should be.
  108844. */
  108845. useAutoMicroSurfaceFromReflectivityMap: boolean;
  108846. /**
  108847. * BJS is using an harcoded light falloff based on a manually sets up range.
  108848. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108849. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108850. */
  108851. /**
  108852. * BJS is using an harcoded light falloff based on a manually sets up range.
  108853. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108854. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108855. */
  108856. usePhysicalLightFalloff: boolean;
  108857. /**
  108858. * In order to support the falloff compatibility with gltf, a special mode has been added
  108859. * to reproduce the gltf light falloff.
  108860. */
  108861. /**
  108862. * In order to support the falloff compatibility with gltf, a special mode has been added
  108863. * to reproduce the gltf light falloff.
  108864. */
  108865. useGLTFLightFalloff: boolean;
  108866. /**
  108867. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108868. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108869. */
  108870. useRadianceOverAlpha: boolean;
  108871. /**
  108872. * Allows using an object space normal map (instead of tangent space).
  108873. */
  108874. useObjectSpaceNormalMap: boolean;
  108875. /**
  108876. * Allows using the bump map in parallax mode.
  108877. */
  108878. useParallax: boolean;
  108879. /**
  108880. * Allows using the bump map in parallax occlusion mode.
  108881. */
  108882. useParallaxOcclusion: boolean;
  108883. /**
  108884. * Controls the scale bias of the parallax mode.
  108885. */
  108886. parallaxScaleBias: number;
  108887. /**
  108888. * If sets to true, disables all the lights affecting the material.
  108889. */
  108890. disableLighting: boolean;
  108891. /**
  108892. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108893. */
  108894. forceIrradianceInFragment: boolean;
  108895. /**
  108896. * Number of Simultaneous lights allowed on the material.
  108897. */
  108898. maxSimultaneousLights: number;
  108899. /**
  108900. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108901. */
  108902. invertNormalMapX: boolean;
  108903. /**
  108904. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108905. */
  108906. invertNormalMapY: boolean;
  108907. /**
  108908. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108909. */
  108910. twoSidedLighting: boolean;
  108911. /**
  108912. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108913. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108914. */
  108915. useAlphaFresnel: boolean;
  108916. /**
  108917. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108918. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108919. */
  108920. useLinearAlphaFresnel: boolean;
  108921. /**
  108922. * Let user defines the brdf lookup texture used for IBL.
  108923. * A default 8bit version is embedded but you could point at :
  108924. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  108925. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108926. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  108927. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108928. */
  108929. environmentBRDFTexture: Nullable<BaseTexture>;
  108930. /**
  108931. * Force normal to face away from face.
  108932. */
  108933. forceNormalForward: boolean;
  108934. /**
  108935. * Enables specular anti aliasing in the PBR shader.
  108936. * It will both interacts on the Geometry for analytical and IBL lighting.
  108937. * It also prefilter the roughness map based on the bump values.
  108938. */
  108939. enableSpecularAntiAliasing: boolean;
  108940. /**
  108941. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108942. * makes the reflect vector face the model (under horizon).
  108943. */
  108944. useHorizonOcclusion: boolean;
  108945. /**
  108946. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108947. * too much the area relying on ambient texture to define their ambient occlusion.
  108948. */
  108949. useRadianceOcclusion: boolean;
  108950. /**
  108951. * If set to true, no lighting calculations will be applied.
  108952. */
  108953. unlit: boolean;
  108954. /**
  108955. * Gets the image processing configuration used either in this material.
  108956. */
  108957. /**
  108958. * Sets the Default image processing configuration used either in the this material.
  108959. *
  108960. * If sets to null, the scene one is in use.
  108961. */
  108962. imageProcessingConfiguration: ImageProcessingConfiguration;
  108963. /**
  108964. * Gets wether the color curves effect is enabled.
  108965. */
  108966. /**
  108967. * Sets wether the color curves effect is enabled.
  108968. */
  108969. cameraColorCurvesEnabled: boolean;
  108970. /**
  108971. * Gets wether the color grading effect is enabled.
  108972. */
  108973. /**
  108974. * Gets wether the color grading effect is enabled.
  108975. */
  108976. cameraColorGradingEnabled: boolean;
  108977. /**
  108978. * Gets wether tonemapping is enabled or not.
  108979. */
  108980. /**
  108981. * Sets wether tonemapping is enabled or not
  108982. */
  108983. cameraToneMappingEnabled: boolean;
  108984. /**
  108985. * The camera exposure used on this material.
  108986. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108987. * This corresponds to a photographic exposure.
  108988. */
  108989. /**
  108990. * The camera exposure used on this material.
  108991. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108992. * This corresponds to a photographic exposure.
  108993. */
  108994. cameraExposure: number;
  108995. /**
  108996. * Gets The camera contrast used on this material.
  108997. */
  108998. /**
  108999. * Sets The camera contrast used on this material.
  109000. */
  109001. cameraContrast: number;
  109002. /**
  109003. * Gets the Color Grading 2D Lookup Texture.
  109004. */
  109005. /**
  109006. * Sets the Color Grading 2D Lookup Texture.
  109007. */
  109008. cameraColorGradingTexture: Nullable<BaseTexture>;
  109009. /**
  109010. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109011. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109012. * 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;
  109013. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109014. */
  109015. /**
  109016. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109017. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109018. * 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;
  109019. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109020. */
  109021. cameraColorCurves: Nullable<ColorCurves>;
  109022. /**
  109023. * Instantiates a new PBRMaterial instance.
  109024. *
  109025. * @param name The material name
  109026. * @param scene The scene the material will be use in.
  109027. */
  109028. constructor(name: string, scene: Scene);
  109029. /**
  109030. * Returns the name of this material class.
  109031. */
  109032. getClassName(): string;
  109033. /**
  109034. * Makes a duplicate of the current material.
  109035. * @param name - name to use for the new material.
  109036. */
  109037. clone(name: string): PBRMaterial;
  109038. /**
  109039. * Serializes this PBR Material.
  109040. * @returns - An object with the serialized material.
  109041. */
  109042. serialize(): any;
  109043. /**
  109044. * Parses a PBR Material from a serialized object.
  109045. * @param source - Serialized object.
  109046. * @param scene - BJS scene instance.
  109047. * @param rootUrl - url for the scene object
  109048. * @returns - PBRMaterial
  109049. */
  109050. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  109051. }
  109052. }
  109053. declare module BABYLON {
  109054. /**
  109055. * Direct draw surface info
  109056. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  109057. */
  109058. export interface DDSInfo {
  109059. /**
  109060. * Width of the texture
  109061. */
  109062. width: number;
  109063. /**
  109064. * Width of the texture
  109065. */
  109066. height: number;
  109067. /**
  109068. * Number of Mipmaps for the texture
  109069. * @see https://en.wikipedia.org/wiki/Mipmap
  109070. */
  109071. mipmapCount: number;
  109072. /**
  109073. * If the textures format is a known fourCC format
  109074. * @see https://www.fourcc.org/
  109075. */
  109076. isFourCC: boolean;
  109077. /**
  109078. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  109079. */
  109080. isRGB: boolean;
  109081. /**
  109082. * If the texture is a lumincance format
  109083. */
  109084. isLuminance: boolean;
  109085. /**
  109086. * If this is a cube texture
  109087. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  109088. */
  109089. isCube: boolean;
  109090. /**
  109091. * If the texture is a compressed format eg. FOURCC_DXT1
  109092. */
  109093. isCompressed: boolean;
  109094. /**
  109095. * The dxgiFormat of the texture
  109096. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  109097. */
  109098. dxgiFormat: number;
  109099. /**
  109100. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  109101. */
  109102. textureType: number;
  109103. /**
  109104. * Sphericle polynomial created for the dds texture
  109105. */
  109106. sphericalPolynomial?: SphericalPolynomial;
  109107. }
  109108. /**
  109109. * Class used to provide DDS decompression tools
  109110. */
  109111. export class DDSTools {
  109112. /**
  109113. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  109114. */
  109115. static StoreLODInAlphaChannel: boolean;
  109116. /**
  109117. * Gets DDS information from an array buffer
  109118. * @param arrayBuffer defines the array buffer to read data from
  109119. * @returns the DDS information
  109120. */
  109121. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  109122. private static _FloatView;
  109123. private static _Int32View;
  109124. private static _ToHalfFloat;
  109125. private static _FromHalfFloat;
  109126. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  109127. private static _GetHalfFloatRGBAArrayBuffer;
  109128. private static _GetFloatRGBAArrayBuffer;
  109129. private static _GetFloatAsUIntRGBAArrayBuffer;
  109130. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  109131. private static _GetRGBAArrayBuffer;
  109132. private static _ExtractLongWordOrder;
  109133. private static _GetRGBArrayBuffer;
  109134. private static _GetLuminanceArrayBuffer;
  109135. /**
  109136. * Uploads DDS Levels to a Babylon Texture
  109137. * @hidden
  109138. */
  109139. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  109140. }
  109141. interface Engine {
  109142. /**
  109143. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  109144. * @param rootUrl defines the url where the file to load is located
  109145. * @param scene defines the current scene
  109146. * @param lodScale defines scale to apply to the mip map selection
  109147. * @param lodOffset defines offset to apply to the mip map selection
  109148. * @param onLoad defines an optional callback raised when the texture is loaded
  109149. * @param onError defines an optional callback raised if there is an issue to load the texture
  109150. * @param format defines the format of the data
  109151. * @param forcedExtension defines the extension to use to pick the right loader
  109152. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  109153. * @returns the cube texture as an InternalTexture
  109154. */
  109155. 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;
  109156. }
  109157. }
  109158. declare module BABYLON {
  109159. /**
  109160. * Implementation of the DDS Texture Loader.
  109161. * @hidden
  109162. */
  109163. export class _DDSTextureLoader implements IInternalTextureLoader {
  109164. /**
  109165. * Defines wether the loader supports cascade loading the different faces.
  109166. */
  109167. readonly supportCascades: boolean;
  109168. /**
  109169. * This returns if the loader support the current file information.
  109170. * @param extension defines the file extension of the file being loaded
  109171. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109172. * @param fallback defines the fallback internal texture if any
  109173. * @param isBase64 defines whether the texture is encoded as a base64
  109174. * @param isBuffer defines whether the texture data are stored as a buffer
  109175. * @returns true if the loader can load the specified file
  109176. */
  109177. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109178. /**
  109179. * Transform the url before loading if required.
  109180. * @param rootUrl the url of the texture
  109181. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109182. * @returns the transformed texture
  109183. */
  109184. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109185. /**
  109186. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109187. * @param rootUrl the url of the texture
  109188. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109189. * @returns the fallback texture
  109190. */
  109191. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109192. /**
  109193. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109194. * @param data contains the texture data
  109195. * @param texture defines the BabylonJS internal texture
  109196. * @param createPolynomials will be true if polynomials have been requested
  109197. * @param onLoad defines the callback to trigger once the texture is ready
  109198. * @param onError defines the callback to trigger in case of error
  109199. */
  109200. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109201. /**
  109202. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109203. * @param data contains the texture data
  109204. * @param texture defines the BabylonJS internal texture
  109205. * @param callback defines the method to call once ready to upload
  109206. */
  109207. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109208. }
  109209. }
  109210. declare module BABYLON {
  109211. /** @hidden */
  109212. export var rgbdEncodePixelShader: {
  109213. name: string;
  109214. shader: string;
  109215. };
  109216. }
  109217. declare module BABYLON {
  109218. /**
  109219. * Raw texture data and descriptor sufficient for WebGL texture upload
  109220. */
  109221. export interface EnvironmentTextureInfo {
  109222. /**
  109223. * Version of the environment map
  109224. */
  109225. version: number;
  109226. /**
  109227. * Width of image
  109228. */
  109229. width: number;
  109230. /**
  109231. * Irradiance information stored in the file.
  109232. */
  109233. irradiance: any;
  109234. /**
  109235. * Specular information stored in the file.
  109236. */
  109237. specular: any;
  109238. }
  109239. /**
  109240. * Sets of helpers addressing the serialization and deserialization of environment texture
  109241. * stored in a BabylonJS env file.
  109242. * Those files are usually stored as .env files.
  109243. */
  109244. export class EnvironmentTextureTools {
  109245. /**
  109246. * Magic number identifying the env file.
  109247. */
  109248. private static _MagicBytes;
  109249. /**
  109250. * Gets the environment info from an env file.
  109251. * @param data The array buffer containing the .env bytes.
  109252. * @returns the environment file info (the json header) if successfully parsed.
  109253. */
  109254. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109255. /**
  109256. * Creates an environment texture from a loaded cube texture.
  109257. * @param texture defines the cube texture to convert in env file
  109258. * @return a promise containing the environment data if succesfull.
  109259. */
  109260. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109261. /**
  109262. * Creates a JSON representation of the spherical data.
  109263. * @param texture defines the texture containing the polynomials
  109264. * @return the JSON representation of the spherical info
  109265. */
  109266. private static _CreateEnvTextureIrradiance;
  109267. /**
  109268. * Uploads the texture info contained in the env file to the GPU.
  109269. * @param texture defines the internal texture to upload to
  109270. * @param arrayBuffer defines the buffer cotaining the data to load
  109271. * @param info defines the texture info retrieved through the GetEnvInfo method
  109272. * @returns a promise
  109273. */
  109274. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109275. /**
  109276. * Uploads the levels of image data to the GPU.
  109277. * @param texture defines the internal texture to upload to
  109278. * @param imageData defines the array buffer views of image data [mipmap][face]
  109279. * @returns a promise
  109280. */
  109281. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109282. /**
  109283. * Uploads spherical polynomials information to the texture.
  109284. * @param texture defines the texture we are trying to upload the information to
  109285. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109286. */
  109287. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109288. /** @hidden */
  109289. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109290. }
  109291. }
  109292. declare module BABYLON {
  109293. /**
  109294. * Implementation of the ENV Texture Loader.
  109295. * @hidden
  109296. */
  109297. export class _ENVTextureLoader implements IInternalTextureLoader {
  109298. /**
  109299. * Defines wether the loader supports cascade loading the different faces.
  109300. */
  109301. readonly supportCascades: boolean;
  109302. /**
  109303. * This returns if the loader support the current file information.
  109304. * @param extension defines the file extension of the file being loaded
  109305. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109306. * @param fallback defines the fallback internal texture if any
  109307. * @param isBase64 defines whether the texture is encoded as a base64
  109308. * @param isBuffer defines whether the texture data are stored as a buffer
  109309. * @returns true if the loader can load the specified file
  109310. */
  109311. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109312. /**
  109313. * Transform the url before loading if required.
  109314. * @param rootUrl the url of the texture
  109315. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109316. * @returns the transformed texture
  109317. */
  109318. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109319. /**
  109320. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109321. * @param rootUrl the url of the texture
  109322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109323. * @returns the fallback texture
  109324. */
  109325. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109326. /**
  109327. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109328. * @param data contains the texture data
  109329. * @param texture defines the BabylonJS internal texture
  109330. * @param createPolynomials will be true if polynomials have been requested
  109331. * @param onLoad defines the callback to trigger once the texture is ready
  109332. * @param onError defines the callback to trigger in case of error
  109333. */
  109334. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109335. /**
  109336. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109337. * @param data contains the texture data
  109338. * @param texture defines the BabylonJS internal texture
  109339. * @param callback defines the method to call once ready to upload
  109340. */
  109341. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109342. }
  109343. }
  109344. declare module BABYLON {
  109345. /**
  109346. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  109347. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  109348. */
  109349. export class KhronosTextureContainer {
  109350. /** contents of the KTX container file */
  109351. arrayBuffer: any;
  109352. private static HEADER_LEN;
  109353. private static COMPRESSED_2D;
  109354. private static COMPRESSED_3D;
  109355. private static TEX_2D;
  109356. private static TEX_3D;
  109357. /**
  109358. * Gets the openGL type
  109359. */
  109360. glType: number;
  109361. /**
  109362. * Gets the openGL type size
  109363. */
  109364. glTypeSize: number;
  109365. /**
  109366. * Gets the openGL format
  109367. */
  109368. glFormat: number;
  109369. /**
  109370. * Gets the openGL internal format
  109371. */
  109372. glInternalFormat: number;
  109373. /**
  109374. * Gets the base internal format
  109375. */
  109376. glBaseInternalFormat: number;
  109377. /**
  109378. * Gets image width in pixel
  109379. */
  109380. pixelWidth: number;
  109381. /**
  109382. * Gets image height in pixel
  109383. */
  109384. pixelHeight: number;
  109385. /**
  109386. * Gets image depth in pixels
  109387. */
  109388. pixelDepth: number;
  109389. /**
  109390. * Gets the number of array elements
  109391. */
  109392. numberOfArrayElements: number;
  109393. /**
  109394. * Gets the number of faces
  109395. */
  109396. numberOfFaces: number;
  109397. /**
  109398. * Gets the number of mipmap levels
  109399. */
  109400. numberOfMipmapLevels: number;
  109401. /**
  109402. * Gets the bytes of key value data
  109403. */
  109404. bytesOfKeyValueData: number;
  109405. /**
  109406. * Gets the load type
  109407. */
  109408. loadType: number;
  109409. /**
  109410. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109411. */
  109412. isInvalid: boolean;
  109413. /**
  109414. * Creates a new KhronosTextureContainer
  109415. * @param arrayBuffer contents of the KTX container file
  109416. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109417. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109418. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109419. */
  109420. constructor(
  109421. /** contents of the KTX container file */
  109422. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109423. /**
  109424. * Uploads KTX content to a Babylon Texture.
  109425. * It is assumed that the texture has already been created & is currently bound
  109426. * @hidden
  109427. */
  109428. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  109429. private _upload2DCompressedLevels;
  109430. }
  109431. }
  109432. declare module BABYLON {
  109433. /**
  109434. * Implementation of the KTX Texture Loader.
  109435. * @hidden
  109436. */
  109437. export class _KTXTextureLoader implements IInternalTextureLoader {
  109438. /**
  109439. * Defines wether the loader supports cascade loading the different faces.
  109440. */
  109441. readonly supportCascades: boolean;
  109442. /**
  109443. * This returns if the loader support the current file information.
  109444. * @param extension defines the file extension of the file being loaded
  109445. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109446. * @param fallback defines the fallback internal texture if any
  109447. * @param isBase64 defines whether the texture is encoded as a base64
  109448. * @param isBuffer defines whether the texture data are stored as a buffer
  109449. * @returns true if the loader can load the specified file
  109450. */
  109451. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109452. /**
  109453. * Transform the url before loading if required.
  109454. * @param rootUrl the url of the texture
  109455. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109456. * @returns the transformed texture
  109457. */
  109458. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109459. /**
  109460. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109461. * @param rootUrl the url of the texture
  109462. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109463. * @returns the fallback texture
  109464. */
  109465. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109466. /**
  109467. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109468. * @param data contains the texture data
  109469. * @param texture defines the BabylonJS internal texture
  109470. * @param createPolynomials will be true if polynomials have been requested
  109471. * @param onLoad defines the callback to trigger once the texture is ready
  109472. * @param onError defines the callback to trigger in case of error
  109473. */
  109474. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109475. /**
  109476. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109477. * @param data contains the texture data
  109478. * @param texture defines the BabylonJS internal texture
  109479. * @param callback defines the method to call once ready to upload
  109480. */
  109481. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  109482. }
  109483. }
  109484. declare module BABYLON {
  109485. /** @hidden */
  109486. export var _forceSceneHelpersToBundle: boolean;
  109487. interface Scene {
  109488. /**
  109489. * Creates a default light for the scene.
  109490. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  109491. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  109492. */
  109493. createDefaultLight(replace?: boolean): void;
  109494. /**
  109495. * Creates a default camera for the scene.
  109496. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  109497. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109498. * @param replace has default false, when true replaces the active camera in the scene
  109499. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  109500. */
  109501. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109502. /**
  109503. * Creates a default camera and a default light.
  109504. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  109505. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109506. * @param replace has the default false, when true replaces the active camera/light in the scene
  109507. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  109508. */
  109509. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109510. /**
  109511. * Creates a new sky box
  109512. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  109513. * @param environmentTexture defines the texture to use as environment texture
  109514. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  109515. * @param scale defines the overall scale of the skybox
  109516. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  109517. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  109518. * @returns a new mesh holding the sky box
  109519. */
  109520. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  109521. /**
  109522. * Creates a new environment
  109523. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  109524. * @param options defines the options you can use to configure the environment
  109525. * @returns the new EnvironmentHelper
  109526. */
  109527. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  109528. /**
  109529. * Creates a new VREXperienceHelper
  109530. * @see http://doc.babylonjs.com/how_to/webvr_helper
  109531. * @param webVROptions defines the options used to create the new VREXperienceHelper
  109532. * @returns a new VREXperienceHelper
  109533. */
  109534. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  109535. /**
  109536. * Creates a new XREXperienceHelper
  109537. * @see http://doc.babylonjs.com/how_to/webxr
  109538. * @returns a promise for a new XREXperienceHelper
  109539. */
  109540. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  109541. }
  109542. }
  109543. declare module BABYLON {
  109544. /**
  109545. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  109546. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  109547. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  109548. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109549. */
  109550. export class VideoDome extends TransformNode {
  109551. /**
  109552. * Define the video source as a Monoscopic panoramic 360 video.
  109553. */
  109554. static readonly MODE_MONOSCOPIC: number;
  109555. /**
  109556. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109557. */
  109558. static readonly MODE_TOPBOTTOM: number;
  109559. /**
  109560. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109561. */
  109562. static readonly MODE_SIDEBYSIDE: number;
  109563. private _useDirectMapping;
  109564. /**
  109565. * The video texture being displayed on the sphere
  109566. */
  109567. protected _videoTexture: VideoTexture;
  109568. /**
  109569. * Gets the video texture being displayed on the sphere
  109570. */
  109571. readonly videoTexture: VideoTexture;
  109572. /**
  109573. * The skybox material
  109574. */
  109575. protected _material: BackgroundMaterial;
  109576. /**
  109577. * The surface used for the skybox
  109578. */
  109579. protected _mesh: Mesh;
  109580. /**
  109581. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109582. * Also see the options.resolution property.
  109583. */
  109584. fovMultiplier: number;
  109585. private _videoMode;
  109586. /**
  109587. * Gets or set the current video mode for the video. It can be:
  109588. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  109589. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109590. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109591. */
  109592. videoMode: number;
  109593. /**
  109594. * Oberserver used in Stereoscopic VR Mode.
  109595. */
  109596. private _onBeforeCameraRenderObserver;
  109597. /**
  109598. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  109599. * @param name Element's name, child elements will append suffixes for their own names.
  109600. * @param urlsOrVideo defines the url(s) or the video element to use
  109601. * @param options An object containing optional or exposed sub element properties
  109602. */
  109603. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  109604. resolution?: number;
  109605. clickToPlay?: boolean;
  109606. autoPlay?: boolean;
  109607. loop?: boolean;
  109608. size?: number;
  109609. poster?: string;
  109610. faceForward?: boolean;
  109611. useDirectMapping?: boolean;
  109612. }, scene: Scene);
  109613. private _changeVideoMode;
  109614. /**
  109615. * Releases resources associated with this node.
  109616. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109617. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109618. */
  109619. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109620. }
  109621. }
  109622. declare module BABYLON {
  109623. /**
  109624. * This class can be used to get instrumentation data from a Babylon engine
  109625. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109626. */
  109627. export class EngineInstrumentation implements IDisposable {
  109628. /**
  109629. * Define the instrumented engine.
  109630. */
  109631. engine: Engine;
  109632. private _captureGPUFrameTime;
  109633. private _gpuFrameTimeToken;
  109634. private _gpuFrameTime;
  109635. private _captureShaderCompilationTime;
  109636. private _shaderCompilationTime;
  109637. private _onBeginFrameObserver;
  109638. private _onEndFrameObserver;
  109639. private _onBeforeShaderCompilationObserver;
  109640. private _onAfterShaderCompilationObserver;
  109641. /**
  109642. * Gets the perf counter used for GPU frame time
  109643. */
  109644. readonly gpuFrameTimeCounter: PerfCounter;
  109645. /**
  109646. * Gets the GPU frame time capture status
  109647. */
  109648. /**
  109649. * Enable or disable the GPU frame time capture
  109650. */
  109651. captureGPUFrameTime: boolean;
  109652. /**
  109653. * Gets the perf counter used for shader compilation time
  109654. */
  109655. readonly shaderCompilationTimeCounter: PerfCounter;
  109656. /**
  109657. * Gets the shader compilation time capture status
  109658. */
  109659. /**
  109660. * Enable or disable the shader compilation time capture
  109661. */
  109662. captureShaderCompilationTime: boolean;
  109663. /**
  109664. * Instantiates a new engine instrumentation.
  109665. * This class can be used to get instrumentation data from a Babylon engine
  109666. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109667. * @param engine Defines the engine to instrument
  109668. */
  109669. constructor(
  109670. /**
  109671. * Define the instrumented engine.
  109672. */
  109673. engine: Engine);
  109674. /**
  109675. * Dispose and release associated resources.
  109676. */
  109677. dispose(): void;
  109678. }
  109679. }
  109680. declare module BABYLON {
  109681. /**
  109682. * This class can be used to get instrumentation data from a Babylon engine
  109683. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109684. */
  109685. export class SceneInstrumentation implements IDisposable {
  109686. /**
  109687. * Defines the scene to instrument
  109688. */
  109689. scene: Scene;
  109690. private _captureActiveMeshesEvaluationTime;
  109691. private _activeMeshesEvaluationTime;
  109692. private _captureRenderTargetsRenderTime;
  109693. private _renderTargetsRenderTime;
  109694. private _captureFrameTime;
  109695. private _frameTime;
  109696. private _captureRenderTime;
  109697. private _renderTime;
  109698. private _captureInterFrameTime;
  109699. private _interFrameTime;
  109700. private _captureParticlesRenderTime;
  109701. private _particlesRenderTime;
  109702. private _captureSpritesRenderTime;
  109703. private _spritesRenderTime;
  109704. private _capturePhysicsTime;
  109705. private _physicsTime;
  109706. private _captureAnimationsTime;
  109707. private _animationsTime;
  109708. private _captureCameraRenderTime;
  109709. private _cameraRenderTime;
  109710. private _onBeforeActiveMeshesEvaluationObserver;
  109711. private _onAfterActiveMeshesEvaluationObserver;
  109712. private _onBeforeRenderTargetsRenderObserver;
  109713. private _onAfterRenderTargetsRenderObserver;
  109714. private _onAfterRenderObserver;
  109715. private _onBeforeDrawPhaseObserver;
  109716. private _onAfterDrawPhaseObserver;
  109717. private _onBeforeAnimationsObserver;
  109718. private _onBeforeParticlesRenderingObserver;
  109719. private _onAfterParticlesRenderingObserver;
  109720. private _onBeforeSpritesRenderingObserver;
  109721. private _onAfterSpritesRenderingObserver;
  109722. private _onBeforePhysicsObserver;
  109723. private _onAfterPhysicsObserver;
  109724. private _onAfterAnimationsObserver;
  109725. private _onBeforeCameraRenderObserver;
  109726. private _onAfterCameraRenderObserver;
  109727. /**
  109728. * Gets the perf counter used for active meshes evaluation time
  109729. */
  109730. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  109731. /**
  109732. * Gets the active meshes evaluation time capture status
  109733. */
  109734. /**
  109735. * Enable or disable the active meshes evaluation time capture
  109736. */
  109737. captureActiveMeshesEvaluationTime: boolean;
  109738. /**
  109739. * Gets the perf counter used for render targets render time
  109740. */
  109741. readonly renderTargetsRenderTimeCounter: PerfCounter;
  109742. /**
  109743. * Gets the render targets render time capture status
  109744. */
  109745. /**
  109746. * Enable or disable the render targets render time capture
  109747. */
  109748. captureRenderTargetsRenderTime: boolean;
  109749. /**
  109750. * Gets the perf counter used for particles render time
  109751. */
  109752. readonly particlesRenderTimeCounter: PerfCounter;
  109753. /**
  109754. * Gets the particles render time capture status
  109755. */
  109756. /**
  109757. * Enable or disable the particles render time capture
  109758. */
  109759. captureParticlesRenderTime: boolean;
  109760. /**
  109761. * Gets the perf counter used for sprites render time
  109762. */
  109763. readonly spritesRenderTimeCounter: PerfCounter;
  109764. /**
  109765. * Gets the sprites render time capture status
  109766. */
  109767. /**
  109768. * Enable or disable the sprites render time capture
  109769. */
  109770. captureSpritesRenderTime: boolean;
  109771. /**
  109772. * Gets the perf counter used for physics time
  109773. */
  109774. readonly physicsTimeCounter: PerfCounter;
  109775. /**
  109776. * Gets the physics time capture status
  109777. */
  109778. /**
  109779. * Enable or disable the physics time capture
  109780. */
  109781. capturePhysicsTime: boolean;
  109782. /**
  109783. * Gets the perf counter used for animations time
  109784. */
  109785. readonly animationsTimeCounter: PerfCounter;
  109786. /**
  109787. * Gets the animations time capture status
  109788. */
  109789. /**
  109790. * Enable or disable the animations time capture
  109791. */
  109792. captureAnimationsTime: boolean;
  109793. /**
  109794. * Gets the perf counter used for frame time capture
  109795. */
  109796. readonly frameTimeCounter: PerfCounter;
  109797. /**
  109798. * Gets the frame time capture status
  109799. */
  109800. /**
  109801. * Enable or disable the frame time capture
  109802. */
  109803. captureFrameTime: boolean;
  109804. /**
  109805. * Gets the perf counter used for inter-frames time capture
  109806. */
  109807. readonly interFrameTimeCounter: PerfCounter;
  109808. /**
  109809. * Gets the inter-frames time capture status
  109810. */
  109811. /**
  109812. * Enable or disable the inter-frames time capture
  109813. */
  109814. captureInterFrameTime: boolean;
  109815. /**
  109816. * Gets the perf counter used for render time capture
  109817. */
  109818. readonly renderTimeCounter: PerfCounter;
  109819. /**
  109820. * Gets the render time capture status
  109821. */
  109822. /**
  109823. * Enable or disable the render time capture
  109824. */
  109825. captureRenderTime: boolean;
  109826. /**
  109827. * Gets the perf counter used for camera render time capture
  109828. */
  109829. readonly cameraRenderTimeCounter: PerfCounter;
  109830. /**
  109831. * Gets the camera render time capture status
  109832. */
  109833. /**
  109834. * Enable or disable the camera render time capture
  109835. */
  109836. captureCameraRenderTime: boolean;
  109837. /**
  109838. * Gets the perf counter used for draw calls
  109839. */
  109840. readonly drawCallsCounter: PerfCounter;
  109841. /**
  109842. * Instantiates a new scene instrumentation.
  109843. * This class can be used to get instrumentation data from a Babylon engine
  109844. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109845. * @param scene Defines the scene to instrument
  109846. */
  109847. constructor(
  109848. /**
  109849. * Defines the scene to instrument
  109850. */
  109851. scene: Scene);
  109852. /**
  109853. * Dispose and release associated resources.
  109854. */
  109855. dispose(): void;
  109856. }
  109857. }
  109858. declare module BABYLON {
  109859. /** @hidden */
  109860. export var glowMapGenerationPixelShader: {
  109861. name: string;
  109862. shader: string;
  109863. };
  109864. }
  109865. declare module BABYLON {
  109866. /** @hidden */
  109867. export var glowMapGenerationVertexShader: {
  109868. name: string;
  109869. shader: string;
  109870. };
  109871. }
  109872. declare module BABYLON {
  109873. /**
  109874. * Effect layer options. This helps customizing the behaviour
  109875. * of the effect layer.
  109876. */
  109877. export interface IEffectLayerOptions {
  109878. /**
  109879. * Multiplication factor apply to the canvas size to compute the render target size
  109880. * used to generated the objects (the smaller the faster).
  109881. */
  109882. mainTextureRatio: number;
  109883. /**
  109884. * Enforces a fixed size texture to ensure effect stability across devices.
  109885. */
  109886. mainTextureFixedSize?: number;
  109887. /**
  109888. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  109889. */
  109890. alphaBlendingMode: number;
  109891. /**
  109892. * The camera attached to the layer.
  109893. */
  109894. camera: Nullable<Camera>;
  109895. /**
  109896. * The rendering group to draw the layer in.
  109897. */
  109898. renderingGroupId: number;
  109899. }
  109900. /**
  109901. * The effect layer Helps adding post process effect blended with the main pass.
  109902. *
  109903. * This can be for instance use to generate glow or higlight effects on the scene.
  109904. *
  109905. * The effect layer class can not be used directly and is intented to inherited from to be
  109906. * customized per effects.
  109907. */
  109908. export abstract class EffectLayer {
  109909. private _vertexBuffers;
  109910. private _indexBuffer;
  109911. private _cachedDefines;
  109912. private _effectLayerMapGenerationEffect;
  109913. private _effectLayerOptions;
  109914. private _mergeEffect;
  109915. protected _scene: Scene;
  109916. protected _engine: Engine;
  109917. protected _maxSize: number;
  109918. protected _mainTextureDesiredSize: ISize;
  109919. protected _mainTexture: RenderTargetTexture;
  109920. protected _shouldRender: boolean;
  109921. protected _postProcesses: PostProcess[];
  109922. protected _textures: BaseTexture[];
  109923. protected _emissiveTextureAndColor: {
  109924. texture: Nullable<BaseTexture>;
  109925. color: Color4;
  109926. };
  109927. /**
  109928. * The name of the layer
  109929. */
  109930. name: string;
  109931. /**
  109932. * The clear color of the texture used to generate the glow map.
  109933. */
  109934. neutralColor: Color4;
  109935. /**
  109936. * Specifies wether the highlight layer is enabled or not.
  109937. */
  109938. isEnabled: boolean;
  109939. /**
  109940. * Gets the camera attached to the layer.
  109941. */
  109942. readonly camera: Nullable<Camera>;
  109943. /**
  109944. * Gets the rendering group id the layer should render in.
  109945. */
  109946. readonly renderingGroupId: number;
  109947. /**
  109948. * An event triggered when the effect layer has been disposed.
  109949. */
  109950. onDisposeObservable: Observable<EffectLayer>;
  109951. /**
  109952. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  109953. */
  109954. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  109955. /**
  109956. * An event triggered when the generated texture is being merged in the scene.
  109957. */
  109958. onBeforeComposeObservable: Observable<EffectLayer>;
  109959. /**
  109960. * An event triggered when the generated texture has been merged in the scene.
  109961. */
  109962. onAfterComposeObservable: Observable<EffectLayer>;
  109963. /**
  109964. * An event triggered when the efffect layer changes its size.
  109965. */
  109966. onSizeChangedObservable: Observable<EffectLayer>;
  109967. /** @hidden */
  109968. static _SceneComponentInitialization: (scene: Scene) => void;
  109969. /**
  109970. * Instantiates a new effect Layer and references it in the scene.
  109971. * @param name The name of the layer
  109972. * @param scene The scene to use the layer in
  109973. */
  109974. constructor(
  109975. /** The Friendly of the effect in the scene */
  109976. name: string, scene: Scene);
  109977. /**
  109978. * Get the effect name of the layer.
  109979. * @return The effect name
  109980. */
  109981. abstract getEffectName(): string;
  109982. /**
  109983. * Checks for the readiness of the element composing the layer.
  109984. * @param subMesh the mesh to check for
  109985. * @param useInstances specify wether or not to use instances to render the mesh
  109986. * @return true if ready otherwise, false
  109987. */
  109988. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109989. /**
  109990. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  109991. * @returns true if the effect requires stencil during the main canvas render pass.
  109992. */
  109993. abstract needStencil(): boolean;
  109994. /**
  109995. * Create the merge effect. This is the shader use to blit the information back
  109996. * to the main canvas at the end of the scene rendering.
  109997. * @returns The effect containing the shader used to merge the effect on the main canvas
  109998. */
  109999. protected abstract _createMergeEffect(): Effect;
  110000. /**
  110001. * Creates the render target textures and post processes used in the effect layer.
  110002. */
  110003. protected abstract _createTextureAndPostProcesses(): void;
  110004. /**
  110005. * Implementation specific of rendering the generating effect on the main canvas.
  110006. * @param effect The effect used to render through
  110007. */
  110008. protected abstract _internalRender(effect: Effect): void;
  110009. /**
  110010. * Sets the required values for both the emissive texture and and the main color.
  110011. */
  110012. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110013. /**
  110014. * Free any resources and references associated to a mesh.
  110015. * Internal use
  110016. * @param mesh The mesh to free.
  110017. */
  110018. abstract _disposeMesh(mesh: Mesh): void;
  110019. /**
  110020. * Serializes this layer (Glow or Highlight for example)
  110021. * @returns a serialized layer object
  110022. */
  110023. abstract serialize?(): any;
  110024. /**
  110025. * Initializes the effect layer with the required options.
  110026. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  110027. */
  110028. protected _init(options: Partial<IEffectLayerOptions>): void;
  110029. /**
  110030. * Generates the index buffer of the full screen quad blending to the main canvas.
  110031. */
  110032. private _generateIndexBuffer;
  110033. /**
  110034. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  110035. */
  110036. private _generateVertexBuffer;
  110037. /**
  110038. * Sets the main texture desired size which is the closest power of two
  110039. * of the engine canvas size.
  110040. */
  110041. private _setMainTextureSize;
  110042. /**
  110043. * Creates the main texture for the effect layer.
  110044. */
  110045. protected _createMainTexture(): void;
  110046. /**
  110047. * Adds specific effects defines.
  110048. * @param defines The defines to add specifics to.
  110049. */
  110050. protected _addCustomEffectDefines(defines: string[]): void;
  110051. /**
  110052. * Checks for the readiness of the element composing the layer.
  110053. * @param subMesh the mesh to check for
  110054. * @param useInstances specify wether or not to use instances to render the mesh
  110055. * @param emissiveTexture the associated emissive texture used to generate the glow
  110056. * @return true if ready otherwise, false
  110057. */
  110058. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  110059. /**
  110060. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  110061. */
  110062. render(): void;
  110063. /**
  110064. * Determine if a given mesh will be used in the current effect.
  110065. * @param mesh mesh to test
  110066. * @returns true if the mesh will be used
  110067. */
  110068. hasMesh(mesh: AbstractMesh): boolean;
  110069. /**
  110070. * Returns true if the layer contains information to display, otherwise false.
  110071. * @returns true if the glow layer should be rendered
  110072. */
  110073. shouldRender(): boolean;
  110074. /**
  110075. * Returns true if the mesh should render, otherwise false.
  110076. * @param mesh The mesh to render
  110077. * @returns true if it should render otherwise false
  110078. */
  110079. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  110080. /**
  110081. * Returns true if the mesh can be rendered, otherwise false.
  110082. * @param mesh The mesh to render
  110083. * @param material The material used on the mesh
  110084. * @returns true if it can be rendered otherwise false
  110085. */
  110086. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110087. /**
  110088. * Returns true if the mesh should render, otherwise false.
  110089. * @param mesh The mesh to render
  110090. * @returns true if it should render otherwise false
  110091. */
  110092. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  110093. /**
  110094. * Renders the submesh passed in parameter to the generation map.
  110095. */
  110096. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  110097. /**
  110098. * Rebuild the required buffers.
  110099. * @hidden Internal use only.
  110100. */
  110101. _rebuild(): void;
  110102. /**
  110103. * Dispose only the render target textures and post process.
  110104. */
  110105. private _disposeTextureAndPostProcesses;
  110106. /**
  110107. * Dispose the highlight layer and free resources.
  110108. */
  110109. dispose(): void;
  110110. /**
  110111. * Gets the class name of the effect layer
  110112. * @returns the string with the class name of the effect layer
  110113. */
  110114. getClassName(): string;
  110115. /**
  110116. * Creates an effect layer from parsed effect layer data
  110117. * @param parsedEffectLayer defines effect layer data
  110118. * @param scene defines the current scene
  110119. * @param rootUrl defines the root URL containing the effect layer information
  110120. * @returns a parsed effect Layer
  110121. */
  110122. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  110123. }
  110124. }
  110125. declare module BABYLON {
  110126. interface AbstractScene {
  110127. /**
  110128. * The list of effect layers (highlights/glow) added to the scene
  110129. * @see http://doc.babylonjs.com/how_to/highlight_layer
  110130. * @see http://doc.babylonjs.com/how_to/glow_layer
  110131. */
  110132. effectLayers: Array<EffectLayer>;
  110133. /**
  110134. * Removes the given effect layer from this scene.
  110135. * @param toRemove defines the effect layer to remove
  110136. * @returns the index of the removed effect layer
  110137. */
  110138. removeEffectLayer(toRemove: EffectLayer): number;
  110139. /**
  110140. * Adds the given effect layer to this scene
  110141. * @param newEffectLayer defines the effect layer to add
  110142. */
  110143. addEffectLayer(newEffectLayer: EffectLayer): void;
  110144. }
  110145. /**
  110146. * Defines the layer scene component responsible to manage any effect layers
  110147. * in a given scene.
  110148. */
  110149. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  110150. /**
  110151. * The component name helpfull to identify the component in the list of scene components.
  110152. */
  110153. readonly name: string;
  110154. /**
  110155. * The scene the component belongs to.
  110156. */
  110157. scene: Scene;
  110158. private _engine;
  110159. private _renderEffects;
  110160. private _needStencil;
  110161. private _previousStencilState;
  110162. /**
  110163. * Creates a new instance of the component for the given scene
  110164. * @param scene Defines the scene to register the component in
  110165. */
  110166. constructor(scene: Scene);
  110167. /**
  110168. * Registers the component in a given scene
  110169. */
  110170. register(): void;
  110171. /**
  110172. * Rebuilds the elements related to this component in case of
  110173. * context lost for instance.
  110174. */
  110175. rebuild(): void;
  110176. /**
  110177. * Serializes the component data to the specified json object
  110178. * @param serializationObject The object to serialize to
  110179. */
  110180. serialize(serializationObject: any): void;
  110181. /**
  110182. * Adds all the elements from the container to the scene
  110183. * @param container the container holding the elements
  110184. */
  110185. addFromContainer(container: AbstractScene): void;
  110186. /**
  110187. * Removes all the elements in the container from the scene
  110188. * @param container contains the elements to remove
  110189. * @param dispose if the removed element should be disposed (default: false)
  110190. */
  110191. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110192. /**
  110193. * Disposes the component and the associated ressources.
  110194. */
  110195. dispose(): void;
  110196. private _isReadyForMesh;
  110197. private _renderMainTexture;
  110198. private _setStencil;
  110199. private _setStencilBack;
  110200. private _draw;
  110201. private _drawCamera;
  110202. private _drawRenderingGroup;
  110203. }
  110204. }
  110205. declare module BABYLON {
  110206. /** @hidden */
  110207. export var glowMapMergePixelShader: {
  110208. name: string;
  110209. shader: string;
  110210. };
  110211. }
  110212. declare module BABYLON {
  110213. /** @hidden */
  110214. export var glowMapMergeVertexShader: {
  110215. name: string;
  110216. shader: string;
  110217. };
  110218. }
  110219. declare module BABYLON {
  110220. interface AbstractScene {
  110221. /**
  110222. * Return a the first highlight layer of the scene with a given name.
  110223. * @param name The name of the highlight layer to look for.
  110224. * @return The highlight layer if found otherwise null.
  110225. */
  110226. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  110227. }
  110228. /**
  110229. * Glow layer options. This helps customizing the behaviour
  110230. * of the glow layer.
  110231. */
  110232. export interface IGlowLayerOptions {
  110233. /**
  110234. * Multiplication factor apply to the canvas size to compute the render target size
  110235. * used to generated the glowing objects (the smaller the faster).
  110236. */
  110237. mainTextureRatio: number;
  110238. /**
  110239. * Enforces a fixed size texture to ensure resize independant blur.
  110240. */
  110241. mainTextureFixedSize?: number;
  110242. /**
  110243. * How big is the kernel of the blur texture.
  110244. */
  110245. blurKernelSize: number;
  110246. /**
  110247. * The camera attached to the layer.
  110248. */
  110249. camera: Nullable<Camera>;
  110250. /**
  110251. * Enable MSAA by chosing the number of samples.
  110252. */
  110253. mainTextureSamples?: number;
  110254. /**
  110255. * The rendering group to draw the layer in.
  110256. */
  110257. renderingGroupId: number;
  110258. }
  110259. /**
  110260. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  110261. *
  110262. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110263. * glowy meshes to your scene.
  110264. *
  110265. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  110266. */
  110267. export class GlowLayer extends EffectLayer {
  110268. /**
  110269. * Effect Name of the layer.
  110270. */
  110271. static readonly EffectName: string;
  110272. /**
  110273. * The default blur kernel size used for the glow.
  110274. */
  110275. static DefaultBlurKernelSize: number;
  110276. /**
  110277. * The default texture size ratio used for the glow.
  110278. */
  110279. static DefaultTextureRatio: number;
  110280. /**
  110281. * Sets the kernel size of the blur.
  110282. */
  110283. /**
  110284. * Gets the kernel size of the blur.
  110285. */
  110286. blurKernelSize: number;
  110287. /**
  110288. * Sets the glow intensity.
  110289. */
  110290. /**
  110291. * Gets the glow intensity.
  110292. */
  110293. intensity: number;
  110294. private _options;
  110295. private _intensity;
  110296. private _horizontalBlurPostprocess1;
  110297. private _verticalBlurPostprocess1;
  110298. private _horizontalBlurPostprocess2;
  110299. private _verticalBlurPostprocess2;
  110300. private _blurTexture1;
  110301. private _blurTexture2;
  110302. private _postProcesses1;
  110303. private _postProcesses2;
  110304. private _includedOnlyMeshes;
  110305. private _excludedMeshes;
  110306. /**
  110307. * Callback used to let the user override the color selection on a per mesh basis
  110308. */
  110309. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  110310. /**
  110311. * Callback used to let the user override the texture selection on a per mesh basis
  110312. */
  110313. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  110314. /**
  110315. * Instantiates a new glow Layer and references it to the scene.
  110316. * @param name The name of the layer
  110317. * @param scene The scene to use the layer in
  110318. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  110319. */
  110320. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  110321. /**
  110322. * Get the effect name of the layer.
  110323. * @return The effect name
  110324. */
  110325. getEffectName(): string;
  110326. /**
  110327. * Create the merge effect. This is the shader use to blit the information back
  110328. * to the main canvas at the end of the scene rendering.
  110329. */
  110330. protected _createMergeEffect(): Effect;
  110331. /**
  110332. * Creates the render target textures and post processes used in the glow layer.
  110333. */
  110334. protected _createTextureAndPostProcesses(): void;
  110335. /**
  110336. * Checks for the readiness of the element composing the layer.
  110337. * @param subMesh the mesh to check for
  110338. * @param useInstances specify wether or not to use instances to render the mesh
  110339. * @param emissiveTexture the associated emissive texture used to generate the glow
  110340. * @return true if ready otherwise, false
  110341. */
  110342. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110343. /**
  110344. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110345. */
  110346. needStencil(): boolean;
  110347. /**
  110348. * Returns true if the mesh can be rendered, otherwise false.
  110349. * @param mesh The mesh to render
  110350. * @param material The material used on the mesh
  110351. * @returns true if it can be rendered otherwise false
  110352. */
  110353. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110354. /**
  110355. * Implementation specific of rendering the generating effect on the main canvas.
  110356. * @param effect The effect used to render through
  110357. */
  110358. protected _internalRender(effect: Effect): void;
  110359. /**
  110360. * Sets the required values for both the emissive texture and and the main color.
  110361. */
  110362. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110363. /**
  110364. * Returns true if the mesh should render, otherwise false.
  110365. * @param mesh The mesh to render
  110366. * @returns true if it should render otherwise false
  110367. */
  110368. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110369. /**
  110370. * Adds specific effects defines.
  110371. * @param defines The defines to add specifics to.
  110372. */
  110373. protected _addCustomEffectDefines(defines: string[]): void;
  110374. /**
  110375. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110376. * @param mesh The mesh to exclude from the glow layer
  110377. */
  110378. addExcludedMesh(mesh: Mesh): void;
  110379. /**
  110380. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110381. * @param mesh The mesh to remove
  110382. */
  110383. removeExcludedMesh(mesh: Mesh): void;
  110384. /**
  110385. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110386. * @param mesh The mesh to include in the glow layer
  110387. */
  110388. addIncludedOnlyMesh(mesh: Mesh): void;
  110389. /**
  110390. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110391. * @param mesh The mesh to remove
  110392. */
  110393. removeIncludedOnlyMesh(mesh: Mesh): void;
  110394. /**
  110395. * Determine if a given mesh will be used in the glow layer
  110396. * @param mesh The mesh to test
  110397. * @returns true if the mesh will be highlighted by the current glow layer
  110398. */
  110399. hasMesh(mesh: AbstractMesh): boolean;
  110400. /**
  110401. * Free any resources and references associated to a mesh.
  110402. * Internal use
  110403. * @param mesh The mesh to free.
  110404. * @hidden
  110405. */
  110406. _disposeMesh(mesh: Mesh): void;
  110407. /**
  110408. * Gets the class name of the effect layer
  110409. * @returns the string with the class name of the effect layer
  110410. */
  110411. getClassName(): string;
  110412. /**
  110413. * Serializes this glow layer
  110414. * @returns a serialized glow layer object
  110415. */
  110416. serialize(): any;
  110417. /**
  110418. * Creates a Glow Layer from parsed glow layer data
  110419. * @param parsedGlowLayer defines glow layer data
  110420. * @param scene defines the current scene
  110421. * @param rootUrl defines the root URL containing the glow layer information
  110422. * @returns a parsed Glow Layer
  110423. */
  110424. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  110425. }
  110426. }
  110427. declare module BABYLON {
  110428. /** @hidden */
  110429. export var glowBlurPostProcessPixelShader: {
  110430. name: string;
  110431. shader: string;
  110432. };
  110433. }
  110434. declare module BABYLON {
  110435. interface AbstractScene {
  110436. /**
  110437. * Return a the first highlight layer of the scene with a given name.
  110438. * @param name The name of the highlight layer to look for.
  110439. * @return The highlight layer if found otherwise null.
  110440. */
  110441. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  110442. }
  110443. /**
  110444. * Highlight layer options. This helps customizing the behaviour
  110445. * of the highlight layer.
  110446. */
  110447. export interface IHighlightLayerOptions {
  110448. /**
  110449. * Multiplication factor apply to the canvas size to compute the render target size
  110450. * used to generated the glowing objects (the smaller the faster).
  110451. */
  110452. mainTextureRatio: number;
  110453. /**
  110454. * Enforces a fixed size texture to ensure resize independant blur.
  110455. */
  110456. mainTextureFixedSize?: number;
  110457. /**
  110458. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  110459. * of the picture to blur (the smaller the faster).
  110460. */
  110461. blurTextureSizeRatio: number;
  110462. /**
  110463. * How big in texel of the blur texture is the vertical blur.
  110464. */
  110465. blurVerticalSize: number;
  110466. /**
  110467. * How big in texel of the blur texture is the horizontal blur.
  110468. */
  110469. blurHorizontalSize: number;
  110470. /**
  110471. * Alpha blending mode used to apply the blur. Default is combine.
  110472. */
  110473. alphaBlendingMode: number;
  110474. /**
  110475. * The camera attached to the layer.
  110476. */
  110477. camera: Nullable<Camera>;
  110478. /**
  110479. * Should we display highlight as a solid stroke?
  110480. */
  110481. isStroke?: boolean;
  110482. /**
  110483. * The rendering group to draw the layer in.
  110484. */
  110485. renderingGroupId: number;
  110486. }
  110487. /**
  110488. * The highlight layer Helps adding a glow effect around a mesh.
  110489. *
  110490. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110491. * glowy meshes to your scene.
  110492. *
  110493. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  110494. */
  110495. export class HighlightLayer extends EffectLayer {
  110496. name: string;
  110497. /**
  110498. * Effect Name of the highlight layer.
  110499. */
  110500. static readonly EffectName: string;
  110501. /**
  110502. * The neutral color used during the preparation of the glow effect.
  110503. * This is black by default as the blend operation is a blend operation.
  110504. */
  110505. static NeutralColor: Color4;
  110506. /**
  110507. * Stencil value used for glowing meshes.
  110508. */
  110509. static GlowingMeshStencilReference: number;
  110510. /**
  110511. * Stencil value used for the other meshes in the scene.
  110512. */
  110513. static NormalMeshStencilReference: number;
  110514. /**
  110515. * Specifies whether or not the inner glow is ACTIVE in the layer.
  110516. */
  110517. innerGlow: boolean;
  110518. /**
  110519. * Specifies whether or not the outer glow is ACTIVE in the layer.
  110520. */
  110521. outerGlow: boolean;
  110522. /**
  110523. * Specifies the horizontal size of the blur.
  110524. */
  110525. /**
  110526. * Gets the horizontal size of the blur.
  110527. */
  110528. blurHorizontalSize: number;
  110529. /**
  110530. * Specifies the vertical size of the blur.
  110531. */
  110532. /**
  110533. * Gets the vertical size of the blur.
  110534. */
  110535. blurVerticalSize: number;
  110536. /**
  110537. * An event triggered when the highlight layer is being blurred.
  110538. */
  110539. onBeforeBlurObservable: Observable<HighlightLayer>;
  110540. /**
  110541. * An event triggered when the highlight layer has been blurred.
  110542. */
  110543. onAfterBlurObservable: Observable<HighlightLayer>;
  110544. private _instanceGlowingMeshStencilReference;
  110545. private _options;
  110546. private _downSamplePostprocess;
  110547. private _horizontalBlurPostprocess;
  110548. private _verticalBlurPostprocess;
  110549. private _blurTexture;
  110550. private _meshes;
  110551. private _excludedMeshes;
  110552. /**
  110553. * Instantiates a new highlight Layer and references it to the scene..
  110554. * @param name The name of the layer
  110555. * @param scene The scene to use the layer in
  110556. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  110557. */
  110558. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  110559. /**
  110560. * Get the effect name of the layer.
  110561. * @return The effect name
  110562. */
  110563. getEffectName(): string;
  110564. /**
  110565. * Create the merge effect. This is the shader use to blit the information back
  110566. * to the main canvas at the end of the scene rendering.
  110567. */
  110568. protected _createMergeEffect(): Effect;
  110569. /**
  110570. * Creates the render target textures and post processes used in the highlight layer.
  110571. */
  110572. protected _createTextureAndPostProcesses(): void;
  110573. /**
  110574. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110575. */
  110576. needStencil(): boolean;
  110577. /**
  110578. * Checks for the readiness of the element composing the layer.
  110579. * @param subMesh the mesh to check for
  110580. * @param useInstances specify wether or not to use instances to render the mesh
  110581. * @param emissiveTexture the associated emissive texture used to generate the glow
  110582. * @return true if ready otherwise, false
  110583. */
  110584. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110585. /**
  110586. * Implementation specific of rendering the generating effect on the main canvas.
  110587. * @param effect The effect used to render through
  110588. */
  110589. protected _internalRender(effect: Effect): void;
  110590. /**
  110591. * Returns true if the layer contains information to display, otherwise false.
  110592. */
  110593. shouldRender(): boolean;
  110594. /**
  110595. * Returns true if the mesh should render, otherwise false.
  110596. * @param mesh The mesh to render
  110597. * @returns true if it should render otherwise false
  110598. */
  110599. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110600. /**
  110601. * Sets the required values for both the emissive texture and and the main color.
  110602. */
  110603. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110604. /**
  110605. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  110606. * @param mesh The mesh to exclude from the highlight layer
  110607. */
  110608. addExcludedMesh(mesh: Mesh): void;
  110609. /**
  110610. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  110611. * @param mesh The mesh to highlight
  110612. */
  110613. removeExcludedMesh(mesh: Mesh): void;
  110614. /**
  110615. * Determine if a given mesh will be highlighted by the current HighlightLayer
  110616. * @param mesh mesh to test
  110617. * @returns true if the mesh will be highlighted by the current HighlightLayer
  110618. */
  110619. hasMesh(mesh: AbstractMesh): boolean;
  110620. /**
  110621. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  110622. * @param mesh The mesh to highlight
  110623. * @param color The color of the highlight
  110624. * @param glowEmissiveOnly Extract the glow from the emissive texture
  110625. */
  110626. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  110627. /**
  110628. * Remove a mesh from the highlight layer in order to make it stop glowing.
  110629. * @param mesh The mesh to highlight
  110630. */
  110631. removeMesh(mesh: Mesh): void;
  110632. /**
  110633. * Force the stencil to the normal expected value for none glowing parts
  110634. */
  110635. private _defaultStencilReference;
  110636. /**
  110637. * Free any resources and references associated to a mesh.
  110638. * Internal use
  110639. * @param mesh The mesh to free.
  110640. * @hidden
  110641. */
  110642. _disposeMesh(mesh: Mesh): void;
  110643. /**
  110644. * Dispose the highlight layer and free resources.
  110645. */
  110646. dispose(): void;
  110647. /**
  110648. * Gets the class name of the effect layer
  110649. * @returns the string with the class name of the effect layer
  110650. */
  110651. getClassName(): string;
  110652. /**
  110653. * Serializes this Highlight layer
  110654. * @returns a serialized Highlight layer object
  110655. */
  110656. serialize(): any;
  110657. /**
  110658. * Creates a Highlight layer from parsed Highlight layer data
  110659. * @param parsedHightlightLayer defines the Highlight layer data
  110660. * @param scene defines the current scene
  110661. * @param rootUrl defines the root URL containing the Highlight layer information
  110662. * @returns a parsed Highlight layer
  110663. */
  110664. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  110665. }
  110666. }
  110667. declare module BABYLON {
  110668. interface AbstractScene {
  110669. /**
  110670. * The list of layers (background and foreground) of the scene
  110671. */
  110672. layers: Array<Layer>;
  110673. }
  110674. /**
  110675. * Defines the layer scene component responsible to manage any layers
  110676. * in a given scene.
  110677. */
  110678. export class LayerSceneComponent implements ISceneComponent {
  110679. /**
  110680. * The component name helpfull to identify the component in the list of scene components.
  110681. */
  110682. readonly name: string;
  110683. /**
  110684. * The scene the component belongs to.
  110685. */
  110686. scene: Scene;
  110687. private _engine;
  110688. /**
  110689. * Creates a new instance of the component for the given scene
  110690. * @param scene Defines the scene to register the component in
  110691. */
  110692. constructor(scene: Scene);
  110693. /**
  110694. * Registers the component in a given scene
  110695. */
  110696. register(): void;
  110697. /**
  110698. * Rebuilds the elements related to this component in case of
  110699. * context lost for instance.
  110700. */
  110701. rebuild(): void;
  110702. /**
  110703. * Disposes the component and the associated ressources.
  110704. */
  110705. dispose(): void;
  110706. private _draw;
  110707. private _drawCameraPredicate;
  110708. private _drawCameraBackground;
  110709. private _drawCameraForeground;
  110710. private _drawRenderTargetPredicate;
  110711. private _drawRenderTargetBackground;
  110712. private _drawRenderTargetForeground;
  110713. /**
  110714. * Adds all the elements from the container to the scene
  110715. * @param container the container holding the elements
  110716. */
  110717. addFromContainer(container: AbstractScene): void;
  110718. /**
  110719. * Removes all the elements in the container from the scene
  110720. * @param container contains the elements to remove
  110721. * @param dispose if the removed element should be disposed (default: false)
  110722. */
  110723. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110724. }
  110725. }
  110726. declare module BABYLON {
  110727. /** @hidden */
  110728. export var layerPixelShader: {
  110729. name: string;
  110730. shader: string;
  110731. };
  110732. }
  110733. declare module BABYLON {
  110734. /** @hidden */
  110735. export var layerVertexShader: {
  110736. name: string;
  110737. shader: string;
  110738. };
  110739. }
  110740. declare module BABYLON {
  110741. /**
  110742. * This represents a full screen 2d layer.
  110743. * This can be useful to display a picture in the background of your scene for instance.
  110744. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110745. */
  110746. export class Layer {
  110747. /**
  110748. * Define the name of the layer.
  110749. */
  110750. name: string;
  110751. /**
  110752. * Define the texture the layer should display.
  110753. */
  110754. texture: Nullable<Texture>;
  110755. /**
  110756. * Is the layer in background or foreground.
  110757. */
  110758. isBackground: boolean;
  110759. /**
  110760. * Define the color of the layer (instead of texture).
  110761. */
  110762. color: Color4;
  110763. /**
  110764. * Define the scale of the layer in order to zoom in out of the texture.
  110765. */
  110766. scale: Vector2;
  110767. /**
  110768. * Define an offset for the layer in order to shift the texture.
  110769. */
  110770. offset: Vector2;
  110771. /**
  110772. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  110773. */
  110774. alphaBlendingMode: number;
  110775. /**
  110776. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  110777. * Alpha test will not mix with the background color in case of transparency.
  110778. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  110779. */
  110780. alphaTest: boolean;
  110781. /**
  110782. * Define a mask to restrict the layer to only some of the scene cameras.
  110783. */
  110784. layerMask: number;
  110785. /**
  110786. * Define the list of render target the layer is visible into.
  110787. */
  110788. renderTargetTextures: RenderTargetTexture[];
  110789. /**
  110790. * Define if the layer is only used in renderTarget or if it also
  110791. * renders in the main frame buffer of the canvas.
  110792. */
  110793. renderOnlyInRenderTargetTextures: boolean;
  110794. private _scene;
  110795. private _vertexBuffers;
  110796. private _indexBuffer;
  110797. private _effect;
  110798. private _alphaTestEffect;
  110799. /**
  110800. * An event triggered when the layer is disposed.
  110801. */
  110802. onDisposeObservable: Observable<Layer>;
  110803. private _onDisposeObserver;
  110804. /**
  110805. * Back compatibility with callback before the onDisposeObservable existed.
  110806. * The set callback will be triggered when the layer has been disposed.
  110807. */
  110808. onDispose: () => void;
  110809. /**
  110810. * An event triggered before rendering the scene
  110811. */
  110812. onBeforeRenderObservable: Observable<Layer>;
  110813. private _onBeforeRenderObserver;
  110814. /**
  110815. * Back compatibility with callback before the onBeforeRenderObservable existed.
  110816. * The set callback will be triggered just before rendering the layer.
  110817. */
  110818. onBeforeRender: () => void;
  110819. /**
  110820. * An event triggered after rendering the scene
  110821. */
  110822. onAfterRenderObservable: Observable<Layer>;
  110823. private _onAfterRenderObserver;
  110824. /**
  110825. * Back compatibility with callback before the onAfterRenderObservable existed.
  110826. * The set callback will be triggered just after rendering the layer.
  110827. */
  110828. onAfterRender: () => void;
  110829. /**
  110830. * Instantiates a new layer.
  110831. * This represents a full screen 2d layer.
  110832. * This can be useful to display a picture in the background of your scene for instance.
  110833. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110834. * @param name Define the name of the layer in the scene
  110835. * @param imgUrl Define the url of the texture to display in the layer
  110836. * @param scene Define the scene the layer belongs to
  110837. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  110838. * @param color Defines a color for the layer
  110839. */
  110840. constructor(
  110841. /**
  110842. * Define the name of the layer.
  110843. */
  110844. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  110845. private _createIndexBuffer;
  110846. /** @hidden */
  110847. _rebuild(): void;
  110848. /**
  110849. * Renders the layer in the scene.
  110850. */
  110851. render(): void;
  110852. /**
  110853. * Disposes and releases the associated ressources.
  110854. */
  110855. dispose(): void;
  110856. }
  110857. }
  110858. declare module BABYLON {
  110859. /** @hidden */
  110860. export var lensFlarePixelShader: {
  110861. name: string;
  110862. shader: string;
  110863. };
  110864. }
  110865. declare module BABYLON {
  110866. /** @hidden */
  110867. export var lensFlareVertexShader: {
  110868. name: string;
  110869. shader: string;
  110870. };
  110871. }
  110872. declare module BABYLON {
  110873. /**
  110874. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  110875. * It is usually composed of several `lensFlare`.
  110876. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110877. */
  110878. export class LensFlareSystem {
  110879. /**
  110880. * Define the name of the lens flare system
  110881. */
  110882. name: string;
  110883. /**
  110884. * List of lens flares used in this system.
  110885. */
  110886. lensFlares: LensFlare[];
  110887. /**
  110888. * Define a limit from the border the lens flare can be visible.
  110889. */
  110890. borderLimit: number;
  110891. /**
  110892. * Define a viewport border we do not want to see the lens flare in.
  110893. */
  110894. viewportBorder: number;
  110895. /**
  110896. * Define a predicate which could limit the list of meshes able to occlude the effect.
  110897. */
  110898. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  110899. /**
  110900. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  110901. */
  110902. layerMask: number;
  110903. /**
  110904. * Define the id of the lens flare system in the scene.
  110905. * (equal to name by default)
  110906. */
  110907. id: string;
  110908. private _scene;
  110909. private _emitter;
  110910. private _vertexBuffers;
  110911. private _indexBuffer;
  110912. private _effect;
  110913. private _positionX;
  110914. private _positionY;
  110915. private _isEnabled;
  110916. /** @hidden */
  110917. static _SceneComponentInitialization: (scene: Scene) => void;
  110918. /**
  110919. * Instantiates a lens flare system.
  110920. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  110921. * It is usually composed of several `lensFlare`.
  110922. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110923. * @param name Define the name of the lens flare system in the scene
  110924. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  110925. * @param scene Define the scene the lens flare system belongs to
  110926. */
  110927. constructor(
  110928. /**
  110929. * Define the name of the lens flare system
  110930. */
  110931. name: string, emitter: any, scene: Scene);
  110932. /**
  110933. * Define if the lens flare system is enabled.
  110934. */
  110935. isEnabled: boolean;
  110936. /**
  110937. * Get the scene the effects belongs to.
  110938. * @returns the scene holding the lens flare system
  110939. */
  110940. getScene(): Scene;
  110941. /**
  110942. * Get the emitter of the lens flare system.
  110943. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  110944. * @returns the emitter of the lens flare system
  110945. */
  110946. getEmitter(): any;
  110947. /**
  110948. * Set the emitter of the lens flare system.
  110949. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  110950. * @param newEmitter Define the new emitter of the system
  110951. */
  110952. setEmitter(newEmitter: any): void;
  110953. /**
  110954. * Get the lens flare system emitter position.
  110955. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  110956. * @returns the position
  110957. */
  110958. getEmitterPosition(): Vector3;
  110959. /**
  110960. * @hidden
  110961. */
  110962. computeEffectivePosition(globalViewport: Viewport): boolean;
  110963. /** @hidden */
  110964. _isVisible(): boolean;
  110965. /**
  110966. * @hidden
  110967. */
  110968. render(): boolean;
  110969. /**
  110970. * Dispose and release the lens flare with its associated resources.
  110971. */
  110972. dispose(): void;
  110973. /**
  110974. * Parse a lens flare system from a JSON repressentation
  110975. * @param parsedLensFlareSystem Define the JSON to parse
  110976. * @param scene Define the scene the parsed system should be instantiated in
  110977. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  110978. * @returns the parsed system
  110979. */
  110980. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  110981. /**
  110982. * Serialize the current Lens Flare System into a JSON representation.
  110983. * @returns the serialized JSON
  110984. */
  110985. serialize(): any;
  110986. }
  110987. }
  110988. declare module BABYLON {
  110989. /**
  110990. * This represents one of the lens effect in a `lensFlareSystem`.
  110991. * It controls one of the indiviual texture used in the effect.
  110992. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110993. */
  110994. export class LensFlare {
  110995. /**
  110996. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  110997. */
  110998. size: number;
  110999. /**
  111000. * 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.
  111001. */
  111002. position: number;
  111003. /**
  111004. * Define the lens color.
  111005. */
  111006. color: Color3;
  111007. /**
  111008. * Define the lens texture.
  111009. */
  111010. texture: Nullable<Texture>;
  111011. /**
  111012. * Define the alpha mode to render this particular lens.
  111013. */
  111014. alphaMode: number;
  111015. private _system;
  111016. /**
  111017. * Creates a new Lens Flare.
  111018. * This represents one of the lens effect in a `lensFlareSystem`.
  111019. * It controls one of the indiviual texture used in the effect.
  111020. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111021. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  111022. * @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.
  111023. * @param color Define the lens color
  111024. * @param imgUrl Define the lens texture url
  111025. * @param system Define the `lensFlareSystem` this flare is part of
  111026. * @returns The newly created Lens Flare
  111027. */
  111028. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  111029. /**
  111030. * Instantiates a new Lens Flare.
  111031. * This represents one of the lens effect in a `lensFlareSystem`.
  111032. * It controls one of the indiviual texture used in the effect.
  111033. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111034. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  111035. * @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.
  111036. * @param color Define the lens color
  111037. * @param imgUrl Define the lens texture url
  111038. * @param system Define the `lensFlareSystem` this flare is part of
  111039. */
  111040. constructor(
  111041. /**
  111042. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111043. */
  111044. size: number,
  111045. /**
  111046. * 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.
  111047. */
  111048. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  111049. /**
  111050. * Dispose and release the lens flare with its associated resources.
  111051. */
  111052. dispose(): void;
  111053. }
  111054. }
  111055. declare module BABYLON {
  111056. interface AbstractScene {
  111057. /**
  111058. * The list of lens flare system added to the scene
  111059. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111060. */
  111061. lensFlareSystems: Array<LensFlareSystem>;
  111062. /**
  111063. * Removes the given lens flare system from this scene.
  111064. * @param toRemove The lens flare system to remove
  111065. * @returns The index of the removed lens flare system
  111066. */
  111067. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  111068. /**
  111069. * Adds the given lens flare system to this scene
  111070. * @param newLensFlareSystem The lens flare system to add
  111071. */
  111072. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  111073. /**
  111074. * Gets a lens flare system using its name
  111075. * @param name defines the name to look for
  111076. * @returns the lens flare system or null if not found
  111077. */
  111078. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  111079. /**
  111080. * Gets a lens flare system using its id
  111081. * @param id defines the id to look for
  111082. * @returns the lens flare system or null if not found
  111083. */
  111084. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  111085. }
  111086. /**
  111087. * Defines the lens flare scene component responsible to manage any lens flares
  111088. * in a given scene.
  111089. */
  111090. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  111091. /**
  111092. * The component name helpfull to identify the component in the list of scene components.
  111093. */
  111094. readonly name: string;
  111095. /**
  111096. * The scene the component belongs to.
  111097. */
  111098. scene: Scene;
  111099. /**
  111100. * Creates a new instance of the component for the given scene
  111101. * @param scene Defines the scene to register the component in
  111102. */
  111103. constructor(scene: Scene);
  111104. /**
  111105. * Registers the component in a given scene
  111106. */
  111107. register(): void;
  111108. /**
  111109. * Rebuilds the elements related to this component in case of
  111110. * context lost for instance.
  111111. */
  111112. rebuild(): void;
  111113. /**
  111114. * Adds all the elements from the container to the scene
  111115. * @param container the container holding the elements
  111116. */
  111117. addFromContainer(container: AbstractScene): void;
  111118. /**
  111119. * Removes all the elements in the container from the scene
  111120. * @param container contains the elements to remove
  111121. * @param dispose if the removed element should be disposed (default: false)
  111122. */
  111123. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111124. /**
  111125. * Serializes the component data to the specified json object
  111126. * @param serializationObject The object to serialize to
  111127. */
  111128. serialize(serializationObject: any): void;
  111129. /**
  111130. * Disposes the component and the associated ressources.
  111131. */
  111132. dispose(): void;
  111133. private _draw;
  111134. }
  111135. }
  111136. declare module BABYLON {
  111137. /**
  111138. * Defines the shadow generator component responsible to manage any shadow generators
  111139. * in a given scene.
  111140. */
  111141. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  111142. /**
  111143. * The component name helpfull to identify the component in the list of scene components.
  111144. */
  111145. readonly name: string;
  111146. /**
  111147. * The scene the component belongs to.
  111148. */
  111149. scene: Scene;
  111150. /**
  111151. * Creates a new instance of the component for the given scene
  111152. * @param scene Defines the scene to register the component in
  111153. */
  111154. constructor(scene: Scene);
  111155. /**
  111156. * Registers the component in a given scene
  111157. */
  111158. register(): void;
  111159. /**
  111160. * Rebuilds the elements related to this component in case of
  111161. * context lost for instance.
  111162. */
  111163. rebuild(): void;
  111164. /**
  111165. * Serializes the component data to the specified json object
  111166. * @param serializationObject The object to serialize to
  111167. */
  111168. serialize(serializationObject: any): void;
  111169. /**
  111170. * Adds all the elements from the container to the scene
  111171. * @param container the container holding the elements
  111172. */
  111173. addFromContainer(container: AbstractScene): void;
  111174. /**
  111175. * Removes all the elements in the container from the scene
  111176. * @param container contains the elements to remove
  111177. * @param dispose if the removed element should be disposed (default: false)
  111178. */
  111179. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111180. /**
  111181. * Rebuilds the elements related to this component in case of
  111182. * context lost for instance.
  111183. */
  111184. dispose(): void;
  111185. private _gatherRenderTargets;
  111186. }
  111187. }
  111188. declare module BABYLON {
  111189. /**
  111190. * A point light is a light defined by an unique point in world space.
  111191. * The light is emitted in every direction from this point.
  111192. * A good example of a point light is a standard light bulb.
  111193. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111194. */
  111195. export class PointLight extends ShadowLight {
  111196. private _shadowAngle;
  111197. /**
  111198. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111199. * This specifies what angle the shadow will use to be created.
  111200. *
  111201. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111202. */
  111203. /**
  111204. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111205. * This specifies what angle the shadow will use to be created.
  111206. *
  111207. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111208. */
  111209. shadowAngle: number;
  111210. /**
  111211. * Gets the direction if it has been set.
  111212. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111213. */
  111214. /**
  111215. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111216. */
  111217. direction: Vector3;
  111218. /**
  111219. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  111220. * A PointLight emits the light in every direction.
  111221. * It can cast shadows.
  111222. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  111223. * ```javascript
  111224. * var pointLight = new PointLight("pl", camera.position, scene);
  111225. * ```
  111226. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111227. * @param name The light friendly name
  111228. * @param position The position of the point light in the scene
  111229. * @param scene The scene the lights belongs to
  111230. */
  111231. constructor(name: string, position: Vector3, scene: Scene);
  111232. /**
  111233. * Returns the string "PointLight"
  111234. * @returns the class name
  111235. */
  111236. getClassName(): string;
  111237. /**
  111238. * Returns the integer 0.
  111239. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111240. */
  111241. getTypeID(): number;
  111242. /**
  111243. * Specifies wether or not the shadowmap should be a cube texture.
  111244. * @returns true if the shadowmap needs to be a cube texture.
  111245. */
  111246. needCube(): boolean;
  111247. /**
  111248. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  111249. * @param faceIndex The index of the face we are computed the direction to generate shadow
  111250. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  111251. */
  111252. getShadowDirection(faceIndex?: number): Vector3;
  111253. /**
  111254. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  111255. * - fov = PI / 2
  111256. * - aspect ratio : 1.0
  111257. * - z-near and far equal to the active camera minZ and maxZ.
  111258. * Returns the PointLight.
  111259. */
  111260. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111261. protected _buildUniformLayout(): void;
  111262. /**
  111263. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  111264. * @param effect The effect to update
  111265. * @param lightIndex The index of the light in the effect to update
  111266. * @returns The point light
  111267. */
  111268. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  111269. /**
  111270. * Prepares the list of defines specific to the light type.
  111271. * @param defines the list of defines
  111272. * @param lightIndex defines the index of the light for the effect
  111273. */
  111274. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111275. }
  111276. }
  111277. declare module BABYLON {
  111278. /**
  111279. * Header information of HDR texture files.
  111280. */
  111281. export interface HDRInfo {
  111282. /**
  111283. * The height of the texture in pixels.
  111284. */
  111285. height: number;
  111286. /**
  111287. * The width of the texture in pixels.
  111288. */
  111289. width: number;
  111290. /**
  111291. * The index of the beginning of the data in the binary file.
  111292. */
  111293. dataPosition: number;
  111294. }
  111295. /**
  111296. * This groups tools to convert HDR texture to native colors array.
  111297. */
  111298. export class HDRTools {
  111299. private static Ldexp;
  111300. private static Rgbe2float;
  111301. private static readStringLine;
  111302. /**
  111303. * Reads header information from an RGBE texture stored in a native array.
  111304. * More information on this format are available here:
  111305. * https://en.wikipedia.org/wiki/RGBE_image_format
  111306. *
  111307. * @param uint8array The binary file stored in native array.
  111308. * @return The header information.
  111309. */
  111310. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  111311. /**
  111312. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  111313. * This RGBE texture needs to store the information as a panorama.
  111314. *
  111315. * More information on this format are available here:
  111316. * https://en.wikipedia.org/wiki/RGBE_image_format
  111317. *
  111318. * @param buffer The binary file stored in an array buffer.
  111319. * @param size The expected size of the extracted cubemap.
  111320. * @return The Cube Map information.
  111321. */
  111322. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  111323. /**
  111324. * Returns the pixels data extracted from an RGBE texture.
  111325. * This pixels will be stored left to right up to down in the R G B order in one array.
  111326. *
  111327. * More information on this format are available here:
  111328. * https://en.wikipedia.org/wiki/RGBE_image_format
  111329. *
  111330. * @param uint8array The binary file stored in an array buffer.
  111331. * @param hdrInfo The header information of the file.
  111332. * @return The pixels data in RGB right to left up to down order.
  111333. */
  111334. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  111335. private static RGBE_ReadPixels_RLE;
  111336. }
  111337. }
  111338. declare module BABYLON {
  111339. /**
  111340. * This represents a texture coming from an HDR input.
  111341. *
  111342. * The only supported format is currently panorama picture stored in RGBE format.
  111343. * Example of such files can be found on HDRLib: http://hdrlib.com/
  111344. */
  111345. export class HDRCubeTexture extends BaseTexture {
  111346. private static _facesMapping;
  111347. private _generateHarmonics;
  111348. private _noMipmap;
  111349. private _textureMatrix;
  111350. private _size;
  111351. private _onLoad;
  111352. private _onError;
  111353. /**
  111354. * The texture URL.
  111355. */
  111356. url: string;
  111357. /**
  111358. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  111359. */
  111360. coordinatesMode: number;
  111361. protected _isBlocking: boolean;
  111362. /**
  111363. * Sets wether or not the texture is blocking during loading.
  111364. */
  111365. /**
  111366. * Gets wether or not the texture is blocking during loading.
  111367. */
  111368. isBlocking: boolean;
  111369. protected _rotationY: number;
  111370. /**
  111371. * Sets texture matrix rotation angle around Y axis in radians.
  111372. */
  111373. /**
  111374. * Gets texture matrix rotation angle around Y axis radians.
  111375. */
  111376. rotationY: number;
  111377. /**
  111378. * Gets or sets the center of the bounding box associated with the cube texture
  111379. * It must define where the camera used to render the texture was set
  111380. */
  111381. boundingBoxPosition: Vector3;
  111382. private _boundingBoxSize;
  111383. /**
  111384. * Gets or sets the size of the bounding box associated with the cube texture
  111385. * When defined, the cubemap will switch to local mode
  111386. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111387. * @example https://www.babylonjs-playground.com/#RNASML
  111388. */
  111389. boundingBoxSize: Vector3;
  111390. /**
  111391. * Instantiates an HDRTexture from the following parameters.
  111392. *
  111393. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  111394. * @param scene The scene the texture will be used in
  111395. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111396. * @param noMipmap Forces to not generate the mipmap if true
  111397. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  111398. * @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)
  111399. * @param reserved Reserved flag for internal use.
  111400. */
  111401. 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>);
  111402. /**
  111403. * Get the current class name of the texture useful for serialization or dynamic coding.
  111404. * @returns "HDRCubeTexture"
  111405. */
  111406. getClassName(): string;
  111407. /**
  111408. * Occurs when the file is raw .hdr file.
  111409. */
  111410. private loadTexture;
  111411. clone(): HDRCubeTexture;
  111412. delayLoad(): void;
  111413. /**
  111414. * Get the texture reflection matrix used to rotate/transform the reflection.
  111415. * @returns the reflection matrix
  111416. */
  111417. getReflectionTextureMatrix(): Matrix;
  111418. /**
  111419. * Set the texture reflection matrix used to rotate/transform the reflection.
  111420. * @param value Define the reflection matrix to set
  111421. */
  111422. setReflectionTextureMatrix(value: Matrix): void;
  111423. /**
  111424. * Parses a JSON representation of an HDR Texture in order to create the texture
  111425. * @param parsedTexture Define the JSON representation
  111426. * @param scene Define the scene the texture should be created in
  111427. * @param rootUrl Define the root url in case we need to load relative dependencies
  111428. * @returns the newly created texture after parsing
  111429. */
  111430. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  111431. serialize(): any;
  111432. }
  111433. }
  111434. declare module BABYLON {
  111435. /**
  111436. * Class used to control physics engine
  111437. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111438. */
  111439. export class PhysicsEngine implements IPhysicsEngine {
  111440. private _physicsPlugin;
  111441. /**
  111442. * Global value used to control the smallest number supported by the simulation
  111443. */
  111444. static Epsilon: number;
  111445. private _impostors;
  111446. private _joints;
  111447. /**
  111448. * Gets the gravity vector used by the simulation
  111449. */
  111450. gravity: Vector3;
  111451. /**
  111452. * Factory used to create the default physics plugin.
  111453. * @returns The default physics plugin
  111454. */
  111455. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  111456. /**
  111457. * Creates a new Physics Engine
  111458. * @param gravity defines the gravity vector used by the simulation
  111459. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  111460. */
  111461. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  111462. /**
  111463. * Sets the gravity vector used by the simulation
  111464. * @param gravity defines the gravity vector to use
  111465. */
  111466. setGravity(gravity: Vector3): void;
  111467. /**
  111468. * Set the time step of the physics engine.
  111469. * Default is 1/60.
  111470. * To slow it down, enter 1/600 for example.
  111471. * To speed it up, 1/30
  111472. * @param newTimeStep defines the new timestep to apply to this world.
  111473. */
  111474. setTimeStep(newTimeStep?: number): void;
  111475. /**
  111476. * Get the time step of the physics engine.
  111477. * @returns the current time step
  111478. */
  111479. getTimeStep(): number;
  111480. /**
  111481. * Release all resources
  111482. */
  111483. dispose(): void;
  111484. /**
  111485. * Gets the name of the current physics plugin
  111486. * @returns the name of the plugin
  111487. */
  111488. getPhysicsPluginName(): string;
  111489. /**
  111490. * Adding a new impostor for the impostor tracking.
  111491. * This will be done by the impostor itself.
  111492. * @param impostor the impostor to add
  111493. */
  111494. addImpostor(impostor: PhysicsImpostor): void;
  111495. /**
  111496. * Remove an impostor from the engine.
  111497. * This impostor and its mesh will not longer be updated by the physics engine.
  111498. * @param impostor the impostor to remove
  111499. */
  111500. removeImpostor(impostor: PhysicsImpostor): void;
  111501. /**
  111502. * Add a joint to the physics engine
  111503. * @param mainImpostor defines the main impostor to which the joint is added.
  111504. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111505. * @param joint defines the joint that will connect both impostors.
  111506. */
  111507. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111508. /**
  111509. * Removes a joint from the simulation
  111510. * @param mainImpostor defines the impostor used with the joint
  111511. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111512. * @param joint defines the joint to remove
  111513. */
  111514. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111515. /**
  111516. * Called by the scene. No need to call it.
  111517. * @param delta defines the timespam between frames
  111518. */
  111519. _step(delta: number): void;
  111520. /**
  111521. * Gets the current plugin used to run the simulation
  111522. * @returns current plugin
  111523. */
  111524. getPhysicsPlugin(): IPhysicsEnginePlugin;
  111525. /**
  111526. * Gets the list of physic impostors
  111527. * @returns an array of PhysicsImpostor
  111528. */
  111529. getImpostors(): Array<PhysicsImpostor>;
  111530. /**
  111531. * Gets the impostor for a physics enabled object
  111532. * @param object defines the object impersonated by the impostor
  111533. * @returns the PhysicsImpostor or null if not found
  111534. */
  111535. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  111536. /**
  111537. * Gets the impostor for a physics body object
  111538. * @param body defines physics body used by the impostor
  111539. * @returns the PhysicsImpostor or null if not found
  111540. */
  111541. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  111542. /**
  111543. * Does a raycast in the physics world
  111544. * @param from when should the ray start?
  111545. * @param to when should the ray end?
  111546. * @returns PhysicsRaycastResult
  111547. */
  111548. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111549. }
  111550. }
  111551. declare module BABYLON {
  111552. /** @hidden */
  111553. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  111554. private _useDeltaForWorldStep;
  111555. world: any;
  111556. name: string;
  111557. private _physicsMaterials;
  111558. private _fixedTimeStep;
  111559. private _cannonRaycastResult;
  111560. private _raycastResult;
  111561. private _removeAfterStep;
  111562. BJSCANNON: any;
  111563. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  111564. setGravity(gravity: Vector3): void;
  111565. setTimeStep(timeStep: number): void;
  111566. getTimeStep(): number;
  111567. executeStep(delta: number): void;
  111568. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111569. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111570. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111571. private _processChildMeshes;
  111572. removePhysicsBody(impostor: PhysicsImpostor): void;
  111573. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111574. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111575. private _addMaterial;
  111576. private _checkWithEpsilon;
  111577. private _createShape;
  111578. private _createHeightmap;
  111579. private _minus90X;
  111580. private _plus90X;
  111581. private _tmpPosition;
  111582. private _tmpDeltaPosition;
  111583. private _tmpUnityRotation;
  111584. private _updatePhysicsBodyTransformation;
  111585. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111586. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111587. isSupported(): boolean;
  111588. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111589. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111590. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111591. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111592. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111593. getBodyMass(impostor: PhysicsImpostor): number;
  111594. getBodyFriction(impostor: PhysicsImpostor): number;
  111595. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111596. getBodyRestitution(impostor: PhysicsImpostor): number;
  111597. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111598. sleepBody(impostor: PhysicsImpostor): void;
  111599. wakeUpBody(impostor: PhysicsImpostor): void;
  111600. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  111601. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  111602. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  111603. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111604. getRadius(impostor: PhysicsImpostor): number;
  111605. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111606. dispose(): void;
  111607. private _extendNamespace;
  111608. /**
  111609. * Does a raycast in the physics world
  111610. * @param from when should the ray start?
  111611. * @param to when should the ray end?
  111612. * @returns PhysicsRaycastResult
  111613. */
  111614. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111615. }
  111616. }
  111617. declare module BABYLON {
  111618. /** @hidden */
  111619. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  111620. world: any;
  111621. name: string;
  111622. BJSOIMO: any;
  111623. private _raycastResult;
  111624. constructor(iterations?: number, oimoInjection?: any);
  111625. setGravity(gravity: Vector3): void;
  111626. setTimeStep(timeStep: number): void;
  111627. getTimeStep(): number;
  111628. private _tmpImpostorsArray;
  111629. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111630. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111631. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111632. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111633. private _tmpPositionVector;
  111634. removePhysicsBody(impostor: PhysicsImpostor): void;
  111635. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111636. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111637. isSupported(): boolean;
  111638. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111639. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111640. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111641. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111642. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111643. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111644. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111645. getBodyMass(impostor: PhysicsImpostor): number;
  111646. getBodyFriction(impostor: PhysicsImpostor): number;
  111647. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111648. getBodyRestitution(impostor: PhysicsImpostor): number;
  111649. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111650. sleepBody(impostor: PhysicsImpostor): void;
  111651. wakeUpBody(impostor: PhysicsImpostor): void;
  111652. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  111653. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  111654. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  111655. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111656. getRadius(impostor: PhysicsImpostor): number;
  111657. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111658. dispose(): void;
  111659. /**
  111660. * Does a raycast in the physics world
  111661. * @param from when should the ray start?
  111662. * @param to when should the ray end?
  111663. * @returns PhysicsRaycastResult
  111664. */
  111665. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111666. }
  111667. }
  111668. declare module BABYLON {
  111669. /**
  111670. * Class containing static functions to help procedurally build meshes
  111671. */
  111672. export class RibbonBuilder {
  111673. /**
  111674. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  111675. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  111676. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  111677. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  111678. * * 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
  111679. * * 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
  111680. * * 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
  111681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111683. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111684. * * 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
  111685. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  111686. * * 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
  111687. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  111688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111689. * @param name defines the name of the mesh
  111690. * @param options defines the options used to create the mesh
  111691. * @param scene defines the hosting scene
  111692. * @returns the ribbon mesh
  111693. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  111694. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111695. */
  111696. static CreateRibbon(name: string, options: {
  111697. pathArray: Vector3[][];
  111698. closeArray?: boolean;
  111699. closePath?: boolean;
  111700. offset?: number;
  111701. updatable?: boolean;
  111702. sideOrientation?: number;
  111703. frontUVs?: Vector4;
  111704. backUVs?: Vector4;
  111705. instance?: Mesh;
  111706. invertUV?: boolean;
  111707. uvs?: Vector2[];
  111708. colors?: Color4[];
  111709. }, scene?: Nullable<Scene>): Mesh;
  111710. }
  111711. }
  111712. declare module BABYLON {
  111713. /**
  111714. * Class containing static functions to help procedurally build meshes
  111715. */
  111716. export class ShapeBuilder {
  111717. /**
  111718. * 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.
  111719. * * 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.
  111720. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111721. * * 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.
  111722. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  111723. * * 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
  111724. * * 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
  111725. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  111726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111728. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  111729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111730. * @param name defines the name of the mesh
  111731. * @param options defines the options used to create the mesh
  111732. * @param scene defines the hosting scene
  111733. * @returns the extruded shape mesh
  111734. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111736. */
  111737. static ExtrudeShape(name: string, options: {
  111738. shape: Vector3[];
  111739. path: Vector3[];
  111740. scale?: number;
  111741. rotation?: number;
  111742. cap?: number;
  111743. updatable?: boolean;
  111744. sideOrientation?: number;
  111745. frontUVs?: Vector4;
  111746. backUVs?: Vector4;
  111747. instance?: Mesh;
  111748. invertUV?: boolean;
  111749. }, scene?: Nullable<Scene>): Mesh;
  111750. /**
  111751. * Creates an custom extruded shape mesh.
  111752. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  111753. * * 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.
  111754. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111755. * * 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
  111756. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  111757. * * 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
  111758. * * It must returns a float value that will be the scale value applied to the shape on each path point
  111759. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  111760. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  111761. * * 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
  111762. * * 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
  111763. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  111764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111766. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111768. * @param name defines the name of the mesh
  111769. * @param options defines the options used to create the mesh
  111770. * @param scene defines the hosting scene
  111771. * @returns the custom extruded shape mesh
  111772. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  111773. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111774. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111775. */
  111776. static ExtrudeShapeCustom(name: string, options: {
  111777. shape: Vector3[];
  111778. path: Vector3[];
  111779. scaleFunction?: any;
  111780. rotationFunction?: any;
  111781. ribbonCloseArray?: boolean;
  111782. ribbonClosePath?: boolean;
  111783. cap?: number;
  111784. updatable?: boolean;
  111785. sideOrientation?: number;
  111786. frontUVs?: Vector4;
  111787. backUVs?: Vector4;
  111788. instance?: Mesh;
  111789. invertUV?: boolean;
  111790. }, scene?: Nullable<Scene>): Mesh;
  111791. private static _ExtrudeShapeGeneric;
  111792. }
  111793. }
  111794. declare module BABYLON {
  111795. /**
  111796. * AmmoJS Physics plugin
  111797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111798. * @see https://github.com/kripken/ammo.js/
  111799. */
  111800. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  111801. private _useDeltaForWorldStep;
  111802. /**
  111803. * Reference to the Ammo library
  111804. */
  111805. bjsAMMO: any;
  111806. /**
  111807. * Created ammoJS world which physics bodies are added to
  111808. */
  111809. world: any;
  111810. /**
  111811. * Name of the plugin
  111812. */
  111813. name: string;
  111814. private _timeStep;
  111815. private _fixedTimeStep;
  111816. private _maxSteps;
  111817. private _tmpQuaternion;
  111818. private _tmpAmmoTransform;
  111819. private _tmpAmmoQuaternion;
  111820. private _tmpAmmoConcreteContactResultCallback;
  111821. private _collisionConfiguration;
  111822. private _dispatcher;
  111823. private _overlappingPairCache;
  111824. private _solver;
  111825. private _softBodySolver;
  111826. private _tmpAmmoVectorA;
  111827. private _tmpAmmoVectorB;
  111828. private _tmpAmmoVectorC;
  111829. private _tmpAmmoVectorD;
  111830. private _tmpContactCallbackResult;
  111831. private _tmpAmmoVectorRCA;
  111832. private _tmpAmmoVectorRCB;
  111833. private _raycastResult;
  111834. private static readonly DISABLE_COLLISION_FLAG;
  111835. private static readonly KINEMATIC_FLAG;
  111836. private static readonly DISABLE_DEACTIVATION_FLAG;
  111837. /**
  111838. * Initializes the ammoJS plugin
  111839. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  111840. * @param ammoInjection can be used to inject your own ammo reference
  111841. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  111842. */
  111843. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  111844. /**
  111845. * Sets the gravity of the physics world (m/(s^2))
  111846. * @param gravity Gravity to set
  111847. */
  111848. setGravity(gravity: Vector3): void;
  111849. /**
  111850. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  111851. * @param timeStep timestep to use in seconds
  111852. */
  111853. setTimeStep(timeStep: number): void;
  111854. /**
  111855. * 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)
  111856. * @param fixedTimeStep fixedTimeStep to use in seconds
  111857. */
  111858. setFixedTimeStep(fixedTimeStep: number): void;
  111859. /**
  111860. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  111861. * @param maxSteps the maximum number of steps by the physics engine per frame
  111862. */
  111863. setMaxSteps(maxSteps: number): void;
  111864. /**
  111865. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  111866. * @returns the current timestep in seconds
  111867. */
  111868. getTimeStep(): number;
  111869. private _isImpostorInContact;
  111870. private _isImpostorPairInContact;
  111871. private _stepSimulation;
  111872. /**
  111873. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  111874. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  111875. * After the step the babylon meshes are set to the position of the physics imposters
  111876. * @param delta amount of time to step forward
  111877. * @param impostors array of imposters to update before/after the step
  111878. */
  111879. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111880. /**
  111881. * Update babylon mesh to match physics world object
  111882. * @param impostor imposter to match
  111883. */
  111884. private _afterSoftStep;
  111885. /**
  111886. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  111887. * @param impostor imposter to match
  111888. */
  111889. private _ropeStep;
  111890. /**
  111891. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  111892. * @param impostor imposter to match
  111893. */
  111894. private _softbodyOrClothStep;
  111895. private _tmpVector;
  111896. private _tmpMatrix;
  111897. /**
  111898. * Applies an impulse on the imposter
  111899. * @param impostor imposter to apply impulse to
  111900. * @param force amount of force to be applied to the imposter
  111901. * @param contactPoint the location to apply the impulse on the imposter
  111902. */
  111903. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111904. /**
  111905. * Applies a force on the imposter
  111906. * @param impostor imposter to apply force
  111907. * @param force amount of force to be applied to the imposter
  111908. * @param contactPoint the location to apply the force on the imposter
  111909. */
  111910. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111911. /**
  111912. * Creates a physics body using the plugin
  111913. * @param impostor the imposter to create the physics body on
  111914. */
  111915. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111916. /**
  111917. * Removes the physics body from the imposter and disposes of the body's memory
  111918. * @param impostor imposter to remove the physics body from
  111919. */
  111920. removePhysicsBody(impostor: PhysicsImpostor): void;
  111921. /**
  111922. * Generates a joint
  111923. * @param impostorJoint the imposter joint to create the joint with
  111924. */
  111925. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111926. /**
  111927. * Removes a joint
  111928. * @param impostorJoint the imposter joint to remove the joint from
  111929. */
  111930. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111931. private _addMeshVerts;
  111932. /**
  111933. * Initialise the soft body vertices to match its object's (mesh) vertices
  111934. * Softbody vertices (nodes) are in world space and to match this
  111935. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  111936. * @param impostor to create the softbody for
  111937. */
  111938. private _softVertexData;
  111939. /**
  111940. * Create an impostor's soft body
  111941. * @param impostor to create the softbody for
  111942. */
  111943. private _createSoftbody;
  111944. /**
  111945. * Create cloth for an impostor
  111946. * @param impostor to create the softbody for
  111947. */
  111948. private _createCloth;
  111949. /**
  111950. * Create rope for an impostor
  111951. * @param impostor to create the softbody for
  111952. */
  111953. private _createRope;
  111954. private _addHullVerts;
  111955. private _createShape;
  111956. /**
  111957. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  111958. * @param impostor imposter containing the physics body and babylon object
  111959. */
  111960. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111961. /**
  111962. * Sets the babylon object's position/rotation from the physics body's position/rotation
  111963. * @param impostor imposter containing the physics body and babylon object
  111964. * @param newPosition new position
  111965. * @param newRotation new rotation
  111966. */
  111967. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111968. /**
  111969. * If this plugin is supported
  111970. * @returns true if its supported
  111971. */
  111972. isSupported(): boolean;
  111973. /**
  111974. * Sets the linear velocity of the physics body
  111975. * @param impostor imposter to set the velocity on
  111976. * @param velocity velocity to set
  111977. */
  111978. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111979. /**
  111980. * Sets the angular velocity of the physics body
  111981. * @param impostor imposter to set the velocity on
  111982. * @param velocity velocity to set
  111983. */
  111984. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111985. /**
  111986. * gets the linear velocity
  111987. * @param impostor imposter to get linear velocity from
  111988. * @returns linear velocity
  111989. */
  111990. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111991. /**
  111992. * gets the angular velocity
  111993. * @param impostor imposter to get angular velocity from
  111994. * @returns angular velocity
  111995. */
  111996. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111997. /**
  111998. * Sets the mass of physics body
  111999. * @param impostor imposter to set the mass on
  112000. * @param mass mass to set
  112001. */
  112002. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112003. /**
  112004. * Gets the mass of the physics body
  112005. * @param impostor imposter to get the mass from
  112006. * @returns mass
  112007. */
  112008. getBodyMass(impostor: PhysicsImpostor): number;
  112009. /**
  112010. * Gets friction of the impostor
  112011. * @param impostor impostor to get friction from
  112012. * @returns friction value
  112013. */
  112014. getBodyFriction(impostor: PhysicsImpostor): number;
  112015. /**
  112016. * Sets friction of the impostor
  112017. * @param impostor impostor to set friction on
  112018. * @param friction friction value
  112019. */
  112020. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112021. /**
  112022. * Gets restitution of the impostor
  112023. * @param impostor impostor to get restitution from
  112024. * @returns restitution value
  112025. */
  112026. getBodyRestitution(impostor: PhysicsImpostor): number;
  112027. /**
  112028. * Sets resitution of the impostor
  112029. * @param impostor impostor to set resitution on
  112030. * @param restitution resitution value
  112031. */
  112032. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112033. /**
  112034. * Gets pressure inside the impostor
  112035. * @param impostor impostor to get pressure from
  112036. * @returns pressure value
  112037. */
  112038. getBodyPressure(impostor: PhysicsImpostor): number;
  112039. /**
  112040. * Sets pressure inside a soft body impostor
  112041. * Cloth and rope must remain 0 pressure
  112042. * @param impostor impostor to set pressure on
  112043. * @param pressure pressure value
  112044. */
  112045. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  112046. /**
  112047. * Gets stiffness of the impostor
  112048. * @param impostor impostor to get stiffness from
  112049. * @returns pressure value
  112050. */
  112051. getBodyStiffness(impostor: PhysicsImpostor): number;
  112052. /**
  112053. * Sets stiffness of the impostor
  112054. * @param impostor impostor to set stiffness on
  112055. * @param stiffness stiffness value from 0 to 1
  112056. */
  112057. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  112058. /**
  112059. * Gets velocityIterations of the impostor
  112060. * @param impostor impostor to get velocity iterations from
  112061. * @returns velocityIterations value
  112062. */
  112063. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  112064. /**
  112065. * Sets velocityIterations of the impostor
  112066. * @param impostor impostor to set velocity iterations on
  112067. * @param velocityIterations velocityIterations value
  112068. */
  112069. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  112070. /**
  112071. * Gets positionIterations of the impostor
  112072. * @param impostor impostor to get position iterations from
  112073. * @returns positionIterations value
  112074. */
  112075. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  112076. /**
  112077. * Sets positionIterations of the impostor
  112078. * @param impostor impostor to set position on
  112079. * @param positionIterations positionIterations value
  112080. */
  112081. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  112082. /**
  112083. * Append an anchor to a cloth object
  112084. * @param impostor is the cloth impostor to add anchor to
  112085. * @param otherImpostor is the rigid impostor to anchor to
  112086. * @param width ratio across width from 0 to 1
  112087. * @param height ratio up height from 0 to 1
  112088. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112089. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112090. */
  112091. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112092. /**
  112093. * Append an hook to a rope object
  112094. * @param impostor is the rope impostor to add hook to
  112095. * @param otherImpostor is the rigid impostor to hook to
  112096. * @param length ratio along the rope from 0 to 1
  112097. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  112098. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112099. */
  112100. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112101. /**
  112102. * Sleeps the physics body and stops it from being active
  112103. * @param impostor impostor to sleep
  112104. */
  112105. sleepBody(impostor: PhysicsImpostor): void;
  112106. /**
  112107. * Activates the physics body
  112108. * @param impostor impostor to activate
  112109. */
  112110. wakeUpBody(impostor: PhysicsImpostor): void;
  112111. /**
  112112. * Updates the distance parameters of the joint
  112113. * @param joint joint to update
  112114. * @param maxDistance maximum distance of the joint
  112115. * @param minDistance minimum distance of the joint
  112116. */
  112117. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112118. /**
  112119. * Sets a motor on the joint
  112120. * @param joint joint to set motor on
  112121. * @param speed speed of the motor
  112122. * @param maxForce maximum force of the motor
  112123. * @param motorIndex index of the motor
  112124. */
  112125. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112126. /**
  112127. * Sets the motors limit
  112128. * @param joint joint to set limit on
  112129. * @param upperLimit upper limit
  112130. * @param lowerLimit lower limit
  112131. */
  112132. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112133. /**
  112134. * Syncs the position and rotation of a mesh with the impostor
  112135. * @param mesh mesh to sync
  112136. * @param impostor impostor to update the mesh with
  112137. */
  112138. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112139. /**
  112140. * Gets the radius of the impostor
  112141. * @param impostor impostor to get radius from
  112142. * @returns the radius
  112143. */
  112144. getRadius(impostor: PhysicsImpostor): number;
  112145. /**
  112146. * Gets the box size of the impostor
  112147. * @param impostor impostor to get box size from
  112148. * @param result the resulting box size
  112149. */
  112150. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112151. /**
  112152. * Disposes of the impostor
  112153. */
  112154. dispose(): void;
  112155. /**
  112156. * Does a raycast in the physics world
  112157. * @param from when should the ray start?
  112158. * @param to when should the ray end?
  112159. * @returns PhysicsRaycastResult
  112160. */
  112161. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112162. }
  112163. }
  112164. declare module BABYLON {
  112165. interface AbstractScene {
  112166. /**
  112167. * The list of reflection probes added to the scene
  112168. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112169. */
  112170. reflectionProbes: Array<ReflectionProbe>;
  112171. /**
  112172. * Removes the given reflection probe from this scene.
  112173. * @param toRemove The reflection probe to remove
  112174. * @returns The index of the removed reflection probe
  112175. */
  112176. removeReflectionProbe(toRemove: ReflectionProbe): number;
  112177. /**
  112178. * Adds the given reflection probe to this scene.
  112179. * @param newReflectionProbe The reflection probe to add
  112180. */
  112181. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  112182. }
  112183. /**
  112184. * Class used to generate realtime reflection / refraction cube textures
  112185. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112186. */
  112187. export class ReflectionProbe {
  112188. /** defines the name of the probe */
  112189. name: string;
  112190. private _scene;
  112191. private _renderTargetTexture;
  112192. private _projectionMatrix;
  112193. private _viewMatrix;
  112194. private _target;
  112195. private _add;
  112196. private _attachedMesh;
  112197. private _invertYAxis;
  112198. /** Gets or sets probe position (center of the cube map) */
  112199. position: Vector3;
  112200. /**
  112201. * Creates a new reflection probe
  112202. * @param name defines the name of the probe
  112203. * @param size defines the texture resolution (for each face)
  112204. * @param scene defines the hosting scene
  112205. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  112206. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  112207. */
  112208. constructor(
  112209. /** defines the name of the probe */
  112210. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  112211. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  112212. samples: number;
  112213. /** Gets or sets the refresh rate to use (on every frame by default) */
  112214. refreshRate: number;
  112215. /**
  112216. * Gets the hosting scene
  112217. * @returns a Scene
  112218. */
  112219. getScene(): Scene;
  112220. /** Gets the internal CubeTexture used to render to */
  112221. readonly cubeTexture: RenderTargetTexture;
  112222. /** Gets the list of meshes to render */
  112223. readonly renderList: Nullable<AbstractMesh[]>;
  112224. /**
  112225. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  112226. * @param mesh defines the mesh to attach to
  112227. */
  112228. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112229. /**
  112230. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  112231. * @param renderingGroupId The rendering group id corresponding to its index
  112232. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  112233. */
  112234. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  112235. /**
  112236. * Clean all associated resources
  112237. */
  112238. dispose(): void;
  112239. /**
  112240. * Converts the reflection probe information to a readable string for debug purpose.
  112241. * @param fullDetails Supports for multiple levels of logging within scene loading
  112242. * @returns the human readable reflection probe info
  112243. */
  112244. toString(fullDetails?: boolean): string;
  112245. /**
  112246. * Get the class name of the relfection probe.
  112247. * @returns "ReflectionProbe"
  112248. */
  112249. getClassName(): string;
  112250. /**
  112251. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  112252. * @returns The JSON representation of the texture
  112253. */
  112254. serialize(): any;
  112255. /**
  112256. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  112257. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  112258. * @param scene Define the scene the parsed reflection probe should be instantiated in
  112259. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  112260. * @returns The parsed reflection probe if successful
  112261. */
  112262. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  112263. }
  112264. }
  112265. declare module BABYLON {
  112266. /** @hidden */
  112267. export var _BabylonLoaderRegistered: boolean;
  112268. }
  112269. declare module BABYLON {
  112270. /**
  112271. * The Physically based simple base material of BJS.
  112272. *
  112273. * This enables better naming and convention enforcements on top of the pbrMaterial.
  112274. * It is used as the base class for both the specGloss and metalRough conventions.
  112275. */
  112276. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  112277. /**
  112278. * Number of Simultaneous lights allowed on the material.
  112279. */
  112280. maxSimultaneousLights: number;
  112281. /**
  112282. * If sets to true, disables all the lights affecting the material.
  112283. */
  112284. disableLighting: boolean;
  112285. /**
  112286. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  112287. */
  112288. environmentTexture: BaseTexture;
  112289. /**
  112290. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112291. */
  112292. invertNormalMapX: boolean;
  112293. /**
  112294. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112295. */
  112296. invertNormalMapY: boolean;
  112297. /**
  112298. * Normal map used in the model.
  112299. */
  112300. normalTexture: BaseTexture;
  112301. /**
  112302. * Emissivie color used to self-illuminate the model.
  112303. */
  112304. emissiveColor: Color3;
  112305. /**
  112306. * Emissivie texture used to self-illuminate the model.
  112307. */
  112308. emissiveTexture: BaseTexture;
  112309. /**
  112310. * Occlusion Channel Strenght.
  112311. */
  112312. occlusionStrength: number;
  112313. /**
  112314. * Occlusion Texture of the material (adding extra occlusion effects).
  112315. */
  112316. occlusionTexture: BaseTexture;
  112317. /**
  112318. * Defines the alpha limits in alpha test mode.
  112319. */
  112320. alphaCutOff: number;
  112321. /**
  112322. * Gets the current double sided mode.
  112323. */
  112324. /**
  112325. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112326. */
  112327. doubleSided: boolean;
  112328. /**
  112329. * Stores the pre-calculated light information of a mesh in a texture.
  112330. */
  112331. lightmapTexture: BaseTexture;
  112332. /**
  112333. * If true, the light map contains occlusion information instead of lighting info.
  112334. */
  112335. useLightmapAsShadowmap: boolean;
  112336. /**
  112337. * Instantiates a new PBRMaterial instance.
  112338. *
  112339. * @param name The material name
  112340. * @param scene The scene the material will be use in.
  112341. */
  112342. constructor(name: string, scene: Scene);
  112343. getClassName(): string;
  112344. }
  112345. }
  112346. declare module BABYLON {
  112347. /**
  112348. * The PBR material of BJS following the metal roughness convention.
  112349. *
  112350. * This fits to the PBR convention in the GLTF definition:
  112351. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  112352. */
  112353. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  112354. /**
  112355. * The base color has two different interpretations depending on the value of metalness.
  112356. * When the material is a metal, the base color is the specific measured reflectance value
  112357. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  112358. * of the material.
  112359. */
  112360. baseColor: Color3;
  112361. /**
  112362. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  112363. * well as opacity information in the alpha channel.
  112364. */
  112365. baseTexture: BaseTexture;
  112366. /**
  112367. * Specifies the metallic scalar value of the material.
  112368. * Can also be used to scale the metalness values of the metallic texture.
  112369. */
  112370. metallic: number;
  112371. /**
  112372. * Specifies the roughness scalar value of the material.
  112373. * Can also be used to scale the roughness values of the metallic texture.
  112374. */
  112375. roughness: number;
  112376. /**
  112377. * Texture containing both the metallic value in the B channel and the
  112378. * roughness value in the G channel to keep better precision.
  112379. */
  112380. metallicRoughnessTexture: BaseTexture;
  112381. /**
  112382. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112383. *
  112384. * @param name The material name
  112385. * @param scene The scene the material will be use in.
  112386. */
  112387. constructor(name: string, scene: Scene);
  112388. /**
  112389. * Return the currrent class name of the material.
  112390. */
  112391. getClassName(): string;
  112392. /**
  112393. * Makes a duplicate of the current material.
  112394. * @param name - name to use for the new material.
  112395. */
  112396. clone(name: string): PBRMetallicRoughnessMaterial;
  112397. /**
  112398. * Serialize the material to a parsable JSON object.
  112399. */
  112400. serialize(): any;
  112401. /**
  112402. * Parses a JSON object correponding to the serialize function.
  112403. */
  112404. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  112405. }
  112406. }
  112407. declare module BABYLON {
  112408. /**
  112409. * The PBR material of BJS following the specular glossiness convention.
  112410. *
  112411. * This fits to the PBR convention in the GLTF definition:
  112412. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  112413. */
  112414. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  112415. /**
  112416. * Specifies the diffuse color of the material.
  112417. */
  112418. diffuseColor: Color3;
  112419. /**
  112420. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  112421. * channel.
  112422. */
  112423. diffuseTexture: BaseTexture;
  112424. /**
  112425. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  112426. */
  112427. specularColor: Color3;
  112428. /**
  112429. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  112430. */
  112431. glossiness: number;
  112432. /**
  112433. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  112434. */
  112435. specularGlossinessTexture: BaseTexture;
  112436. /**
  112437. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  112438. *
  112439. * @param name The material name
  112440. * @param scene The scene the material will be use in.
  112441. */
  112442. constructor(name: string, scene: Scene);
  112443. /**
  112444. * Return the currrent class name of the material.
  112445. */
  112446. getClassName(): string;
  112447. /**
  112448. * Makes a duplicate of the current material.
  112449. * @param name - name to use for the new material.
  112450. */
  112451. clone(name: string): PBRSpecularGlossinessMaterial;
  112452. /**
  112453. * Serialize the material to a parsable JSON object.
  112454. */
  112455. serialize(): any;
  112456. /**
  112457. * Parses a JSON object correponding to the serialize function.
  112458. */
  112459. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  112460. }
  112461. }
  112462. declare module BABYLON {
  112463. /**
  112464. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  112465. * It can help converting any input color in a desired output one. This can then be used to create effects
  112466. * from sepia, black and white to sixties or futuristic rendering...
  112467. *
  112468. * The only supported format is currently 3dl.
  112469. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  112470. */
  112471. export class ColorGradingTexture extends BaseTexture {
  112472. /**
  112473. * The current texture matrix. (will always be identity in color grading texture)
  112474. */
  112475. private _textureMatrix;
  112476. /**
  112477. * The texture URL.
  112478. */
  112479. url: string;
  112480. /**
  112481. * Empty line regex stored for GC.
  112482. */
  112483. private static _noneEmptyLineRegex;
  112484. private _engine;
  112485. /**
  112486. * Instantiates a ColorGradingTexture from the following parameters.
  112487. *
  112488. * @param url The location of the color gradind data (currently only supporting 3dl)
  112489. * @param scene The scene the texture will be used in
  112490. */
  112491. constructor(url: string, scene: Scene);
  112492. /**
  112493. * Returns the texture matrix used in most of the material.
  112494. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  112495. */
  112496. getTextureMatrix(): Matrix;
  112497. /**
  112498. * Occurs when the file being loaded is a .3dl LUT file.
  112499. */
  112500. private load3dlTexture;
  112501. /**
  112502. * Starts the loading process of the texture.
  112503. */
  112504. private loadTexture;
  112505. /**
  112506. * Clones the color gradind texture.
  112507. */
  112508. clone(): ColorGradingTexture;
  112509. /**
  112510. * Called during delayed load for textures.
  112511. */
  112512. delayLoad(): void;
  112513. /**
  112514. * Parses a color grading texture serialized by Babylon.
  112515. * @param parsedTexture The texture information being parsedTexture
  112516. * @param scene The scene to load the texture in
  112517. * @param rootUrl The root url of the data assets to load
  112518. * @return A color gradind texture
  112519. */
  112520. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  112521. /**
  112522. * Serializes the LUT texture to json format.
  112523. */
  112524. serialize(): any;
  112525. }
  112526. }
  112527. declare module BABYLON {
  112528. /**
  112529. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  112530. */
  112531. export class EquiRectangularCubeTexture extends BaseTexture {
  112532. /** The six faces of the cube. */
  112533. private static _FacesMapping;
  112534. private _noMipmap;
  112535. private _onLoad;
  112536. private _onError;
  112537. /** The size of the cubemap. */
  112538. private _size;
  112539. /** The buffer of the image. */
  112540. private _buffer;
  112541. /** The width of the input image. */
  112542. private _width;
  112543. /** The height of the input image. */
  112544. private _height;
  112545. /** The URL to the image. */
  112546. url: string;
  112547. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  112548. coordinatesMode: number;
  112549. /**
  112550. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  112551. * @param url The location of the image
  112552. * @param scene The scene the texture will be used in
  112553. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  112554. * @param noMipmap Forces to not generate the mipmap if true
  112555. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  112556. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  112557. * @param onLoad — defines a callback called when texture is loaded
  112558. * @param onError — defines a callback called if there is an error
  112559. */
  112560. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  112561. /**
  112562. * Load the image data, by putting the image on a canvas and extracting its buffer.
  112563. */
  112564. private loadImage;
  112565. /**
  112566. * Convert the image buffer into a cubemap and create a CubeTexture.
  112567. */
  112568. private loadTexture;
  112569. /**
  112570. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  112571. * @param buffer The ArrayBuffer that should be converted.
  112572. * @returns The buffer as Float32Array.
  112573. */
  112574. private getFloat32ArrayFromArrayBuffer;
  112575. /**
  112576. * Get the current class name of the texture useful for serialization or dynamic coding.
  112577. * @returns "EquiRectangularCubeTexture"
  112578. */
  112579. getClassName(): string;
  112580. /**
  112581. * Create a clone of the current EquiRectangularCubeTexture and return it.
  112582. * @returns A clone of the current EquiRectangularCubeTexture.
  112583. */
  112584. clone(): EquiRectangularCubeTexture;
  112585. }
  112586. }
  112587. declare module BABYLON {
  112588. /**
  112589. * Based on jsTGALoader - Javascript loader for TGA file
  112590. * By Vincent Thibault
  112591. * @see http://blog.robrowser.com/javascript-tga-loader.html
  112592. */
  112593. export class TGATools {
  112594. private static _TYPE_INDEXED;
  112595. private static _TYPE_RGB;
  112596. private static _TYPE_GREY;
  112597. private static _TYPE_RLE_INDEXED;
  112598. private static _TYPE_RLE_RGB;
  112599. private static _TYPE_RLE_GREY;
  112600. private static _ORIGIN_MASK;
  112601. private static _ORIGIN_SHIFT;
  112602. private static _ORIGIN_BL;
  112603. private static _ORIGIN_BR;
  112604. private static _ORIGIN_UL;
  112605. private static _ORIGIN_UR;
  112606. /**
  112607. * Gets the header of a TGA file
  112608. * @param data defines the TGA data
  112609. * @returns the header
  112610. */
  112611. static GetTGAHeader(data: Uint8Array): any;
  112612. /**
  112613. * Uploads TGA content to a Babylon Texture
  112614. * @hidden
  112615. */
  112616. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  112617. /** @hidden */
  112618. 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;
  112619. /** @hidden */
  112620. 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;
  112621. /** @hidden */
  112622. 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;
  112623. /** @hidden */
  112624. 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;
  112625. /** @hidden */
  112626. 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;
  112627. /** @hidden */
  112628. 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;
  112629. }
  112630. }
  112631. declare module BABYLON {
  112632. /**
  112633. * Implementation of the TGA Texture Loader.
  112634. * @hidden
  112635. */
  112636. export class _TGATextureLoader implements IInternalTextureLoader {
  112637. /**
  112638. * Defines wether the loader supports cascade loading the different faces.
  112639. */
  112640. readonly supportCascades: boolean;
  112641. /**
  112642. * This returns if the loader support the current file information.
  112643. * @param extension defines the file extension of the file being loaded
  112644. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112645. * @param fallback defines the fallback internal texture if any
  112646. * @param isBase64 defines whether the texture is encoded as a base64
  112647. * @param isBuffer defines whether the texture data are stored as a buffer
  112648. * @returns true if the loader can load the specified file
  112649. */
  112650. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112651. /**
  112652. * Transform the url before loading if required.
  112653. * @param rootUrl the url of the texture
  112654. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112655. * @returns the transformed texture
  112656. */
  112657. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112658. /**
  112659. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112660. * @param rootUrl the url of the texture
  112661. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112662. * @returns the fallback texture
  112663. */
  112664. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112665. /**
  112666. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112667. * @param data contains the texture data
  112668. * @param texture defines the BabylonJS internal texture
  112669. * @param createPolynomials will be true if polynomials have been requested
  112670. * @param onLoad defines the callback to trigger once the texture is ready
  112671. * @param onError defines the callback to trigger in case of error
  112672. */
  112673. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112674. /**
  112675. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112676. * @param data contains the texture data
  112677. * @param texture defines the BabylonJS internal texture
  112678. * @param callback defines the method to call once ready to upload
  112679. */
  112680. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112681. }
  112682. }
  112683. declare module BABYLON {
  112684. /**
  112685. * Info about the .basis files
  112686. */
  112687. class BasisFileInfo {
  112688. /**
  112689. * If the file has alpha
  112690. */
  112691. hasAlpha: boolean;
  112692. /**
  112693. * Info about each image of the basis file
  112694. */
  112695. images: Array<{
  112696. levels: Array<{
  112697. width: number;
  112698. height: number;
  112699. transcodedPixels: ArrayBufferView;
  112700. }>;
  112701. }>;
  112702. }
  112703. /**
  112704. * Configuration options for the Basis transcoder
  112705. */
  112706. export class BasisTranscodeConfiguration {
  112707. /**
  112708. * Supported compression formats used to determine the supported output format of the transcoder
  112709. */
  112710. supportedCompressionFormats?: {
  112711. /**
  112712. * etc1 compression format
  112713. */
  112714. etc1?: boolean;
  112715. /**
  112716. * s3tc compression format
  112717. */
  112718. s3tc?: boolean;
  112719. /**
  112720. * pvrtc compression format
  112721. */
  112722. pvrtc?: boolean;
  112723. /**
  112724. * etc2 compression format
  112725. */
  112726. etc2?: boolean;
  112727. };
  112728. /**
  112729. * If mipmap levels should be loaded for transcoded images (Default: true)
  112730. */
  112731. loadMipmapLevels?: boolean;
  112732. /**
  112733. * Index of a single image to load (Default: all images)
  112734. */
  112735. loadSingleImage?: number;
  112736. }
  112737. /**
  112738. * Used to load .Basis files
  112739. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  112740. */
  112741. export class BasisTools {
  112742. private static _IgnoreSupportedFormats;
  112743. /**
  112744. * URL to use when loading the basis transcoder
  112745. */
  112746. static JSModuleURL: string;
  112747. /**
  112748. * URL to use when loading the wasm module for the transcoder
  112749. */
  112750. static WasmModuleURL: string;
  112751. /**
  112752. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  112753. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  112754. * @returns internal format corresponding to the Basis format
  112755. */
  112756. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  112757. private static _WorkerPromise;
  112758. private static _Worker;
  112759. private static _CreateWorkerAsync;
  112760. /**
  112761. * Transcodes a loaded image file to compressed pixel data
  112762. * @param imageData image data to transcode
  112763. * @param config configuration options for the transcoding
  112764. * @returns a promise resulting in the transcoded image
  112765. */
  112766. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<{
  112767. fileInfo: BasisFileInfo;
  112768. format: number;
  112769. }>;
  112770. }
  112771. }
  112772. declare module BABYLON {
  112773. /**
  112774. * Loader for .basis file format
  112775. */
  112776. export class _BasisTextureLoader implements IInternalTextureLoader {
  112777. /**
  112778. * Defines whether the loader supports cascade loading the different faces.
  112779. */
  112780. readonly supportCascades: boolean;
  112781. /**
  112782. * This returns if the loader support the current file information.
  112783. * @param extension defines the file extension of the file being loaded
  112784. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112785. * @param fallback defines the fallback internal texture if any
  112786. * @param isBase64 defines whether the texture is encoded as a base64
  112787. * @param isBuffer defines whether the texture data are stored as a buffer
  112788. * @returns true if the loader can load the specified file
  112789. */
  112790. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112791. /**
  112792. * Transform the url before loading if required.
  112793. * @param rootUrl the url of the texture
  112794. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112795. * @returns the transformed texture
  112796. */
  112797. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112798. /**
  112799. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112800. * @param rootUrl the url of the texture
  112801. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112802. * @returns the fallback texture
  112803. */
  112804. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112805. /**
  112806. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  112807. * @param data contains the texture data
  112808. * @param texture defines the BabylonJS internal texture
  112809. * @param createPolynomials will be true if polynomials have been requested
  112810. * @param onLoad defines the callback to trigger once the texture is ready
  112811. * @param onError defines the callback to trigger in case of error
  112812. */
  112813. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112814. /**
  112815. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112816. * @param data contains the texture data
  112817. * @param texture defines the BabylonJS internal texture
  112818. * @param callback defines the method to call once ready to upload
  112819. */
  112820. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112821. }
  112822. }
  112823. declare module BABYLON {
  112824. /**
  112825. * 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.
  112826. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  112827. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  112828. */
  112829. export class CustomProceduralTexture extends ProceduralTexture {
  112830. private _animate;
  112831. private _time;
  112832. private _config;
  112833. private _texturePath;
  112834. /**
  112835. * Instantiates a new Custom Procedural Texture.
  112836. * 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.
  112837. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  112838. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  112839. * @param name Define the name of the texture
  112840. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  112841. * @param size Define the size of the texture to create
  112842. * @param scene Define the scene the texture belongs to
  112843. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  112844. * @param generateMipMaps Define if the texture should creates mip maps or not
  112845. */
  112846. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  112847. private _loadJson;
  112848. /**
  112849. * Is the texture ready to be used ? (rendered at least once)
  112850. * @returns true if ready, otherwise, false.
  112851. */
  112852. isReady(): boolean;
  112853. /**
  112854. * Render the texture to its associated render target.
  112855. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  112856. */
  112857. render(useCameraPostProcess?: boolean): void;
  112858. /**
  112859. * Update the list of dependant textures samplers in the shader.
  112860. */
  112861. updateTextures(): void;
  112862. /**
  112863. * Update the uniform values of the procedural texture in the shader.
  112864. */
  112865. updateShaderUniforms(): void;
  112866. /**
  112867. * Define if the texture animates or not.
  112868. */
  112869. animate: boolean;
  112870. }
  112871. }
  112872. declare module BABYLON {
  112873. /** @hidden */
  112874. export var noisePixelShader: {
  112875. name: string;
  112876. shader: string;
  112877. };
  112878. }
  112879. declare module BABYLON {
  112880. /**
  112881. * Class used to generate noise procedural textures
  112882. */
  112883. export class NoiseProceduralTexture extends ProceduralTexture {
  112884. private _time;
  112885. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  112886. brightness: number;
  112887. /** Defines the number of octaves to process */
  112888. octaves: number;
  112889. /** Defines the level of persistence (0.8 by default) */
  112890. persistence: number;
  112891. /** Gets or sets animation speed factor (default is 1) */
  112892. animationSpeedFactor: number;
  112893. /**
  112894. * Creates a new NoiseProceduralTexture
  112895. * @param name defines the name fo the texture
  112896. * @param size defines the size of the texture (default is 256)
  112897. * @param scene defines the hosting scene
  112898. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  112899. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  112900. */
  112901. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  112902. private _updateShaderUniforms;
  112903. protected _getDefines(): string;
  112904. /** Generate the current state of the procedural texture */
  112905. render(useCameraPostProcess?: boolean): void;
  112906. /**
  112907. * Serializes this noise procedural texture
  112908. * @returns a serialized noise procedural texture object
  112909. */
  112910. serialize(): any;
  112911. /**
  112912. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  112913. * @param parsedTexture defines parsed texture data
  112914. * @param scene defines the current scene
  112915. * @param rootUrl defines the root URL containing noise procedural texture information
  112916. * @returns a parsed NoiseProceduralTexture
  112917. */
  112918. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  112919. }
  112920. }
  112921. declare module BABYLON {
  112922. /**
  112923. * Raw cube texture where the raw buffers are passed in
  112924. */
  112925. export class RawCubeTexture extends CubeTexture {
  112926. /**
  112927. * Creates a cube texture where the raw buffers are passed in.
  112928. * @param scene defines the scene the texture is attached to
  112929. * @param data defines the array of data to use to create each face
  112930. * @param size defines the size of the textures
  112931. * @param format defines the format of the data
  112932. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  112933. * @param generateMipMaps defines if the engine should generate the mip levels
  112934. * @param invertY defines if data must be stored with Y axis inverted
  112935. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  112936. * @param compression defines the compression used (null by default)
  112937. */
  112938. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  112939. /**
  112940. * Updates the raw cube texture.
  112941. * @param data defines the data to store
  112942. * @param format defines the data format
  112943. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  112944. * @param invertY defines if data must be stored with Y axis inverted
  112945. * @param compression defines the compression used (null by default)
  112946. * @param level defines which level of the texture to update
  112947. */
  112948. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  112949. /**
  112950. * Updates a raw cube texture with RGBD encoded data.
  112951. * @param data defines the array of data [mipmap][face] to use to create each face
  112952. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  112953. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112954. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112955. * @returns a promsie that resolves when the operation is complete
  112956. */
  112957. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  112958. /**
  112959. * Clones the raw cube texture.
  112960. * @return a new cube texture
  112961. */
  112962. clone(): CubeTexture;
  112963. /** @hidden */
  112964. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112965. }
  112966. }
  112967. declare module BABYLON {
  112968. /**
  112969. * Class used to store 3D textures containing user data
  112970. */
  112971. export class RawTexture3D extends Texture {
  112972. /** Gets or sets the texture format to use */
  112973. format: number;
  112974. private _engine;
  112975. /**
  112976. * Create a new RawTexture3D
  112977. * @param data defines the data of the texture
  112978. * @param width defines the width of the texture
  112979. * @param height defines the height of the texture
  112980. * @param depth defines the depth of the texture
  112981. * @param format defines the texture format to use
  112982. * @param scene defines the hosting scene
  112983. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  112984. * @param invertY defines if texture must be stored with Y axis inverted
  112985. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  112986. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  112987. */
  112988. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  112989. /** Gets or sets the texture format to use */
  112990. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  112991. /**
  112992. * Update the texture with new data
  112993. * @param data defines the data to store in the texture
  112994. */
  112995. update(data: ArrayBufferView): void;
  112996. }
  112997. }
  112998. declare module BABYLON {
  112999. /**
  113000. * Creates a refraction texture used by refraction channel of the standard material.
  113001. * It is like a mirror but to see through a material.
  113002. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113003. */
  113004. export class RefractionTexture extends RenderTargetTexture {
  113005. /**
  113006. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  113007. * 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.
  113008. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113009. */
  113010. refractionPlane: Plane;
  113011. /**
  113012. * Define how deep under the surface we should see.
  113013. */
  113014. depth: number;
  113015. /**
  113016. * Creates a refraction texture used by refraction channel of the standard material.
  113017. * It is like a mirror but to see through a material.
  113018. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113019. * @param name Define the texture name
  113020. * @param size Define the size of the underlying texture
  113021. * @param scene Define the scene the refraction belongs to
  113022. * @param generateMipMaps Define if we need to generate mips level for the refraction
  113023. */
  113024. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  113025. /**
  113026. * Clone the refraction texture.
  113027. * @returns the cloned texture
  113028. */
  113029. clone(): RefractionTexture;
  113030. /**
  113031. * Serialize the texture to a JSON representation you could use in Parse later on
  113032. * @returns the serialized JSON representation
  113033. */
  113034. serialize(): any;
  113035. }
  113036. }
  113037. declare module BABYLON {
  113038. /**
  113039. * Defines the options related to the creation of an HtmlElementTexture
  113040. */
  113041. export interface IHtmlElementTextureOptions {
  113042. /**
  113043. * Defines wether mip maps should be created or not.
  113044. */
  113045. generateMipMaps?: boolean;
  113046. /**
  113047. * Defines the sampling mode of the texture.
  113048. */
  113049. samplingMode?: number;
  113050. /**
  113051. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  113052. */
  113053. engine: Nullable<Engine>;
  113054. /**
  113055. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  113056. */
  113057. scene: Nullable<Scene>;
  113058. }
  113059. /**
  113060. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  113061. * To be as efficient as possible depending on your constraints nothing aside the first upload
  113062. * is automatically managed.
  113063. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  113064. * in your application.
  113065. *
  113066. * As the update is not automatic, you need to call them manually.
  113067. */
  113068. export class HtmlElementTexture extends BaseTexture {
  113069. /**
  113070. * The texture URL.
  113071. */
  113072. element: HTMLVideoElement | HTMLCanvasElement;
  113073. private static readonly DefaultOptions;
  113074. private _textureMatrix;
  113075. private _engine;
  113076. private _isVideo;
  113077. private _generateMipMaps;
  113078. private _samplingMode;
  113079. /**
  113080. * Instantiates a HtmlElementTexture from the following parameters.
  113081. *
  113082. * @param name Defines the name of the texture
  113083. * @param element Defines the video or canvas the texture is filled with
  113084. * @param options Defines the other none mandatory texture creation options
  113085. */
  113086. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  113087. private _createInternalTexture;
  113088. /**
  113089. * Returns the texture matrix used in most of the material.
  113090. */
  113091. getTextureMatrix(): Matrix;
  113092. /**
  113093. * Updates the content of the texture.
  113094. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  113095. */
  113096. update(invertY?: Nullable<boolean>): void;
  113097. }
  113098. }
  113099. declare module BABYLON {
  113100. /**
  113101. * Enum used to define the target of a block
  113102. */
  113103. export enum NodeMaterialBlockTargets {
  113104. /** Vertex shader */
  113105. Vertex = 1,
  113106. /** Fragment shader */
  113107. Fragment = 2,
  113108. /** Vertex and Fragment */
  113109. VertexAndFragment = 3
  113110. }
  113111. }
  113112. declare module BABYLON {
  113113. /**
  113114. * Defines the kind of connection point for node based material
  113115. */
  113116. export enum NodeMaterialBlockConnectionPointTypes {
  113117. /** Float */
  113118. Float = 1,
  113119. /** Int */
  113120. Int = 2,
  113121. /** Vector2 */
  113122. Vector2 = 4,
  113123. /** Vector3 */
  113124. Vector3 = 8,
  113125. /** Vector4 */
  113126. Vector4 = 16,
  113127. /** Color3 */
  113128. Color3 = 32,
  113129. /** Color4 */
  113130. Color4 = 64,
  113131. /** Matrix */
  113132. Matrix = 128,
  113133. /** Texture */
  113134. Texture = 256,
  113135. /** Texture3D */
  113136. Texture3D = 512,
  113137. /** Vector3 or Color3 */
  113138. Vector3OrColor3 = 40,
  113139. /** Vector3 or Vector4 */
  113140. Vector3OrVector4 = 24,
  113141. /** Vector4 or Color4 */
  113142. Vector4OrColor4 = 80,
  113143. /** Color3 or Color4 */
  113144. Color3OrColor4 = 96,
  113145. /** Vector3 or Color3 */
  113146. Vector3OrColor3OrVector4OrColor4 = 120,
  113147. /** Detect type based on connection */
  113148. AutoDetect = 1024,
  113149. /** Output type that will be defined by input type */
  113150. BasedOnInput = 2048
  113151. }
  113152. }
  113153. declare module BABYLON {
  113154. /**
  113155. * Enum used to define well known values e.g. values automatically provided by the system
  113156. */
  113157. export enum NodeMaterialWellKnownValues {
  113158. /** World */
  113159. World = 1,
  113160. /** View */
  113161. View = 2,
  113162. /** Projection */
  113163. Projection = 3,
  113164. /** ViewProjection */
  113165. ViewProjection = 4,
  113166. /** WorldView */
  113167. WorldView = 5,
  113168. /** WorldViewProjection */
  113169. WorldViewProjection = 6,
  113170. /** Will be filled by the block itself */
  113171. Automatic = 7
  113172. }
  113173. }
  113174. declare module BABYLON {
  113175. /**
  113176. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  113177. */
  113178. export enum NodeMaterialBlockConnectionPointMode {
  113179. /** Value is an uniform */
  113180. Uniform = 0,
  113181. /** Value is a mesh attribute */
  113182. Attribute = 1,
  113183. /** Value is a varying between vertex and fragment shaders */
  113184. Varying = 2,
  113185. /** Mode is undefined */
  113186. Undefined = 3
  113187. }
  113188. }
  113189. declare module BABYLON {
  113190. /**
  113191. * Class used to store shared data between 2 NodeMaterialBuildState
  113192. */
  113193. export class NodeMaterialBuildStateSharedData {
  113194. /**
  113195. * Gets the list of emitted varyings
  113196. */
  113197. varyings: string[];
  113198. /**
  113199. * Gets the varying declaration string
  113200. */
  113201. varyingDeclaration: string;
  113202. /**
  113203. * Uniform connection points
  113204. */
  113205. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  113206. /**
  113207. * Bindable blocks (Blocks that need to set data to the effect)
  113208. */
  113209. bindableBlocks: NodeMaterialBlock[];
  113210. /**
  113211. * List of blocks that can provide a compilation fallback
  113212. */
  113213. blocksWithFallbacks: NodeMaterialBlock[];
  113214. /**
  113215. * List of blocks that can provide a define update
  113216. */
  113217. blocksWithDefines: NodeMaterialBlock[];
  113218. /**
  113219. * List of blocks that can provide a repeatable content
  113220. */
  113221. repeatableContentBlocks: NodeMaterialBlock[];
  113222. /**
  113223. * List of blocks that can block the isReady function for the material
  113224. */
  113225. blockingBlocks: NodeMaterialBlock[];
  113226. /**
  113227. * Build Id used to avoid multiple recompilations
  113228. */
  113229. buildId: number;
  113230. /** List of emitted variables */
  113231. variableNames: {
  113232. [key: string]: number;
  113233. };
  113234. /** List of emitted defines */
  113235. defineNames: {
  113236. [key: string]: number;
  113237. };
  113238. /** Should emit comments? */
  113239. emitComments: boolean;
  113240. /** Emit build activity */
  113241. verbose: boolean;
  113242. /**
  113243. * Gets the compilation hints emitted at compilation time
  113244. */
  113245. hints: {
  113246. needWorldViewMatrix: boolean;
  113247. needWorldViewProjectionMatrix: boolean;
  113248. needAlphaBlending: boolean;
  113249. needAlphaTesting: boolean;
  113250. };
  113251. /**
  113252. * List of compilation checks
  113253. */
  113254. checks: {
  113255. emitVertex: boolean;
  113256. emitFragment: boolean;
  113257. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  113258. };
  113259. /** Creates a new shared data */
  113260. constructor();
  113261. /**
  113262. * Emits console errors and exceptions if there is a failing check
  113263. */
  113264. emitErrors(): void;
  113265. }
  113266. }
  113267. declare module BABYLON {
  113268. /**
  113269. * Class used to store node based material build state
  113270. */
  113271. export class NodeMaterialBuildState {
  113272. /**
  113273. * Gets the list of emitted attributes
  113274. */
  113275. attributes: string[];
  113276. /**
  113277. * Gets the list of emitted uniforms
  113278. */
  113279. uniforms: string[];
  113280. /**
  113281. * Gets the list of emitted samplers
  113282. */
  113283. samplers: string[];
  113284. /**
  113285. * Gets the list of emitted functions
  113286. */
  113287. functions: {
  113288. [key: string]: string;
  113289. };
  113290. /**
  113291. * Gets the target of the compilation state
  113292. */
  113293. target: NodeMaterialBlockTargets;
  113294. /**
  113295. * Shared data between multiple NodeMaterialBuildState instances
  113296. */
  113297. sharedData: NodeMaterialBuildStateSharedData;
  113298. /** @hidden */
  113299. _vertexState: NodeMaterialBuildState;
  113300. private _attributeDeclaration;
  113301. private _uniformDeclaration;
  113302. private _samplerDeclaration;
  113303. private _varyingTransfer;
  113304. private _repeatableContentAnchorIndex;
  113305. /** @hidden */
  113306. _builtCompilationString: string;
  113307. /**
  113308. * Gets the emitted compilation strings
  113309. */
  113310. compilationString: string;
  113311. /**
  113312. * Finalize the compilation strings
  113313. * @param state defines the current compilation state
  113314. */
  113315. finalize(state: NodeMaterialBuildState): void;
  113316. /** @hidden */
  113317. readonly _repeatableContentAnchor: string;
  113318. /** @hidden */
  113319. _getFreeVariableName(prefix: string): string;
  113320. /** @hidden */
  113321. _getFreeDefineName(prefix: string): string;
  113322. /** @hidden */
  113323. _excludeVariableName(name: string): void;
  113324. /** @hidden */
  113325. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  113326. /** @hidden */
  113327. _emitFunction(name: string, code: string, comments: string): void;
  113328. /** @hidden */
  113329. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  113330. replaceStrings?: {
  113331. search: RegExp;
  113332. replace: string;
  113333. }[];
  113334. }): string;
  113335. /** @hidden */
  113336. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  113337. repeatKey?: string;
  113338. removeAttributes?: boolean;
  113339. removeUniforms?: boolean;
  113340. removeVaryings?: boolean;
  113341. removeIfDef?: boolean;
  113342. replaceStrings?: {
  113343. search: RegExp;
  113344. replace: string;
  113345. }[];
  113346. }): void;
  113347. /** @hidden */
  113348. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  113349. private _emitDefine;
  113350. /** @hidden */
  113351. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  113352. }
  113353. }
  113354. declare module BABYLON {
  113355. /**
  113356. * Root class for all node material optimizers
  113357. */
  113358. export class NodeMaterialOptimizer {
  113359. /**
  113360. * Function used to optimize a NodeMaterial graph
  113361. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  113362. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  113363. */
  113364. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  113365. }
  113366. }
  113367. declare module BABYLON {
  113368. /**
  113369. * Block used to transform a vector4 with a matrix
  113370. */
  113371. export class Vector4TransformBlock extends NodeMaterialBlock {
  113372. /**
  113373. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113374. */
  113375. complementW: number;
  113376. /**
  113377. * Creates a new Vector4TransformBlock
  113378. * @param name defines the block name
  113379. */
  113380. constructor(name: string);
  113381. /**
  113382. * Gets the current class name
  113383. * @returns the class name
  113384. */
  113385. getClassName(): string;
  113386. /**
  113387. * Gets the vector input
  113388. */
  113389. readonly vector: NodeMaterialConnectionPoint;
  113390. /**
  113391. * Gets the matrix transform input
  113392. */
  113393. readonly transform: NodeMaterialConnectionPoint;
  113394. protected _buildBlock(state: NodeMaterialBuildState): this;
  113395. }
  113396. }
  113397. declare module BABYLON {
  113398. /**
  113399. * Block used to output the vertex position
  113400. */
  113401. export class VertexOutputBlock extends NodeMaterialBlock {
  113402. /**
  113403. * Creates a new VertexOutputBlock
  113404. * @param name defines the block name
  113405. */
  113406. constructor(name: string);
  113407. /**
  113408. * Gets the current class name
  113409. * @returns the class name
  113410. */
  113411. getClassName(): string;
  113412. /**
  113413. * Gets the vector input component
  113414. */
  113415. readonly vector: NodeMaterialConnectionPoint;
  113416. protected _buildBlock(state: NodeMaterialBuildState): this;
  113417. }
  113418. }
  113419. declare module BABYLON {
  113420. /**
  113421. * Block used to output the final color
  113422. */
  113423. export class FragmentOutputBlock extends NodeMaterialBlock {
  113424. /**
  113425. * Gets or sets a boolean indicating if this block will output an alpha value
  113426. */
  113427. alphaBlendingEnabled: boolean;
  113428. /**
  113429. * Create a new FragmentOutputBlock
  113430. * @param name defines the block name
  113431. */
  113432. constructor(name: string);
  113433. /**
  113434. * Gets the current class name
  113435. * @returns the class name
  113436. */
  113437. getClassName(): string;
  113438. /**
  113439. * Gets the color input component
  113440. */
  113441. readonly color: NodeMaterialConnectionPoint;
  113442. protected _buildBlock(state: NodeMaterialBuildState): this;
  113443. }
  113444. }
  113445. declare module BABYLON {
  113446. /**
  113447. * Interface used to configure the node material editor
  113448. */
  113449. export interface INodeMaterialEditorOptions {
  113450. /** Define the URl to load node editor script */
  113451. editorURL?: string;
  113452. }
  113453. /** @hidden */
  113454. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  113455. /** BONES */
  113456. NUM_BONE_INFLUENCERS: number;
  113457. BonesPerMesh: number;
  113458. BONETEXTURE: boolean;
  113459. /** MORPH TARGETS */
  113460. MORPHTARGETS: boolean;
  113461. MORPHTARGETS_NORMAL: boolean;
  113462. MORPHTARGETS_TANGENT: boolean;
  113463. NUM_MORPH_INFLUENCERS: number;
  113464. /** IMAGE PROCESSING */
  113465. IMAGEPROCESSING: boolean;
  113466. VIGNETTE: boolean;
  113467. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113468. VIGNETTEBLENDMODEOPAQUE: boolean;
  113469. TONEMAPPING: boolean;
  113470. TONEMAPPING_ACES: boolean;
  113471. CONTRAST: boolean;
  113472. EXPOSURE: boolean;
  113473. COLORCURVES: boolean;
  113474. COLORGRADING: boolean;
  113475. COLORGRADING3D: boolean;
  113476. SAMPLER3DGREENDEPTH: boolean;
  113477. SAMPLER3DBGRMAP: boolean;
  113478. IMAGEPROCESSINGPOSTPROCESS: boolean;
  113479. constructor();
  113480. setValue(name: string, value: boolean): void;
  113481. }
  113482. /**
  113483. * Class used to configure NodeMaterial
  113484. */
  113485. export interface INodeMaterialOptions {
  113486. /**
  113487. * Defines if blocks should emit comments
  113488. */
  113489. emitComments: boolean;
  113490. }
  113491. /**
  113492. * Class used to create a node based material built by assembling shader blocks
  113493. */
  113494. export class NodeMaterial extends PushMaterial {
  113495. private _options;
  113496. private _vertexCompilationState;
  113497. private _fragmentCompilationState;
  113498. private _sharedData;
  113499. private _buildId;
  113500. private _buildWasSuccessful;
  113501. private _cachedWorldViewMatrix;
  113502. private _cachedWorldViewProjectionMatrix;
  113503. private _textureConnectionPoints;
  113504. private _optimizers;
  113505. /** Define the URl to load node editor script */
  113506. static EditorURL: string;
  113507. private BJSNODEMATERIALEDITOR;
  113508. /** Get the inspector from bundle or global */
  113509. private _getGlobalNodeMaterialEditor;
  113510. /**
  113511. * Defines the maximum number of lights that can be used in the material
  113512. */
  113513. maxSimultaneousLights: number;
  113514. /**
  113515. * Observable raised when the material is built
  113516. */
  113517. onBuildObservable: Observable<NodeMaterial>;
  113518. /**
  113519. * Gets or sets the root nodes of the material vertex shader
  113520. */
  113521. _vertexOutputNodes: NodeMaterialBlock[];
  113522. /**
  113523. * Gets or sets the root nodes of the material fragment (pixel) shader
  113524. */
  113525. _fragmentOutputNodes: NodeMaterialBlock[];
  113526. /** Gets or sets options to control the node material overall behavior */
  113527. options: INodeMaterialOptions;
  113528. /**
  113529. * Default configuration related to image processing available in the standard Material.
  113530. */
  113531. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113532. /**
  113533. * Gets the image processing configuration used either in this material.
  113534. */
  113535. /**
  113536. * Sets the Default image processing configuration used either in the this material.
  113537. *
  113538. * If sets to null, the scene one is in use.
  113539. */
  113540. imageProcessingConfiguration: ImageProcessingConfiguration;
  113541. /**
  113542. * Create a new node based material
  113543. * @param name defines the material name
  113544. * @param scene defines the hosting scene
  113545. * @param options defines creation option
  113546. */
  113547. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  113548. /**
  113549. * Gets the current class name of the material e.g. "NodeMaterial"
  113550. * @returns the class name
  113551. */
  113552. getClassName(): string;
  113553. /**
  113554. * Keep track of the image processing observer to allow dispose and replace.
  113555. */
  113556. private _imageProcessingObserver;
  113557. /**
  113558. * Attaches a new image processing configuration to the Standard Material.
  113559. * @param configuration
  113560. */
  113561. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113562. /**
  113563. * Adds a new optimizer to the list of optimizers
  113564. * @param optimizer defines the optimizers to add
  113565. * @returns the current material
  113566. */
  113567. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113568. /**
  113569. * Remove an optimizer from the list of optimizers
  113570. * @param optimizer defines the optimizers to remove
  113571. * @returns the current material
  113572. */
  113573. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113574. /**
  113575. * Add a new block to the list of output nodes
  113576. * @param node defines the node to add
  113577. * @returns the current material
  113578. */
  113579. addOutputNode(node: NodeMaterialBlock): this;
  113580. /**
  113581. * Remove a block from the list of root nodes
  113582. * @param node defines the node to remove
  113583. * @returns the current material
  113584. */
  113585. removeOutputNode(node: NodeMaterialBlock): this;
  113586. private _addVertexOutputNode;
  113587. private _removeVertexOutputNode;
  113588. private _addFragmentOutputNode;
  113589. private _removeFragmentOutputNode;
  113590. /**
  113591. * Specifies if the material will require alpha blending
  113592. * @returns a boolean specifying if alpha blending is needed
  113593. */
  113594. needAlphaBlending(): boolean;
  113595. /**
  113596. * Specifies if this material should be rendered in alpha test mode
  113597. * @returns a boolean specifying if an alpha test is needed.
  113598. */
  113599. needAlphaTesting(): boolean;
  113600. private _initializeBlock;
  113601. private _resetDualBlocks;
  113602. /**
  113603. * Build the material and generates the inner effect
  113604. * @param verbose defines if the build should log activity
  113605. */
  113606. build(verbose?: boolean): void;
  113607. /**
  113608. * Runs an otpimization phase to try to improve the shader code
  113609. */
  113610. optimize(): void;
  113611. private _prepareDefinesForAttributes;
  113612. /**
  113613. * Get if the submesh is ready to be used and all its information available.
  113614. * Child classes can use it to update shaders
  113615. * @param mesh defines the mesh to check
  113616. * @param subMesh defines which submesh to check
  113617. * @param useInstances specifies that instances should be used
  113618. * @returns a boolean indicating that the submesh is ready or not
  113619. */
  113620. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113621. /**
  113622. * Binds the world matrix to the material
  113623. * @param world defines the world transformation matrix
  113624. */
  113625. bindOnlyWorldMatrix(world: Matrix): void;
  113626. /**
  113627. * Binds the submesh to this material by preparing the effect and shader to draw
  113628. * @param world defines the world transformation matrix
  113629. * @param mesh defines the mesh containing the submesh
  113630. * @param subMesh defines the submesh to bind the material to
  113631. */
  113632. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113633. /**
  113634. * Gets the active textures from the material
  113635. * @returns an array of textures
  113636. */
  113637. getActiveTextures(): BaseTexture[];
  113638. /**
  113639. * Specifies if the material uses a texture
  113640. * @param texture defines the texture to check against the material
  113641. * @returns a boolean specifying if the material uses the texture
  113642. */
  113643. hasTexture(texture: BaseTexture): boolean;
  113644. /**
  113645. * Disposes the material
  113646. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  113647. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  113648. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  113649. */
  113650. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  113651. /** Creates the node editor window. */
  113652. private _createNodeEditor;
  113653. /**
  113654. * Launch the node material editor
  113655. * @param config Define the configuration of the editor
  113656. * @return a promise fulfilled when the node editor is visible
  113657. */
  113658. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  113659. /**
  113660. * Clear the current material
  113661. */
  113662. clear(): void;
  113663. /**
  113664. * Clear the current material and set it to a default state
  113665. */
  113666. setToDefault(): void;
  113667. }
  113668. }
  113669. declare module BABYLON {
  113670. /**
  113671. * Defines a block that can be used inside a node based material
  113672. */
  113673. export class NodeMaterialBlock {
  113674. private _buildId;
  113675. private _target;
  113676. private _isFinalMerger;
  113677. /** @hidden */
  113678. _inputs: NodeMaterialConnectionPoint[];
  113679. /** @hidden */
  113680. _outputs: NodeMaterialConnectionPoint[];
  113681. /**
  113682. * Gets or sets the name of the block
  113683. */
  113684. name: string;
  113685. /**
  113686. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  113687. */
  113688. readonly isFinalMerger: boolean;
  113689. /**
  113690. * Gets or sets the build Id
  113691. */
  113692. buildId: number;
  113693. /**
  113694. * Gets or sets the target of the block
  113695. */
  113696. target: NodeMaterialBlockTargets;
  113697. /**
  113698. * Gets the list of input points
  113699. */
  113700. readonly inputs: NodeMaterialConnectionPoint[];
  113701. /** Gets the list of output points */
  113702. readonly outputs: NodeMaterialConnectionPoint[];
  113703. /**
  113704. * Find an input by its name
  113705. * @param name defines the name of the input to look for
  113706. * @returns the input or null if not found
  113707. */
  113708. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113709. /**
  113710. * Find an output by its name
  113711. * @param name defines the name of the outputto look for
  113712. * @returns the output or null if not found
  113713. */
  113714. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113715. /**
  113716. * Creates a new NodeMaterialBlock
  113717. * @param name defines the block name
  113718. * @param target defines the target of that block (Vertex by default)
  113719. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  113720. */
  113721. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  113722. /**
  113723. * Initialize the block and prepare the context for build
  113724. * @param state defines the state that will be used for the build
  113725. */
  113726. initialize(state: NodeMaterialBuildState): void;
  113727. /**
  113728. * Bind data to effect. Will only be called for blocks with isBindable === true
  113729. * @param effect defines the effect to bind data to
  113730. * @param nodeMaterial defines the hosting NodeMaterial
  113731. * @param mesh defines the mesh that will be rendered
  113732. */
  113733. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113734. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  113735. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  113736. protected _writeFloat(value: number): string;
  113737. /**
  113738. * Gets the current class name e.g. "NodeMaterialBlock"
  113739. * @returns the class name
  113740. */
  113741. getClassName(): string;
  113742. /**
  113743. * Register a new input. Must be called inside a block constructor
  113744. * @param name defines the connection point name
  113745. * @param type defines the connection point type
  113746. * @param isOptional defines a boolean indicating that this input can be omitted
  113747. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  113748. * @returns the current block
  113749. */
  113750. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  113751. /**
  113752. * Register a new output. Must be called inside a block constructor
  113753. * @param name defines the connection point name
  113754. * @param type defines the connection point type
  113755. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  113756. * @returns the current block
  113757. */
  113758. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  113759. /**
  113760. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  113761. * @param forOutput defines an optional connection point to check compatibility with
  113762. * @returns the first available input or null
  113763. */
  113764. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  113765. /**
  113766. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  113767. * @param forBlock defines an optional block to check compatibility with
  113768. * @returns the first available input or null
  113769. */
  113770. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  113771. /**
  113772. * Connect current block with another block
  113773. * @param other defines the block to connect with
  113774. * @param options define the various options to help pick the right connections
  113775. * @returns the current block
  113776. */
  113777. connectTo(other: NodeMaterialBlock, options?: {
  113778. input?: string;
  113779. output?: string;
  113780. outputSwizzle?: string;
  113781. }): this | undefined;
  113782. protected _buildBlock(state: NodeMaterialBuildState): void;
  113783. /**
  113784. * Add potential fallbacks if shader compilation fails
  113785. * @param mesh defines the mesh to be rendered
  113786. * @param fallbacks defines the current prioritized list of fallbacks
  113787. */
  113788. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  113789. /**
  113790. * Update defines for shader compilation
  113791. * @param mesh defines the mesh to be rendered
  113792. * @param nodeMaterial defines the node material requesting the update
  113793. * @param defines defines the material defines to update
  113794. * @param useInstances specifies that instances should be used
  113795. */
  113796. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  113797. /**
  113798. * Lets the block try to connect some inputs automatically
  113799. */
  113800. autoConfigure(): void;
  113801. /**
  113802. * Function called when a block is declared as repeatable content generator
  113803. * @param vertexShaderState defines the current compilation state for the vertex shader
  113804. * @param fragmentShaderState defines the current compilation state for the fragment shader
  113805. * @param mesh defines the mesh to be rendered
  113806. * @param defines defines the material defines to update
  113807. */
  113808. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  113809. /**
  113810. * Checks if the block is ready
  113811. * @param mesh defines the mesh to be rendered
  113812. * @param nodeMaterial defines the node material requesting the update
  113813. * @param defines defines the material defines to update
  113814. * @param useInstances specifies that instances should be used
  113815. * @returns true if the block is ready
  113816. */
  113817. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  113818. /**
  113819. * Compile the current node and generate the shader code
  113820. * @param state defines the current compilation state (uniforms, samplers, current string)
  113821. * @returns the current block
  113822. */
  113823. build(state: NodeMaterialBuildState): this | undefined;
  113824. }
  113825. }
  113826. declare module BABYLON {
  113827. /**
  113828. * Defines a connection point for a block
  113829. */
  113830. export class NodeMaterialConnectionPoint {
  113831. /** @hidden */
  113832. _ownerBlock: NodeMaterialBlock;
  113833. /** @hidden */
  113834. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  113835. private _associatedVariableName;
  113836. private _endpoints;
  113837. private _storedValue;
  113838. private _valueCallback;
  113839. private _mode;
  113840. /** @hidden */
  113841. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  113842. /** @hidden */
  113843. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  113844. /** @hidden */
  113845. _needToEmitVarying: boolean;
  113846. private _type;
  113847. /**
  113848. * Gets or sets the connection point type (default is float)
  113849. */
  113850. type: NodeMaterialBlockConnectionPointTypes;
  113851. /**
  113852. * Gets or sets the connection point name
  113853. */
  113854. name: string;
  113855. /**
  113856. * Gets or sets the swizzle to apply to this connection point when reading or writing
  113857. */
  113858. swizzle: string;
  113859. /**
  113860. * Gets or sets a boolean indicating that this connection point can be omitted
  113861. */
  113862. isOptional: boolean;
  113863. /**
  113864. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  113865. */
  113866. define: string;
  113867. /** Gets or sets the target of that connection point */
  113868. target: NodeMaterialBlockTargets;
  113869. /**
  113870. * Gets or sets the value of that point.
  113871. * Please note that this value will be ignored if valueCallback is defined
  113872. */
  113873. value: any;
  113874. /**
  113875. * Gets or sets a callback used to get the value of that point.
  113876. * Please note that setting this value will force the connection point to ignore the value property
  113877. */
  113878. valueCallback: () => any;
  113879. /**
  113880. * Gets or sets the associated variable name in the shader
  113881. */
  113882. associatedVariableName: string;
  113883. /**
  113884. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  113885. * In this case the connection point name must be the name of the uniform to use.
  113886. * Can only be set on inputs
  113887. */
  113888. isUniform: boolean;
  113889. /**
  113890. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  113891. * In this case the connection point name must be the name of the attribute to use
  113892. * Can only be set on inputs
  113893. */
  113894. isAttribute: boolean;
  113895. /**
  113896. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  113897. * Can only be set on exit points
  113898. */
  113899. isVarying: boolean;
  113900. /** Get the other side of the connection (if any) */
  113901. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  113902. /** Get the block that owns this connection point */
  113903. readonly ownerBlock: NodeMaterialBlock;
  113904. /** Get the block connected on the other side of this connection (if any) */
  113905. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  113906. /** Get the block connected on the endpoints of this connection (if any) */
  113907. readonly connectedBlocks: Array<NodeMaterialBlock>;
  113908. /**
  113909. * Creates a new connection point
  113910. * @param name defines the connection point name
  113911. * @param ownerBlock defines the block hosting this connection point
  113912. */
  113913. constructor(name: string, ownerBlock: NodeMaterialBlock);
  113914. /**
  113915. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  113916. * @returns the class name
  113917. */
  113918. getClassName(): string;
  113919. /**
  113920. * Set the source of this connection point to a vertex attribute
  113921. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  113922. * @returns the current connection point
  113923. */
  113924. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  113925. /**
  113926. * Set the source of this connection point to a well known value
  113927. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  113928. * @returns the current connection point
  113929. */
  113930. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  113931. /**
  113932. * Gets a boolean indicating that the current connection point is a well known value
  113933. */
  113934. readonly isWellKnownValue: boolean;
  113935. /**
  113936. * Gets or sets the current well known value or null if not defined as well know value
  113937. */
  113938. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  113939. private _getTypeLength;
  113940. /**
  113941. * Connect this point to another connection point
  113942. * @param connectionPoint defines the other connection point
  113943. * @returns the current connection point
  113944. */
  113945. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  113946. /**
  113947. * Disconnect this point from one of his endpoint
  113948. * @param endpoint defines the other connection point
  113949. * @returns the current connection point
  113950. */
  113951. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  113952. /**
  113953. * When connection point is an uniform, this function will send its value to the effect
  113954. * @param effect defines the effect to transmit value to
  113955. * @param world defines the world matrix
  113956. * @param worldView defines the worldxview matrix
  113957. * @param worldViewProjection defines the worldxviewxprojection matrix
  113958. */
  113959. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  113960. /**
  113961. * When connection point is an uniform, this function will send its value to the effect
  113962. * @param effect defines the effect to transmit value to
  113963. * @param scene defines the hosting scene
  113964. */
  113965. transmit(effect: Effect, scene: Scene): void;
  113966. }
  113967. }
  113968. declare module BABYLON {
  113969. /**
  113970. * Block used to add support for vertex skinning (bones)
  113971. */
  113972. export class BonesBlock extends NodeMaterialBlock {
  113973. /**
  113974. * Creates a new BonesBlock
  113975. * @param name defines the block name
  113976. */
  113977. constructor(name: string);
  113978. /**
  113979. * Initialize the block and prepare the context for build
  113980. * @param state defines the state that will be used for the build
  113981. */
  113982. initialize(state: NodeMaterialBuildState): void;
  113983. /**
  113984. * Gets the current class name
  113985. * @returns the class name
  113986. */
  113987. getClassName(): string;
  113988. /**
  113989. * Gets the matrix indices input component
  113990. */
  113991. readonly matricesIndices: NodeMaterialConnectionPoint;
  113992. /**
  113993. * Gets the matrix weights input component
  113994. */
  113995. readonly matricesWeights: NodeMaterialConnectionPoint;
  113996. /**
  113997. * Gets the extra matrix indices input component
  113998. */
  113999. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  114000. /**
  114001. * Gets the extra matrix weights input component
  114002. */
  114003. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  114004. /**
  114005. * Gets the world input component
  114006. */
  114007. readonly world: NodeMaterialConnectionPoint;
  114008. autoConfigure(): void;
  114009. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114010. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114011. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114012. protected _buildBlock(state: NodeMaterialBuildState): this;
  114013. }
  114014. }
  114015. declare module BABYLON {
  114016. /**
  114017. * Block used to add support for instances
  114018. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114019. */
  114020. export class InstancesBlock extends NodeMaterialBlock {
  114021. /**
  114022. * Creates a new InstancesBlock
  114023. * @param name defines the block name
  114024. */
  114025. constructor(name: string);
  114026. /**
  114027. * Gets the current class name
  114028. * @returns the class name
  114029. */
  114030. getClassName(): string;
  114031. /**
  114032. * Gets the first world row input component
  114033. */
  114034. readonly world0: NodeMaterialConnectionPoint;
  114035. /**
  114036. * Gets the second world row input component
  114037. */
  114038. readonly world1: NodeMaterialConnectionPoint;
  114039. /**
  114040. * Gets the third world row input component
  114041. */
  114042. readonly world2: NodeMaterialConnectionPoint;
  114043. /**
  114044. * Gets the forth world row input component
  114045. */
  114046. readonly world3: NodeMaterialConnectionPoint;
  114047. /**
  114048. * Gets the world input component
  114049. */
  114050. readonly world: NodeMaterialConnectionPoint;
  114051. /**
  114052. * Gets the output component
  114053. */
  114054. readonly output: NodeMaterialConnectionPoint;
  114055. autoConfigure(): void;
  114056. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114057. protected _buildBlock(state: NodeMaterialBuildState): this;
  114058. }
  114059. }
  114060. declare module BABYLON {
  114061. /**
  114062. * Block used to add morph targets support to vertex shader
  114063. */
  114064. export class MorphTargetsBlock extends NodeMaterialBlock {
  114065. private _repeatableContentAnchor;
  114066. private _repeatebleContentGenerated;
  114067. /**
  114068. * Create a new MorphTargetsBlock
  114069. * @param name defines the block name
  114070. */
  114071. constructor(name: string);
  114072. /**
  114073. * Gets the current class name
  114074. * @returns the class name
  114075. */
  114076. getClassName(): string;
  114077. /**
  114078. * Gets the position input component
  114079. */
  114080. readonly position: NodeMaterialConnectionPoint;
  114081. /**
  114082. * Gets the normal input component
  114083. */
  114084. readonly normal: NodeMaterialConnectionPoint;
  114085. /**
  114086. * Gets the tangent input component
  114087. */
  114088. readonly tangent: NodeMaterialConnectionPoint;
  114089. /**
  114090. * Gets the position output component
  114091. */
  114092. readonly positionOutput: NodeMaterialConnectionPoint;
  114093. /**
  114094. * Gets the normal output component
  114095. */
  114096. readonly normalOutput: NodeMaterialConnectionPoint;
  114097. /**
  114098. * Gets the tangent output component
  114099. */
  114100. readonly tangentOutput: NodeMaterialConnectionPoint;
  114101. initialize(state: NodeMaterialBuildState): void;
  114102. autoConfigure(): void;
  114103. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114104. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114105. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114106. protected _buildBlock(state: NodeMaterialBuildState): this;
  114107. }
  114108. }
  114109. declare module BABYLON {
  114110. /**
  114111. * Block used to add an alpha test in the fragment shader
  114112. */
  114113. export class AlphaTestBlock extends NodeMaterialBlock {
  114114. /**
  114115. * Gets or sets the alpha value where alpha testing happens
  114116. */
  114117. alphaCutOff: number;
  114118. /**
  114119. * Create a new AlphaTestBlock
  114120. * @param name defines the block name
  114121. */
  114122. constructor(name: string);
  114123. /**
  114124. * Gets the current class name
  114125. * @returns the class name
  114126. */
  114127. getClassName(): string;
  114128. /**
  114129. * Gets the color input component
  114130. */
  114131. readonly color: NodeMaterialConnectionPoint;
  114132. protected _buildBlock(state: NodeMaterialBuildState): this;
  114133. }
  114134. }
  114135. declare module BABYLON {
  114136. /**
  114137. * Block used to create a Color4 out of 4 inputs (one for each component)
  114138. */
  114139. export class RGBAMergerBlock extends NodeMaterialBlock {
  114140. /**
  114141. * Create a new RGBAMergerBlock
  114142. * @param name defines the block name
  114143. */
  114144. constructor(name: string);
  114145. /**
  114146. * Gets the current class name
  114147. * @returns the class name
  114148. */
  114149. getClassName(): string;
  114150. /**
  114151. * Gets the R input component
  114152. */
  114153. readonly r: NodeMaterialConnectionPoint;
  114154. /**
  114155. * Gets the G input component
  114156. */
  114157. readonly g: NodeMaterialConnectionPoint;
  114158. /**
  114159. * Gets the B input component
  114160. */
  114161. readonly b: NodeMaterialConnectionPoint;
  114162. /**
  114163. * Gets the RGB input component
  114164. */
  114165. readonly rgb: NodeMaterialConnectionPoint;
  114166. /**
  114167. * Gets the R input component
  114168. */
  114169. readonly a: NodeMaterialConnectionPoint;
  114170. protected _buildBlock(state: NodeMaterialBuildState): this;
  114171. }
  114172. }
  114173. declare module BABYLON {
  114174. /**
  114175. * Block used to create a Color3 out of 3 inputs (one for each component)
  114176. */
  114177. export class RGBMergerBlock extends NodeMaterialBlock {
  114178. /**
  114179. * Create a new RGBMergerBlock
  114180. * @param name defines the block name
  114181. */
  114182. constructor(name: string);
  114183. /**
  114184. * Gets the current class name
  114185. * @returns the class name
  114186. */
  114187. getClassName(): string;
  114188. /**
  114189. * Gets the R component input
  114190. */
  114191. readonly r: NodeMaterialConnectionPoint;
  114192. /**
  114193. * Gets the G component input
  114194. */
  114195. readonly g: NodeMaterialConnectionPoint;
  114196. /**
  114197. * Gets the B component input
  114198. */
  114199. readonly b: NodeMaterialConnectionPoint;
  114200. protected _buildBlock(state: NodeMaterialBuildState): this;
  114201. }
  114202. }
  114203. declare module BABYLON {
  114204. /**
  114205. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  114206. */
  114207. export class RGBASplitterBlock extends NodeMaterialBlock {
  114208. /**
  114209. * Create a new RGBASplitterBlock
  114210. * @param name defines the block name
  114211. */
  114212. constructor(name: string);
  114213. /**
  114214. * Gets the current class name
  114215. * @returns the class name
  114216. */
  114217. getClassName(): string;
  114218. /**
  114219. * Gets the input component
  114220. */
  114221. readonly input: NodeMaterialConnectionPoint;
  114222. protected _buildBlock(state: NodeMaterialBuildState): this;
  114223. }
  114224. }
  114225. declare module BABYLON {
  114226. /**
  114227. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  114228. */
  114229. export class RGBSplitterBlock extends NodeMaterialBlock {
  114230. /**
  114231. * Create a new RGBSplitterBlock
  114232. * @param name defines the block name
  114233. */
  114234. constructor(name: string);
  114235. /**
  114236. * Gets the current class name
  114237. * @returns the class name
  114238. */
  114239. getClassName(): string;
  114240. /**
  114241. * Gets the input component
  114242. */
  114243. readonly input: NodeMaterialConnectionPoint;
  114244. protected _buildBlock(state: NodeMaterialBuildState): this;
  114245. }
  114246. }
  114247. declare module BABYLON {
  114248. /**
  114249. * Block used to read a texture from a sampler
  114250. */
  114251. export class TextureBlock extends NodeMaterialBlock {
  114252. private _defineName;
  114253. /**
  114254. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  114255. */
  114256. autoConnectTextureMatrix: boolean;
  114257. /**
  114258. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  114259. */
  114260. autoSelectUV: boolean;
  114261. /**
  114262. * Create a new TextureBlock
  114263. * @param name defines the block name
  114264. */
  114265. constructor(name: string);
  114266. /**
  114267. * Gets the current class name
  114268. * @returns the class name
  114269. */
  114270. getClassName(): string;
  114271. /**
  114272. * Gets the uv input component
  114273. */
  114274. readonly uv: NodeMaterialConnectionPoint;
  114275. /**
  114276. * Gets the texture information input component
  114277. */
  114278. readonly textureInfo: NodeMaterialConnectionPoint;
  114279. /**
  114280. * Gets the transformed uv input component
  114281. */
  114282. readonly transformedUV: NodeMaterialConnectionPoint;
  114283. /**
  114284. * Gets the texture input component
  114285. */
  114286. readonly texture: NodeMaterialConnectionPoint;
  114287. /**
  114288. * Gets the texture transform input component
  114289. */
  114290. readonly textureTransform: NodeMaterialConnectionPoint;
  114291. autoConfigure(): void;
  114292. initialize(state: NodeMaterialBuildState): void;
  114293. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114294. isReady(): boolean;
  114295. private _injectVertexCode;
  114296. protected _buildBlock(state: NodeMaterialBuildState): this;
  114297. }
  114298. }
  114299. declare module BABYLON {
  114300. /**
  114301. * Block used to add image processing support to fragment shader
  114302. */
  114303. export class ImageProcessingBlock extends NodeMaterialBlock {
  114304. /**
  114305. * Create a new ImageProcessingBlock
  114306. * @param name defines the block name
  114307. */
  114308. constructor(name: string);
  114309. /**
  114310. * Gets the current class name
  114311. * @returns the class name
  114312. */
  114313. getClassName(): string;
  114314. /**
  114315. * Gets the color input component
  114316. */
  114317. readonly color: NodeMaterialConnectionPoint;
  114318. /**
  114319. * Initialize the block and prepare the context for build
  114320. * @param state defines the state that will be used for the build
  114321. */
  114322. initialize(state: NodeMaterialBuildState): void;
  114323. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  114324. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114325. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114326. protected _buildBlock(state: NodeMaterialBuildState): this;
  114327. }
  114328. }
  114329. declare module BABYLON {
  114330. /**
  114331. * Block used to add support for scene fog
  114332. */
  114333. export class FogBlock extends NodeMaterialBlock {
  114334. /**
  114335. * Create a new FogBlock
  114336. * @param name defines the block name
  114337. */
  114338. constructor(name: string);
  114339. /**
  114340. * Gets the current class name
  114341. * @returns the class name
  114342. */
  114343. getClassName(): string;
  114344. /**
  114345. * Gets the world position input component
  114346. */
  114347. readonly worldPosition: NodeMaterialConnectionPoint;
  114348. /**
  114349. * Gets the view input component
  114350. */
  114351. readonly view: NodeMaterialConnectionPoint;
  114352. /**
  114353. * Gets the color input component
  114354. */
  114355. readonly color: NodeMaterialConnectionPoint;
  114356. /**
  114357. * Gets the fog color input component
  114358. */
  114359. readonly fogColor: NodeMaterialConnectionPoint;
  114360. /**
  114361. * Gets the for parameter input component
  114362. */
  114363. readonly fogParameters: NodeMaterialConnectionPoint;
  114364. autoConfigure(): void;
  114365. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114366. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114367. protected _buildBlock(state: NodeMaterialBuildState): this;
  114368. }
  114369. }
  114370. declare module BABYLON {
  114371. /**
  114372. * Block used to multiply 2 vector4
  114373. */
  114374. export class MultiplyBlock extends NodeMaterialBlock {
  114375. /**
  114376. * Creates a new MultiplyBlock
  114377. * @param name defines the block name
  114378. */
  114379. constructor(name: string);
  114380. /**
  114381. * Gets the current class name
  114382. * @returns the class name
  114383. */
  114384. getClassName(): string;
  114385. /**
  114386. * Gets the left operand input component
  114387. */
  114388. readonly left: NodeMaterialConnectionPoint;
  114389. /**
  114390. * Gets the right operand input component
  114391. */
  114392. readonly right: NodeMaterialConnectionPoint;
  114393. protected _buildBlock(state: NodeMaterialBuildState): this;
  114394. }
  114395. }
  114396. declare module BABYLON {
  114397. /**
  114398. * Block used to add 2 vector4
  114399. */
  114400. export class AddBlock extends NodeMaterialBlock {
  114401. /**
  114402. * Creates a new AddBlock
  114403. * @param name defines the block name
  114404. */
  114405. constructor(name: string);
  114406. /**
  114407. * Gets the current class name
  114408. * @returns the class name
  114409. */
  114410. getClassName(): string;
  114411. /**
  114412. * Gets the left operand input component
  114413. */
  114414. readonly left: NodeMaterialConnectionPoint;
  114415. /**
  114416. * Gets the right operand input component
  114417. */
  114418. readonly right: NodeMaterialConnectionPoint;
  114419. protected _buildBlock(state: NodeMaterialBuildState): this;
  114420. }
  114421. }
  114422. declare module BABYLON {
  114423. /**
  114424. * Block used to clamp a float
  114425. */
  114426. export class ClampBlock extends NodeMaterialBlock {
  114427. /** Gets or sets the minimum range */
  114428. minimum: number;
  114429. /** Gets or sets the maximum range */
  114430. maximum: number;
  114431. /**
  114432. * Creates a new ClampBlock
  114433. * @param name defines the block name
  114434. */
  114435. constructor(name: string);
  114436. /**
  114437. * Gets the current class name
  114438. * @returns the class name
  114439. */
  114440. getClassName(): string;
  114441. /**
  114442. * Gets the value input component
  114443. */
  114444. readonly value: NodeMaterialConnectionPoint;
  114445. protected _buildBlock(state: NodeMaterialBuildState): this;
  114446. }
  114447. }
  114448. declare module BABYLON {
  114449. /**
  114450. * Block used to scale a value
  114451. */
  114452. export class ScaleBlock extends NodeMaterialBlock {
  114453. /**
  114454. * Creates a new ScaleBlock
  114455. * @param name defines the block name
  114456. */
  114457. constructor(name: string);
  114458. /**
  114459. * Gets the current class name
  114460. * @returns the class name
  114461. */
  114462. getClassName(): string;
  114463. /**
  114464. * Gets the value operand input component
  114465. */
  114466. readonly value: NodeMaterialConnectionPoint;
  114467. /**
  114468. * Gets the scale operand input component
  114469. */
  114470. readonly scale: NodeMaterialConnectionPoint;
  114471. protected _buildBlock(state: NodeMaterialBuildState): this;
  114472. }
  114473. }
  114474. declare module BABYLON {
  114475. /**
  114476. * Block used to transform a vector2 with a matrix
  114477. */
  114478. export class Vector2TransformBlock extends NodeMaterialBlock {
  114479. /**
  114480. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114481. */
  114482. complementZ: number;
  114483. /**
  114484. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114485. */
  114486. complementW: number;
  114487. /**
  114488. * Creates a new Vector2TransformBlock
  114489. * @param name defines the block name
  114490. */
  114491. constructor(name: string);
  114492. /**
  114493. * Gets the vector input
  114494. */
  114495. readonly vector: NodeMaterialConnectionPoint;
  114496. /**
  114497. * Gets the matrix transform input
  114498. */
  114499. readonly transform: NodeMaterialConnectionPoint;
  114500. /**
  114501. * Gets the current class name
  114502. * @returns the class name
  114503. */
  114504. getClassName(): string;
  114505. protected _buildBlock(state: NodeMaterialBuildState): this;
  114506. }
  114507. }
  114508. declare module BABYLON {
  114509. /**
  114510. * Block used to transform a vector3 with a matrix
  114511. */
  114512. export class Vector3TransformBlock extends NodeMaterialBlock {
  114513. /**
  114514. * Defines the value to use to complement Vector3 to transform it to a Vector4
  114515. */
  114516. complement: number;
  114517. /**
  114518. * Creates a new Vector3TransformBlock
  114519. * @param name defines the block name
  114520. */
  114521. constructor(name: string);
  114522. /**
  114523. * Gets the vector input
  114524. */
  114525. readonly vector: NodeMaterialConnectionPoint;
  114526. /**
  114527. * Gets the matrix transform input
  114528. */
  114529. readonly transform: NodeMaterialConnectionPoint;
  114530. /**
  114531. * Gets the current class name
  114532. * @returns the class name
  114533. */
  114534. getClassName(): string;
  114535. protected _buildBlock(state: NodeMaterialBuildState): this;
  114536. }
  114537. }
  114538. declare module BABYLON {
  114539. /**
  114540. * Block used to multiply two matrices
  114541. */
  114542. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  114543. /**
  114544. * Creates a new MatrixMultiplicationBlock
  114545. * @param name defines the block name
  114546. */
  114547. constructor(name: string);
  114548. /**
  114549. * Gets the left operand
  114550. */
  114551. readonly left: NodeMaterialConnectionPoint;
  114552. /**
  114553. * Gets the right operand
  114554. */
  114555. readonly right: NodeMaterialConnectionPoint;
  114556. /**
  114557. * Gets the current class name
  114558. * @returns the class name
  114559. */
  114560. getClassName(): string;
  114561. protected _buildBlock(state: NodeMaterialBuildState): this;
  114562. }
  114563. }
  114564. declare module BABYLON {
  114565. /**
  114566. * Helper class to push actions to a pool of workers.
  114567. */
  114568. export class WorkerPool implements IDisposable {
  114569. private _workerInfos;
  114570. private _pendingActions;
  114571. /**
  114572. * Constructor
  114573. * @param workers Array of workers to use for actions
  114574. */
  114575. constructor(workers: Array<Worker>);
  114576. /**
  114577. * Terminates all workers and clears any pending actions.
  114578. */
  114579. dispose(): void;
  114580. /**
  114581. * Pushes an action to the worker pool. If all the workers are active, the action will be
  114582. * pended until a worker has completed its action.
  114583. * @param action The action to perform. Call onComplete when the action is complete.
  114584. */
  114585. push(action: (worker: Worker, onComplete: () => void) => void): void;
  114586. private _execute;
  114587. }
  114588. }
  114589. declare module BABYLON {
  114590. /**
  114591. * Configuration for Draco compression
  114592. */
  114593. export interface IDracoCompressionConfiguration {
  114594. /**
  114595. * Configuration for the decoder.
  114596. */
  114597. decoder: {
  114598. /**
  114599. * The url to the WebAssembly module.
  114600. */
  114601. wasmUrl?: string;
  114602. /**
  114603. * The url to the WebAssembly binary.
  114604. */
  114605. wasmBinaryUrl?: string;
  114606. /**
  114607. * The url to the fallback JavaScript module.
  114608. */
  114609. fallbackUrl?: string;
  114610. };
  114611. }
  114612. /**
  114613. * Draco compression (https://google.github.io/draco/)
  114614. *
  114615. * This class wraps the Draco module.
  114616. *
  114617. * **Encoder**
  114618. *
  114619. * The encoder is not currently implemented.
  114620. *
  114621. * **Decoder**
  114622. *
  114623. * 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.
  114624. *
  114625. * To update the configuration, use the following code:
  114626. * ```javascript
  114627. * DracoCompression.Configuration = {
  114628. * decoder: {
  114629. * wasmUrl: "<url to the WebAssembly library>",
  114630. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  114631. * fallbackUrl: "<url to the fallback JavaScript library>",
  114632. * }
  114633. * };
  114634. * ```
  114635. *
  114636. * 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.
  114637. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  114638. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  114639. *
  114640. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  114641. * ```javascript
  114642. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  114643. * ```
  114644. *
  114645. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  114646. */
  114647. export class DracoCompression implements IDisposable {
  114648. private _workerPoolPromise?;
  114649. private _decoderModulePromise?;
  114650. /**
  114651. * The configuration. Defaults to the following urls:
  114652. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  114653. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  114654. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  114655. */
  114656. static Configuration: IDracoCompressionConfiguration;
  114657. /**
  114658. * Returns true if the decoder configuration is available.
  114659. */
  114660. static readonly DecoderAvailable: boolean;
  114661. /**
  114662. * Default number of workers to create when creating the draco compression object.
  114663. */
  114664. static DefaultNumWorkers: number;
  114665. private static GetDefaultNumWorkers;
  114666. private static _Default;
  114667. /**
  114668. * Default instance for the draco compression object.
  114669. */
  114670. static readonly Default: DracoCompression;
  114671. /**
  114672. * Constructor
  114673. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  114674. */
  114675. constructor(numWorkers?: number);
  114676. /**
  114677. * Stop all async operations and release resources.
  114678. */
  114679. dispose(): void;
  114680. /**
  114681. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  114682. * @returns a promise that resolves when ready
  114683. */
  114684. whenReadyAsync(): Promise<void>;
  114685. /**
  114686. * Decode Draco compressed mesh data to vertex data.
  114687. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  114688. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  114689. * @returns A promise that resolves with the decoded vertex data
  114690. */
  114691. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  114692. [kind: string]: number;
  114693. }): Promise<VertexData>;
  114694. }
  114695. }
  114696. declare module BABYLON {
  114697. /**
  114698. * Class for building Constructive Solid Geometry
  114699. */
  114700. export class CSG {
  114701. private polygons;
  114702. /**
  114703. * The world matrix
  114704. */
  114705. matrix: Matrix;
  114706. /**
  114707. * Stores the position
  114708. */
  114709. position: Vector3;
  114710. /**
  114711. * Stores the rotation
  114712. */
  114713. rotation: Vector3;
  114714. /**
  114715. * Stores the rotation quaternion
  114716. */
  114717. rotationQuaternion: Nullable<Quaternion>;
  114718. /**
  114719. * Stores the scaling vector
  114720. */
  114721. scaling: Vector3;
  114722. /**
  114723. * Convert the Mesh to CSG
  114724. * @param mesh The Mesh to convert to CSG
  114725. * @returns A new CSG from the Mesh
  114726. */
  114727. static FromMesh(mesh: Mesh): CSG;
  114728. /**
  114729. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  114730. * @param polygons Polygons used to construct a CSG solid
  114731. */
  114732. private static FromPolygons;
  114733. /**
  114734. * Clones, or makes a deep copy, of the CSG
  114735. * @returns A new CSG
  114736. */
  114737. clone(): CSG;
  114738. /**
  114739. * Unions this CSG with another CSG
  114740. * @param csg The CSG to union against this CSG
  114741. * @returns The unioned CSG
  114742. */
  114743. union(csg: CSG): CSG;
  114744. /**
  114745. * Unions this CSG with another CSG in place
  114746. * @param csg The CSG to union against this CSG
  114747. */
  114748. unionInPlace(csg: CSG): void;
  114749. /**
  114750. * Subtracts this CSG with another CSG
  114751. * @param csg The CSG to subtract against this CSG
  114752. * @returns A new CSG
  114753. */
  114754. subtract(csg: CSG): CSG;
  114755. /**
  114756. * Subtracts this CSG with another CSG in place
  114757. * @param csg The CSG to subtact against this CSG
  114758. */
  114759. subtractInPlace(csg: CSG): void;
  114760. /**
  114761. * Intersect this CSG with another CSG
  114762. * @param csg The CSG to intersect against this CSG
  114763. * @returns A new CSG
  114764. */
  114765. intersect(csg: CSG): CSG;
  114766. /**
  114767. * Intersects this CSG with another CSG in place
  114768. * @param csg The CSG to intersect against this CSG
  114769. */
  114770. intersectInPlace(csg: CSG): void;
  114771. /**
  114772. * Return a new CSG solid with solid and empty space switched. This solid is
  114773. * not modified.
  114774. * @returns A new CSG solid with solid and empty space switched
  114775. */
  114776. inverse(): CSG;
  114777. /**
  114778. * Inverses the CSG in place
  114779. */
  114780. inverseInPlace(): void;
  114781. /**
  114782. * This is used to keep meshes transformations so they can be restored
  114783. * when we build back a Babylon Mesh
  114784. * NB : All CSG operations are performed in world coordinates
  114785. * @param csg The CSG to copy the transform attributes from
  114786. * @returns This CSG
  114787. */
  114788. copyTransformAttributes(csg: CSG): CSG;
  114789. /**
  114790. * Build Raw mesh from CSG
  114791. * Coordinates here are in world space
  114792. * @param name The name of the mesh geometry
  114793. * @param scene The Scene
  114794. * @param keepSubMeshes Specifies if the submeshes should be kept
  114795. * @returns A new Mesh
  114796. */
  114797. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  114798. /**
  114799. * Build Mesh from CSG taking material and transforms into account
  114800. * @param name The name of the Mesh
  114801. * @param material The material of the Mesh
  114802. * @param scene The Scene
  114803. * @param keepSubMeshes Specifies if submeshes should be kept
  114804. * @returns The new Mesh
  114805. */
  114806. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  114807. }
  114808. }
  114809. declare module BABYLON {
  114810. /**
  114811. * Class used to create a trail following a mesh
  114812. */
  114813. export class TrailMesh extends Mesh {
  114814. private _generator;
  114815. private _autoStart;
  114816. private _running;
  114817. private _diameter;
  114818. private _length;
  114819. private _sectionPolygonPointsCount;
  114820. private _sectionVectors;
  114821. private _sectionNormalVectors;
  114822. private _beforeRenderObserver;
  114823. /**
  114824. * @constructor
  114825. * @param name The value used by scene.getMeshByName() to do a lookup.
  114826. * @param generator The mesh to generate a trail.
  114827. * @param scene The scene to add this mesh to.
  114828. * @param diameter Diameter of trailing mesh. Default is 1.
  114829. * @param length Length of trailing mesh. Default is 60.
  114830. * @param autoStart Automatically start trailing mesh. Default true.
  114831. */
  114832. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  114833. /**
  114834. * "TrailMesh"
  114835. * @returns "TrailMesh"
  114836. */
  114837. getClassName(): string;
  114838. private _createMesh;
  114839. /**
  114840. * Start trailing mesh.
  114841. */
  114842. start(): void;
  114843. /**
  114844. * Stop trailing mesh.
  114845. */
  114846. stop(): void;
  114847. /**
  114848. * Update trailing mesh geometry.
  114849. */
  114850. update(): void;
  114851. /**
  114852. * Returns a new TrailMesh object.
  114853. * @param name is a string, the name given to the new mesh
  114854. * @param newGenerator use new generator object for cloned trail mesh
  114855. * @returns a new mesh
  114856. */
  114857. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  114858. /**
  114859. * Serializes this trail mesh
  114860. * @param serializationObject object to write serialization to
  114861. */
  114862. serialize(serializationObject: any): void;
  114863. /**
  114864. * Parses a serialized trail mesh
  114865. * @param parsedMesh the serialized mesh
  114866. * @param scene the scene to create the trail mesh in
  114867. * @returns the created trail mesh
  114868. */
  114869. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  114870. }
  114871. }
  114872. declare module BABYLON {
  114873. /**
  114874. * Class containing static functions to help procedurally build meshes
  114875. */
  114876. export class TiledBoxBuilder {
  114877. /**
  114878. * Creates a box mesh
  114879. * 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)
  114880. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114884. * @param name defines the name of the mesh
  114885. * @param options defines the options used to create the mesh
  114886. * @param scene defines the hosting scene
  114887. * @returns the box mesh
  114888. */
  114889. static CreateTiledBox(name: string, options: {
  114890. pattern?: number;
  114891. width?: number;
  114892. height?: number;
  114893. depth?: number;
  114894. tileSize?: number;
  114895. tileWidth?: number;
  114896. tileHeight?: number;
  114897. alignHorizontal?: number;
  114898. alignVertical?: number;
  114899. faceUV?: Vector4[];
  114900. faceColors?: Color4[];
  114901. sideOrientation?: number;
  114902. updatable?: boolean;
  114903. }, scene?: Nullable<Scene>): Mesh;
  114904. }
  114905. }
  114906. declare module BABYLON {
  114907. /**
  114908. * Class containing static functions to help procedurally build meshes
  114909. */
  114910. export class TorusKnotBuilder {
  114911. /**
  114912. * Creates a torus knot mesh
  114913. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  114914. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  114915. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  114916. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  114917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114920. * @param name defines the name of the mesh
  114921. * @param options defines the options used to create the mesh
  114922. * @param scene defines the hosting scene
  114923. * @returns the torus knot mesh
  114924. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  114925. */
  114926. static CreateTorusKnot(name: string, options: {
  114927. radius?: number;
  114928. tube?: number;
  114929. radialSegments?: number;
  114930. tubularSegments?: number;
  114931. p?: number;
  114932. q?: number;
  114933. updatable?: boolean;
  114934. sideOrientation?: number;
  114935. frontUVs?: Vector4;
  114936. backUVs?: Vector4;
  114937. }, scene: any): Mesh;
  114938. }
  114939. }
  114940. declare module BABYLON {
  114941. /**
  114942. * Polygon
  114943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114944. */
  114945. export class Polygon {
  114946. /**
  114947. * Creates a rectangle
  114948. * @param xmin bottom X coord
  114949. * @param ymin bottom Y coord
  114950. * @param xmax top X coord
  114951. * @param ymax top Y coord
  114952. * @returns points that make the resulting rectation
  114953. */
  114954. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  114955. /**
  114956. * Creates a circle
  114957. * @param radius radius of circle
  114958. * @param cx scale in x
  114959. * @param cy scale in y
  114960. * @param numberOfSides number of sides that make up the circle
  114961. * @returns points that make the resulting circle
  114962. */
  114963. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  114964. /**
  114965. * Creates a polygon from input string
  114966. * @param input Input polygon data
  114967. * @returns the parsed points
  114968. */
  114969. static Parse(input: string): Vector2[];
  114970. /**
  114971. * Starts building a polygon from x and y coordinates
  114972. * @param x x coordinate
  114973. * @param y y coordinate
  114974. * @returns the started path2
  114975. */
  114976. static StartingAt(x: number, y: number): Path2;
  114977. }
  114978. /**
  114979. * Builds a polygon
  114980. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  114981. */
  114982. export class PolygonMeshBuilder {
  114983. private _points;
  114984. private _outlinepoints;
  114985. private _holes;
  114986. private _name;
  114987. private _scene;
  114988. private _epoints;
  114989. private _eholes;
  114990. private _addToepoint;
  114991. /**
  114992. * Babylon reference to the earcut plugin.
  114993. */
  114994. bjsEarcut: any;
  114995. /**
  114996. * Creates a PolygonMeshBuilder
  114997. * @param name name of the builder
  114998. * @param contours Path of the polygon
  114999. * @param scene scene to add to when creating the mesh
  115000. * @param earcutInjection can be used to inject your own earcut reference
  115001. */
  115002. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  115003. /**
  115004. * Adds a whole within the polygon
  115005. * @param hole Array of points defining the hole
  115006. * @returns this
  115007. */
  115008. addHole(hole: Vector2[]): PolygonMeshBuilder;
  115009. /**
  115010. * Creates the polygon
  115011. * @param updatable If the mesh should be updatable
  115012. * @param depth The depth of the mesh created
  115013. * @returns the created mesh
  115014. */
  115015. build(updatable?: boolean, depth?: number): Mesh;
  115016. /**
  115017. * Creates the polygon
  115018. * @param depth The depth of the mesh created
  115019. * @returns the created VertexData
  115020. */
  115021. buildVertexData(depth?: number): VertexData;
  115022. /**
  115023. * Adds a side to the polygon
  115024. * @param positions points that make the polygon
  115025. * @param normals normals of the polygon
  115026. * @param uvs uvs of the polygon
  115027. * @param indices indices of the polygon
  115028. * @param bounds bounds of the polygon
  115029. * @param points points of the polygon
  115030. * @param depth depth of the polygon
  115031. * @param flip flip of the polygon
  115032. */
  115033. private addSide;
  115034. }
  115035. }
  115036. declare module BABYLON {
  115037. /**
  115038. * Class containing static functions to help procedurally build meshes
  115039. */
  115040. export class PolygonBuilder {
  115041. /**
  115042. * Creates a polygon mesh
  115043. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115044. * * 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
  115045. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115048. * * Remember you can only change the shape positions, not their number when updating a polygon
  115049. * @param name defines the name of the mesh
  115050. * @param options defines the options used to create the mesh
  115051. * @param scene defines the hosting scene
  115052. * @param earcutInjection can be used to inject your own earcut reference
  115053. * @returns the polygon mesh
  115054. */
  115055. static CreatePolygon(name: string, options: {
  115056. shape: Vector3[];
  115057. holes?: Vector3[][];
  115058. depth?: number;
  115059. faceUV?: Vector4[];
  115060. faceColors?: Color4[];
  115061. updatable?: boolean;
  115062. sideOrientation?: number;
  115063. frontUVs?: Vector4;
  115064. backUVs?: Vector4;
  115065. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115066. /**
  115067. * Creates an extruded polygon mesh, with depth in the Y direction.
  115068. * * 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)
  115069. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115070. * @param name defines the name of the mesh
  115071. * @param options defines the options used to create the mesh
  115072. * @param scene defines the hosting scene
  115073. * @param earcutInjection can be used to inject your own earcut reference
  115074. * @returns the polygon mesh
  115075. */
  115076. static ExtrudePolygon(name: string, options: {
  115077. shape: Vector3[];
  115078. holes?: Vector3[][];
  115079. depth?: number;
  115080. faceUV?: Vector4[];
  115081. faceColors?: Color4[];
  115082. updatable?: boolean;
  115083. sideOrientation?: number;
  115084. frontUVs?: Vector4;
  115085. backUVs?: Vector4;
  115086. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115087. }
  115088. }
  115089. declare module BABYLON {
  115090. /**
  115091. * Class containing static functions to help procedurally build meshes
  115092. */
  115093. export class LatheBuilder {
  115094. /**
  115095. * Creates lathe mesh.
  115096. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115097. * * 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
  115098. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115099. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115100. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115101. * * 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
  115102. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115103. * * 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
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115108. * @param name defines the name of the mesh
  115109. * @param options defines the options used to create the mesh
  115110. * @param scene defines the hosting scene
  115111. * @returns the lathe mesh
  115112. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115113. */
  115114. static CreateLathe(name: string, options: {
  115115. shape: Vector3[];
  115116. radius?: number;
  115117. tessellation?: number;
  115118. clip?: number;
  115119. arc?: number;
  115120. closed?: boolean;
  115121. updatable?: boolean;
  115122. sideOrientation?: number;
  115123. frontUVs?: Vector4;
  115124. backUVs?: Vector4;
  115125. cap?: number;
  115126. invertUV?: boolean;
  115127. }, scene?: Nullable<Scene>): Mesh;
  115128. }
  115129. }
  115130. declare module BABYLON {
  115131. /**
  115132. * Class containing static functions to help procedurally build meshes
  115133. */
  115134. export class TiledPlaneBuilder {
  115135. /**
  115136. * Creates a tiled plane mesh
  115137. * * The parameter `pattern` will, depending on value, do nothing or
  115138. * * * flip (reflect about central vertical) alternate tiles across and up
  115139. * * * flip every tile on alternate rows
  115140. * * * rotate (180 degs) alternate tiles across and up
  115141. * * * rotate every tile on alternate rows
  115142. * * * flip and rotate alternate tiles across and up
  115143. * * * flip and rotate every tile on alternate rows
  115144. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  115145. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  115146. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115148. * * 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)
  115149. * * 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)
  115150. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115151. * @param name defines the name of the mesh
  115152. * @param options defines the options used to create the mesh
  115153. * @param scene defines the hosting scene
  115154. * @returns the box mesh
  115155. */
  115156. static CreateTiledPlane(name: string, options: {
  115157. pattern?: number;
  115158. tileSize?: number;
  115159. tileWidth?: number;
  115160. tileHeight?: number;
  115161. size?: number;
  115162. width?: number;
  115163. height?: number;
  115164. alignHorizontal?: number;
  115165. alignVertical?: number;
  115166. sideOrientation?: number;
  115167. frontUVs?: Vector4;
  115168. backUVs?: Vector4;
  115169. updatable?: boolean;
  115170. }, scene?: Nullable<Scene>): Mesh;
  115171. }
  115172. }
  115173. declare module BABYLON {
  115174. /**
  115175. * Class containing static functions to help procedurally build meshes
  115176. */
  115177. export class TubeBuilder {
  115178. /**
  115179. * Creates a tube mesh.
  115180. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115181. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115182. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115183. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115184. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115185. * * 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)
  115186. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115187. * * 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
  115188. * * 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
  115189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115191. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115193. * @param name defines the name of the mesh
  115194. * @param options defines the options used to create the mesh
  115195. * @param scene defines the hosting scene
  115196. * @returns the tube mesh
  115197. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115198. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115199. */
  115200. static CreateTube(name: string, options: {
  115201. path: Vector3[];
  115202. radius?: number;
  115203. tessellation?: number;
  115204. radiusFunction?: {
  115205. (i: number, distance: number): number;
  115206. };
  115207. cap?: number;
  115208. arc?: number;
  115209. updatable?: boolean;
  115210. sideOrientation?: number;
  115211. frontUVs?: Vector4;
  115212. backUVs?: Vector4;
  115213. instance?: Mesh;
  115214. invertUV?: boolean;
  115215. }, scene?: Nullable<Scene>): Mesh;
  115216. }
  115217. }
  115218. declare module BABYLON {
  115219. /**
  115220. * Class containing static functions to help procedurally build meshes
  115221. */
  115222. export class IcoSphereBuilder {
  115223. /**
  115224. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115225. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115226. * * 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`)
  115227. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115228. * * 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
  115229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115232. * @param name defines the name of the mesh
  115233. * @param options defines the options used to create the mesh
  115234. * @param scene defines the hosting scene
  115235. * @returns the icosahedron mesh
  115236. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115237. */
  115238. static CreateIcoSphere(name: string, options: {
  115239. radius?: number;
  115240. radiusX?: number;
  115241. radiusY?: number;
  115242. radiusZ?: number;
  115243. flat?: boolean;
  115244. subdivisions?: number;
  115245. sideOrientation?: number;
  115246. frontUVs?: Vector4;
  115247. backUVs?: Vector4;
  115248. updatable?: boolean;
  115249. }, scene?: Nullable<Scene>): Mesh;
  115250. }
  115251. }
  115252. declare module BABYLON {
  115253. /**
  115254. * Class containing static functions to help procedurally build meshes
  115255. */
  115256. export class DecalBuilder {
  115257. /**
  115258. * Creates a decal mesh.
  115259. * 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
  115260. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115261. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115262. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115263. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115264. * @param name defines the name of the mesh
  115265. * @param sourceMesh defines the mesh where the decal must be applied
  115266. * @param options defines the options used to create the mesh
  115267. * @param scene defines the hosting scene
  115268. * @returns the decal mesh
  115269. * @see https://doc.babylonjs.com/how_to/decals
  115270. */
  115271. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115272. position?: Vector3;
  115273. normal?: Vector3;
  115274. size?: Vector3;
  115275. angle?: number;
  115276. }): Mesh;
  115277. }
  115278. }
  115279. declare module BABYLON {
  115280. /**
  115281. * Class containing static functions to help procedurally build meshes
  115282. */
  115283. export class MeshBuilder {
  115284. /**
  115285. * Creates a box mesh
  115286. * * The parameter `size` sets the size (float) of each box side (default 1)
  115287. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  115288. * * 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)
  115289. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115293. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115294. * @param name defines the name of the mesh
  115295. * @param options defines the options used to create the mesh
  115296. * @param scene defines the hosting scene
  115297. * @returns the box mesh
  115298. */
  115299. static CreateBox(name: string, options: {
  115300. size?: number;
  115301. width?: number;
  115302. height?: number;
  115303. depth?: number;
  115304. faceUV?: Vector4[];
  115305. faceColors?: Color4[];
  115306. sideOrientation?: number;
  115307. frontUVs?: Vector4;
  115308. backUVs?: Vector4;
  115309. updatable?: boolean;
  115310. }, scene?: Nullable<Scene>): Mesh;
  115311. /**
  115312. * Creates a tiled box mesh
  115313. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115315. * @param name defines the name of the mesh
  115316. * @param options defines the options used to create the mesh
  115317. * @param scene defines the hosting scene
  115318. * @returns the tiled box mesh
  115319. */
  115320. static CreateTiledBox(name: string, options: {
  115321. pattern?: number;
  115322. size?: number;
  115323. width?: number;
  115324. height?: number;
  115325. depth: number;
  115326. tileSize?: number;
  115327. tileWidth?: number;
  115328. tileHeight?: number;
  115329. faceUV?: Vector4[];
  115330. faceColors?: Color4[];
  115331. alignHorizontal?: number;
  115332. alignVertical?: number;
  115333. sideOrientation?: number;
  115334. updatable?: boolean;
  115335. }, scene?: Nullable<Scene>): Mesh;
  115336. /**
  115337. * Creates a sphere mesh
  115338. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  115339. * * 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`)
  115340. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  115341. * * 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
  115342. * * 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)
  115343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115346. * @param name defines the name of the mesh
  115347. * @param options defines the options used to create the mesh
  115348. * @param scene defines the hosting scene
  115349. * @returns the sphere mesh
  115350. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  115351. */
  115352. static CreateSphere(name: string, options: {
  115353. segments?: number;
  115354. diameter?: number;
  115355. diameterX?: number;
  115356. diameterY?: number;
  115357. diameterZ?: number;
  115358. arc?: number;
  115359. slice?: number;
  115360. sideOrientation?: number;
  115361. frontUVs?: Vector4;
  115362. backUVs?: Vector4;
  115363. updatable?: boolean;
  115364. }, scene?: Nullable<Scene>): Mesh;
  115365. /**
  115366. * Creates a plane polygonal mesh. By default, this is a disc
  115367. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115368. * * 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
  115369. * * 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
  115370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115373. * @param name defines the name of the mesh
  115374. * @param options defines the options used to create the mesh
  115375. * @param scene defines the hosting scene
  115376. * @returns the plane polygonal mesh
  115377. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115378. */
  115379. static CreateDisc(name: string, options: {
  115380. radius?: number;
  115381. tessellation?: number;
  115382. arc?: number;
  115383. updatable?: boolean;
  115384. sideOrientation?: number;
  115385. frontUVs?: Vector4;
  115386. backUVs?: Vector4;
  115387. }, scene?: Nullable<Scene>): Mesh;
  115388. /**
  115389. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115390. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115391. * * 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`)
  115392. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115393. * * 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
  115394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115397. * @param name defines the name of the mesh
  115398. * @param options defines the options used to create the mesh
  115399. * @param scene defines the hosting scene
  115400. * @returns the icosahedron mesh
  115401. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115402. */
  115403. static CreateIcoSphere(name: string, options: {
  115404. radius?: number;
  115405. radiusX?: number;
  115406. radiusY?: number;
  115407. radiusZ?: number;
  115408. flat?: boolean;
  115409. subdivisions?: number;
  115410. sideOrientation?: number;
  115411. frontUVs?: Vector4;
  115412. backUVs?: Vector4;
  115413. updatable?: boolean;
  115414. }, scene?: Nullable<Scene>): Mesh;
  115415. /**
  115416. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115417. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  115418. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  115419. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  115420. * * 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
  115421. * * 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
  115422. * * 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
  115423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115425. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115426. * * 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
  115427. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  115428. * * 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
  115429. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  115430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115431. * @param name defines the name of the mesh
  115432. * @param options defines the options used to create the mesh
  115433. * @param scene defines the hosting scene
  115434. * @returns the ribbon mesh
  115435. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  115436. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115437. */
  115438. static CreateRibbon(name: string, options: {
  115439. pathArray: Vector3[][];
  115440. closeArray?: boolean;
  115441. closePath?: boolean;
  115442. offset?: number;
  115443. updatable?: boolean;
  115444. sideOrientation?: number;
  115445. frontUVs?: Vector4;
  115446. backUVs?: Vector4;
  115447. instance?: Mesh;
  115448. invertUV?: boolean;
  115449. uvs?: Vector2[];
  115450. colors?: Color4[];
  115451. }, scene?: Nullable<Scene>): Mesh;
  115452. /**
  115453. * Creates a cylinder or a cone mesh
  115454. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115455. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115456. * * 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.
  115457. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115458. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115459. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115460. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115461. * * 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).
  115462. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115463. * * 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).
  115464. * * 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
  115465. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115466. * * 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
  115467. * * 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.
  115468. * * If `enclose` is false, a ring surface is one element.
  115469. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115470. * * 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
  115471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115474. * @param name defines the name of the mesh
  115475. * @param options defines the options used to create the mesh
  115476. * @param scene defines the hosting scene
  115477. * @returns the cylinder mesh
  115478. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115479. */
  115480. static CreateCylinder(name: string, options: {
  115481. height?: number;
  115482. diameterTop?: number;
  115483. diameterBottom?: number;
  115484. diameter?: number;
  115485. tessellation?: number;
  115486. subdivisions?: number;
  115487. arc?: number;
  115488. faceColors?: Color4[];
  115489. faceUV?: Vector4[];
  115490. updatable?: boolean;
  115491. hasRings?: boolean;
  115492. enclose?: boolean;
  115493. cap?: number;
  115494. sideOrientation?: number;
  115495. frontUVs?: Vector4;
  115496. backUVs?: Vector4;
  115497. }, scene?: Nullable<Scene>): Mesh;
  115498. /**
  115499. * Creates a torus mesh
  115500. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115501. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115502. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115506. * @param name defines the name of the mesh
  115507. * @param options defines the options used to create the mesh
  115508. * @param scene defines the hosting scene
  115509. * @returns the torus mesh
  115510. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115511. */
  115512. static CreateTorus(name: string, options: {
  115513. diameter?: number;
  115514. thickness?: number;
  115515. tessellation?: number;
  115516. updatable?: boolean;
  115517. sideOrientation?: number;
  115518. frontUVs?: Vector4;
  115519. backUVs?: Vector4;
  115520. }, scene?: Nullable<Scene>): Mesh;
  115521. /**
  115522. * Creates a torus knot mesh
  115523. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115524. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115525. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115526. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115528. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115530. * @param name defines the name of the mesh
  115531. * @param options defines the options used to create the mesh
  115532. * @param scene defines the hosting scene
  115533. * @returns the torus knot mesh
  115534. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115535. */
  115536. static CreateTorusKnot(name: string, options: {
  115537. radius?: number;
  115538. tube?: number;
  115539. radialSegments?: number;
  115540. tubularSegments?: number;
  115541. p?: number;
  115542. q?: number;
  115543. updatable?: boolean;
  115544. sideOrientation?: number;
  115545. frontUVs?: Vector4;
  115546. backUVs?: Vector4;
  115547. }, scene?: Nullable<Scene>): Mesh;
  115548. /**
  115549. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  115550. * * 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
  115551. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  115552. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  115553. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  115554. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  115555. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  115556. * * 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
  115557. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  115558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  115560. * @param name defines the name of the new line system
  115561. * @param options defines the options used to create the line system
  115562. * @param scene defines the hosting scene
  115563. * @returns a new line system mesh
  115564. */
  115565. static CreateLineSystem(name: string, options: {
  115566. lines: Vector3[][];
  115567. updatable?: boolean;
  115568. instance?: Nullable<LinesMesh>;
  115569. colors?: Nullable<Color4[][]>;
  115570. useVertexAlpha?: boolean;
  115571. }, scene: Nullable<Scene>): LinesMesh;
  115572. /**
  115573. * Creates a line mesh
  115574. * 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
  115575. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115576. * * The parameter `points` is an array successive Vector3
  115577. * * 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
  115578. * * The optional parameter `colors` is an array of successive Color4, one per line point
  115579. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  115580. * * When updating an instance, remember that only point positions can change, not the number of points
  115581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115582. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  115583. * @param name defines the name of the new line system
  115584. * @param options defines the options used to create the line system
  115585. * @param scene defines the hosting scene
  115586. * @returns a new line mesh
  115587. */
  115588. static CreateLines(name: string, options: {
  115589. points: Vector3[];
  115590. updatable?: boolean;
  115591. instance?: Nullable<LinesMesh>;
  115592. colors?: Color4[];
  115593. useVertexAlpha?: boolean;
  115594. }, scene?: Nullable<Scene>): LinesMesh;
  115595. /**
  115596. * Creates a dashed line mesh
  115597. * * 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
  115598. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115599. * * The parameter `points` is an array successive Vector3
  115600. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  115601. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  115602. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  115603. * * 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
  115604. * * When updating an instance, remember that only point positions can change, not the number of points
  115605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115606. * @param name defines the name of the mesh
  115607. * @param options defines the options used to create the mesh
  115608. * @param scene defines the hosting scene
  115609. * @returns the dashed line mesh
  115610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  115611. */
  115612. static CreateDashedLines(name: string, options: {
  115613. points: Vector3[];
  115614. dashSize?: number;
  115615. gapSize?: number;
  115616. dashNb?: number;
  115617. updatable?: boolean;
  115618. instance?: LinesMesh;
  115619. }, scene?: Nullable<Scene>): LinesMesh;
  115620. /**
  115621. * 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.
  115622. * * 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.
  115623. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115624. * * 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.
  115625. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  115626. * * 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
  115627. * * 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
  115628. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  115629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115631. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  115632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115633. * @param name defines the name of the mesh
  115634. * @param options defines the options used to create the mesh
  115635. * @param scene defines the hosting scene
  115636. * @returns the extruded shape mesh
  115637. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115639. */
  115640. static ExtrudeShape(name: string, options: {
  115641. shape: Vector3[];
  115642. path: Vector3[];
  115643. scale?: number;
  115644. rotation?: number;
  115645. cap?: number;
  115646. updatable?: boolean;
  115647. sideOrientation?: number;
  115648. frontUVs?: Vector4;
  115649. backUVs?: Vector4;
  115650. instance?: Mesh;
  115651. invertUV?: boolean;
  115652. }, scene?: Nullable<Scene>): Mesh;
  115653. /**
  115654. * Creates an custom extruded shape mesh.
  115655. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  115656. * * 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.
  115657. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115658. * * 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
  115659. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  115660. * * 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
  115661. * * It must returns a float value that will be the scale value applied to the shape on each path point
  115662. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  115663. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  115664. * * 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
  115665. * * 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
  115666. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  115667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115668. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115669. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115671. * @param name defines the name of the mesh
  115672. * @param options defines the options used to create the mesh
  115673. * @param scene defines the hosting scene
  115674. * @returns the custom extruded shape mesh
  115675. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  115676. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115678. */
  115679. static ExtrudeShapeCustom(name: string, options: {
  115680. shape: Vector3[];
  115681. path: Vector3[];
  115682. scaleFunction?: any;
  115683. rotationFunction?: any;
  115684. ribbonCloseArray?: boolean;
  115685. ribbonClosePath?: boolean;
  115686. cap?: number;
  115687. updatable?: boolean;
  115688. sideOrientation?: number;
  115689. frontUVs?: Vector4;
  115690. backUVs?: Vector4;
  115691. instance?: Mesh;
  115692. invertUV?: boolean;
  115693. }, scene?: Nullable<Scene>): Mesh;
  115694. /**
  115695. * Creates lathe mesh.
  115696. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115697. * * 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
  115698. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115699. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115700. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115701. * * 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
  115702. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115703. * * 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
  115704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115706. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115708. * @param name defines the name of the mesh
  115709. * @param options defines the options used to create the mesh
  115710. * @param scene defines the hosting scene
  115711. * @returns the lathe mesh
  115712. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115713. */
  115714. static CreateLathe(name: string, options: {
  115715. shape: Vector3[];
  115716. radius?: number;
  115717. tessellation?: number;
  115718. clip?: number;
  115719. arc?: number;
  115720. closed?: boolean;
  115721. updatable?: boolean;
  115722. sideOrientation?: number;
  115723. frontUVs?: Vector4;
  115724. backUVs?: Vector4;
  115725. cap?: number;
  115726. invertUV?: boolean;
  115727. }, scene?: Nullable<Scene>): Mesh;
  115728. /**
  115729. * Creates a tiled plane mesh
  115730. * * You can set a limited pattern arrangement with the tiles
  115731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115734. * @param name defines the name of the mesh
  115735. * @param options defines the options used to create the mesh
  115736. * @param scene defines the hosting scene
  115737. * @returns the plane mesh
  115738. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115739. */
  115740. static CreateTiledPlane(name: string, options: {
  115741. pattern?: number;
  115742. tileSize?: number;
  115743. tileWidth?: number;
  115744. tileHeight?: number;
  115745. size?: number;
  115746. width?: number;
  115747. height?: number;
  115748. alignHorizontal?: number;
  115749. alignVertical?: number;
  115750. sideOrientation?: number;
  115751. frontUVs?: Vector4;
  115752. backUVs?: Vector4;
  115753. updatable?: boolean;
  115754. }, scene?: Nullable<Scene>): Mesh;
  115755. /**
  115756. * Creates a plane mesh
  115757. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  115758. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  115759. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  115760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115761. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115763. * @param name defines the name of the mesh
  115764. * @param options defines the options used to create the mesh
  115765. * @param scene defines the hosting scene
  115766. * @returns the plane mesh
  115767. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115768. */
  115769. static CreatePlane(name: string, options: {
  115770. size?: number;
  115771. width?: number;
  115772. height?: number;
  115773. sideOrientation?: number;
  115774. frontUVs?: Vector4;
  115775. backUVs?: Vector4;
  115776. updatable?: boolean;
  115777. sourcePlane?: Plane;
  115778. }, scene?: Nullable<Scene>): Mesh;
  115779. /**
  115780. * Creates a ground mesh
  115781. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115782. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115784. * @param name defines the name of the mesh
  115785. * @param options defines the options used to create the mesh
  115786. * @param scene defines the hosting scene
  115787. * @returns the ground mesh
  115788. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115789. */
  115790. static CreateGround(name: string, options: {
  115791. width?: number;
  115792. height?: number;
  115793. subdivisions?: number;
  115794. subdivisionsX?: number;
  115795. subdivisionsY?: number;
  115796. updatable?: boolean;
  115797. }, scene?: Nullable<Scene>): Mesh;
  115798. /**
  115799. * Creates a tiled ground mesh
  115800. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115801. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115802. * * 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
  115803. * * 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
  115804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115805. * @param name defines the name of the mesh
  115806. * @param options defines the options used to create the mesh
  115807. * @param scene defines the hosting scene
  115808. * @returns the tiled ground mesh
  115809. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115810. */
  115811. static CreateTiledGround(name: string, options: {
  115812. xmin: number;
  115813. zmin: number;
  115814. xmax: number;
  115815. zmax: number;
  115816. subdivisions?: {
  115817. w: number;
  115818. h: number;
  115819. };
  115820. precision?: {
  115821. w: number;
  115822. h: number;
  115823. };
  115824. updatable?: boolean;
  115825. }, scene?: Nullable<Scene>): Mesh;
  115826. /**
  115827. * Creates a ground mesh from a height map
  115828. * * The parameter `url` sets the URL of the height map image resource.
  115829. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115830. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115831. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115832. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115833. * * 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.
  115834. * * 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).
  115835. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115837. * @param name defines the name of the mesh
  115838. * @param url defines the url to the height map
  115839. * @param options defines the options used to create the mesh
  115840. * @param scene defines the hosting scene
  115841. * @returns the ground mesh
  115842. * @see https://doc.babylonjs.com/babylon101/height_map
  115843. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115844. */
  115845. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115846. width?: number;
  115847. height?: number;
  115848. subdivisions?: number;
  115849. minHeight?: number;
  115850. maxHeight?: number;
  115851. colorFilter?: Color3;
  115852. alphaFilter?: number;
  115853. updatable?: boolean;
  115854. onReady?: (mesh: GroundMesh) => void;
  115855. }, scene?: Nullable<Scene>): GroundMesh;
  115856. /**
  115857. * Creates a polygon mesh
  115858. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115859. * * 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
  115860. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115863. * * Remember you can only change the shape positions, not their number when updating a polygon
  115864. * @param name defines the name of the mesh
  115865. * @param options defines the options used to create the mesh
  115866. * @param scene defines the hosting scene
  115867. * @param earcutInjection can be used to inject your own earcut reference
  115868. * @returns the polygon mesh
  115869. */
  115870. static CreatePolygon(name: string, options: {
  115871. shape: Vector3[];
  115872. holes?: Vector3[][];
  115873. depth?: number;
  115874. faceUV?: Vector4[];
  115875. faceColors?: Color4[];
  115876. updatable?: boolean;
  115877. sideOrientation?: number;
  115878. frontUVs?: Vector4;
  115879. backUVs?: Vector4;
  115880. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115881. /**
  115882. * Creates an extruded polygon mesh, with depth in the Y direction.
  115883. * * 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)
  115884. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115885. * @param name defines the name of the mesh
  115886. * @param options defines the options used to create the mesh
  115887. * @param scene defines the hosting scene
  115888. * @param earcutInjection can be used to inject your own earcut reference
  115889. * @returns the polygon mesh
  115890. */
  115891. static ExtrudePolygon(name: string, options: {
  115892. shape: Vector3[];
  115893. holes?: Vector3[][];
  115894. depth?: number;
  115895. faceUV?: Vector4[];
  115896. faceColors?: Color4[];
  115897. updatable?: boolean;
  115898. sideOrientation?: number;
  115899. frontUVs?: Vector4;
  115900. backUVs?: Vector4;
  115901. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115902. /**
  115903. * Creates a tube mesh.
  115904. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115905. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115906. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115907. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115908. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115909. * * 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)
  115910. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115911. * * 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
  115912. * * 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
  115913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115914. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115915. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115917. * @param name defines the name of the mesh
  115918. * @param options defines the options used to create the mesh
  115919. * @param scene defines the hosting scene
  115920. * @returns the tube mesh
  115921. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115922. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115923. */
  115924. static CreateTube(name: string, options: {
  115925. path: Vector3[];
  115926. radius?: number;
  115927. tessellation?: number;
  115928. radiusFunction?: {
  115929. (i: number, distance: number): number;
  115930. };
  115931. cap?: number;
  115932. arc?: number;
  115933. updatable?: boolean;
  115934. sideOrientation?: number;
  115935. frontUVs?: Vector4;
  115936. backUVs?: Vector4;
  115937. instance?: Mesh;
  115938. invertUV?: boolean;
  115939. }, scene?: Nullable<Scene>): Mesh;
  115940. /**
  115941. * Creates a polyhedron mesh
  115942. * * 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
  115943. * * The parameter `size` (positive float, default 1) sets the polygon size
  115944. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  115945. * * 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`
  115946. * * 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
  115947. * * 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)`)
  115948. * * 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
  115949. * * 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
  115950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115951. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115953. * @param name defines the name of the mesh
  115954. * @param options defines the options used to create the mesh
  115955. * @param scene defines the hosting scene
  115956. * @returns the polyhedron mesh
  115957. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  115958. */
  115959. static CreatePolyhedron(name: string, options: {
  115960. type?: number;
  115961. size?: number;
  115962. sizeX?: number;
  115963. sizeY?: number;
  115964. sizeZ?: number;
  115965. custom?: any;
  115966. faceUV?: Vector4[];
  115967. faceColors?: Color4[];
  115968. flat?: boolean;
  115969. updatable?: boolean;
  115970. sideOrientation?: number;
  115971. frontUVs?: Vector4;
  115972. backUVs?: Vector4;
  115973. }, scene?: Nullable<Scene>): Mesh;
  115974. /**
  115975. * Creates a decal mesh.
  115976. * 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
  115977. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115978. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115979. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115980. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115981. * @param name defines the name of the mesh
  115982. * @param sourceMesh defines the mesh where the decal must be applied
  115983. * @param options defines the options used to create the mesh
  115984. * @param scene defines the hosting scene
  115985. * @returns the decal mesh
  115986. * @see https://doc.babylonjs.com/how_to/decals
  115987. */
  115988. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115989. position?: Vector3;
  115990. normal?: Vector3;
  115991. size?: Vector3;
  115992. angle?: number;
  115993. }): Mesh;
  115994. }
  115995. }
  115996. declare module BABYLON {
  115997. /**
  115998. * A simplifier interface for future simplification implementations
  115999. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116000. */
  116001. export interface ISimplifier {
  116002. /**
  116003. * Simplification of a given mesh according to the given settings.
  116004. * Since this requires computation, it is assumed that the function runs async.
  116005. * @param settings The settings of the simplification, including quality and distance
  116006. * @param successCallback A callback that will be called after the mesh was simplified.
  116007. * @param errorCallback in case of an error, this callback will be called. optional.
  116008. */
  116009. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  116010. }
  116011. /**
  116012. * Expected simplification settings.
  116013. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  116014. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116015. */
  116016. export interface ISimplificationSettings {
  116017. /**
  116018. * Gets or sets the expected quality
  116019. */
  116020. quality: number;
  116021. /**
  116022. * Gets or sets the distance when this optimized version should be used
  116023. */
  116024. distance: number;
  116025. /**
  116026. * Gets an already optimized mesh
  116027. */
  116028. optimizeMesh?: boolean;
  116029. }
  116030. /**
  116031. * Class used to specify simplification options
  116032. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116033. */
  116034. export class SimplificationSettings implements ISimplificationSettings {
  116035. /** expected quality */
  116036. quality: number;
  116037. /** distance when this optimized version should be used */
  116038. distance: number;
  116039. /** already optimized mesh */
  116040. optimizeMesh?: boolean | undefined;
  116041. /**
  116042. * Creates a SimplificationSettings
  116043. * @param quality expected quality
  116044. * @param distance distance when this optimized version should be used
  116045. * @param optimizeMesh already optimized mesh
  116046. */
  116047. constructor(
  116048. /** expected quality */
  116049. quality: number,
  116050. /** distance when this optimized version should be used */
  116051. distance: number,
  116052. /** already optimized mesh */
  116053. optimizeMesh?: boolean | undefined);
  116054. }
  116055. /**
  116056. * Interface used to define a simplification task
  116057. */
  116058. export interface ISimplificationTask {
  116059. /**
  116060. * Array of settings
  116061. */
  116062. settings: Array<ISimplificationSettings>;
  116063. /**
  116064. * Simplification type
  116065. */
  116066. simplificationType: SimplificationType;
  116067. /**
  116068. * Mesh to simplify
  116069. */
  116070. mesh: Mesh;
  116071. /**
  116072. * Callback called on success
  116073. */
  116074. successCallback?: () => void;
  116075. /**
  116076. * Defines if parallel processing can be used
  116077. */
  116078. parallelProcessing: boolean;
  116079. }
  116080. /**
  116081. * Queue used to order the simplification tasks
  116082. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116083. */
  116084. export class SimplificationQueue {
  116085. private _simplificationArray;
  116086. /**
  116087. * Gets a boolean indicating that the process is still running
  116088. */
  116089. running: boolean;
  116090. /**
  116091. * Creates a new queue
  116092. */
  116093. constructor();
  116094. /**
  116095. * Adds a new simplification task
  116096. * @param task defines a task to add
  116097. */
  116098. addTask(task: ISimplificationTask): void;
  116099. /**
  116100. * Execute next task
  116101. */
  116102. executeNext(): void;
  116103. /**
  116104. * Execute a simplification task
  116105. * @param task defines the task to run
  116106. */
  116107. runSimplification(task: ISimplificationTask): void;
  116108. private getSimplifier;
  116109. }
  116110. /**
  116111. * The implemented types of simplification
  116112. * At the moment only Quadratic Error Decimation is implemented
  116113. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116114. */
  116115. export enum SimplificationType {
  116116. /** Quadratic error decimation */
  116117. QUADRATIC = 0
  116118. }
  116119. }
  116120. declare module BABYLON {
  116121. interface Scene {
  116122. /** @hidden (Backing field) */
  116123. _simplificationQueue: SimplificationQueue;
  116124. /**
  116125. * Gets or sets the simplification queue attached to the scene
  116126. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116127. */
  116128. simplificationQueue: SimplificationQueue;
  116129. }
  116130. interface Mesh {
  116131. /**
  116132. * Simplify the mesh according to the given array of settings.
  116133. * Function will return immediately and will simplify async
  116134. * @param settings a collection of simplification settings
  116135. * @param parallelProcessing should all levels calculate parallel or one after the other
  116136. * @param simplificationType the type of simplification to run
  116137. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  116138. * @returns the current mesh
  116139. */
  116140. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  116141. }
  116142. /**
  116143. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  116144. * created in a scene
  116145. */
  116146. export class SimplicationQueueSceneComponent implements ISceneComponent {
  116147. /**
  116148. * The component name helpfull to identify the component in the list of scene components.
  116149. */
  116150. readonly name: string;
  116151. /**
  116152. * The scene the component belongs to.
  116153. */
  116154. scene: Scene;
  116155. /**
  116156. * Creates a new instance of the component for the given scene
  116157. * @param scene Defines the scene to register the component in
  116158. */
  116159. constructor(scene: Scene);
  116160. /**
  116161. * Registers the component in a given scene
  116162. */
  116163. register(): void;
  116164. /**
  116165. * Rebuilds the elements related to this component in case of
  116166. * context lost for instance.
  116167. */
  116168. rebuild(): void;
  116169. /**
  116170. * Disposes the component and the associated ressources
  116171. */
  116172. dispose(): void;
  116173. private _beforeCameraUpdate;
  116174. }
  116175. }
  116176. declare module BABYLON {
  116177. /**
  116178. * Class used to enable access to IndexedDB
  116179. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116180. */
  116181. export class Database implements IOfflineProvider {
  116182. private _callbackManifestChecked;
  116183. private _currentSceneUrl;
  116184. private _db;
  116185. private _enableSceneOffline;
  116186. private _enableTexturesOffline;
  116187. private _manifestVersionFound;
  116188. private _mustUpdateRessources;
  116189. private _hasReachedQuota;
  116190. private _isSupported;
  116191. private _idbFactory;
  116192. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  116193. private static IsUASupportingBlobStorage;
  116194. /**
  116195. * Gets a boolean indicating if Database storate is enabled (off by default)
  116196. */
  116197. static IDBStorageEnabled: boolean;
  116198. /**
  116199. * Gets a boolean indicating if scene must be saved in the database
  116200. */
  116201. readonly enableSceneOffline: boolean;
  116202. /**
  116203. * Gets a boolean indicating if textures must be saved in the database
  116204. */
  116205. readonly enableTexturesOffline: boolean;
  116206. /**
  116207. * Creates a new Database
  116208. * @param urlToScene defines the url to load the scene
  116209. * @param callbackManifestChecked defines the callback to use when manifest is checked
  116210. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  116211. */
  116212. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  116213. private static _ParseURL;
  116214. private static _ReturnFullUrlLocation;
  116215. private _checkManifestFile;
  116216. /**
  116217. * Open the database and make it available
  116218. * @param successCallback defines the callback to call on success
  116219. * @param errorCallback defines the callback to call on error
  116220. */
  116221. open(successCallback: () => void, errorCallback: () => void): void;
  116222. /**
  116223. * Loads an image from the database
  116224. * @param url defines the url to load from
  116225. * @param image defines the target DOM image
  116226. */
  116227. loadImage(url: string, image: HTMLImageElement): void;
  116228. private _loadImageFromDBAsync;
  116229. private _saveImageIntoDBAsync;
  116230. private _checkVersionFromDB;
  116231. private _loadVersionFromDBAsync;
  116232. private _saveVersionIntoDBAsync;
  116233. /**
  116234. * Loads a file from database
  116235. * @param url defines the URL to load from
  116236. * @param sceneLoaded defines a callback to call on success
  116237. * @param progressCallBack defines a callback to call when progress changed
  116238. * @param errorCallback defines a callback to call on error
  116239. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  116240. */
  116241. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  116242. private _loadFileAsync;
  116243. private _saveFileAsync;
  116244. /**
  116245. * Validates if xhr data is correct
  116246. * @param xhr defines the request to validate
  116247. * @param dataType defines the expected data type
  116248. * @returns true if data is correct
  116249. */
  116250. private static _ValidateXHRData;
  116251. }
  116252. }
  116253. declare module BABYLON {
  116254. /** @hidden */
  116255. export var gpuUpdateParticlesPixelShader: {
  116256. name: string;
  116257. shader: string;
  116258. };
  116259. }
  116260. declare module BABYLON {
  116261. /** @hidden */
  116262. export var gpuUpdateParticlesVertexShader: {
  116263. name: string;
  116264. shader: string;
  116265. };
  116266. }
  116267. declare module BABYLON {
  116268. /** @hidden */
  116269. export var clipPlaneFragmentDeclaration2: {
  116270. name: string;
  116271. shader: string;
  116272. };
  116273. }
  116274. declare module BABYLON {
  116275. /** @hidden */
  116276. export var gpuRenderParticlesPixelShader: {
  116277. name: string;
  116278. shader: string;
  116279. };
  116280. }
  116281. declare module BABYLON {
  116282. /** @hidden */
  116283. export var clipPlaneVertexDeclaration2: {
  116284. name: string;
  116285. shader: string;
  116286. };
  116287. }
  116288. declare module BABYLON {
  116289. /** @hidden */
  116290. export var gpuRenderParticlesVertexShader: {
  116291. name: string;
  116292. shader: string;
  116293. };
  116294. }
  116295. declare module BABYLON {
  116296. /**
  116297. * This represents a GPU particle system in Babylon
  116298. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  116299. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  116300. */
  116301. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  116302. /**
  116303. * The layer mask we are rendering the particles through.
  116304. */
  116305. layerMask: number;
  116306. private _capacity;
  116307. private _activeCount;
  116308. private _currentActiveCount;
  116309. private _accumulatedCount;
  116310. private _renderEffect;
  116311. private _updateEffect;
  116312. private _buffer0;
  116313. private _buffer1;
  116314. private _spriteBuffer;
  116315. private _updateVAO;
  116316. private _renderVAO;
  116317. private _targetIndex;
  116318. private _sourceBuffer;
  116319. private _targetBuffer;
  116320. private _engine;
  116321. private _currentRenderId;
  116322. private _started;
  116323. private _stopped;
  116324. private _timeDelta;
  116325. private _randomTexture;
  116326. private _randomTexture2;
  116327. private _attributesStrideSize;
  116328. private _updateEffectOptions;
  116329. private _randomTextureSize;
  116330. private _actualFrame;
  116331. private readonly _rawTextureWidth;
  116332. /**
  116333. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  116334. */
  116335. static readonly IsSupported: boolean;
  116336. /**
  116337. * An event triggered when the system is disposed.
  116338. */
  116339. onDisposeObservable: Observable<GPUParticleSystem>;
  116340. /**
  116341. * Gets the maximum number of particles active at the same time.
  116342. * @returns The max number of active particles.
  116343. */
  116344. getCapacity(): number;
  116345. /**
  116346. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  116347. * to override the particles.
  116348. */
  116349. forceDepthWrite: boolean;
  116350. /**
  116351. * Gets or set the number of active particles
  116352. */
  116353. activeParticleCount: number;
  116354. private _preWarmDone;
  116355. /**
  116356. * Is this system ready to be used/rendered
  116357. * @return true if the system is ready
  116358. */
  116359. isReady(): boolean;
  116360. /**
  116361. * Gets if the system has been started. (Note: this will still be true after stop is called)
  116362. * @returns True if it has been started, otherwise false.
  116363. */
  116364. isStarted(): boolean;
  116365. /**
  116366. * Starts the particle system and begins to emit
  116367. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  116368. */
  116369. start(delay?: number): void;
  116370. /**
  116371. * Stops the particle system.
  116372. */
  116373. stop(): void;
  116374. /**
  116375. * Remove all active particles
  116376. */
  116377. reset(): void;
  116378. /**
  116379. * Returns the string "GPUParticleSystem"
  116380. * @returns a string containing the class name
  116381. */
  116382. getClassName(): string;
  116383. private _colorGradientsTexture;
  116384. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  116385. /**
  116386. * Adds a new color gradient
  116387. * @param gradient defines the gradient to use (between 0 and 1)
  116388. * @param color1 defines the color to affect to the specified gradient
  116389. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  116390. * @returns the current particle system
  116391. */
  116392. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  116393. /**
  116394. * Remove a specific color gradient
  116395. * @param gradient defines the gradient to remove
  116396. * @returns the current particle system
  116397. */
  116398. removeColorGradient(gradient: number): GPUParticleSystem;
  116399. private _angularSpeedGradientsTexture;
  116400. private _sizeGradientsTexture;
  116401. private _velocityGradientsTexture;
  116402. private _limitVelocityGradientsTexture;
  116403. private _dragGradientsTexture;
  116404. private _addFactorGradient;
  116405. /**
  116406. * Adds a new size gradient
  116407. * @param gradient defines the gradient to use (between 0 and 1)
  116408. * @param factor defines the size factor to affect to the specified gradient
  116409. * @returns the current particle system
  116410. */
  116411. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  116412. /**
  116413. * Remove a specific size gradient
  116414. * @param gradient defines the gradient to remove
  116415. * @returns the current particle system
  116416. */
  116417. removeSizeGradient(gradient: number): GPUParticleSystem;
  116418. /**
  116419. * Adds a new angular speed gradient
  116420. * @param gradient defines the gradient to use (between 0 and 1)
  116421. * @param factor defines the angular speed to affect to the specified gradient
  116422. * @returns the current particle system
  116423. */
  116424. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  116425. /**
  116426. * Remove a specific angular speed gradient
  116427. * @param gradient defines the gradient to remove
  116428. * @returns the current particle system
  116429. */
  116430. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  116431. /**
  116432. * Adds a new velocity gradient
  116433. * @param gradient defines the gradient to use (between 0 and 1)
  116434. * @param factor defines the velocity to affect to the specified gradient
  116435. * @returns the current particle system
  116436. */
  116437. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116438. /**
  116439. * Remove a specific velocity gradient
  116440. * @param gradient defines the gradient to remove
  116441. * @returns the current particle system
  116442. */
  116443. removeVelocityGradient(gradient: number): GPUParticleSystem;
  116444. /**
  116445. * Adds a new limit velocity gradient
  116446. * @param gradient defines the gradient to use (between 0 and 1)
  116447. * @param factor defines the limit velocity value to affect to the specified gradient
  116448. * @returns the current particle system
  116449. */
  116450. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116451. /**
  116452. * Remove a specific limit velocity gradient
  116453. * @param gradient defines the gradient to remove
  116454. * @returns the current particle system
  116455. */
  116456. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  116457. /**
  116458. * Adds a new drag gradient
  116459. * @param gradient defines the gradient to use (between 0 and 1)
  116460. * @param factor defines the drag value to affect to the specified gradient
  116461. * @returns the current particle system
  116462. */
  116463. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  116464. /**
  116465. * Remove a specific drag gradient
  116466. * @param gradient defines the gradient to remove
  116467. * @returns the current particle system
  116468. */
  116469. removeDragGradient(gradient: number): GPUParticleSystem;
  116470. /**
  116471. * Not supported by GPUParticleSystem
  116472. * @param gradient defines the gradient to use (between 0 and 1)
  116473. * @param factor defines the emit rate value to affect to the specified gradient
  116474. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116475. * @returns the current particle system
  116476. */
  116477. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116478. /**
  116479. * Not supported by GPUParticleSystem
  116480. * @param gradient defines the gradient to remove
  116481. * @returns the current particle system
  116482. */
  116483. removeEmitRateGradient(gradient: number): IParticleSystem;
  116484. /**
  116485. * Not supported by GPUParticleSystem
  116486. * @param gradient defines the gradient to use (between 0 and 1)
  116487. * @param factor defines the start size value to affect to the specified gradient
  116488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116489. * @returns the current particle system
  116490. */
  116491. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116492. /**
  116493. * Not supported by GPUParticleSystem
  116494. * @param gradient defines the gradient to remove
  116495. * @returns the current particle system
  116496. */
  116497. removeStartSizeGradient(gradient: number): IParticleSystem;
  116498. /**
  116499. * Not supported by GPUParticleSystem
  116500. * @param gradient defines the gradient to use (between 0 and 1)
  116501. * @param min defines the color remap minimal range
  116502. * @param max defines the color remap maximal range
  116503. * @returns the current particle system
  116504. */
  116505. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116506. /**
  116507. * Not supported by GPUParticleSystem
  116508. * @param gradient defines the gradient to remove
  116509. * @returns the current particle system
  116510. */
  116511. removeColorRemapGradient(): IParticleSystem;
  116512. /**
  116513. * Not supported by GPUParticleSystem
  116514. * @param gradient defines the gradient to use (between 0 and 1)
  116515. * @param min defines the alpha remap minimal range
  116516. * @param max defines the alpha remap maximal range
  116517. * @returns the current particle system
  116518. */
  116519. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116520. /**
  116521. * Not supported by GPUParticleSystem
  116522. * @param gradient defines the gradient to remove
  116523. * @returns the current particle system
  116524. */
  116525. removeAlphaRemapGradient(): IParticleSystem;
  116526. /**
  116527. * Not supported by GPUParticleSystem
  116528. * @param gradient defines the gradient to use (between 0 and 1)
  116529. * @param color defines the color to affect to the specified gradient
  116530. * @returns the current particle system
  116531. */
  116532. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  116533. /**
  116534. * Not supported by GPUParticleSystem
  116535. * @param gradient defines the gradient to remove
  116536. * @returns the current particle system
  116537. */
  116538. removeRampGradient(): IParticleSystem;
  116539. /**
  116540. * Not supported by GPUParticleSystem
  116541. * @returns the list of ramp gradients
  116542. */
  116543. getRampGradients(): Nullable<Array<Color3Gradient>>;
  116544. /**
  116545. * Not supported by GPUParticleSystem
  116546. * Gets or sets a boolean indicating that ramp gradients must be used
  116547. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  116548. */
  116549. useRampGradients: boolean;
  116550. /**
  116551. * Not supported by GPUParticleSystem
  116552. * @param gradient defines the gradient to use (between 0 and 1)
  116553. * @param factor defines the life time factor to affect to the specified gradient
  116554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116555. * @returns the current particle system
  116556. */
  116557. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116558. /**
  116559. * Not supported by GPUParticleSystem
  116560. * @param gradient defines the gradient to remove
  116561. * @returns the current particle system
  116562. */
  116563. removeLifeTimeGradient(gradient: number): IParticleSystem;
  116564. /**
  116565. * Instantiates a GPU particle system.
  116566. * 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.
  116567. * @param name The name of the particle system
  116568. * @param options The options used to create the system
  116569. * @param scene The scene the particle system belongs to
  116570. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  116571. */
  116572. constructor(name: string, options: Partial<{
  116573. capacity: number;
  116574. randomTextureSize: number;
  116575. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  116576. protected _reset(): void;
  116577. private _createUpdateVAO;
  116578. private _createRenderVAO;
  116579. private _initialize;
  116580. /** @hidden */
  116581. _recreateUpdateEffect(): void;
  116582. /** @hidden */
  116583. _recreateRenderEffect(): void;
  116584. /**
  116585. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  116586. * @param preWarm defines if we are in the pre-warmimg phase
  116587. */
  116588. animate(preWarm?: boolean): void;
  116589. private _createFactorGradientTexture;
  116590. private _createSizeGradientTexture;
  116591. private _createAngularSpeedGradientTexture;
  116592. private _createVelocityGradientTexture;
  116593. private _createLimitVelocityGradientTexture;
  116594. private _createDragGradientTexture;
  116595. private _createColorGradientTexture;
  116596. /**
  116597. * Renders the particle system in its current state
  116598. * @param preWarm defines if the system should only update the particles but not render them
  116599. * @returns the current number of particles
  116600. */
  116601. render(preWarm?: boolean): number;
  116602. /**
  116603. * Rebuilds the particle system
  116604. */
  116605. rebuild(): void;
  116606. private _releaseBuffers;
  116607. private _releaseVAOs;
  116608. /**
  116609. * Disposes the particle system and free the associated resources
  116610. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  116611. */
  116612. dispose(disposeTexture?: boolean): void;
  116613. /**
  116614. * Clones the particle system.
  116615. * @param name The name of the cloned object
  116616. * @param newEmitter The new emitter to use
  116617. * @returns the cloned particle system
  116618. */
  116619. clone(name: string, newEmitter: any): GPUParticleSystem;
  116620. /**
  116621. * Serializes the particle system to a JSON object.
  116622. * @returns the JSON object
  116623. */
  116624. serialize(): any;
  116625. /**
  116626. * Parses a JSON object to create a GPU particle system.
  116627. * @param parsedParticleSystem The JSON object to parse
  116628. * @param scene The scene to create the particle system in
  116629. * @param rootUrl The root url to use to load external dependencies like texture
  116630. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  116631. * @returns the parsed GPU particle system
  116632. */
  116633. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  116634. }
  116635. }
  116636. declare module BABYLON {
  116637. /**
  116638. * Represents a set of particle systems working together to create a specific effect
  116639. */
  116640. export class ParticleSystemSet implements IDisposable {
  116641. private _emitterCreationOptions;
  116642. private _emitterNode;
  116643. /**
  116644. * Gets the particle system list
  116645. */
  116646. systems: IParticleSystem[];
  116647. /**
  116648. * Gets the emitter node used with this set
  116649. */
  116650. readonly emitterNode: Nullable<TransformNode>;
  116651. /**
  116652. * Creates a new emitter mesh as a sphere
  116653. * @param options defines the options used to create the sphere
  116654. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  116655. * @param scene defines the hosting scene
  116656. */
  116657. setEmitterAsSphere(options: {
  116658. diameter: number;
  116659. segments: number;
  116660. color: Color3;
  116661. }, renderingGroupId: number, scene: Scene): void;
  116662. /**
  116663. * Starts all particle systems of the set
  116664. * @param emitter defines an optional mesh to use as emitter for the particle systems
  116665. */
  116666. start(emitter?: AbstractMesh): void;
  116667. /**
  116668. * Release all associated resources
  116669. */
  116670. dispose(): void;
  116671. /**
  116672. * Serialize the set into a JSON compatible object
  116673. * @returns a JSON compatible representation of the set
  116674. */
  116675. serialize(): any;
  116676. /**
  116677. * Parse a new ParticleSystemSet from a serialized source
  116678. * @param data defines a JSON compatible representation of the set
  116679. * @param scene defines the hosting scene
  116680. * @param gpu defines if we want GPU particles or CPU particles
  116681. * @returns a new ParticleSystemSet
  116682. */
  116683. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  116684. }
  116685. }
  116686. declare module BABYLON {
  116687. /**
  116688. * This class is made for on one-liner static method to help creating particle system set.
  116689. */
  116690. export class ParticleHelper {
  116691. /**
  116692. * Gets or sets base Assets URL
  116693. */
  116694. static BaseAssetsUrl: string;
  116695. /**
  116696. * Create a default particle system that you can tweak
  116697. * @param emitter defines the emitter to use
  116698. * @param capacity defines the system capacity (default is 500 particles)
  116699. * @param scene defines the hosting scene
  116700. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  116701. * @returns the new Particle system
  116702. */
  116703. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  116704. /**
  116705. * This is the main static method (one-liner) of this helper to create different particle systems
  116706. * @param type This string represents the type to the particle system to create
  116707. * @param scene The scene where the particle system should live
  116708. * @param gpu If the system will use gpu
  116709. * @returns the ParticleSystemSet created
  116710. */
  116711. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  116712. /**
  116713. * Static function used to export a particle system to a ParticleSystemSet variable.
  116714. * Please note that the emitter shape is not exported
  116715. * @param systems defines the particle systems to export
  116716. * @returns the created particle system set
  116717. */
  116718. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  116719. }
  116720. }
  116721. declare module BABYLON {
  116722. interface Engine {
  116723. /**
  116724. * Create an effect to use with particle systems.
  116725. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  116726. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  116727. * @param uniformsNames defines a list of attribute names
  116728. * @param samplers defines an array of string used to represent textures
  116729. * @param defines defines the string containing the defines to use to compile the shaders
  116730. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116731. * @param onCompiled defines a function to call when the effect creation is successful
  116732. * @param onError defines a function to call when the effect creation has failed
  116733. * @returns the new Effect
  116734. */
  116735. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  116736. }
  116737. interface Mesh {
  116738. /**
  116739. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  116740. * @returns an array of IParticleSystem
  116741. */
  116742. getEmittedParticleSystems(): IParticleSystem[];
  116743. /**
  116744. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  116745. * @returns an array of IParticleSystem
  116746. */
  116747. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  116748. }
  116749. /**
  116750. * @hidden
  116751. */
  116752. export var _IDoNeedToBeInTheBuild: number;
  116753. }
  116754. declare module BABYLON {
  116755. interface Scene {
  116756. /** @hidden (Backing field) */
  116757. _physicsEngine: Nullable<IPhysicsEngine>;
  116758. /**
  116759. * Gets the current physics engine
  116760. * @returns a IPhysicsEngine or null if none attached
  116761. */
  116762. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  116763. /**
  116764. * Enables physics to the current scene
  116765. * @param gravity defines the scene's gravity for the physics engine
  116766. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  116767. * @return a boolean indicating if the physics engine was initialized
  116768. */
  116769. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  116770. /**
  116771. * Disables and disposes the physics engine associated with the scene
  116772. */
  116773. disablePhysicsEngine(): void;
  116774. /**
  116775. * Gets a boolean indicating if there is an active physics engine
  116776. * @returns a boolean indicating if there is an active physics engine
  116777. */
  116778. isPhysicsEnabled(): boolean;
  116779. /**
  116780. * Deletes a physics compound impostor
  116781. * @param compound defines the compound to delete
  116782. */
  116783. deleteCompoundImpostor(compound: any): void;
  116784. /**
  116785. * An event triggered when physic simulation is about to be run
  116786. */
  116787. onBeforePhysicsObservable: Observable<Scene>;
  116788. /**
  116789. * An event triggered when physic simulation has been done
  116790. */
  116791. onAfterPhysicsObservable: Observable<Scene>;
  116792. }
  116793. interface AbstractMesh {
  116794. /** @hidden */
  116795. _physicsImpostor: Nullable<PhysicsImpostor>;
  116796. /**
  116797. * Gets or sets impostor used for physic simulation
  116798. * @see http://doc.babylonjs.com/features/physics_engine
  116799. */
  116800. physicsImpostor: Nullable<PhysicsImpostor>;
  116801. /**
  116802. * Gets the current physics impostor
  116803. * @see http://doc.babylonjs.com/features/physics_engine
  116804. * @returns a physics impostor or null
  116805. */
  116806. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  116807. /** Apply a physic impulse to the mesh
  116808. * @param force defines the force to apply
  116809. * @param contactPoint defines where to apply the force
  116810. * @returns the current mesh
  116811. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116812. */
  116813. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  116814. /**
  116815. * Creates a physic joint between two meshes
  116816. * @param otherMesh defines the other mesh to use
  116817. * @param pivot1 defines the pivot to use on this mesh
  116818. * @param pivot2 defines the pivot to use on the other mesh
  116819. * @param options defines additional options (can be plugin dependent)
  116820. * @returns the current mesh
  116821. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  116822. */
  116823. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  116824. /** @hidden */
  116825. _disposePhysicsObserver: Nullable<Observer<Node>>;
  116826. }
  116827. /**
  116828. * Defines the physics engine scene component responsible to manage a physics engine
  116829. */
  116830. export class PhysicsEngineSceneComponent implements ISceneComponent {
  116831. /**
  116832. * The component name helpful to identify the component in the list of scene components.
  116833. */
  116834. readonly name: string;
  116835. /**
  116836. * The scene the component belongs to.
  116837. */
  116838. scene: Scene;
  116839. /**
  116840. * Creates a new instance of the component for the given scene
  116841. * @param scene Defines the scene to register the component in
  116842. */
  116843. constructor(scene: Scene);
  116844. /**
  116845. * Registers the component in a given scene
  116846. */
  116847. register(): void;
  116848. /**
  116849. * Rebuilds the elements related to this component in case of
  116850. * context lost for instance.
  116851. */
  116852. rebuild(): void;
  116853. /**
  116854. * Disposes the component and the associated ressources
  116855. */
  116856. dispose(): void;
  116857. }
  116858. }
  116859. declare module BABYLON {
  116860. /**
  116861. * A helper for physics simulations
  116862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116863. */
  116864. export class PhysicsHelper {
  116865. private _scene;
  116866. private _physicsEngine;
  116867. /**
  116868. * Initializes the Physics helper
  116869. * @param scene Babylon.js scene
  116870. */
  116871. constructor(scene: Scene);
  116872. /**
  116873. * Applies a radial explosion impulse
  116874. * @param origin the origin of the explosion
  116875. * @param radiusOrEventOptions the radius or the options of radial explosion
  116876. * @param strength the explosion strength
  116877. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116878. * @returns A physics radial explosion event, or null
  116879. */
  116880. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  116881. /**
  116882. * Applies a radial explosion force
  116883. * @param origin the origin of the explosion
  116884. * @param radiusOrEventOptions the radius or the options of radial explosion
  116885. * @param strength the explosion strength
  116886. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116887. * @returns A physics radial explosion event, or null
  116888. */
  116889. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  116890. /**
  116891. * Creates a gravitational field
  116892. * @param origin the origin of the explosion
  116893. * @param radiusOrEventOptions the radius or the options of radial explosion
  116894. * @param strength the explosion strength
  116895. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116896. * @returns A physics gravitational field event, or null
  116897. */
  116898. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  116899. /**
  116900. * Creates a physics updraft event
  116901. * @param origin the origin of the updraft
  116902. * @param radiusOrEventOptions the radius or the options of the updraft
  116903. * @param strength the strength of the updraft
  116904. * @param height the height of the updraft
  116905. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  116906. * @returns A physics updraft event, or null
  116907. */
  116908. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  116909. /**
  116910. * Creates a physics vortex event
  116911. * @param origin the of the vortex
  116912. * @param radiusOrEventOptions the radius or the options of the vortex
  116913. * @param strength the strength of the vortex
  116914. * @param height the height of the vortex
  116915. * @returns a Physics vortex event, or null
  116916. * A physics vortex event or null
  116917. */
  116918. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  116919. }
  116920. /**
  116921. * Represents a physics radial explosion event
  116922. */
  116923. class PhysicsRadialExplosionEvent {
  116924. private _scene;
  116925. private _options;
  116926. private _sphere;
  116927. private _dataFetched;
  116928. /**
  116929. * Initializes a radial explosioin event
  116930. * @param _scene BabylonJS scene
  116931. * @param _options The options for the vortex event
  116932. */
  116933. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  116934. /**
  116935. * Returns the data related to the radial explosion event (sphere).
  116936. * @returns The radial explosion event data
  116937. */
  116938. getData(): PhysicsRadialExplosionEventData;
  116939. /**
  116940. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  116941. * @param impostor A physics imposter
  116942. * @param origin the origin of the explosion
  116943. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  116944. */
  116945. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  116946. /**
  116947. * Triggers affecterd impostors callbacks
  116948. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  116949. */
  116950. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  116951. /**
  116952. * Disposes the sphere.
  116953. * @param force Specifies if the sphere should be disposed by force
  116954. */
  116955. dispose(force?: boolean): void;
  116956. /*** Helpers ***/
  116957. private _prepareSphere;
  116958. private _intersectsWithSphere;
  116959. }
  116960. /**
  116961. * Represents a gravitational field event
  116962. */
  116963. class PhysicsGravitationalFieldEvent {
  116964. private _physicsHelper;
  116965. private _scene;
  116966. private _origin;
  116967. private _options;
  116968. private _tickCallback;
  116969. private _sphere;
  116970. private _dataFetched;
  116971. /**
  116972. * Initializes the physics gravitational field event
  116973. * @param _physicsHelper A physics helper
  116974. * @param _scene BabylonJS scene
  116975. * @param _origin The origin position of the gravitational field event
  116976. * @param _options The options for the vortex event
  116977. */
  116978. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  116979. /**
  116980. * Returns the data related to the gravitational field event (sphere).
  116981. * @returns A gravitational field event
  116982. */
  116983. getData(): PhysicsGravitationalFieldEventData;
  116984. /**
  116985. * Enables the gravitational field.
  116986. */
  116987. enable(): void;
  116988. /**
  116989. * Disables the gravitational field.
  116990. */
  116991. disable(): void;
  116992. /**
  116993. * Disposes the sphere.
  116994. * @param force The force to dispose from the gravitational field event
  116995. */
  116996. dispose(force?: boolean): void;
  116997. private _tick;
  116998. }
  116999. /**
  117000. * Represents a physics updraft event
  117001. */
  117002. class PhysicsUpdraftEvent {
  117003. private _scene;
  117004. private _origin;
  117005. private _options;
  117006. private _physicsEngine;
  117007. private _originTop;
  117008. private _originDirection;
  117009. private _tickCallback;
  117010. private _cylinder;
  117011. private _cylinderPosition;
  117012. private _dataFetched;
  117013. /**
  117014. * Initializes the physics updraft event
  117015. * @param _scene BabylonJS scene
  117016. * @param _origin The origin position of the updraft
  117017. * @param _options The options for the updraft event
  117018. */
  117019. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  117020. /**
  117021. * Returns the data related to the updraft event (cylinder).
  117022. * @returns A physics updraft event
  117023. */
  117024. getData(): PhysicsUpdraftEventData;
  117025. /**
  117026. * Enables the updraft.
  117027. */
  117028. enable(): void;
  117029. /**
  117030. * Disables the updraft.
  117031. */
  117032. disable(): void;
  117033. /**
  117034. * Disposes the cylinder.
  117035. * @param force Specifies if the updraft should be disposed by force
  117036. */
  117037. dispose(force?: boolean): void;
  117038. private getImpostorHitData;
  117039. private _tick;
  117040. /*** Helpers ***/
  117041. private _prepareCylinder;
  117042. private _intersectsWithCylinder;
  117043. }
  117044. /**
  117045. * Represents a physics vortex event
  117046. */
  117047. class PhysicsVortexEvent {
  117048. private _scene;
  117049. private _origin;
  117050. private _options;
  117051. private _physicsEngine;
  117052. private _originTop;
  117053. private _tickCallback;
  117054. private _cylinder;
  117055. private _cylinderPosition;
  117056. private _dataFetched;
  117057. /**
  117058. * Initializes the physics vortex event
  117059. * @param _scene The BabylonJS scene
  117060. * @param _origin The origin position of the vortex
  117061. * @param _options The options for the vortex event
  117062. */
  117063. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  117064. /**
  117065. * Returns the data related to the vortex event (cylinder).
  117066. * @returns The physics vortex event data
  117067. */
  117068. getData(): PhysicsVortexEventData;
  117069. /**
  117070. * Enables the vortex.
  117071. */
  117072. enable(): void;
  117073. /**
  117074. * Disables the cortex.
  117075. */
  117076. disable(): void;
  117077. /**
  117078. * Disposes the sphere.
  117079. * @param force
  117080. */
  117081. dispose(force?: boolean): void;
  117082. private getImpostorHitData;
  117083. private _tick;
  117084. /*** Helpers ***/
  117085. private _prepareCylinder;
  117086. private _intersectsWithCylinder;
  117087. }
  117088. /**
  117089. * Options fot the radial explosion event
  117090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117091. */
  117092. export class PhysicsRadialExplosionEventOptions {
  117093. /**
  117094. * The radius of the sphere for the radial explosion.
  117095. */
  117096. radius: number;
  117097. /**
  117098. * The strenth of the explosion.
  117099. */
  117100. strength: number;
  117101. /**
  117102. * The strenght of the force in correspondence to the distance of the affected object
  117103. */
  117104. falloff: PhysicsRadialImpulseFalloff;
  117105. /**
  117106. * Sphere options for the radial explosion.
  117107. */
  117108. sphere: {
  117109. segments: number;
  117110. diameter: number;
  117111. };
  117112. /**
  117113. * Sphere options for the radial explosion.
  117114. */
  117115. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  117116. }
  117117. /**
  117118. * Options fot the updraft event
  117119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117120. */
  117121. export class PhysicsUpdraftEventOptions {
  117122. /**
  117123. * The radius of the cylinder for the vortex
  117124. */
  117125. radius: number;
  117126. /**
  117127. * The strenth of the updraft.
  117128. */
  117129. strength: number;
  117130. /**
  117131. * The height of the cylinder for the updraft.
  117132. */
  117133. height: number;
  117134. /**
  117135. * The mode for the the updraft.
  117136. */
  117137. updraftMode: PhysicsUpdraftMode;
  117138. }
  117139. /**
  117140. * Options fot the vortex event
  117141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117142. */
  117143. export class PhysicsVortexEventOptions {
  117144. /**
  117145. * The radius of the cylinder for the vortex
  117146. */
  117147. radius: number;
  117148. /**
  117149. * The strenth of the vortex.
  117150. */
  117151. strength: number;
  117152. /**
  117153. * The height of the cylinder for the vortex.
  117154. */
  117155. height: number;
  117156. /**
  117157. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  117158. */
  117159. centripetalForceThreshold: number;
  117160. /**
  117161. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  117162. */
  117163. centripetalForceMultiplier: number;
  117164. /**
  117165. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  117166. */
  117167. centrifugalForceMultiplier: number;
  117168. /**
  117169. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  117170. */
  117171. updraftForceMultiplier: number;
  117172. }
  117173. /**
  117174. * The strenght of the force in correspondence to the distance of the affected object
  117175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117176. */
  117177. export enum PhysicsRadialImpulseFalloff {
  117178. /** Defines that impulse is constant in strength across it's whole radius */
  117179. Constant = 0,
  117180. /** Defines that impulse gets weaker if it's further from the origin */
  117181. Linear = 1
  117182. }
  117183. /**
  117184. * The strength of the force in correspondence to the distance of the affected object
  117185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117186. */
  117187. export enum PhysicsUpdraftMode {
  117188. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  117189. Center = 0,
  117190. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  117191. Perpendicular = 1
  117192. }
  117193. /**
  117194. * Interface for a physics hit data
  117195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117196. */
  117197. export interface PhysicsHitData {
  117198. /**
  117199. * The force applied at the contact point
  117200. */
  117201. force: Vector3;
  117202. /**
  117203. * The contact point
  117204. */
  117205. contactPoint: Vector3;
  117206. /**
  117207. * The distance from the origin to the contact point
  117208. */
  117209. distanceFromOrigin: number;
  117210. }
  117211. /**
  117212. * Interface for radial explosion event data
  117213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117214. */
  117215. export interface PhysicsRadialExplosionEventData {
  117216. /**
  117217. * A sphere used for the radial explosion event
  117218. */
  117219. sphere: Mesh;
  117220. }
  117221. /**
  117222. * Interface for gravitational field event data
  117223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117224. */
  117225. export interface PhysicsGravitationalFieldEventData {
  117226. /**
  117227. * A sphere mesh used for the gravitational field event
  117228. */
  117229. sphere: Mesh;
  117230. }
  117231. /**
  117232. * Interface for updraft event data
  117233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117234. */
  117235. export interface PhysicsUpdraftEventData {
  117236. /**
  117237. * A cylinder used for the updraft event
  117238. */
  117239. cylinder: Mesh;
  117240. }
  117241. /**
  117242. * Interface for vortex event data
  117243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117244. */
  117245. export interface PhysicsVortexEventData {
  117246. /**
  117247. * A cylinder used for the vortex event
  117248. */
  117249. cylinder: Mesh;
  117250. }
  117251. /**
  117252. * Interface for an affected physics impostor
  117253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117254. */
  117255. export interface PhysicsAffectedImpostorWithData {
  117256. /**
  117257. * The impostor affected by the effect
  117258. */
  117259. impostor: PhysicsImpostor;
  117260. /**
  117261. * The data about the hit/horce from the explosion
  117262. */
  117263. hitData: PhysicsHitData;
  117264. }
  117265. }
  117266. declare module BABYLON {
  117267. /** @hidden */
  117268. export var blackAndWhitePixelShader: {
  117269. name: string;
  117270. shader: string;
  117271. };
  117272. }
  117273. declare module BABYLON {
  117274. /**
  117275. * Post process used to render in black and white
  117276. */
  117277. export class BlackAndWhitePostProcess extends PostProcess {
  117278. /**
  117279. * Linear about to convert he result to black and white (default: 1)
  117280. */
  117281. degree: number;
  117282. /**
  117283. * Creates a black and white post process
  117284. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  117285. * @param name The name of the effect.
  117286. * @param options The required width/height ratio to downsize to before computing the render pass.
  117287. * @param camera The camera to apply the render pass to.
  117288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117289. * @param engine The engine which the post process will be applied. (default: current engine)
  117290. * @param reusable If the post process can be reused on the same frame. (default: false)
  117291. */
  117292. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117293. }
  117294. }
  117295. declare module BABYLON {
  117296. /**
  117297. * This represents a set of one or more post processes in Babylon.
  117298. * A post process can be used to apply a shader to a texture after it is rendered.
  117299. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117300. */
  117301. export class PostProcessRenderEffect {
  117302. private _postProcesses;
  117303. private _getPostProcesses;
  117304. private _singleInstance;
  117305. private _cameras;
  117306. private _indicesForCamera;
  117307. /**
  117308. * Name of the effect
  117309. * @hidden
  117310. */
  117311. _name: string;
  117312. /**
  117313. * Instantiates a post process render effect.
  117314. * A post process can be used to apply a shader to a texture after it is rendered.
  117315. * @param engine The engine the effect is tied to
  117316. * @param name The name of the effect
  117317. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  117318. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  117319. */
  117320. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  117321. /**
  117322. * Checks if all the post processes in the effect are supported.
  117323. */
  117324. readonly isSupported: boolean;
  117325. /**
  117326. * Updates the current state of the effect
  117327. * @hidden
  117328. */
  117329. _update(): void;
  117330. /**
  117331. * Attaches the effect on cameras
  117332. * @param cameras The camera to attach to.
  117333. * @hidden
  117334. */
  117335. _attachCameras(cameras: Camera): void;
  117336. /**
  117337. * Attaches the effect on cameras
  117338. * @param cameras The camera to attach to.
  117339. * @hidden
  117340. */
  117341. _attachCameras(cameras: Camera[]): void;
  117342. /**
  117343. * Detaches the effect on cameras
  117344. * @param cameras The camera to detatch from.
  117345. * @hidden
  117346. */
  117347. _detachCameras(cameras: Camera): void;
  117348. /**
  117349. * Detatches the effect on cameras
  117350. * @param cameras The camera to detatch from.
  117351. * @hidden
  117352. */
  117353. _detachCameras(cameras: Camera[]): void;
  117354. /**
  117355. * Enables the effect on given cameras
  117356. * @param cameras The camera to enable.
  117357. * @hidden
  117358. */
  117359. _enable(cameras: Camera): void;
  117360. /**
  117361. * Enables the effect on given cameras
  117362. * @param cameras The camera to enable.
  117363. * @hidden
  117364. */
  117365. _enable(cameras: Nullable<Camera[]>): void;
  117366. /**
  117367. * Disables the effect on the given cameras
  117368. * @param cameras The camera to disable.
  117369. * @hidden
  117370. */
  117371. _disable(cameras: Camera): void;
  117372. /**
  117373. * Disables the effect on the given cameras
  117374. * @param cameras The camera to disable.
  117375. * @hidden
  117376. */
  117377. _disable(cameras: Nullable<Camera[]>): void;
  117378. /**
  117379. * Gets a list of the post processes contained in the effect.
  117380. * @param camera The camera to get the post processes on.
  117381. * @returns The list of the post processes in the effect.
  117382. */
  117383. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  117384. }
  117385. }
  117386. declare module BABYLON {
  117387. /** @hidden */
  117388. export var extractHighlightsPixelShader: {
  117389. name: string;
  117390. shader: string;
  117391. };
  117392. }
  117393. declare module BABYLON {
  117394. /**
  117395. * 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.
  117396. */
  117397. export class ExtractHighlightsPostProcess extends PostProcess {
  117398. /**
  117399. * The luminance threshold, pixels below this value will be set to black.
  117400. */
  117401. threshold: number;
  117402. /** @hidden */
  117403. _exposure: number;
  117404. /**
  117405. * Post process which has the input texture to be used when performing highlight extraction
  117406. * @hidden
  117407. */
  117408. _inputPostProcess: Nullable<PostProcess>;
  117409. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117410. }
  117411. }
  117412. declare module BABYLON {
  117413. /** @hidden */
  117414. export var bloomMergePixelShader: {
  117415. name: string;
  117416. shader: string;
  117417. };
  117418. }
  117419. declare module BABYLON {
  117420. /**
  117421. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117422. */
  117423. export class BloomMergePostProcess extends PostProcess {
  117424. /** Weight of the bloom to be added to the original input. */
  117425. weight: number;
  117426. /**
  117427. * Creates a new instance of @see BloomMergePostProcess
  117428. * @param name The name of the effect.
  117429. * @param originalFromInput Post process which's input will be used for the merge.
  117430. * @param blurred Blurred highlights post process which's output will be used.
  117431. * @param weight Weight of the bloom to be added to the original input.
  117432. * @param options The required width/height ratio to downsize to before computing the render pass.
  117433. * @param camera The camera to apply the render pass to.
  117434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117435. * @param engine The engine which the post process will be applied. (default: current engine)
  117436. * @param reusable If the post process can be reused on the same frame. (default: false)
  117437. * @param textureType Type of textures used when performing the post process. (default: 0)
  117438. * @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)
  117439. */
  117440. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  117441. /** Weight of the bloom to be added to the original input. */
  117442. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117443. }
  117444. }
  117445. declare module BABYLON {
  117446. /**
  117447. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  117448. */
  117449. export class BloomEffect extends PostProcessRenderEffect {
  117450. private bloomScale;
  117451. /**
  117452. * @hidden Internal
  117453. */
  117454. _effects: Array<PostProcess>;
  117455. /**
  117456. * @hidden Internal
  117457. */
  117458. _downscale: ExtractHighlightsPostProcess;
  117459. private _blurX;
  117460. private _blurY;
  117461. private _merge;
  117462. /**
  117463. * The luminance threshold to find bright areas of the image to bloom.
  117464. */
  117465. threshold: number;
  117466. /**
  117467. * The strength of the bloom.
  117468. */
  117469. weight: number;
  117470. /**
  117471. * Specifies the size of the bloom blur kernel, relative to the final output size
  117472. */
  117473. kernel: number;
  117474. /**
  117475. * Creates a new instance of @see BloomEffect
  117476. * @param scene The scene the effect belongs to.
  117477. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  117478. * @param bloomKernel The size of the kernel to be used when applying the blur.
  117479. * @param bloomWeight The the strength of bloom.
  117480. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117481. * @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)
  117482. */
  117483. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  117484. /**
  117485. * Disposes each of the internal effects for a given camera.
  117486. * @param camera The camera to dispose the effect on.
  117487. */
  117488. disposeEffects(camera: Camera): void;
  117489. /**
  117490. * @hidden Internal
  117491. */
  117492. _updateEffects(): void;
  117493. /**
  117494. * Internal
  117495. * @returns if all the contained post processes are ready.
  117496. * @hidden
  117497. */
  117498. _isReady(): boolean;
  117499. }
  117500. }
  117501. declare module BABYLON {
  117502. /** @hidden */
  117503. export var chromaticAberrationPixelShader: {
  117504. name: string;
  117505. shader: string;
  117506. };
  117507. }
  117508. declare module BABYLON {
  117509. /**
  117510. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  117511. */
  117512. export class ChromaticAberrationPostProcess extends PostProcess {
  117513. /**
  117514. * The amount of seperation of rgb channels (default: 30)
  117515. */
  117516. aberrationAmount: number;
  117517. /**
  117518. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  117519. */
  117520. radialIntensity: number;
  117521. /**
  117522. * 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))
  117523. */
  117524. direction: Vector2;
  117525. /**
  117526. * 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))
  117527. */
  117528. centerPosition: Vector2;
  117529. /**
  117530. * Creates a new instance ChromaticAberrationPostProcess
  117531. * @param name The name of the effect.
  117532. * @param screenWidth The width of the screen to apply the effect on.
  117533. * @param screenHeight The height of the screen to apply the effect on.
  117534. * @param options The required width/height ratio to downsize to before computing the render pass.
  117535. * @param camera The camera to apply the render pass to.
  117536. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117537. * @param engine The engine which the post process will be applied. (default: current engine)
  117538. * @param reusable If the post process can be reused on the same frame. (default: false)
  117539. * @param textureType Type of textures used when performing the post process. (default: 0)
  117540. * @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)
  117541. */
  117542. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117543. }
  117544. }
  117545. declare module BABYLON {
  117546. /** @hidden */
  117547. export var circleOfConfusionPixelShader: {
  117548. name: string;
  117549. shader: string;
  117550. };
  117551. }
  117552. declare module BABYLON {
  117553. /**
  117554. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  117555. */
  117556. export class CircleOfConfusionPostProcess extends PostProcess {
  117557. /**
  117558. * 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.
  117559. */
  117560. lensSize: number;
  117561. /**
  117562. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117563. */
  117564. fStop: number;
  117565. /**
  117566. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117567. */
  117568. focusDistance: number;
  117569. /**
  117570. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  117571. */
  117572. focalLength: number;
  117573. private _depthTexture;
  117574. /**
  117575. * Creates a new instance CircleOfConfusionPostProcess
  117576. * @param name The name of the effect.
  117577. * @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.
  117578. * @param options The required width/height ratio to downsize to before computing the render pass.
  117579. * @param camera The camera to apply the render pass to.
  117580. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117581. * @param engine The engine which the post process will be applied. (default: current engine)
  117582. * @param reusable If the post process can be reused on the same frame. (default: false)
  117583. * @param textureType Type of textures used when performing the post process. (default: 0)
  117584. * @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)
  117585. */
  117586. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117587. /**
  117588. * 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.
  117589. */
  117590. depthTexture: RenderTargetTexture;
  117591. }
  117592. }
  117593. declare module BABYLON {
  117594. /** @hidden */
  117595. export var colorCorrectionPixelShader: {
  117596. name: string;
  117597. shader: string;
  117598. };
  117599. }
  117600. declare module BABYLON {
  117601. /**
  117602. *
  117603. * This post-process allows the modification of rendered colors by using
  117604. * a 'look-up table' (LUT). This effect is also called Color Grading.
  117605. *
  117606. * The object needs to be provided an url to a texture containing the color
  117607. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  117608. * Use an image editing software to tweak the LUT to match your needs.
  117609. *
  117610. * For an example of a color LUT, see here:
  117611. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  117612. * For explanations on color grading, see here:
  117613. * @see http://udn.epicgames.com/Three/ColorGrading.html
  117614. *
  117615. */
  117616. export class ColorCorrectionPostProcess extends PostProcess {
  117617. private _colorTableTexture;
  117618. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117619. }
  117620. }
  117621. declare module BABYLON {
  117622. /** @hidden */
  117623. export var convolutionPixelShader: {
  117624. name: string;
  117625. shader: string;
  117626. };
  117627. }
  117628. declare module BABYLON {
  117629. /**
  117630. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  117631. * input texture to perform effects such as edge detection or sharpening
  117632. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117633. */
  117634. export class ConvolutionPostProcess extends PostProcess {
  117635. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  117636. kernel: number[];
  117637. /**
  117638. * Creates a new instance ConvolutionPostProcess
  117639. * @param name The name of the effect.
  117640. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  117641. * @param options The required width/height ratio to downsize to before computing the render pass.
  117642. * @param camera The camera to apply the render pass to.
  117643. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117644. * @param engine The engine which the post process will be applied. (default: current engine)
  117645. * @param reusable If the post process can be reused on the same frame. (default: false)
  117646. * @param textureType Type of textures used when performing the post process. (default: 0)
  117647. */
  117648. constructor(name: string,
  117649. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  117650. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117651. /**
  117652. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117653. */
  117654. static EdgeDetect0Kernel: number[];
  117655. /**
  117656. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117657. */
  117658. static EdgeDetect1Kernel: number[];
  117659. /**
  117660. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117661. */
  117662. static EdgeDetect2Kernel: number[];
  117663. /**
  117664. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117665. */
  117666. static SharpenKernel: number[];
  117667. /**
  117668. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117669. */
  117670. static EmbossKernel: number[];
  117671. /**
  117672. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117673. */
  117674. static GaussianKernel: number[];
  117675. }
  117676. }
  117677. declare module BABYLON {
  117678. /**
  117679. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  117680. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  117681. * based on samples that have a large difference in distance than the center pixel.
  117682. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  117683. */
  117684. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  117685. direction: Vector2;
  117686. /**
  117687. * Creates a new instance CircleOfConfusionPostProcess
  117688. * @param name The name of the effect.
  117689. * @param scene The scene the effect belongs to.
  117690. * @param direction The direction the blur should be applied.
  117691. * @param kernel The size of the kernel used to blur.
  117692. * @param options The required width/height ratio to downsize to before computing the render pass.
  117693. * @param camera The camera to apply the render pass to.
  117694. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  117695. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  117696. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117697. * @param engine The engine which the post process will be applied. (default: current engine)
  117698. * @param reusable If the post process can be reused on the same frame. (default: false)
  117699. * @param textureType Type of textures used when performing the post process. (default: 0)
  117700. * @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)
  117701. */
  117702. 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);
  117703. }
  117704. }
  117705. declare module BABYLON {
  117706. /** @hidden */
  117707. export var depthOfFieldMergePixelShader: {
  117708. name: string;
  117709. shader: string;
  117710. };
  117711. }
  117712. declare module BABYLON {
  117713. /**
  117714. * Options to be set when merging outputs from the default pipeline.
  117715. */
  117716. export class DepthOfFieldMergePostProcessOptions {
  117717. /**
  117718. * The original image to merge on top of
  117719. */
  117720. originalFromInput: PostProcess;
  117721. /**
  117722. * Parameters to perform the merge of the depth of field effect
  117723. */
  117724. depthOfField?: {
  117725. circleOfConfusion: PostProcess;
  117726. blurSteps: Array<PostProcess>;
  117727. };
  117728. /**
  117729. * Parameters to perform the merge of bloom effect
  117730. */
  117731. bloom?: {
  117732. blurred: PostProcess;
  117733. weight: number;
  117734. };
  117735. }
  117736. /**
  117737. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117738. */
  117739. export class DepthOfFieldMergePostProcess extends PostProcess {
  117740. private blurSteps;
  117741. /**
  117742. * Creates a new instance of DepthOfFieldMergePostProcess
  117743. * @param name The name of the effect.
  117744. * @param originalFromInput Post process which's input will be used for the merge.
  117745. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  117746. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  117747. * @param options The required width/height ratio to downsize to before computing the render pass.
  117748. * @param camera The camera to apply the render pass to.
  117749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117750. * @param engine The engine which the post process will be applied. (default: current engine)
  117751. * @param reusable If the post process can be reused on the same frame. (default: false)
  117752. * @param textureType Type of textures used when performing the post process. (default: 0)
  117753. * @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)
  117754. */
  117755. 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);
  117756. /**
  117757. * Updates the effect with the current post process compile time values and recompiles the shader.
  117758. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  117759. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  117760. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  117761. * @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
  117762. * @param onCompiled Called when the shader has been compiled.
  117763. * @param onError Called if there is an error when compiling a shader.
  117764. */
  117765. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  117766. }
  117767. }
  117768. declare module BABYLON {
  117769. /**
  117770. * Specifies the level of max blur that should be applied when using the depth of field effect
  117771. */
  117772. export enum DepthOfFieldEffectBlurLevel {
  117773. /**
  117774. * Subtle blur
  117775. */
  117776. Low = 0,
  117777. /**
  117778. * Medium blur
  117779. */
  117780. Medium = 1,
  117781. /**
  117782. * Large blur
  117783. */
  117784. High = 2
  117785. }
  117786. /**
  117787. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  117788. */
  117789. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  117790. private _circleOfConfusion;
  117791. /**
  117792. * @hidden Internal, blurs from high to low
  117793. */
  117794. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  117795. private _depthOfFieldBlurY;
  117796. private _dofMerge;
  117797. /**
  117798. * @hidden Internal post processes in depth of field effect
  117799. */
  117800. _effects: Array<PostProcess>;
  117801. /**
  117802. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  117803. */
  117804. focalLength: number;
  117805. /**
  117806. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117807. */
  117808. fStop: number;
  117809. /**
  117810. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117811. */
  117812. focusDistance: number;
  117813. /**
  117814. * 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.
  117815. */
  117816. lensSize: number;
  117817. /**
  117818. * Creates a new instance DepthOfFieldEffect
  117819. * @param scene The scene the effect belongs to.
  117820. * @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.
  117821. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117822. * @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)
  117823. */
  117824. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  117825. /**
  117826. * Get the current class name of the current effet
  117827. * @returns "DepthOfFieldEffect"
  117828. */
  117829. getClassName(): string;
  117830. /**
  117831. * 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.
  117832. */
  117833. depthTexture: RenderTargetTexture;
  117834. /**
  117835. * Disposes each of the internal effects for a given camera.
  117836. * @param camera The camera to dispose the effect on.
  117837. */
  117838. disposeEffects(camera: Camera): void;
  117839. /**
  117840. * @hidden Internal
  117841. */
  117842. _updateEffects(): void;
  117843. /**
  117844. * Internal
  117845. * @returns if all the contained post processes are ready.
  117846. * @hidden
  117847. */
  117848. _isReady(): boolean;
  117849. }
  117850. }
  117851. declare module BABYLON {
  117852. /** @hidden */
  117853. export var displayPassPixelShader: {
  117854. name: string;
  117855. shader: string;
  117856. };
  117857. }
  117858. declare module BABYLON {
  117859. /**
  117860. * DisplayPassPostProcess which produces an output the same as it's input
  117861. */
  117862. export class DisplayPassPostProcess extends PostProcess {
  117863. /**
  117864. * Creates the DisplayPassPostProcess
  117865. * @param name The name of the effect.
  117866. * @param options The required width/height ratio to downsize to before computing the render pass.
  117867. * @param camera The camera to apply the render pass to.
  117868. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117869. * @param engine The engine which the post process will be applied. (default: current engine)
  117870. * @param reusable If the post process can be reused on the same frame. (default: false)
  117871. */
  117872. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117873. }
  117874. }
  117875. declare module BABYLON {
  117876. /** @hidden */
  117877. export var filterPixelShader: {
  117878. name: string;
  117879. shader: string;
  117880. };
  117881. }
  117882. declare module BABYLON {
  117883. /**
  117884. * Applies a kernel filter to the image
  117885. */
  117886. export class FilterPostProcess extends PostProcess {
  117887. /** The matrix to be applied to the image */
  117888. kernelMatrix: Matrix;
  117889. /**
  117890. *
  117891. * @param name The name of the effect.
  117892. * @param kernelMatrix The matrix to be applied to the image
  117893. * @param options The required width/height ratio to downsize to before computing the render pass.
  117894. * @param camera The camera to apply the render pass to.
  117895. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117896. * @param engine The engine which the post process will be applied. (default: current engine)
  117897. * @param reusable If the post process can be reused on the same frame. (default: false)
  117898. */
  117899. constructor(name: string,
  117900. /** The matrix to be applied to the image */
  117901. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117902. }
  117903. }
  117904. declare module BABYLON {
  117905. /** @hidden */
  117906. export var fxaaPixelShader: {
  117907. name: string;
  117908. shader: string;
  117909. };
  117910. }
  117911. declare module BABYLON {
  117912. /** @hidden */
  117913. export var fxaaVertexShader: {
  117914. name: string;
  117915. shader: string;
  117916. };
  117917. }
  117918. declare module BABYLON {
  117919. /**
  117920. * Fxaa post process
  117921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  117922. */
  117923. export class FxaaPostProcess extends PostProcess {
  117924. /** @hidden */
  117925. texelWidth: number;
  117926. /** @hidden */
  117927. texelHeight: number;
  117928. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117929. private _getDefines;
  117930. }
  117931. }
  117932. declare module BABYLON {
  117933. /** @hidden */
  117934. export var grainPixelShader: {
  117935. name: string;
  117936. shader: string;
  117937. };
  117938. }
  117939. declare module BABYLON {
  117940. /**
  117941. * The GrainPostProcess adds noise to the image at mid luminance levels
  117942. */
  117943. export class GrainPostProcess extends PostProcess {
  117944. /**
  117945. * The intensity of the grain added (default: 30)
  117946. */
  117947. intensity: number;
  117948. /**
  117949. * If the grain should be randomized on every frame
  117950. */
  117951. animated: boolean;
  117952. /**
  117953. * Creates a new instance of @see GrainPostProcess
  117954. * @param name The name of the effect.
  117955. * @param options The required width/height ratio to downsize to before computing the render pass.
  117956. * @param camera The camera to apply the render pass to.
  117957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117958. * @param engine The engine which the post process will be applied. (default: current engine)
  117959. * @param reusable If the post process can be reused on the same frame. (default: false)
  117960. * @param textureType Type of textures used when performing the post process. (default: 0)
  117961. * @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)
  117962. */
  117963. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117964. }
  117965. }
  117966. declare module BABYLON {
  117967. /** @hidden */
  117968. export var highlightsPixelShader: {
  117969. name: string;
  117970. shader: string;
  117971. };
  117972. }
  117973. declare module BABYLON {
  117974. /**
  117975. * Extracts highlights from the image
  117976. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117977. */
  117978. export class HighlightsPostProcess extends PostProcess {
  117979. /**
  117980. * Extracts highlights from the image
  117981. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117982. * @param name The name of the effect.
  117983. * @param options The required width/height ratio to downsize to before computing the render pass.
  117984. * @param camera The camera to apply the render pass to.
  117985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117986. * @param engine The engine which the post process will be applied. (default: current engine)
  117987. * @param reusable If the post process can be reused on the same frame. (default: false)
  117988. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  117989. */
  117990. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117991. }
  117992. }
  117993. declare module BABYLON {
  117994. /** @hidden */
  117995. export var mrtFragmentDeclaration: {
  117996. name: string;
  117997. shader: string;
  117998. };
  117999. }
  118000. declare module BABYLON {
  118001. /** @hidden */
  118002. export var geometryPixelShader: {
  118003. name: string;
  118004. shader: string;
  118005. };
  118006. }
  118007. declare module BABYLON {
  118008. /** @hidden */
  118009. export var geometryVertexShader: {
  118010. name: string;
  118011. shader: string;
  118012. };
  118013. }
  118014. declare module BABYLON {
  118015. /** @hidden */
  118016. interface ISavedTransformationMatrix {
  118017. world: Matrix;
  118018. viewProjection: Matrix;
  118019. }
  118020. /**
  118021. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  118022. */
  118023. export class GeometryBufferRenderer {
  118024. /**
  118025. * Constant used to retrieve the position texture index in the G-Buffer textures array
  118026. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  118027. */
  118028. static readonly POSITION_TEXTURE_TYPE: number;
  118029. /**
  118030. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  118031. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  118032. */
  118033. static readonly VELOCITY_TEXTURE_TYPE: number;
  118034. /**
  118035. * Dictionary used to store the previous transformation matrices of each rendered mesh
  118036. * in order to compute objects velocities when enableVelocity is set to "true"
  118037. * @hidden
  118038. */
  118039. _previousTransformationMatrices: {
  118040. [index: number]: ISavedTransformationMatrix;
  118041. };
  118042. /**
  118043. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  118044. * in order to compute objects velocities when enableVelocity is set to "true"
  118045. * @hidden
  118046. */
  118047. _previousBonesTransformationMatrices: {
  118048. [index: number]: Float32Array;
  118049. };
  118050. /**
  118051. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  118052. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  118053. */
  118054. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  118055. private _scene;
  118056. private _multiRenderTarget;
  118057. private _ratio;
  118058. private _enablePosition;
  118059. private _enableVelocity;
  118060. private _positionIndex;
  118061. private _velocityIndex;
  118062. protected _effect: Effect;
  118063. protected _cachedDefines: string;
  118064. /**
  118065. * Set the render list (meshes to be rendered) used in the G buffer.
  118066. */
  118067. renderList: Mesh[];
  118068. /**
  118069. * Gets wether or not G buffer are supported by the running hardware.
  118070. * This requires draw buffer supports
  118071. */
  118072. readonly isSupported: boolean;
  118073. /**
  118074. * Returns the index of the given texture type in the G-Buffer textures array
  118075. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  118076. * @returns the index of the given texture type in the G-Buffer textures array
  118077. */
  118078. getTextureIndex(textureType: number): number;
  118079. /**
  118080. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  118081. */
  118082. /**
  118083. * Sets whether or not objects positions are enabled for the G buffer.
  118084. */
  118085. enablePosition: boolean;
  118086. /**
  118087. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  118088. */
  118089. /**
  118090. * Sets wether or not objects velocities are enabled for the G buffer.
  118091. */
  118092. enableVelocity: boolean;
  118093. /**
  118094. * Gets the scene associated with the buffer.
  118095. */
  118096. readonly scene: Scene;
  118097. /**
  118098. * Gets the ratio used by the buffer during its creation.
  118099. * How big is the buffer related to the main canvas.
  118100. */
  118101. readonly ratio: number;
  118102. /** @hidden */
  118103. static _SceneComponentInitialization: (scene: Scene) => void;
  118104. /**
  118105. * Creates a new G Buffer for the scene
  118106. * @param scene The scene the buffer belongs to
  118107. * @param ratio How big is the buffer related to the main canvas.
  118108. */
  118109. constructor(scene: Scene, ratio?: number);
  118110. /**
  118111. * Checks wether everything is ready to render a submesh to the G buffer.
  118112. * @param subMesh the submesh to check readiness for
  118113. * @param useInstances is the mesh drawn using instance or not
  118114. * @returns true if ready otherwise false
  118115. */
  118116. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118117. /**
  118118. * Gets the current underlying G Buffer.
  118119. * @returns the buffer
  118120. */
  118121. getGBuffer(): MultiRenderTarget;
  118122. /**
  118123. * Gets the number of samples used to render the buffer (anti aliasing).
  118124. */
  118125. /**
  118126. * Sets the number of samples used to render the buffer (anti aliasing).
  118127. */
  118128. samples: number;
  118129. /**
  118130. * Disposes the renderer and frees up associated resources.
  118131. */
  118132. dispose(): void;
  118133. protected _createRenderTargets(): void;
  118134. private _copyBonesTransformationMatrices;
  118135. }
  118136. }
  118137. declare module BABYLON {
  118138. interface Scene {
  118139. /** @hidden (Backing field) */
  118140. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118141. /**
  118142. * Gets or Sets the current geometry buffer associated to the scene.
  118143. */
  118144. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118145. /**
  118146. * Enables a GeometryBufferRender and associates it with the scene
  118147. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  118148. * @returns the GeometryBufferRenderer
  118149. */
  118150. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  118151. /**
  118152. * Disables the GeometryBufferRender associated with the scene
  118153. */
  118154. disableGeometryBufferRenderer(): void;
  118155. }
  118156. /**
  118157. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  118158. * in several rendering techniques.
  118159. */
  118160. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  118161. /**
  118162. * The component name helpful to identify the component in the list of scene components.
  118163. */
  118164. readonly name: string;
  118165. /**
  118166. * The scene the component belongs to.
  118167. */
  118168. scene: Scene;
  118169. /**
  118170. * Creates a new instance of the component for the given scene
  118171. * @param scene Defines the scene to register the component in
  118172. */
  118173. constructor(scene: Scene);
  118174. /**
  118175. * Registers the component in a given scene
  118176. */
  118177. register(): void;
  118178. /**
  118179. * Rebuilds the elements related to this component in case of
  118180. * context lost for instance.
  118181. */
  118182. rebuild(): void;
  118183. /**
  118184. * Disposes the component and the associated ressources
  118185. */
  118186. dispose(): void;
  118187. private _gatherRenderTargets;
  118188. }
  118189. }
  118190. declare module BABYLON {
  118191. /** @hidden */
  118192. export var motionBlurPixelShader: {
  118193. name: string;
  118194. shader: string;
  118195. };
  118196. }
  118197. declare module BABYLON {
  118198. /**
  118199. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118200. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118201. * As an example, all you have to do is to create the post-process:
  118202. * var mb = new BABYLON.MotionBlurPostProcess(
  118203. * 'mb', // The name of the effect.
  118204. * scene, // The scene containing the objects to blur according to their velocity.
  118205. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118206. * camera // The camera to apply the render pass to.
  118207. * );
  118208. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118209. */
  118210. export class MotionBlurPostProcess extends PostProcess {
  118211. /**
  118212. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118213. */
  118214. motionStrength: number;
  118215. /**
  118216. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118217. */
  118218. /**
  118219. * Sets the number of iterations to be used for motion blur quality
  118220. */
  118221. motionBlurSamples: number;
  118222. private _motionBlurSamples;
  118223. private _geometryBufferRenderer;
  118224. /**
  118225. * Creates a new instance MotionBlurPostProcess
  118226. * @param name The name of the effect.
  118227. * @param scene The scene containing the objects to blur according to their velocity.
  118228. * @param options The required width/height ratio to downsize to before computing the render pass.
  118229. * @param camera The camera to apply the render pass to.
  118230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118231. * @param engine The engine which the post process will be applied. (default: current engine)
  118232. * @param reusable If the post process can be reused on the same frame. (default: false)
  118233. * @param textureType Type of textures used when performing the post process. (default: 0)
  118234. * @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)
  118235. */
  118236. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118237. /**
  118238. * Excludes the given skinned mesh from computing bones velocities.
  118239. * 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.
  118240. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  118241. */
  118242. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118243. /**
  118244. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  118245. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  118246. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  118247. */
  118248. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118249. /**
  118250. * Disposes the post process.
  118251. * @param camera The camera to dispose the post process on.
  118252. */
  118253. dispose(camera?: Camera): void;
  118254. }
  118255. }
  118256. declare module BABYLON {
  118257. /** @hidden */
  118258. export var refractionPixelShader: {
  118259. name: string;
  118260. shader: string;
  118261. };
  118262. }
  118263. declare module BABYLON {
  118264. /**
  118265. * Post process which applies a refractin texture
  118266. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118267. */
  118268. export class RefractionPostProcess extends PostProcess {
  118269. /** the base color of the refraction (used to taint the rendering) */
  118270. color: Color3;
  118271. /** simulated refraction depth */
  118272. depth: number;
  118273. /** the coefficient of the base color (0 to remove base color tainting) */
  118274. colorLevel: number;
  118275. private _refTexture;
  118276. private _ownRefractionTexture;
  118277. /**
  118278. * Gets or sets the refraction texture
  118279. * Please note that you are responsible for disposing the texture if you set it manually
  118280. */
  118281. refractionTexture: Texture;
  118282. /**
  118283. * Initializes the RefractionPostProcess
  118284. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118285. * @param name The name of the effect.
  118286. * @param refractionTextureUrl Url of the refraction texture to use
  118287. * @param color the base color of the refraction (used to taint the rendering)
  118288. * @param depth simulated refraction depth
  118289. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  118290. * @param camera The camera to apply the render pass to.
  118291. * @param options The required width/height ratio to downsize to before computing the render pass.
  118292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118293. * @param engine The engine which the post process will be applied. (default: current engine)
  118294. * @param reusable If the post process can be reused on the same frame. (default: false)
  118295. */
  118296. constructor(name: string, refractionTextureUrl: string,
  118297. /** the base color of the refraction (used to taint the rendering) */
  118298. color: Color3,
  118299. /** simulated refraction depth */
  118300. depth: number,
  118301. /** the coefficient of the base color (0 to remove base color tainting) */
  118302. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118303. /**
  118304. * Disposes of the post process
  118305. * @param camera Camera to dispose post process on
  118306. */
  118307. dispose(camera: Camera): void;
  118308. }
  118309. }
  118310. declare module BABYLON {
  118311. /** @hidden */
  118312. export var sharpenPixelShader: {
  118313. name: string;
  118314. shader: string;
  118315. };
  118316. }
  118317. declare module BABYLON {
  118318. /**
  118319. * The SharpenPostProcess applies a sharpen kernel to every pixel
  118320. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118321. */
  118322. export class SharpenPostProcess extends PostProcess {
  118323. /**
  118324. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  118325. */
  118326. colorAmount: number;
  118327. /**
  118328. * How much sharpness should be applied (default: 0.3)
  118329. */
  118330. edgeAmount: number;
  118331. /**
  118332. * Creates a new instance ConvolutionPostProcess
  118333. * @param name The name of the effect.
  118334. * @param options The required width/height ratio to downsize to before computing the render pass.
  118335. * @param camera The camera to apply the render pass to.
  118336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118337. * @param engine The engine which the post process will be applied. (default: current engine)
  118338. * @param reusable If the post process can be reused on the same frame. (default: false)
  118339. * @param textureType Type of textures used when performing the post process. (default: 0)
  118340. * @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)
  118341. */
  118342. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118343. }
  118344. }
  118345. declare module BABYLON {
  118346. /**
  118347. * PostProcessRenderPipeline
  118348. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118349. */
  118350. export class PostProcessRenderPipeline {
  118351. private engine;
  118352. private _renderEffects;
  118353. private _renderEffectsForIsolatedPass;
  118354. /**
  118355. * List of inspectable custom properties (used by the Inspector)
  118356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  118357. */
  118358. inspectableCustomProperties: IInspectable[];
  118359. /**
  118360. * @hidden
  118361. */
  118362. protected _cameras: Camera[];
  118363. /** @hidden */
  118364. _name: string;
  118365. /**
  118366. * Gets pipeline name
  118367. */
  118368. readonly name: string;
  118369. /**
  118370. * Initializes a PostProcessRenderPipeline
  118371. * @param engine engine to add the pipeline to
  118372. * @param name name of the pipeline
  118373. */
  118374. constructor(engine: Engine, name: string);
  118375. /**
  118376. * Gets the class name
  118377. * @returns "PostProcessRenderPipeline"
  118378. */
  118379. getClassName(): string;
  118380. /**
  118381. * If all the render effects in the pipeline are supported
  118382. */
  118383. readonly isSupported: boolean;
  118384. /**
  118385. * Adds an effect to the pipeline
  118386. * @param renderEffect the effect to add
  118387. */
  118388. addEffect(renderEffect: PostProcessRenderEffect): void;
  118389. /** @hidden */
  118390. _rebuild(): void;
  118391. /** @hidden */
  118392. _enableEffect(renderEffectName: string, cameras: Camera): void;
  118393. /** @hidden */
  118394. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  118395. /** @hidden */
  118396. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  118397. /** @hidden */
  118398. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  118399. /** @hidden */
  118400. _attachCameras(cameras: Camera, unique: boolean): void;
  118401. /** @hidden */
  118402. _attachCameras(cameras: Camera[], unique: boolean): void;
  118403. /** @hidden */
  118404. _detachCameras(cameras: Camera): void;
  118405. /** @hidden */
  118406. _detachCameras(cameras: Nullable<Camera[]>): void;
  118407. /** @hidden */
  118408. _update(): void;
  118409. /** @hidden */
  118410. _reset(): void;
  118411. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  118412. /**
  118413. * Disposes of the pipeline
  118414. */
  118415. dispose(): void;
  118416. }
  118417. }
  118418. declare module BABYLON {
  118419. /**
  118420. * PostProcessRenderPipelineManager class
  118421. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118422. */
  118423. export class PostProcessRenderPipelineManager {
  118424. private _renderPipelines;
  118425. /**
  118426. * Initializes a PostProcessRenderPipelineManager
  118427. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118428. */
  118429. constructor();
  118430. /**
  118431. * Gets the list of supported render pipelines
  118432. */
  118433. readonly supportedPipelines: PostProcessRenderPipeline[];
  118434. /**
  118435. * Adds a pipeline to the manager
  118436. * @param renderPipeline The pipeline to add
  118437. */
  118438. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  118439. /**
  118440. * Attaches a camera to the pipeline
  118441. * @param renderPipelineName The name of the pipeline to attach to
  118442. * @param cameras the camera to attach
  118443. * @param unique if the camera can be attached multiple times to the pipeline
  118444. */
  118445. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  118446. /**
  118447. * Detaches a camera from the pipeline
  118448. * @param renderPipelineName The name of the pipeline to detach from
  118449. * @param cameras the camera to detach
  118450. */
  118451. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  118452. /**
  118453. * Enables an effect by name on a pipeline
  118454. * @param renderPipelineName the name of the pipeline to enable the effect in
  118455. * @param renderEffectName the name of the effect to enable
  118456. * @param cameras the cameras that the effect should be enabled on
  118457. */
  118458. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  118459. /**
  118460. * Disables an effect by name on a pipeline
  118461. * @param renderPipelineName the name of the pipeline to disable the effect in
  118462. * @param renderEffectName the name of the effect to disable
  118463. * @param cameras the cameras that the effect should be disabled on
  118464. */
  118465. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  118466. /**
  118467. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  118468. */
  118469. update(): void;
  118470. /** @hidden */
  118471. _rebuild(): void;
  118472. /**
  118473. * Disposes of the manager and pipelines
  118474. */
  118475. dispose(): void;
  118476. }
  118477. }
  118478. declare module BABYLON {
  118479. interface Scene {
  118480. /** @hidden (Backing field) */
  118481. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  118482. /**
  118483. * Gets the postprocess render pipeline manager
  118484. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118485. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118486. */
  118487. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  118488. }
  118489. /**
  118490. * Defines the Render Pipeline scene component responsible to rendering pipelines
  118491. */
  118492. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  118493. /**
  118494. * The component name helpfull to identify the component in the list of scene components.
  118495. */
  118496. readonly name: string;
  118497. /**
  118498. * The scene the component belongs to.
  118499. */
  118500. scene: Scene;
  118501. /**
  118502. * Creates a new instance of the component for the given scene
  118503. * @param scene Defines the scene to register the component in
  118504. */
  118505. constructor(scene: Scene);
  118506. /**
  118507. * Registers the component in a given scene
  118508. */
  118509. register(): void;
  118510. /**
  118511. * Rebuilds the elements related to this component in case of
  118512. * context lost for instance.
  118513. */
  118514. rebuild(): void;
  118515. /**
  118516. * Disposes the component and the associated ressources
  118517. */
  118518. dispose(): void;
  118519. private _gatherRenderTargets;
  118520. }
  118521. }
  118522. declare module BABYLON {
  118523. /**
  118524. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  118525. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118526. */
  118527. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  118528. private _scene;
  118529. private _camerasToBeAttached;
  118530. /**
  118531. * ID of the sharpen post process,
  118532. */
  118533. private readonly SharpenPostProcessId;
  118534. /**
  118535. * @ignore
  118536. * ID of the image processing post process;
  118537. */
  118538. readonly ImageProcessingPostProcessId: string;
  118539. /**
  118540. * @ignore
  118541. * ID of the Fast Approximate Anti-Aliasing post process;
  118542. */
  118543. readonly FxaaPostProcessId: string;
  118544. /**
  118545. * ID of the chromatic aberration post process,
  118546. */
  118547. private readonly ChromaticAberrationPostProcessId;
  118548. /**
  118549. * ID of the grain post process
  118550. */
  118551. private readonly GrainPostProcessId;
  118552. /**
  118553. * Sharpen post process which will apply a sharpen convolution to enhance edges
  118554. */
  118555. sharpen: SharpenPostProcess;
  118556. private _sharpenEffect;
  118557. private bloom;
  118558. /**
  118559. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  118560. */
  118561. depthOfField: DepthOfFieldEffect;
  118562. /**
  118563. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  118564. */
  118565. fxaa: FxaaPostProcess;
  118566. /**
  118567. * Image post processing pass used to perform operations such as tone mapping or color grading.
  118568. */
  118569. imageProcessing: ImageProcessingPostProcess;
  118570. /**
  118571. * Chromatic aberration post process which will shift rgb colors in the image
  118572. */
  118573. chromaticAberration: ChromaticAberrationPostProcess;
  118574. private _chromaticAberrationEffect;
  118575. /**
  118576. * Grain post process which add noise to the image
  118577. */
  118578. grain: GrainPostProcess;
  118579. private _grainEffect;
  118580. /**
  118581. * Glow post process which adds a glow to emissive areas of the image
  118582. */
  118583. private _glowLayer;
  118584. /**
  118585. * Animations which can be used to tweak settings over a period of time
  118586. */
  118587. animations: Animation[];
  118588. private _imageProcessingConfigurationObserver;
  118589. private _sharpenEnabled;
  118590. private _bloomEnabled;
  118591. private _depthOfFieldEnabled;
  118592. private _depthOfFieldBlurLevel;
  118593. private _fxaaEnabled;
  118594. private _imageProcessingEnabled;
  118595. private _defaultPipelineTextureType;
  118596. private _bloomScale;
  118597. private _chromaticAberrationEnabled;
  118598. private _grainEnabled;
  118599. private _buildAllowed;
  118600. /**
  118601. * Gets active scene
  118602. */
  118603. readonly scene: Scene;
  118604. /**
  118605. * Enable or disable the sharpen process from the pipeline
  118606. */
  118607. sharpenEnabled: boolean;
  118608. private _resizeObserver;
  118609. private _hardwareScaleLevel;
  118610. private _bloomKernel;
  118611. /**
  118612. * Specifies the size of the bloom blur kernel, relative to the final output size
  118613. */
  118614. bloomKernel: number;
  118615. /**
  118616. * Specifies the weight of the bloom in the final rendering
  118617. */
  118618. private _bloomWeight;
  118619. /**
  118620. * Specifies the luma threshold for the area that will be blurred by the bloom
  118621. */
  118622. private _bloomThreshold;
  118623. private _hdr;
  118624. /**
  118625. * The strength of the bloom.
  118626. */
  118627. bloomWeight: number;
  118628. /**
  118629. * The strength of the bloom.
  118630. */
  118631. bloomThreshold: number;
  118632. /**
  118633. * The scale of the bloom, lower value will provide better performance.
  118634. */
  118635. bloomScale: number;
  118636. /**
  118637. * Enable or disable the bloom from the pipeline
  118638. */
  118639. bloomEnabled: boolean;
  118640. private _rebuildBloom;
  118641. /**
  118642. * If the depth of field is enabled.
  118643. */
  118644. depthOfFieldEnabled: boolean;
  118645. /**
  118646. * Blur level of the depth of field effect. (Higher blur will effect performance)
  118647. */
  118648. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  118649. /**
  118650. * If the anti aliasing is enabled.
  118651. */
  118652. fxaaEnabled: boolean;
  118653. private _samples;
  118654. /**
  118655. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  118656. */
  118657. samples: number;
  118658. /**
  118659. * If image processing is enabled.
  118660. */
  118661. imageProcessingEnabled: boolean;
  118662. /**
  118663. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  118664. */
  118665. glowLayerEnabled: boolean;
  118666. /**
  118667. * Gets the glow layer (or null if not defined)
  118668. */
  118669. readonly glowLayer: Nullable<GlowLayer>;
  118670. /**
  118671. * Enable or disable the chromaticAberration process from the pipeline
  118672. */
  118673. chromaticAberrationEnabled: boolean;
  118674. /**
  118675. * Enable or disable the grain process from the pipeline
  118676. */
  118677. grainEnabled: boolean;
  118678. /**
  118679. * @constructor
  118680. * @param name - The rendering pipeline name (default: "")
  118681. * @param hdr - If high dynamic range textures should be used (default: true)
  118682. * @param scene - The scene linked to this pipeline (default: the last created scene)
  118683. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  118684. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  118685. */
  118686. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  118687. /**
  118688. * Get the class name
  118689. * @returns "DefaultRenderingPipeline"
  118690. */
  118691. getClassName(): string;
  118692. /**
  118693. * Force the compilation of the entire pipeline.
  118694. */
  118695. prepare(): void;
  118696. private _hasCleared;
  118697. private _prevPostProcess;
  118698. private _prevPrevPostProcess;
  118699. private _setAutoClearAndTextureSharing;
  118700. private _depthOfFieldSceneObserver;
  118701. private _buildPipeline;
  118702. private _disposePostProcesses;
  118703. /**
  118704. * Adds a camera to the pipeline
  118705. * @param camera the camera to be added
  118706. */
  118707. addCamera(camera: Camera): void;
  118708. /**
  118709. * Removes a camera from the pipeline
  118710. * @param camera the camera to remove
  118711. */
  118712. removeCamera(camera: Camera): void;
  118713. /**
  118714. * Dispose of the pipeline and stop all post processes
  118715. */
  118716. dispose(): void;
  118717. /**
  118718. * Serialize the rendering pipeline (Used when exporting)
  118719. * @returns the serialized object
  118720. */
  118721. serialize(): any;
  118722. /**
  118723. * Parse the serialized pipeline
  118724. * @param source Source pipeline.
  118725. * @param scene The scene to load the pipeline to.
  118726. * @param rootUrl The URL of the serialized pipeline.
  118727. * @returns An instantiated pipeline from the serialized object.
  118728. */
  118729. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  118730. }
  118731. }
  118732. declare module BABYLON {
  118733. /** @hidden */
  118734. export var lensHighlightsPixelShader: {
  118735. name: string;
  118736. shader: string;
  118737. };
  118738. }
  118739. declare module BABYLON {
  118740. /** @hidden */
  118741. export var depthOfFieldPixelShader: {
  118742. name: string;
  118743. shader: string;
  118744. };
  118745. }
  118746. declare module BABYLON {
  118747. /**
  118748. * BABYLON.JS Chromatic Aberration GLSL Shader
  118749. * Author: Olivier Guyot
  118750. * Separates very slightly R, G and B colors on the edges of the screen
  118751. * Inspired by Francois Tarlier & Martins Upitis
  118752. */
  118753. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  118754. /**
  118755. * @ignore
  118756. * The chromatic aberration PostProcess id in the pipeline
  118757. */
  118758. LensChromaticAberrationEffect: string;
  118759. /**
  118760. * @ignore
  118761. * The highlights enhancing PostProcess id in the pipeline
  118762. */
  118763. HighlightsEnhancingEffect: string;
  118764. /**
  118765. * @ignore
  118766. * The depth-of-field PostProcess id in the pipeline
  118767. */
  118768. LensDepthOfFieldEffect: string;
  118769. private _scene;
  118770. private _depthTexture;
  118771. private _grainTexture;
  118772. private _chromaticAberrationPostProcess;
  118773. private _highlightsPostProcess;
  118774. private _depthOfFieldPostProcess;
  118775. private _edgeBlur;
  118776. private _grainAmount;
  118777. private _chromaticAberration;
  118778. private _distortion;
  118779. private _highlightsGain;
  118780. private _highlightsThreshold;
  118781. private _dofDistance;
  118782. private _dofAperture;
  118783. private _dofDarken;
  118784. private _dofPentagon;
  118785. private _blurNoise;
  118786. /**
  118787. * @constructor
  118788. *
  118789. * Effect parameters are as follow:
  118790. * {
  118791. * chromatic_aberration: number; // from 0 to x (1 for realism)
  118792. * edge_blur: number; // from 0 to x (1 for realism)
  118793. * distortion: number; // from 0 to x (1 for realism)
  118794. * grain_amount: number; // from 0 to 1
  118795. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  118796. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  118797. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  118798. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  118799. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  118800. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  118801. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  118802. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  118803. * }
  118804. * Note: if an effect parameter is unset, effect is disabled
  118805. *
  118806. * @param name The rendering pipeline name
  118807. * @param parameters - An object containing all parameters (see above)
  118808. * @param scene The scene linked to this pipeline
  118809. * @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)
  118810. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118811. */
  118812. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  118813. /**
  118814. * Get the class name
  118815. * @returns "LensRenderingPipeline"
  118816. */
  118817. getClassName(): string;
  118818. /**
  118819. * Gets associated scene
  118820. */
  118821. readonly scene: Scene;
  118822. /**
  118823. * Gets or sets the edge blur
  118824. */
  118825. edgeBlur: number;
  118826. /**
  118827. * Gets or sets the grain amount
  118828. */
  118829. grainAmount: number;
  118830. /**
  118831. * Gets or sets the chromatic aberration amount
  118832. */
  118833. chromaticAberration: number;
  118834. /**
  118835. * Gets or sets the depth of field aperture
  118836. */
  118837. dofAperture: number;
  118838. /**
  118839. * Gets or sets the edge distortion
  118840. */
  118841. edgeDistortion: number;
  118842. /**
  118843. * Gets or sets the depth of field distortion
  118844. */
  118845. dofDistortion: number;
  118846. /**
  118847. * Gets or sets the darken out of focus amount
  118848. */
  118849. darkenOutOfFocus: number;
  118850. /**
  118851. * Gets or sets a boolean indicating if blur noise is enabled
  118852. */
  118853. blurNoise: boolean;
  118854. /**
  118855. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  118856. */
  118857. pentagonBokeh: boolean;
  118858. /**
  118859. * Gets or sets the highlight grain amount
  118860. */
  118861. highlightsGain: number;
  118862. /**
  118863. * Gets or sets the highlight threshold
  118864. */
  118865. highlightsThreshold: number;
  118866. /**
  118867. * Sets the amount of blur at the edges
  118868. * @param amount blur amount
  118869. */
  118870. setEdgeBlur(amount: number): void;
  118871. /**
  118872. * Sets edge blur to 0
  118873. */
  118874. disableEdgeBlur(): void;
  118875. /**
  118876. * Sets the amout of grain
  118877. * @param amount Amount of grain
  118878. */
  118879. setGrainAmount(amount: number): void;
  118880. /**
  118881. * Set grain amount to 0
  118882. */
  118883. disableGrain(): void;
  118884. /**
  118885. * Sets the chromatic aberration amount
  118886. * @param amount amount of chromatic aberration
  118887. */
  118888. setChromaticAberration(amount: number): void;
  118889. /**
  118890. * Sets chromatic aberration amount to 0
  118891. */
  118892. disableChromaticAberration(): void;
  118893. /**
  118894. * Sets the EdgeDistortion amount
  118895. * @param amount amount of EdgeDistortion
  118896. */
  118897. setEdgeDistortion(amount: number): void;
  118898. /**
  118899. * Sets edge distortion to 0
  118900. */
  118901. disableEdgeDistortion(): void;
  118902. /**
  118903. * Sets the FocusDistance amount
  118904. * @param amount amount of FocusDistance
  118905. */
  118906. setFocusDistance(amount: number): void;
  118907. /**
  118908. * Disables depth of field
  118909. */
  118910. disableDepthOfField(): void;
  118911. /**
  118912. * Sets the Aperture amount
  118913. * @param amount amount of Aperture
  118914. */
  118915. setAperture(amount: number): void;
  118916. /**
  118917. * Sets the DarkenOutOfFocus amount
  118918. * @param amount amount of DarkenOutOfFocus
  118919. */
  118920. setDarkenOutOfFocus(amount: number): void;
  118921. private _pentagonBokehIsEnabled;
  118922. /**
  118923. * Creates a pentagon bokeh effect
  118924. */
  118925. enablePentagonBokeh(): void;
  118926. /**
  118927. * Disables the pentagon bokeh effect
  118928. */
  118929. disablePentagonBokeh(): void;
  118930. /**
  118931. * Enables noise blur
  118932. */
  118933. enableNoiseBlur(): void;
  118934. /**
  118935. * Disables noise blur
  118936. */
  118937. disableNoiseBlur(): void;
  118938. /**
  118939. * Sets the HighlightsGain amount
  118940. * @param amount amount of HighlightsGain
  118941. */
  118942. setHighlightsGain(amount: number): void;
  118943. /**
  118944. * Sets the HighlightsThreshold amount
  118945. * @param amount amount of HighlightsThreshold
  118946. */
  118947. setHighlightsThreshold(amount: number): void;
  118948. /**
  118949. * Disables highlights
  118950. */
  118951. disableHighlights(): void;
  118952. /**
  118953. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  118954. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  118955. */
  118956. dispose(disableDepthRender?: boolean): void;
  118957. private _createChromaticAberrationPostProcess;
  118958. private _createHighlightsPostProcess;
  118959. private _createDepthOfFieldPostProcess;
  118960. private _createGrainTexture;
  118961. }
  118962. }
  118963. declare module BABYLON {
  118964. /** @hidden */
  118965. export var ssao2PixelShader: {
  118966. name: string;
  118967. shader: string;
  118968. };
  118969. }
  118970. declare module BABYLON {
  118971. /** @hidden */
  118972. export var ssaoCombinePixelShader: {
  118973. name: string;
  118974. shader: string;
  118975. };
  118976. }
  118977. declare module BABYLON {
  118978. /**
  118979. * Render pipeline to produce ssao effect
  118980. */
  118981. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  118982. /**
  118983. * @ignore
  118984. * The PassPostProcess id in the pipeline that contains the original scene color
  118985. */
  118986. SSAOOriginalSceneColorEffect: string;
  118987. /**
  118988. * @ignore
  118989. * The SSAO PostProcess id in the pipeline
  118990. */
  118991. SSAORenderEffect: string;
  118992. /**
  118993. * @ignore
  118994. * The horizontal blur PostProcess id in the pipeline
  118995. */
  118996. SSAOBlurHRenderEffect: string;
  118997. /**
  118998. * @ignore
  118999. * The vertical blur PostProcess id in the pipeline
  119000. */
  119001. SSAOBlurVRenderEffect: string;
  119002. /**
  119003. * @ignore
  119004. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119005. */
  119006. SSAOCombineRenderEffect: string;
  119007. /**
  119008. * The output strength of the SSAO post-process. Default value is 1.0.
  119009. */
  119010. totalStrength: number;
  119011. /**
  119012. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  119013. */
  119014. maxZ: number;
  119015. /**
  119016. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  119017. */
  119018. minZAspect: number;
  119019. private _samples;
  119020. /**
  119021. * Number of samples used for the SSAO calculations. Default value is 8
  119022. */
  119023. samples: number;
  119024. private _textureSamples;
  119025. /**
  119026. * Number of samples to use for antialiasing
  119027. */
  119028. textureSamples: number;
  119029. /**
  119030. * Ratio object used for SSAO ratio and blur ratio
  119031. */
  119032. private _ratio;
  119033. /**
  119034. * Dynamically generated sphere sampler.
  119035. */
  119036. private _sampleSphere;
  119037. /**
  119038. * Blur filter offsets
  119039. */
  119040. private _samplerOffsets;
  119041. private _expensiveBlur;
  119042. /**
  119043. * If bilateral blur should be used
  119044. */
  119045. expensiveBlur: boolean;
  119046. /**
  119047. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  119048. */
  119049. radius: number;
  119050. /**
  119051. * The base color of the SSAO post-process
  119052. * The final result is "base + ssao" between [0, 1]
  119053. */
  119054. base: number;
  119055. /**
  119056. * Support test.
  119057. */
  119058. static readonly IsSupported: boolean;
  119059. private _scene;
  119060. private _depthTexture;
  119061. private _normalTexture;
  119062. private _randomTexture;
  119063. private _originalColorPostProcess;
  119064. private _ssaoPostProcess;
  119065. private _blurHPostProcess;
  119066. private _blurVPostProcess;
  119067. private _ssaoCombinePostProcess;
  119068. private _firstUpdate;
  119069. /**
  119070. * Gets active scene
  119071. */
  119072. readonly scene: Scene;
  119073. /**
  119074. * @constructor
  119075. * @param name The rendering pipeline name
  119076. * @param scene The scene linked to this pipeline
  119077. * @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 }
  119078. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119079. */
  119080. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119081. /**
  119082. * Get the class name
  119083. * @returns "SSAO2RenderingPipeline"
  119084. */
  119085. getClassName(): string;
  119086. /**
  119087. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119088. */
  119089. dispose(disableGeometryBufferRenderer?: boolean): void;
  119090. private _createBlurPostProcess;
  119091. /** @hidden */
  119092. _rebuild(): void;
  119093. private _bits;
  119094. private _radicalInverse_VdC;
  119095. private _hammersley;
  119096. private _hemisphereSample_uniform;
  119097. private _generateHemisphere;
  119098. private _createSSAOPostProcess;
  119099. private _createSSAOCombinePostProcess;
  119100. private _createRandomTexture;
  119101. /**
  119102. * Serialize the rendering pipeline (Used when exporting)
  119103. * @returns the serialized object
  119104. */
  119105. serialize(): any;
  119106. /**
  119107. * Parse the serialized pipeline
  119108. * @param source Source pipeline.
  119109. * @param scene The scene to load the pipeline to.
  119110. * @param rootUrl The URL of the serialized pipeline.
  119111. * @returns An instantiated pipeline from the serialized object.
  119112. */
  119113. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  119114. }
  119115. }
  119116. declare module BABYLON {
  119117. /** @hidden */
  119118. export var ssaoPixelShader: {
  119119. name: string;
  119120. shader: string;
  119121. };
  119122. }
  119123. declare module BABYLON {
  119124. /**
  119125. * Render pipeline to produce ssao effect
  119126. */
  119127. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  119128. /**
  119129. * @ignore
  119130. * The PassPostProcess id in the pipeline that contains the original scene color
  119131. */
  119132. SSAOOriginalSceneColorEffect: string;
  119133. /**
  119134. * @ignore
  119135. * The SSAO PostProcess id in the pipeline
  119136. */
  119137. SSAORenderEffect: string;
  119138. /**
  119139. * @ignore
  119140. * The horizontal blur PostProcess id in the pipeline
  119141. */
  119142. SSAOBlurHRenderEffect: string;
  119143. /**
  119144. * @ignore
  119145. * The vertical blur PostProcess id in the pipeline
  119146. */
  119147. SSAOBlurVRenderEffect: string;
  119148. /**
  119149. * @ignore
  119150. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119151. */
  119152. SSAOCombineRenderEffect: string;
  119153. /**
  119154. * The output strength of the SSAO post-process. Default value is 1.0.
  119155. */
  119156. totalStrength: number;
  119157. /**
  119158. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  119159. */
  119160. radius: number;
  119161. /**
  119162. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  119163. * Must not be equal to fallOff and superior to fallOff.
  119164. * Default value is 0.0075
  119165. */
  119166. area: number;
  119167. /**
  119168. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  119169. * Must not be equal to area and inferior to area.
  119170. * Default value is 0.000001
  119171. */
  119172. fallOff: number;
  119173. /**
  119174. * The base color of the SSAO post-process
  119175. * The final result is "base + ssao" between [0, 1]
  119176. */
  119177. base: number;
  119178. private _scene;
  119179. private _depthTexture;
  119180. private _randomTexture;
  119181. private _originalColorPostProcess;
  119182. private _ssaoPostProcess;
  119183. private _blurHPostProcess;
  119184. private _blurVPostProcess;
  119185. private _ssaoCombinePostProcess;
  119186. private _firstUpdate;
  119187. /**
  119188. * Gets active scene
  119189. */
  119190. readonly scene: Scene;
  119191. /**
  119192. * @constructor
  119193. * @param name - The rendering pipeline name
  119194. * @param scene - The scene linked to this pipeline
  119195. * @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 }
  119196. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  119197. */
  119198. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119199. /**
  119200. * Get the class name
  119201. * @returns "SSAORenderingPipeline"
  119202. */
  119203. getClassName(): string;
  119204. /**
  119205. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119206. */
  119207. dispose(disableDepthRender?: boolean): void;
  119208. private _createBlurPostProcess;
  119209. /** @hidden */
  119210. _rebuild(): void;
  119211. private _createSSAOPostProcess;
  119212. private _createSSAOCombinePostProcess;
  119213. private _createRandomTexture;
  119214. }
  119215. }
  119216. declare module BABYLON {
  119217. /** @hidden */
  119218. export var standardPixelShader: {
  119219. name: string;
  119220. shader: string;
  119221. };
  119222. }
  119223. declare module BABYLON {
  119224. /**
  119225. * Standard rendering pipeline
  119226. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119227. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  119228. */
  119229. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119230. /**
  119231. * Public members
  119232. */
  119233. /**
  119234. * Post-process which contains the original scene color before the pipeline applies all the effects
  119235. */
  119236. originalPostProcess: Nullable<PostProcess>;
  119237. /**
  119238. * Post-process used to down scale an image x4
  119239. */
  119240. downSampleX4PostProcess: Nullable<PostProcess>;
  119241. /**
  119242. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  119243. */
  119244. brightPassPostProcess: Nullable<PostProcess>;
  119245. /**
  119246. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  119247. */
  119248. blurHPostProcesses: PostProcess[];
  119249. /**
  119250. * Post-process array storing all the vertical blur post-processes used by the pipeline
  119251. */
  119252. blurVPostProcesses: PostProcess[];
  119253. /**
  119254. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  119255. */
  119256. textureAdderPostProcess: Nullable<PostProcess>;
  119257. /**
  119258. * Post-process used to create volumetric lighting effect
  119259. */
  119260. volumetricLightPostProcess: Nullable<PostProcess>;
  119261. /**
  119262. * Post-process used to smooth the previous volumetric light post-process on the X axis
  119263. */
  119264. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  119265. /**
  119266. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  119267. */
  119268. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  119269. /**
  119270. * Post-process used to merge the volumetric light effect and the real scene color
  119271. */
  119272. volumetricLightMergePostProces: Nullable<PostProcess>;
  119273. /**
  119274. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  119275. */
  119276. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  119277. /**
  119278. * Base post-process used to calculate the average luminance of the final image for HDR
  119279. */
  119280. luminancePostProcess: Nullable<PostProcess>;
  119281. /**
  119282. * Post-processes used to create down sample post-processes in order to get
  119283. * the average luminance of the final image for HDR
  119284. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  119285. */
  119286. luminanceDownSamplePostProcesses: PostProcess[];
  119287. /**
  119288. * Post-process used to create a HDR effect (light adaptation)
  119289. */
  119290. hdrPostProcess: Nullable<PostProcess>;
  119291. /**
  119292. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  119293. */
  119294. textureAdderFinalPostProcess: Nullable<PostProcess>;
  119295. /**
  119296. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  119297. */
  119298. lensFlareFinalPostProcess: Nullable<PostProcess>;
  119299. /**
  119300. * Post-process used to merge the final HDR post-process and the real scene color
  119301. */
  119302. hdrFinalPostProcess: Nullable<PostProcess>;
  119303. /**
  119304. * Post-process used to create a lens flare effect
  119305. */
  119306. lensFlarePostProcess: Nullable<PostProcess>;
  119307. /**
  119308. * Post-process that merges the result of the lens flare post-process and the real scene color
  119309. */
  119310. lensFlareComposePostProcess: Nullable<PostProcess>;
  119311. /**
  119312. * Post-process used to create a motion blur effect
  119313. */
  119314. motionBlurPostProcess: Nullable<PostProcess>;
  119315. /**
  119316. * Post-process used to create a depth of field effect
  119317. */
  119318. depthOfFieldPostProcess: Nullable<PostProcess>;
  119319. /**
  119320. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119321. */
  119322. fxaaPostProcess: Nullable<FxaaPostProcess>;
  119323. /**
  119324. * Represents the brightness threshold in order to configure the illuminated surfaces
  119325. */
  119326. brightThreshold: number;
  119327. /**
  119328. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  119329. */
  119330. blurWidth: number;
  119331. /**
  119332. * Sets if the blur for highlighted surfaces must be only horizontal
  119333. */
  119334. horizontalBlur: boolean;
  119335. /**
  119336. * Gets the overall exposure used by the pipeline
  119337. */
  119338. /**
  119339. * Sets the overall exposure used by the pipeline
  119340. */
  119341. exposure: number;
  119342. /**
  119343. * Texture used typically to simulate "dirty" on camera lens
  119344. */
  119345. lensTexture: Nullable<Texture>;
  119346. /**
  119347. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  119348. */
  119349. volumetricLightCoefficient: number;
  119350. /**
  119351. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  119352. */
  119353. volumetricLightPower: number;
  119354. /**
  119355. * Used the set the blur intensity to smooth the volumetric lights
  119356. */
  119357. volumetricLightBlurScale: number;
  119358. /**
  119359. * Light (spot or directional) used to generate the volumetric lights rays
  119360. * The source light must have a shadow generate so the pipeline can get its
  119361. * depth map
  119362. */
  119363. sourceLight: Nullable<SpotLight | DirectionalLight>;
  119364. /**
  119365. * For eye adaptation, represents the minimum luminance the eye can see
  119366. */
  119367. hdrMinimumLuminance: number;
  119368. /**
  119369. * For eye adaptation, represents the decrease luminance speed
  119370. */
  119371. hdrDecreaseRate: number;
  119372. /**
  119373. * For eye adaptation, represents the increase luminance speed
  119374. */
  119375. hdrIncreaseRate: number;
  119376. /**
  119377. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119378. */
  119379. /**
  119380. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119381. */
  119382. hdrAutoExposure: boolean;
  119383. /**
  119384. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  119385. */
  119386. lensColorTexture: Nullable<Texture>;
  119387. /**
  119388. * The overall strengh for the lens flare effect
  119389. */
  119390. lensFlareStrength: number;
  119391. /**
  119392. * Dispersion coefficient for lens flare ghosts
  119393. */
  119394. lensFlareGhostDispersal: number;
  119395. /**
  119396. * Main lens flare halo width
  119397. */
  119398. lensFlareHaloWidth: number;
  119399. /**
  119400. * Based on the lens distortion effect, defines how much the lens flare result
  119401. * is distorted
  119402. */
  119403. lensFlareDistortionStrength: number;
  119404. /**
  119405. * Lens star texture must be used to simulate rays on the flares and is available
  119406. * in the documentation
  119407. */
  119408. lensStarTexture: Nullable<Texture>;
  119409. /**
  119410. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  119411. * flare effect by taking account of the dirt texture
  119412. */
  119413. lensFlareDirtTexture: Nullable<Texture>;
  119414. /**
  119415. * Represents the focal length for the depth of field effect
  119416. */
  119417. depthOfFieldDistance: number;
  119418. /**
  119419. * Represents the blur intensity for the blurred part of the depth of field effect
  119420. */
  119421. depthOfFieldBlurWidth: number;
  119422. /**
  119423. * Gets how much the image is blurred by the movement while using the motion blur post-process
  119424. */
  119425. /**
  119426. * Sets how much the image is blurred by the movement while using the motion blur post-process
  119427. */
  119428. motionStrength: number;
  119429. /**
  119430. * Gets wether or not the motion blur post-process is object based or screen based.
  119431. */
  119432. /**
  119433. * Sets wether or not the motion blur post-process should be object based or screen based
  119434. */
  119435. objectBasedMotionBlur: boolean;
  119436. /**
  119437. * List of animations for the pipeline (IAnimatable implementation)
  119438. */
  119439. animations: Animation[];
  119440. /**
  119441. * Private members
  119442. */
  119443. private _scene;
  119444. private _currentDepthOfFieldSource;
  119445. private _basePostProcess;
  119446. private _fixedExposure;
  119447. private _currentExposure;
  119448. private _hdrAutoExposure;
  119449. private _hdrCurrentLuminance;
  119450. private _motionStrength;
  119451. private _isObjectBasedMotionBlur;
  119452. private _floatTextureType;
  119453. private _ratio;
  119454. private _bloomEnabled;
  119455. private _depthOfFieldEnabled;
  119456. private _vlsEnabled;
  119457. private _lensFlareEnabled;
  119458. private _hdrEnabled;
  119459. private _motionBlurEnabled;
  119460. private _fxaaEnabled;
  119461. private _motionBlurSamples;
  119462. private _volumetricLightStepsCount;
  119463. private _samples;
  119464. /**
  119465. * @ignore
  119466. * Specifies if the bloom pipeline is enabled
  119467. */
  119468. BloomEnabled: boolean;
  119469. /**
  119470. * @ignore
  119471. * Specifies if the depth of field pipeline is enabed
  119472. */
  119473. DepthOfFieldEnabled: boolean;
  119474. /**
  119475. * @ignore
  119476. * Specifies if the lens flare pipeline is enabed
  119477. */
  119478. LensFlareEnabled: boolean;
  119479. /**
  119480. * @ignore
  119481. * Specifies if the HDR pipeline is enabled
  119482. */
  119483. HDREnabled: boolean;
  119484. /**
  119485. * @ignore
  119486. * Specifies if the volumetric lights scattering effect is enabled
  119487. */
  119488. VLSEnabled: boolean;
  119489. /**
  119490. * @ignore
  119491. * Specifies if the motion blur effect is enabled
  119492. */
  119493. MotionBlurEnabled: boolean;
  119494. /**
  119495. * Specifies if anti-aliasing is enabled
  119496. */
  119497. fxaaEnabled: boolean;
  119498. /**
  119499. * Specifies the number of steps used to calculate the volumetric lights
  119500. * Typically in interval [50, 200]
  119501. */
  119502. volumetricLightStepsCount: number;
  119503. /**
  119504. * Specifies the number of samples used for the motion blur effect
  119505. * Typically in interval [16, 64]
  119506. */
  119507. motionBlurSamples: number;
  119508. /**
  119509. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119510. */
  119511. samples: number;
  119512. /**
  119513. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119514. * @constructor
  119515. * @param name The rendering pipeline name
  119516. * @param scene The scene linked to this pipeline
  119517. * @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)
  119518. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  119519. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119520. */
  119521. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  119522. private _buildPipeline;
  119523. private _createDownSampleX4PostProcess;
  119524. private _createBrightPassPostProcess;
  119525. private _createBlurPostProcesses;
  119526. private _createTextureAdderPostProcess;
  119527. private _createVolumetricLightPostProcess;
  119528. private _createLuminancePostProcesses;
  119529. private _createHdrPostProcess;
  119530. private _createLensFlarePostProcess;
  119531. private _createDepthOfFieldPostProcess;
  119532. private _createMotionBlurPostProcess;
  119533. private _getDepthTexture;
  119534. private _disposePostProcesses;
  119535. /**
  119536. * Dispose of the pipeline and stop all post processes
  119537. */
  119538. dispose(): void;
  119539. /**
  119540. * Serialize the rendering pipeline (Used when exporting)
  119541. * @returns the serialized object
  119542. */
  119543. serialize(): any;
  119544. /**
  119545. * Parse the serialized pipeline
  119546. * @param source Source pipeline.
  119547. * @param scene The scene to load the pipeline to.
  119548. * @param rootUrl The URL of the serialized pipeline.
  119549. * @returns An instantiated pipeline from the serialized object.
  119550. */
  119551. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  119552. /**
  119553. * Luminance steps
  119554. */
  119555. static LuminanceSteps: number;
  119556. }
  119557. }
  119558. declare module BABYLON {
  119559. /** @hidden */
  119560. export var tonemapPixelShader: {
  119561. name: string;
  119562. shader: string;
  119563. };
  119564. }
  119565. declare module BABYLON {
  119566. /** Defines operator used for tonemapping */
  119567. export enum TonemappingOperator {
  119568. /** Hable */
  119569. Hable = 0,
  119570. /** Reinhard */
  119571. Reinhard = 1,
  119572. /** HejiDawson */
  119573. HejiDawson = 2,
  119574. /** Photographic */
  119575. Photographic = 3
  119576. }
  119577. /**
  119578. * Defines a post process to apply tone mapping
  119579. */
  119580. export class TonemapPostProcess extends PostProcess {
  119581. private _operator;
  119582. /** Defines the required exposure adjustement */
  119583. exposureAdjustment: number;
  119584. /**
  119585. * Creates a new TonemapPostProcess
  119586. * @param name defines the name of the postprocess
  119587. * @param _operator defines the operator to use
  119588. * @param exposureAdjustment defines the required exposure adjustement
  119589. * @param camera defines the camera to use (can be null)
  119590. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  119591. * @param engine defines the hosting engine (can be ignore if camera is set)
  119592. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119593. */
  119594. constructor(name: string, _operator: TonemappingOperator,
  119595. /** Defines the required exposure adjustement */
  119596. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  119597. }
  119598. }
  119599. declare module BABYLON {
  119600. /** @hidden */
  119601. export var depthVertexShader: {
  119602. name: string;
  119603. shader: string;
  119604. };
  119605. }
  119606. declare module BABYLON {
  119607. /** @hidden */
  119608. export var volumetricLightScatteringPixelShader: {
  119609. name: string;
  119610. shader: string;
  119611. };
  119612. }
  119613. declare module BABYLON {
  119614. /** @hidden */
  119615. export var volumetricLightScatteringPassPixelShader: {
  119616. name: string;
  119617. shader: string;
  119618. };
  119619. }
  119620. declare module BABYLON {
  119621. /**
  119622. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  119623. */
  119624. export class VolumetricLightScatteringPostProcess extends PostProcess {
  119625. private _volumetricLightScatteringPass;
  119626. private _volumetricLightScatteringRTT;
  119627. private _viewPort;
  119628. private _screenCoordinates;
  119629. private _cachedDefines;
  119630. /**
  119631. * If not undefined, the mesh position is computed from the attached node position
  119632. */
  119633. attachedNode: {
  119634. position: Vector3;
  119635. };
  119636. /**
  119637. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  119638. */
  119639. customMeshPosition: Vector3;
  119640. /**
  119641. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  119642. */
  119643. useCustomMeshPosition: boolean;
  119644. /**
  119645. * If the post-process should inverse the light scattering direction
  119646. */
  119647. invert: boolean;
  119648. /**
  119649. * The internal mesh used by the post-process
  119650. */
  119651. mesh: Mesh;
  119652. /**
  119653. * @hidden
  119654. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  119655. */
  119656. useDiffuseColor: boolean;
  119657. /**
  119658. * Array containing the excluded meshes not rendered in the internal pass
  119659. */
  119660. excludedMeshes: AbstractMesh[];
  119661. /**
  119662. * Controls the overall intensity of the post-process
  119663. */
  119664. exposure: number;
  119665. /**
  119666. * Dissipates each sample's contribution in range [0, 1]
  119667. */
  119668. decay: number;
  119669. /**
  119670. * Controls the overall intensity of each sample
  119671. */
  119672. weight: number;
  119673. /**
  119674. * Controls the density of each sample
  119675. */
  119676. density: number;
  119677. /**
  119678. * @constructor
  119679. * @param name The post-process name
  119680. * @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)
  119681. * @param camera The camera that the post-process will be attached to
  119682. * @param mesh The mesh used to create the light scattering
  119683. * @param samples The post-process quality, default 100
  119684. * @param samplingModeThe post-process filtering mode
  119685. * @param engine The babylon engine
  119686. * @param reusable If the post-process is reusable
  119687. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  119688. */
  119689. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  119690. /**
  119691. * Returns the string "VolumetricLightScatteringPostProcess"
  119692. * @returns "VolumetricLightScatteringPostProcess"
  119693. */
  119694. getClassName(): string;
  119695. private _isReady;
  119696. /**
  119697. * Sets the new light position for light scattering effect
  119698. * @param position The new custom light position
  119699. */
  119700. setCustomMeshPosition(position: Vector3): void;
  119701. /**
  119702. * Returns the light position for light scattering effect
  119703. * @return Vector3 The custom light position
  119704. */
  119705. getCustomMeshPosition(): Vector3;
  119706. /**
  119707. * Disposes the internal assets and detaches the post-process from the camera
  119708. */
  119709. dispose(camera: Camera): void;
  119710. /**
  119711. * Returns the render target texture used by the post-process
  119712. * @return the render target texture used by the post-process
  119713. */
  119714. getPass(): RenderTargetTexture;
  119715. private _meshExcluded;
  119716. private _createPass;
  119717. private _updateMeshScreenCoordinates;
  119718. /**
  119719. * Creates a default mesh for the Volumeric Light Scattering post-process
  119720. * @param name The mesh name
  119721. * @param scene The scene where to create the mesh
  119722. * @return the default mesh
  119723. */
  119724. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  119725. }
  119726. }
  119727. declare module BABYLON {
  119728. interface Scene {
  119729. /** @hidden (Backing field) */
  119730. _boundingBoxRenderer: BoundingBoxRenderer;
  119731. /** @hidden (Backing field) */
  119732. _forceShowBoundingBoxes: boolean;
  119733. /**
  119734. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  119735. */
  119736. forceShowBoundingBoxes: boolean;
  119737. /**
  119738. * Gets the bounding box renderer associated with the scene
  119739. * @returns a BoundingBoxRenderer
  119740. */
  119741. getBoundingBoxRenderer(): BoundingBoxRenderer;
  119742. }
  119743. interface AbstractMesh {
  119744. /** @hidden (Backing field) */
  119745. _showBoundingBox: boolean;
  119746. /**
  119747. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  119748. */
  119749. showBoundingBox: boolean;
  119750. }
  119751. /**
  119752. * Component responsible of rendering the bounding box of the meshes in a scene.
  119753. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  119754. */
  119755. export class BoundingBoxRenderer implements ISceneComponent {
  119756. /**
  119757. * The component name helpfull to identify the component in the list of scene components.
  119758. */
  119759. readonly name: string;
  119760. /**
  119761. * The scene the component belongs to.
  119762. */
  119763. scene: Scene;
  119764. /**
  119765. * Color of the bounding box lines placed in front of an object
  119766. */
  119767. frontColor: Color3;
  119768. /**
  119769. * Color of the bounding box lines placed behind an object
  119770. */
  119771. backColor: Color3;
  119772. /**
  119773. * Defines if the renderer should show the back lines or not
  119774. */
  119775. showBackLines: boolean;
  119776. /**
  119777. * @hidden
  119778. */
  119779. renderList: SmartArray<BoundingBox>;
  119780. private _colorShader;
  119781. private _vertexBuffers;
  119782. private _indexBuffer;
  119783. private _fillIndexBuffer;
  119784. private _fillIndexData;
  119785. /**
  119786. * Instantiates a new bounding box renderer in a scene.
  119787. * @param scene the scene the renderer renders in
  119788. */
  119789. constructor(scene: Scene);
  119790. /**
  119791. * Registers the component in a given scene
  119792. */
  119793. register(): void;
  119794. private _evaluateSubMesh;
  119795. private _activeMesh;
  119796. private _prepareRessources;
  119797. private _createIndexBuffer;
  119798. /**
  119799. * Rebuilds the elements related to this component in case of
  119800. * context lost for instance.
  119801. */
  119802. rebuild(): void;
  119803. /**
  119804. * @hidden
  119805. */
  119806. reset(): void;
  119807. /**
  119808. * Render the bounding boxes of a specific rendering group
  119809. * @param renderingGroupId defines the rendering group to render
  119810. */
  119811. render(renderingGroupId: number): void;
  119812. /**
  119813. * In case of occlusion queries, we can render the occlusion bounding box through this method
  119814. * @param mesh Define the mesh to render the occlusion bounding box for
  119815. */
  119816. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  119817. /**
  119818. * Dispose and release the resources attached to this renderer.
  119819. */
  119820. dispose(): void;
  119821. }
  119822. }
  119823. declare module BABYLON {
  119824. /** @hidden */
  119825. export var depthPixelShader: {
  119826. name: string;
  119827. shader: string;
  119828. };
  119829. }
  119830. declare module BABYLON {
  119831. /**
  119832. * This represents a depth renderer in Babylon.
  119833. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  119834. */
  119835. export class DepthRenderer {
  119836. private _scene;
  119837. private _depthMap;
  119838. private _effect;
  119839. private _cachedDefines;
  119840. private _camera;
  119841. /**
  119842. * Specifiess that the depth renderer will only be used within
  119843. * the camera it is created for.
  119844. * This can help forcing its rendering during the camera processing.
  119845. */
  119846. useOnlyInActiveCamera: boolean;
  119847. /** @hidden */
  119848. static _SceneComponentInitialization: (scene: Scene) => void;
  119849. /**
  119850. * Instantiates a depth renderer
  119851. * @param scene The scene the renderer belongs to
  119852. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  119853. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  119854. */
  119855. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  119856. /**
  119857. * Creates the depth rendering effect and checks if the effect is ready.
  119858. * @param subMesh The submesh to be used to render the depth map of
  119859. * @param useInstances If multiple world instances should be used
  119860. * @returns if the depth renderer is ready to render the depth map
  119861. */
  119862. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119863. /**
  119864. * Gets the texture which the depth map will be written to.
  119865. * @returns The depth map texture
  119866. */
  119867. getDepthMap(): RenderTargetTexture;
  119868. /**
  119869. * Disposes of the depth renderer.
  119870. */
  119871. dispose(): void;
  119872. }
  119873. }
  119874. declare module BABYLON {
  119875. interface Scene {
  119876. /** @hidden (Backing field) */
  119877. _depthRenderer: {
  119878. [id: string]: DepthRenderer;
  119879. };
  119880. /**
  119881. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  119882. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  119883. * @returns the created depth renderer
  119884. */
  119885. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  119886. /**
  119887. * Disables a depth renderer for a given camera
  119888. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  119889. */
  119890. disableDepthRenderer(camera?: Nullable<Camera>): void;
  119891. }
  119892. /**
  119893. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  119894. * in several rendering techniques.
  119895. */
  119896. export class DepthRendererSceneComponent implements ISceneComponent {
  119897. /**
  119898. * The component name helpfull to identify the component in the list of scene components.
  119899. */
  119900. readonly name: string;
  119901. /**
  119902. * The scene the component belongs to.
  119903. */
  119904. scene: Scene;
  119905. /**
  119906. * Creates a new instance of the component for the given scene
  119907. * @param scene Defines the scene to register the component in
  119908. */
  119909. constructor(scene: Scene);
  119910. /**
  119911. * Registers the component in a given scene
  119912. */
  119913. register(): void;
  119914. /**
  119915. * Rebuilds the elements related to this component in case of
  119916. * context lost for instance.
  119917. */
  119918. rebuild(): void;
  119919. /**
  119920. * Disposes the component and the associated ressources
  119921. */
  119922. dispose(): void;
  119923. private _gatherRenderTargets;
  119924. private _gatherActiveCameraRenderTargets;
  119925. }
  119926. }
  119927. declare module BABYLON {
  119928. /** @hidden */
  119929. export var outlinePixelShader: {
  119930. name: string;
  119931. shader: string;
  119932. };
  119933. }
  119934. declare module BABYLON {
  119935. /** @hidden */
  119936. export var outlineVertexShader: {
  119937. name: string;
  119938. shader: string;
  119939. };
  119940. }
  119941. declare module BABYLON {
  119942. interface Scene {
  119943. /** @hidden */
  119944. _outlineRenderer: OutlineRenderer;
  119945. /**
  119946. * Gets the outline renderer associated with the scene
  119947. * @returns a OutlineRenderer
  119948. */
  119949. getOutlineRenderer(): OutlineRenderer;
  119950. }
  119951. interface AbstractMesh {
  119952. /** @hidden (Backing field) */
  119953. _renderOutline: boolean;
  119954. /**
  119955. * Gets or sets a boolean indicating if the outline must be rendered as well
  119956. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  119957. */
  119958. renderOutline: boolean;
  119959. /** @hidden (Backing field) */
  119960. _renderOverlay: boolean;
  119961. /**
  119962. * Gets or sets a boolean indicating if the overlay must be rendered as well
  119963. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  119964. */
  119965. renderOverlay: boolean;
  119966. }
  119967. /**
  119968. * This class is responsible to draw bothe outline/overlay of meshes.
  119969. * It should not be used directly but through the available method on mesh.
  119970. */
  119971. export class OutlineRenderer implements ISceneComponent {
  119972. /**
  119973. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  119974. */
  119975. private static _StencilReference;
  119976. /**
  119977. * The name of the component. Each component must have a unique name.
  119978. */
  119979. name: string;
  119980. /**
  119981. * The scene the component belongs to.
  119982. */
  119983. scene: Scene;
  119984. /**
  119985. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  119986. */
  119987. zOffset: number;
  119988. private _engine;
  119989. private _effect;
  119990. private _cachedDefines;
  119991. private _savedDepthWrite;
  119992. /**
  119993. * Instantiates a new outline renderer. (There could be only one per scene).
  119994. * @param scene Defines the scene it belongs to
  119995. */
  119996. constructor(scene: Scene);
  119997. /**
  119998. * Register the component to one instance of a scene.
  119999. */
  120000. register(): void;
  120001. /**
  120002. * Rebuilds the elements related to this component in case of
  120003. * context lost for instance.
  120004. */
  120005. rebuild(): void;
  120006. /**
  120007. * Disposes the component and the associated ressources.
  120008. */
  120009. dispose(): void;
  120010. /**
  120011. * Renders the outline in the canvas.
  120012. * @param subMesh Defines the sumesh to render
  120013. * @param batch Defines the batch of meshes in case of instances
  120014. * @param useOverlay Defines if the rendering is for the overlay or the outline
  120015. */
  120016. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  120017. /**
  120018. * Returns whether or not the outline renderer is ready for a given submesh.
  120019. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  120020. * @param subMesh Defines the submesh to check readyness for
  120021. * @param useInstances Defines wheter wee are trying to render instances or not
  120022. * @returns true if ready otherwise false
  120023. */
  120024. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120025. private _beforeRenderingMesh;
  120026. private _afterRenderingMesh;
  120027. }
  120028. }
  120029. declare module BABYLON {
  120030. /**
  120031. * Defines the list of states available for a task inside a AssetsManager
  120032. */
  120033. export enum AssetTaskState {
  120034. /**
  120035. * Initialization
  120036. */
  120037. INIT = 0,
  120038. /**
  120039. * Running
  120040. */
  120041. RUNNING = 1,
  120042. /**
  120043. * Done
  120044. */
  120045. DONE = 2,
  120046. /**
  120047. * Error
  120048. */
  120049. ERROR = 3
  120050. }
  120051. /**
  120052. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  120053. */
  120054. export abstract class AbstractAssetTask {
  120055. /**
  120056. * Task name
  120057. */ name: string;
  120058. /**
  120059. * Callback called when the task is successful
  120060. */
  120061. onSuccess: (task: any) => void;
  120062. /**
  120063. * Callback called when the task is not successful
  120064. */
  120065. onError: (task: any, message?: string, exception?: any) => void;
  120066. /**
  120067. * Creates a new AssetsManager
  120068. * @param name defines the name of the task
  120069. */
  120070. constructor(
  120071. /**
  120072. * Task name
  120073. */ name: string);
  120074. private _isCompleted;
  120075. private _taskState;
  120076. private _errorObject;
  120077. /**
  120078. * Get if the task is completed
  120079. */
  120080. readonly isCompleted: boolean;
  120081. /**
  120082. * Gets the current state of the task
  120083. */
  120084. readonly taskState: AssetTaskState;
  120085. /**
  120086. * Gets the current error object (if task is in error)
  120087. */
  120088. readonly errorObject: {
  120089. message?: string;
  120090. exception?: any;
  120091. };
  120092. /**
  120093. * Internal only
  120094. * @hidden
  120095. */
  120096. _setErrorObject(message?: string, exception?: any): void;
  120097. /**
  120098. * Execute the current task
  120099. * @param scene defines the scene where you want your assets to be loaded
  120100. * @param onSuccess is a callback called when the task is successfully executed
  120101. * @param onError is a callback called if an error occurs
  120102. */
  120103. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120104. /**
  120105. * Execute the current task
  120106. * @param scene defines the scene where you want your assets to be loaded
  120107. * @param onSuccess is a callback called when the task is successfully executed
  120108. * @param onError is a callback called if an error occurs
  120109. */
  120110. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120111. /**
  120112. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  120113. * This can be used with failed tasks that have the reason for failure fixed.
  120114. */
  120115. reset(): void;
  120116. private onErrorCallback;
  120117. private onDoneCallback;
  120118. }
  120119. /**
  120120. * Define the interface used by progress events raised during assets loading
  120121. */
  120122. export interface IAssetsProgressEvent {
  120123. /**
  120124. * Defines the number of remaining tasks to process
  120125. */
  120126. remainingCount: number;
  120127. /**
  120128. * Defines the total number of tasks
  120129. */
  120130. totalCount: number;
  120131. /**
  120132. * Defines the task that was just processed
  120133. */
  120134. task: AbstractAssetTask;
  120135. }
  120136. /**
  120137. * Class used to share progress information about assets loading
  120138. */
  120139. export class AssetsProgressEvent implements IAssetsProgressEvent {
  120140. /**
  120141. * Defines the number of remaining tasks to process
  120142. */
  120143. remainingCount: number;
  120144. /**
  120145. * Defines the total number of tasks
  120146. */
  120147. totalCount: number;
  120148. /**
  120149. * Defines the task that was just processed
  120150. */
  120151. task: AbstractAssetTask;
  120152. /**
  120153. * Creates a AssetsProgressEvent
  120154. * @param remainingCount defines the number of remaining tasks to process
  120155. * @param totalCount defines the total number of tasks
  120156. * @param task defines the task that was just processed
  120157. */
  120158. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  120159. }
  120160. /**
  120161. * Define a task used by AssetsManager to load meshes
  120162. */
  120163. export class MeshAssetTask extends AbstractAssetTask {
  120164. /**
  120165. * Defines the name of the task
  120166. */
  120167. name: string;
  120168. /**
  120169. * Defines the list of mesh's names you want to load
  120170. */
  120171. meshesNames: any;
  120172. /**
  120173. * Defines the root url to use as a base to load your meshes and associated resources
  120174. */
  120175. rootUrl: string;
  120176. /**
  120177. * Defines the filename of the scene to load from
  120178. */
  120179. sceneFilename: string;
  120180. /**
  120181. * Gets the list of loaded meshes
  120182. */
  120183. loadedMeshes: Array<AbstractMesh>;
  120184. /**
  120185. * Gets the list of loaded particle systems
  120186. */
  120187. loadedParticleSystems: Array<IParticleSystem>;
  120188. /**
  120189. * Gets the list of loaded skeletons
  120190. */
  120191. loadedSkeletons: Array<Skeleton>;
  120192. /**
  120193. * Gets the list of loaded animation groups
  120194. */
  120195. loadedAnimationGroups: Array<AnimationGroup>;
  120196. /**
  120197. * Callback called when the task is successful
  120198. */
  120199. onSuccess: (task: MeshAssetTask) => void;
  120200. /**
  120201. * Callback called when the task is successful
  120202. */
  120203. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  120204. /**
  120205. * Creates a new MeshAssetTask
  120206. * @param name defines the name of the task
  120207. * @param meshesNames defines the list of mesh's names you want to load
  120208. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  120209. * @param sceneFilename defines the filename of the scene to load from
  120210. */
  120211. constructor(
  120212. /**
  120213. * Defines the name of the task
  120214. */
  120215. name: string,
  120216. /**
  120217. * Defines the list of mesh's names you want to load
  120218. */
  120219. meshesNames: any,
  120220. /**
  120221. * Defines the root url to use as a base to load your meshes and associated resources
  120222. */
  120223. rootUrl: string,
  120224. /**
  120225. * Defines the filename of the scene to load from
  120226. */
  120227. sceneFilename: string);
  120228. /**
  120229. * Execute the current task
  120230. * @param scene defines the scene where you want your assets to be loaded
  120231. * @param onSuccess is a callback called when the task is successfully executed
  120232. * @param onError is a callback called if an error occurs
  120233. */
  120234. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120235. }
  120236. /**
  120237. * Define a task used by AssetsManager to load text content
  120238. */
  120239. export class TextFileAssetTask extends AbstractAssetTask {
  120240. /**
  120241. * Defines the name of the task
  120242. */
  120243. name: string;
  120244. /**
  120245. * Defines the location of the file to load
  120246. */
  120247. url: string;
  120248. /**
  120249. * Gets the loaded text string
  120250. */
  120251. text: string;
  120252. /**
  120253. * Callback called when the task is successful
  120254. */
  120255. onSuccess: (task: TextFileAssetTask) => void;
  120256. /**
  120257. * Callback called when the task is successful
  120258. */
  120259. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  120260. /**
  120261. * Creates a new TextFileAssetTask object
  120262. * @param name defines the name of the task
  120263. * @param url defines the location of the file to load
  120264. */
  120265. constructor(
  120266. /**
  120267. * Defines the name of the task
  120268. */
  120269. name: string,
  120270. /**
  120271. * Defines the location of the file to load
  120272. */
  120273. url: string);
  120274. /**
  120275. * Execute the current task
  120276. * @param scene defines the scene where you want your assets to be loaded
  120277. * @param onSuccess is a callback called when the task is successfully executed
  120278. * @param onError is a callback called if an error occurs
  120279. */
  120280. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120281. }
  120282. /**
  120283. * Define a task used by AssetsManager to load binary data
  120284. */
  120285. export class BinaryFileAssetTask extends AbstractAssetTask {
  120286. /**
  120287. * Defines the name of the task
  120288. */
  120289. name: string;
  120290. /**
  120291. * Defines the location of the file to load
  120292. */
  120293. url: string;
  120294. /**
  120295. * Gets the lodaded data (as an array buffer)
  120296. */
  120297. data: ArrayBuffer;
  120298. /**
  120299. * Callback called when the task is successful
  120300. */
  120301. onSuccess: (task: BinaryFileAssetTask) => void;
  120302. /**
  120303. * Callback called when the task is successful
  120304. */
  120305. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  120306. /**
  120307. * Creates a new BinaryFileAssetTask object
  120308. * @param name defines the name of the new task
  120309. * @param url defines the location of the file to load
  120310. */
  120311. constructor(
  120312. /**
  120313. * Defines the name of the task
  120314. */
  120315. name: string,
  120316. /**
  120317. * Defines the location of the file to load
  120318. */
  120319. url: string);
  120320. /**
  120321. * Execute the current task
  120322. * @param scene defines the scene where you want your assets to be loaded
  120323. * @param onSuccess is a callback called when the task is successfully executed
  120324. * @param onError is a callback called if an error occurs
  120325. */
  120326. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120327. }
  120328. /**
  120329. * Define a task used by AssetsManager to load images
  120330. */
  120331. export class ImageAssetTask extends AbstractAssetTask {
  120332. /**
  120333. * Defines the name of the task
  120334. */
  120335. name: string;
  120336. /**
  120337. * Defines the location of the image to load
  120338. */
  120339. url: string;
  120340. /**
  120341. * Gets the loaded images
  120342. */
  120343. image: HTMLImageElement;
  120344. /**
  120345. * Callback called when the task is successful
  120346. */
  120347. onSuccess: (task: ImageAssetTask) => void;
  120348. /**
  120349. * Callback called when the task is successful
  120350. */
  120351. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  120352. /**
  120353. * Creates a new ImageAssetTask
  120354. * @param name defines the name of the task
  120355. * @param url defines the location of the image to load
  120356. */
  120357. constructor(
  120358. /**
  120359. * Defines the name of the task
  120360. */
  120361. name: string,
  120362. /**
  120363. * Defines the location of the image to load
  120364. */
  120365. url: string);
  120366. /**
  120367. * Execute the current task
  120368. * @param scene defines the scene where you want your assets to be loaded
  120369. * @param onSuccess is a callback called when the task is successfully executed
  120370. * @param onError is a callback called if an error occurs
  120371. */
  120372. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120373. }
  120374. /**
  120375. * Defines the interface used by texture loading tasks
  120376. */
  120377. export interface ITextureAssetTask<TEX extends BaseTexture> {
  120378. /**
  120379. * Gets the loaded texture
  120380. */
  120381. texture: TEX;
  120382. }
  120383. /**
  120384. * Define a task used by AssetsManager to load 2D textures
  120385. */
  120386. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  120387. /**
  120388. * Defines the name of the task
  120389. */
  120390. name: string;
  120391. /**
  120392. * Defines the location of the file to load
  120393. */
  120394. url: string;
  120395. /**
  120396. * Defines if mipmap should not be generated (default is false)
  120397. */
  120398. noMipmap?: boolean | undefined;
  120399. /**
  120400. * Defines if texture must be inverted on Y axis (default is false)
  120401. */
  120402. invertY?: boolean | undefined;
  120403. /**
  120404. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120405. */
  120406. samplingMode: number;
  120407. /**
  120408. * Gets the loaded texture
  120409. */
  120410. texture: Texture;
  120411. /**
  120412. * Callback called when the task is successful
  120413. */
  120414. onSuccess: (task: TextureAssetTask) => void;
  120415. /**
  120416. * Callback called when the task is successful
  120417. */
  120418. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  120419. /**
  120420. * Creates a new TextureAssetTask object
  120421. * @param name defines the name of the task
  120422. * @param url defines the location of the file to load
  120423. * @param noMipmap defines if mipmap should not be generated (default is false)
  120424. * @param invertY defines if texture must be inverted on Y axis (default is false)
  120425. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120426. */
  120427. constructor(
  120428. /**
  120429. * Defines the name of the task
  120430. */
  120431. name: string,
  120432. /**
  120433. * Defines the location of the file to load
  120434. */
  120435. url: string,
  120436. /**
  120437. * Defines if mipmap should not be generated (default is false)
  120438. */
  120439. noMipmap?: boolean | undefined,
  120440. /**
  120441. * Defines if texture must be inverted on Y axis (default is false)
  120442. */
  120443. invertY?: boolean | undefined,
  120444. /**
  120445. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120446. */
  120447. samplingMode?: number);
  120448. /**
  120449. * Execute the current task
  120450. * @param scene defines the scene where you want your assets to be loaded
  120451. * @param onSuccess is a callback called when the task is successfully executed
  120452. * @param onError is a callback called if an error occurs
  120453. */
  120454. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120455. }
  120456. /**
  120457. * Define a task used by AssetsManager to load cube textures
  120458. */
  120459. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  120460. /**
  120461. * Defines the name of the task
  120462. */
  120463. name: string;
  120464. /**
  120465. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120466. */
  120467. url: string;
  120468. /**
  120469. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120470. */
  120471. extensions?: string[] | undefined;
  120472. /**
  120473. * Defines if mipmaps should not be generated (default is false)
  120474. */
  120475. noMipmap?: boolean | undefined;
  120476. /**
  120477. * Defines the explicit list of files (undefined by default)
  120478. */
  120479. files?: string[] | undefined;
  120480. /**
  120481. * Gets the loaded texture
  120482. */
  120483. texture: CubeTexture;
  120484. /**
  120485. * Callback called when the task is successful
  120486. */
  120487. onSuccess: (task: CubeTextureAssetTask) => void;
  120488. /**
  120489. * Callback called when the task is successful
  120490. */
  120491. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  120492. /**
  120493. * Creates a new CubeTextureAssetTask
  120494. * @param name defines the name of the task
  120495. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120496. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120497. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120498. * @param files defines the explicit list of files (undefined by default)
  120499. */
  120500. constructor(
  120501. /**
  120502. * Defines the name of the task
  120503. */
  120504. name: string,
  120505. /**
  120506. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120507. */
  120508. url: string,
  120509. /**
  120510. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120511. */
  120512. extensions?: string[] | undefined,
  120513. /**
  120514. * Defines if mipmaps should not be generated (default is false)
  120515. */
  120516. noMipmap?: boolean | undefined,
  120517. /**
  120518. * Defines the explicit list of files (undefined by default)
  120519. */
  120520. files?: string[] | undefined);
  120521. /**
  120522. * Execute the current task
  120523. * @param scene defines the scene where you want your assets to be loaded
  120524. * @param onSuccess is a callback called when the task is successfully executed
  120525. * @param onError is a callback called if an error occurs
  120526. */
  120527. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120528. }
  120529. /**
  120530. * Define a task used by AssetsManager to load HDR cube textures
  120531. */
  120532. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  120533. /**
  120534. * Defines the name of the task
  120535. */
  120536. name: string;
  120537. /**
  120538. * Defines the location of the file to load
  120539. */
  120540. url: string;
  120541. /**
  120542. * Defines the desired size (the more it increases the longer the generation will be)
  120543. */
  120544. size: number;
  120545. /**
  120546. * Defines if mipmaps should not be generated (default is false)
  120547. */
  120548. noMipmap: boolean;
  120549. /**
  120550. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120551. */
  120552. generateHarmonics: boolean;
  120553. /**
  120554. * 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)
  120555. */
  120556. gammaSpace: boolean;
  120557. /**
  120558. * Internal Use Only
  120559. */
  120560. reserved: boolean;
  120561. /**
  120562. * Gets the loaded texture
  120563. */
  120564. texture: HDRCubeTexture;
  120565. /**
  120566. * Callback called when the task is successful
  120567. */
  120568. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  120569. /**
  120570. * Callback called when the task is successful
  120571. */
  120572. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  120573. /**
  120574. * Creates a new HDRCubeTextureAssetTask object
  120575. * @param name defines the name of the task
  120576. * @param url defines the location of the file to load
  120577. * @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.
  120578. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120579. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120580. * @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)
  120581. * @param reserved Internal use only
  120582. */
  120583. constructor(
  120584. /**
  120585. * Defines the name of the task
  120586. */
  120587. name: string,
  120588. /**
  120589. * Defines the location of the file to load
  120590. */
  120591. url: string,
  120592. /**
  120593. * Defines the desired size (the more it increases the longer the generation will be)
  120594. */
  120595. size: number,
  120596. /**
  120597. * Defines if mipmaps should not be generated (default is false)
  120598. */
  120599. noMipmap?: boolean,
  120600. /**
  120601. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120602. */
  120603. generateHarmonics?: boolean,
  120604. /**
  120605. * 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)
  120606. */
  120607. gammaSpace?: boolean,
  120608. /**
  120609. * Internal Use Only
  120610. */
  120611. reserved?: boolean);
  120612. /**
  120613. * Execute the current task
  120614. * @param scene defines the scene where you want your assets to be loaded
  120615. * @param onSuccess is a callback called when the task is successfully executed
  120616. * @param onError is a callback called if an error occurs
  120617. */
  120618. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120619. }
  120620. /**
  120621. * Define a task used by AssetsManager to load Equirectangular cube textures
  120622. */
  120623. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  120624. /**
  120625. * Defines the name of the task
  120626. */
  120627. name: string;
  120628. /**
  120629. * Defines the location of the file to load
  120630. */
  120631. url: string;
  120632. /**
  120633. * Defines the desired size (the more it increases the longer the generation will be)
  120634. */
  120635. size: number;
  120636. /**
  120637. * Defines if mipmaps should not be generated (default is false)
  120638. */
  120639. noMipmap: boolean;
  120640. /**
  120641. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  120642. * but the standard material would require them in Gamma space) (default is true)
  120643. */
  120644. gammaSpace: boolean;
  120645. /**
  120646. * Gets the loaded texture
  120647. */
  120648. texture: EquiRectangularCubeTexture;
  120649. /**
  120650. * Callback called when the task is successful
  120651. */
  120652. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  120653. /**
  120654. * Callback called when the task is successful
  120655. */
  120656. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  120657. /**
  120658. * Creates a new EquiRectangularCubeTextureAssetTask object
  120659. * @param name defines the name of the task
  120660. * @param url defines the location of the file to load
  120661. * @param size defines the desired size (the more it increases the longer the generation will be)
  120662. * If the size is omitted this implies you are using a preprocessed cubemap.
  120663. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120664. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  120665. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  120666. * (default is true)
  120667. */
  120668. constructor(
  120669. /**
  120670. * Defines the name of the task
  120671. */
  120672. name: string,
  120673. /**
  120674. * Defines the location of the file to load
  120675. */
  120676. url: string,
  120677. /**
  120678. * Defines the desired size (the more it increases the longer the generation will be)
  120679. */
  120680. size: number,
  120681. /**
  120682. * Defines if mipmaps should not be generated (default is false)
  120683. */
  120684. noMipmap?: boolean,
  120685. /**
  120686. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  120687. * but the standard material would require them in Gamma space) (default is true)
  120688. */
  120689. gammaSpace?: boolean);
  120690. /**
  120691. * Execute the current task
  120692. * @param scene defines the scene where you want your assets to be loaded
  120693. * @param onSuccess is a callback called when the task is successfully executed
  120694. * @param onError is a callback called if an error occurs
  120695. */
  120696. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120697. }
  120698. /**
  120699. * This class can be used to easily import assets into a scene
  120700. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  120701. */
  120702. export class AssetsManager {
  120703. private _scene;
  120704. private _isLoading;
  120705. protected _tasks: AbstractAssetTask[];
  120706. protected _waitingTasksCount: number;
  120707. protected _totalTasksCount: number;
  120708. /**
  120709. * Callback called when all tasks are processed
  120710. */
  120711. onFinish: (tasks: AbstractAssetTask[]) => void;
  120712. /**
  120713. * Callback called when a task is successful
  120714. */
  120715. onTaskSuccess: (task: AbstractAssetTask) => void;
  120716. /**
  120717. * Callback called when a task had an error
  120718. */
  120719. onTaskError: (task: AbstractAssetTask) => void;
  120720. /**
  120721. * Callback called when a task is done (whatever the result is)
  120722. */
  120723. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  120724. /**
  120725. * Observable called when all tasks are processed
  120726. */
  120727. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  120728. /**
  120729. * Observable called when a task had an error
  120730. */
  120731. onTaskErrorObservable: Observable<AbstractAssetTask>;
  120732. /**
  120733. * Observable called when all tasks were executed
  120734. */
  120735. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  120736. /**
  120737. * Observable called when a task is done (whatever the result is)
  120738. */
  120739. onProgressObservable: Observable<IAssetsProgressEvent>;
  120740. /**
  120741. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  120742. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120743. */
  120744. useDefaultLoadingScreen: boolean;
  120745. /**
  120746. * Creates a new AssetsManager
  120747. * @param scene defines the scene to work on
  120748. */
  120749. constructor(scene: Scene);
  120750. /**
  120751. * Add a MeshAssetTask to the list of active tasks
  120752. * @param taskName defines the name of the new task
  120753. * @param meshesNames defines the name of meshes to load
  120754. * @param rootUrl defines the root url to use to locate files
  120755. * @param sceneFilename defines the filename of the scene file
  120756. * @returns a new MeshAssetTask object
  120757. */
  120758. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  120759. /**
  120760. * Add a TextFileAssetTask to the list of active tasks
  120761. * @param taskName defines the name of the new task
  120762. * @param url defines the url of the file to load
  120763. * @returns a new TextFileAssetTask object
  120764. */
  120765. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  120766. /**
  120767. * Add a BinaryFileAssetTask to the list of active tasks
  120768. * @param taskName defines the name of the new task
  120769. * @param url defines the url of the file to load
  120770. * @returns a new BinaryFileAssetTask object
  120771. */
  120772. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  120773. /**
  120774. * Add a ImageAssetTask to the list of active tasks
  120775. * @param taskName defines the name of the new task
  120776. * @param url defines the url of the file to load
  120777. * @returns a new ImageAssetTask object
  120778. */
  120779. addImageTask(taskName: string, url: string): ImageAssetTask;
  120780. /**
  120781. * Add a TextureAssetTask to the list of active tasks
  120782. * @param taskName defines the name of the new task
  120783. * @param url defines the url of the file to load
  120784. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120785. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  120786. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  120787. * @returns a new TextureAssetTask object
  120788. */
  120789. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  120790. /**
  120791. * Add a CubeTextureAssetTask to the list of active tasks
  120792. * @param taskName defines the name of the new task
  120793. * @param url defines the url of the file to load
  120794. * @param extensions defines the extension to use to load the cube map (can be null)
  120795. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120796. * @param files defines the list of files to load (can be null)
  120797. * @returns a new CubeTextureAssetTask object
  120798. */
  120799. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  120800. /**
  120801. *
  120802. * Add a HDRCubeTextureAssetTask to the list of active tasks
  120803. * @param taskName defines the name of the new task
  120804. * @param url defines the url of the file to load
  120805. * @param size defines the size you want for the cubemap (can be null)
  120806. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120807. * @param generateHarmonics defines if you want to automatically generate (true by default)
  120808. * @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)
  120809. * @param reserved Internal use only
  120810. * @returns a new HDRCubeTextureAssetTask object
  120811. */
  120812. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  120813. /**
  120814. *
  120815. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  120816. * @param taskName defines the name of the new task
  120817. * @param url defines the url of the file to load
  120818. * @param size defines the size you want for the cubemap (can be null)
  120819. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120820. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120821. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120822. * @returns a new EquiRectangularCubeTextureAssetTask object
  120823. */
  120824. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  120825. /**
  120826. * Remove a task from the assets manager.
  120827. * @param task the task to remove
  120828. */
  120829. removeTask(task: AbstractAssetTask): void;
  120830. private _decreaseWaitingTasksCount;
  120831. private _runTask;
  120832. /**
  120833. * Reset the AssetsManager and remove all tasks
  120834. * @return the current instance of the AssetsManager
  120835. */
  120836. reset(): AssetsManager;
  120837. /**
  120838. * Start the loading process
  120839. * @return the current instance of the AssetsManager
  120840. */
  120841. load(): AssetsManager;
  120842. /**
  120843. * Start the loading process as an async operation
  120844. * @return a promise returning the list of failed tasks
  120845. */
  120846. loadAsync(): Promise<void>;
  120847. }
  120848. }
  120849. declare module BABYLON {
  120850. /**
  120851. * Wrapper class for promise with external resolve and reject.
  120852. */
  120853. export class Deferred<T> {
  120854. /**
  120855. * The promise associated with this deferred object.
  120856. */
  120857. readonly promise: Promise<T>;
  120858. private _resolve;
  120859. private _reject;
  120860. /**
  120861. * The resolve method of the promise associated with this deferred object.
  120862. */
  120863. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  120864. /**
  120865. * The reject method of the promise associated with this deferred object.
  120866. */
  120867. readonly reject: (reason?: any) => void;
  120868. /**
  120869. * Constructor for this deferred object.
  120870. */
  120871. constructor();
  120872. }
  120873. }
  120874. declare module BABYLON {
  120875. /**
  120876. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  120877. */
  120878. export class MeshExploder {
  120879. private _centerMesh;
  120880. private _meshes;
  120881. private _meshesOrigins;
  120882. private _toCenterVectors;
  120883. private _scaledDirection;
  120884. private _newPosition;
  120885. private _centerPosition;
  120886. /**
  120887. * Explodes meshes from a center mesh.
  120888. * @param meshes The meshes to explode.
  120889. * @param centerMesh The mesh to be center of explosion.
  120890. */
  120891. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  120892. private _setCenterMesh;
  120893. /**
  120894. * Get class name
  120895. * @returns "MeshExploder"
  120896. */
  120897. getClassName(): string;
  120898. /**
  120899. * "Exploded meshes"
  120900. * @returns Array of meshes with the centerMesh at index 0.
  120901. */
  120902. getMeshes(): Array<Mesh>;
  120903. /**
  120904. * Explodes meshes giving a specific direction
  120905. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  120906. */
  120907. explode(direction?: number): void;
  120908. }
  120909. }
  120910. declare module BABYLON {
  120911. /**
  120912. * Class used to help managing file picking and drag'n'drop
  120913. */
  120914. export class FilesInput {
  120915. /**
  120916. * List of files ready to be loaded
  120917. */
  120918. static readonly FilesToLoad: {
  120919. [key: string]: File;
  120920. };
  120921. /**
  120922. * Callback called when a file is processed
  120923. */
  120924. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  120925. private _engine;
  120926. private _currentScene;
  120927. private _sceneLoadedCallback;
  120928. private _progressCallback;
  120929. private _additionalRenderLoopLogicCallback;
  120930. private _textureLoadingCallback;
  120931. private _startingProcessingFilesCallback;
  120932. private _onReloadCallback;
  120933. private _errorCallback;
  120934. private _elementToMonitor;
  120935. private _sceneFileToLoad;
  120936. private _filesToLoad;
  120937. /**
  120938. * Creates a new FilesInput
  120939. * @param engine defines the rendering engine
  120940. * @param scene defines the hosting scene
  120941. * @param sceneLoadedCallback callback called when scene is loaded
  120942. * @param progressCallback callback called to track progress
  120943. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  120944. * @param textureLoadingCallback callback called when a texture is loading
  120945. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  120946. * @param onReloadCallback callback called when a reload is requested
  120947. * @param errorCallback callback call if an error occurs
  120948. */
  120949. 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);
  120950. private _dragEnterHandler;
  120951. private _dragOverHandler;
  120952. private _dropHandler;
  120953. /**
  120954. * Calls this function to listen to drag'n'drop events on a specific DOM element
  120955. * @param elementToMonitor defines the DOM element to track
  120956. */
  120957. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  120958. /**
  120959. * Release all associated resources
  120960. */
  120961. dispose(): void;
  120962. private renderFunction;
  120963. private drag;
  120964. private drop;
  120965. private _traverseFolder;
  120966. private _processFiles;
  120967. /**
  120968. * Load files from a drop event
  120969. * @param event defines the drop event to use as source
  120970. */
  120971. loadFiles(event: any): void;
  120972. private _processReload;
  120973. /**
  120974. * Reload the current scene from the loaded files
  120975. */
  120976. reload(): void;
  120977. }
  120978. }
  120979. declare module BABYLON {
  120980. /**
  120981. * Defines the root class used to create scene optimization to use with SceneOptimizer
  120982. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120983. */
  120984. export class SceneOptimization {
  120985. /**
  120986. * Defines the priority of this optimization (0 by default which means first in the list)
  120987. */
  120988. priority: number;
  120989. /**
  120990. * Gets a string describing the action executed by the current optimization
  120991. * @returns description string
  120992. */
  120993. getDescription(): string;
  120994. /**
  120995. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120996. * @param scene defines the current scene where to apply this optimization
  120997. * @param optimizer defines the current optimizer
  120998. * @returns true if everything that can be done was applied
  120999. */
  121000. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121001. /**
  121002. * Creates the SceneOptimization object
  121003. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121004. * @param desc defines the description associated with the optimization
  121005. */
  121006. constructor(
  121007. /**
  121008. * Defines the priority of this optimization (0 by default which means first in the list)
  121009. */
  121010. priority?: number);
  121011. }
  121012. /**
  121013. * Defines an optimization used to reduce the size of render target textures
  121014. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121015. */
  121016. export class TextureOptimization extends SceneOptimization {
  121017. /**
  121018. * Defines the priority of this optimization (0 by default which means first in the list)
  121019. */
  121020. priority: number;
  121021. /**
  121022. * 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
  121023. */
  121024. maximumSize: number;
  121025. /**
  121026. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121027. */
  121028. step: number;
  121029. /**
  121030. * Gets a string describing the action executed by the current optimization
  121031. * @returns description string
  121032. */
  121033. getDescription(): string;
  121034. /**
  121035. * Creates the TextureOptimization object
  121036. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121037. * @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
  121038. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121039. */
  121040. constructor(
  121041. /**
  121042. * Defines the priority of this optimization (0 by default which means first in the list)
  121043. */
  121044. priority?: number,
  121045. /**
  121046. * 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
  121047. */
  121048. maximumSize?: number,
  121049. /**
  121050. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121051. */
  121052. step?: number);
  121053. /**
  121054. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121055. * @param scene defines the current scene where to apply this optimization
  121056. * @param optimizer defines the current optimizer
  121057. * @returns true if everything that can be done was applied
  121058. */
  121059. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121060. }
  121061. /**
  121062. * Defines an optimization used to increase or decrease the rendering resolution
  121063. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121064. */
  121065. export class HardwareScalingOptimization extends SceneOptimization {
  121066. /**
  121067. * Defines the priority of this optimization (0 by default which means first in the list)
  121068. */
  121069. priority: number;
  121070. /**
  121071. * Defines the maximum scale to use (2 by default)
  121072. */
  121073. maximumScale: number;
  121074. /**
  121075. * Defines the step to use between two passes (0.5 by default)
  121076. */
  121077. step: number;
  121078. private _currentScale;
  121079. private _directionOffset;
  121080. /**
  121081. * Gets a string describing the action executed by the current optimization
  121082. * @return description string
  121083. */
  121084. getDescription(): string;
  121085. /**
  121086. * Creates the HardwareScalingOptimization object
  121087. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121088. * @param maximumScale defines the maximum scale to use (2 by default)
  121089. * @param step defines the step to use between two passes (0.5 by default)
  121090. */
  121091. constructor(
  121092. /**
  121093. * Defines the priority of this optimization (0 by default which means first in the list)
  121094. */
  121095. priority?: number,
  121096. /**
  121097. * Defines the maximum scale to use (2 by default)
  121098. */
  121099. maximumScale?: number,
  121100. /**
  121101. * Defines the step to use between two passes (0.5 by default)
  121102. */
  121103. step?: number);
  121104. /**
  121105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121106. * @param scene defines the current scene where to apply this optimization
  121107. * @param optimizer defines the current optimizer
  121108. * @returns true if everything that can be done was applied
  121109. */
  121110. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121111. }
  121112. /**
  121113. * Defines an optimization used to remove shadows
  121114. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121115. */
  121116. export class ShadowsOptimization extends SceneOptimization {
  121117. /**
  121118. * Gets a string describing the action executed by the current optimization
  121119. * @return description string
  121120. */
  121121. getDescription(): string;
  121122. /**
  121123. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121124. * @param scene defines the current scene where to apply this optimization
  121125. * @param optimizer defines the current optimizer
  121126. * @returns true if everything that can be done was applied
  121127. */
  121128. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121129. }
  121130. /**
  121131. * Defines an optimization used to turn post-processes off
  121132. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121133. */
  121134. export class PostProcessesOptimization extends SceneOptimization {
  121135. /**
  121136. * Gets a string describing the action executed by the current optimization
  121137. * @return description string
  121138. */
  121139. getDescription(): string;
  121140. /**
  121141. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121142. * @param scene defines the current scene where to apply this optimization
  121143. * @param optimizer defines the current optimizer
  121144. * @returns true if everything that can be done was applied
  121145. */
  121146. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121147. }
  121148. /**
  121149. * Defines an optimization used to turn lens flares off
  121150. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121151. */
  121152. export class LensFlaresOptimization extends SceneOptimization {
  121153. /**
  121154. * Gets a string describing the action executed by the current optimization
  121155. * @return description string
  121156. */
  121157. getDescription(): string;
  121158. /**
  121159. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121160. * @param scene defines the current scene where to apply this optimization
  121161. * @param optimizer defines the current optimizer
  121162. * @returns true if everything that can be done was applied
  121163. */
  121164. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121165. }
  121166. /**
  121167. * Defines an optimization based on user defined callback.
  121168. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121169. */
  121170. export class CustomOptimization extends SceneOptimization {
  121171. /**
  121172. * Callback called to apply the custom optimization.
  121173. */
  121174. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  121175. /**
  121176. * Callback called to get custom description
  121177. */
  121178. onGetDescription: () => string;
  121179. /**
  121180. * Gets a string describing the action executed by the current optimization
  121181. * @returns description string
  121182. */
  121183. getDescription(): string;
  121184. /**
  121185. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121186. * @param scene defines the current scene where to apply this optimization
  121187. * @param optimizer defines the current optimizer
  121188. * @returns true if everything that can be done was applied
  121189. */
  121190. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121191. }
  121192. /**
  121193. * Defines an optimization used to turn particles off
  121194. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121195. */
  121196. export class ParticlesOptimization extends SceneOptimization {
  121197. /**
  121198. * Gets a string describing the action executed by the current optimization
  121199. * @return description string
  121200. */
  121201. getDescription(): string;
  121202. /**
  121203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121204. * @param scene defines the current scene where to apply this optimization
  121205. * @param optimizer defines the current optimizer
  121206. * @returns true if everything that can be done was applied
  121207. */
  121208. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121209. }
  121210. /**
  121211. * Defines an optimization used to turn render targets off
  121212. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121213. */
  121214. export class RenderTargetsOptimization extends SceneOptimization {
  121215. /**
  121216. * Gets a string describing the action executed by the current optimization
  121217. * @return description string
  121218. */
  121219. getDescription(): string;
  121220. /**
  121221. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121222. * @param scene defines the current scene where to apply this optimization
  121223. * @param optimizer defines the current optimizer
  121224. * @returns true if everything that can be done was applied
  121225. */
  121226. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121227. }
  121228. /**
  121229. * Defines an optimization used to merge meshes with compatible materials
  121230. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121231. */
  121232. export class MergeMeshesOptimization extends SceneOptimization {
  121233. private static _UpdateSelectionTree;
  121234. /**
  121235. * Gets or sets a boolean which defines if optimization octree has to be updated
  121236. */
  121237. /**
  121238. * Gets or sets a boolean which defines if optimization octree has to be updated
  121239. */
  121240. static UpdateSelectionTree: boolean;
  121241. /**
  121242. * Gets a string describing the action executed by the current optimization
  121243. * @return description string
  121244. */
  121245. getDescription(): string;
  121246. private _canBeMerged;
  121247. /**
  121248. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121249. * @param scene defines the current scene where to apply this optimization
  121250. * @param optimizer defines the current optimizer
  121251. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  121252. * @returns true if everything that can be done was applied
  121253. */
  121254. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  121255. }
  121256. /**
  121257. * Defines a list of options used by SceneOptimizer
  121258. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121259. */
  121260. export class SceneOptimizerOptions {
  121261. /**
  121262. * Defines the target frame rate to reach (60 by default)
  121263. */
  121264. targetFrameRate: number;
  121265. /**
  121266. * Defines the interval between two checkes (2000ms by default)
  121267. */
  121268. trackerDuration: number;
  121269. /**
  121270. * Gets the list of optimizations to apply
  121271. */
  121272. optimizations: SceneOptimization[];
  121273. /**
  121274. * Creates a new list of options used by SceneOptimizer
  121275. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  121276. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  121277. */
  121278. constructor(
  121279. /**
  121280. * Defines the target frame rate to reach (60 by default)
  121281. */
  121282. targetFrameRate?: number,
  121283. /**
  121284. * Defines the interval between two checkes (2000ms by default)
  121285. */
  121286. trackerDuration?: number);
  121287. /**
  121288. * Add a new optimization
  121289. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  121290. * @returns the current SceneOptimizerOptions
  121291. */
  121292. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  121293. /**
  121294. * Add a new custom optimization
  121295. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  121296. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  121297. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121298. * @returns the current SceneOptimizerOptions
  121299. */
  121300. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  121301. /**
  121302. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  121303. * @param targetFrameRate defines the target frame rate (60 by default)
  121304. * @returns a SceneOptimizerOptions object
  121305. */
  121306. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121307. /**
  121308. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  121309. * @param targetFrameRate defines the target frame rate (60 by default)
  121310. * @returns a SceneOptimizerOptions object
  121311. */
  121312. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121313. /**
  121314. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  121315. * @param targetFrameRate defines the target frame rate (60 by default)
  121316. * @returns a SceneOptimizerOptions object
  121317. */
  121318. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121319. }
  121320. /**
  121321. * Class used to run optimizations in order to reach a target frame rate
  121322. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121323. */
  121324. export class SceneOptimizer implements IDisposable {
  121325. private _isRunning;
  121326. private _options;
  121327. private _scene;
  121328. private _currentPriorityLevel;
  121329. private _targetFrameRate;
  121330. private _trackerDuration;
  121331. private _currentFrameRate;
  121332. private _sceneDisposeObserver;
  121333. private _improvementMode;
  121334. /**
  121335. * Defines an observable called when the optimizer reaches the target frame rate
  121336. */
  121337. onSuccessObservable: Observable<SceneOptimizer>;
  121338. /**
  121339. * Defines an observable called when the optimizer enables an optimization
  121340. */
  121341. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  121342. /**
  121343. * Defines an observable called when the optimizer is not able to reach the target frame rate
  121344. */
  121345. onFailureObservable: Observable<SceneOptimizer>;
  121346. /**
  121347. * Gets a boolean indicating if the optimizer is in improvement mode
  121348. */
  121349. readonly isInImprovementMode: boolean;
  121350. /**
  121351. * Gets the current priority level (0 at start)
  121352. */
  121353. readonly currentPriorityLevel: number;
  121354. /**
  121355. * Gets the current frame rate checked by the SceneOptimizer
  121356. */
  121357. readonly currentFrameRate: number;
  121358. /**
  121359. * Gets or sets the current target frame rate (60 by default)
  121360. */
  121361. /**
  121362. * Gets or sets the current target frame rate (60 by default)
  121363. */
  121364. targetFrameRate: number;
  121365. /**
  121366. * Gets or sets the current interval between two checks (every 2000ms by default)
  121367. */
  121368. /**
  121369. * Gets or sets the current interval between two checks (every 2000ms by default)
  121370. */
  121371. trackerDuration: number;
  121372. /**
  121373. * Gets the list of active optimizations
  121374. */
  121375. readonly optimizations: SceneOptimization[];
  121376. /**
  121377. * Creates a new SceneOptimizer
  121378. * @param scene defines the scene to work on
  121379. * @param options defines the options to use with the SceneOptimizer
  121380. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  121381. * @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)
  121382. */
  121383. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  121384. /**
  121385. * Stops the current optimizer
  121386. */
  121387. stop(): void;
  121388. /**
  121389. * Reset the optimizer to initial step (current priority level = 0)
  121390. */
  121391. reset(): void;
  121392. /**
  121393. * Start the optimizer. By default it will try to reach a specific framerate
  121394. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  121395. */
  121396. start(): void;
  121397. private _checkCurrentState;
  121398. /**
  121399. * Release all resources
  121400. */
  121401. dispose(): void;
  121402. /**
  121403. * Helper function to create a SceneOptimizer with one single line of code
  121404. * @param scene defines the scene to work on
  121405. * @param options defines the options to use with the SceneOptimizer
  121406. * @param onSuccess defines a callback to call on success
  121407. * @param onFailure defines a callback to call on failure
  121408. * @returns the new SceneOptimizer object
  121409. */
  121410. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  121411. }
  121412. }
  121413. declare module BABYLON {
  121414. /**
  121415. * Class used to serialize a scene into a string
  121416. */
  121417. export class SceneSerializer {
  121418. /**
  121419. * Clear cache used by a previous serialization
  121420. */
  121421. static ClearCache(): void;
  121422. /**
  121423. * Serialize a scene into a JSON compatible object
  121424. * @param scene defines the scene to serialize
  121425. * @returns a JSON compatible object
  121426. */
  121427. static Serialize(scene: Scene): any;
  121428. /**
  121429. * Serialize a mesh into a JSON compatible object
  121430. * @param toSerialize defines the mesh to serialize
  121431. * @param withParents defines if parents must be serialized as well
  121432. * @param withChildren defines if children must be serialized as well
  121433. * @returns a JSON compatible object
  121434. */
  121435. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  121436. }
  121437. }
  121438. declare module BABYLON {
  121439. /**
  121440. * Class used to host texture specific utilities
  121441. */
  121442. export class TextureTools {
  121443. /**
  121444. * Uses the GPU to create a copy texture rescaled at a given size
  121445. * @param texture Texture to copy from
  121446. * @param width defines the desired width
  121447. * @param height defines the desired height
  121448. * @param useBilinearMode defines if bilinear mode has to be used
  121449. * @return the generated texture
  121450. */
  121451. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  121452. }
  121453. }
  121454. declare module BABYLON {
  121455. /**
  121456. * This represents the different options available for the video capture.
  121457. */
  121458. export interface VideoRecorderOptions {
  121459. /** Defines the mime type of the video. */
  121460. mimeType: string;
  121461. /** Defines the FPS the video should be recorded at. */
  121462. fps: number;
  121463. /** Defines the chunk size for the recording data. */
  121464. recordChunckSize: number;
  121465. /** The audio tracks to attach to the recording. */
  121466. audioTracks?: MediaStreamTrack[];
  121467. }
  121468. /**
  121469. * This can help with recording videos from BabylonJS.
  121470. * This is based on the available WebRTC functionalities of the browser.
  121471. *
  121472. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  121473. */
  121474. export class VideoRecorder {
  121475. private static readonly _defaultOptions;
  121476. /**
  121477. * Returns whether or not the VideoRecorder is available in your browser.
  121478. * @param engine Defines the Babylon Engine.
  121479. * @returns true if supported otherwise false.
  121480. */
  121481. static IsSupported(engine: Engine): boolean;
  121482. private readonly _options;
  121483. private _canvas;
  121484. private _mediaRecorder;
  121485. private _recordedChunks;
  121486. private _fileName;
  121487. private _resolve;
  121488. private _reject;
  121489. /**
  121490. * True when a recording is already in progress.
  121491. */
  121492. readonly isRecording: boolean;
  121493. /**
  121494. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  121495. * @param engine Defines the BabylonJS Engine you wish to record.
  121496. * @param options Defines options that can be used to customize the capture.
  121497. */
  121498. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  121499. /**
  121500. * Stops the current recording before the default capture timeout passed in the startRecording function.
  121501. */
  121502. stopRecording(): void;
  121503. /**
  121504. * Starts recording the canvas for a max duration specified in parameters.
  121505. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  121506. * If null no automatic download will start and you can rely on the promise to get the data back.
  121507. * @param maxDuration Defines the maximum recording time in seconds.
  121508. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  121509. * @return A promise callback at the end of the recording with the video data in Blob.
  121510. */
  121511. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  121512. /**
  121513. * Releases internal resources used during the recording.
  121514. */
  121515. dispose(): void;
  121516. private _handleDataAvailable;
  121517. private _handleError;
  121518. private _handleStop;
  121519. }
  121520. }
  121521. declare module BABYLON {
  121522. /**
  121523. * Class containing a set of static utilities functions for screenshots
  121524. */
  121525. export class ScreenshotTools {
  121526. /**
  121527. * Captures a screenshot of the current rendering
  121528. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121529. * @param engine defines the rendering engine
  121530. * @param camera defines the source camera
  121531. * @param size This parameter can be set to a single number or to an object with the
  121532. * following (optional) properties: precision, width, height. If a single number is passed,
  121533. * it will be used for both width and height. If an object is passed, the screenshot size
  121534. * will be derived from the parameters. The precision property is a multiplier allowing
  121535. * rendering at a higher or lower resolution
  121536. * @param successCallback defines the callback receives a single parameter which contains the
  121537. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121538. * src parameter of an <img> to display it
  121539. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  121540. * Check your browser for supported MIME types
  121541. */
  121542. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  121543. /**
  121544. * Generates an image screenshot from the specified camera.
  121545. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121546. * @param engine The engine to use for rendering
  121547. * @param camera The camera to use for rendering
  121548. * @param size This parameter can be set to a single number or to an object with the
  121549. * following (optional) properties: precision, width, height. If a single number is passed,
  121550. * it will be used for both width and height. If an object is passed, the screenshot size
  121551. * will be derived from the parameters. The precision property is a multiplier allowing
  121552. * rendering at a higher or lower resolution
  121553. * @param successCallback The callback receives a single parameter which contains the
  121554. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121555. * src parameter of an <img> to display it
  121556. * @param mimeType The MIME type of the screenshot image (default: image/png).
  121557. * Check your browser for supported MIME types
  121558. * @param samples Texture samples (default: 1)
  121559. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  121560. * @param fileName A name for for the downloaded file.
  121561. */
  121562. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  121563. }
  121564. }
  121565. declare module BABYLON {
  121566. /**
  121567. * A cursor which tracks a point on a path
  121568. */
  121569. export class PathCursor {
  121570. private path;
  121571. /**
  121572. * Stores path cursor callbacks for when an onchange event is triggered
  121573. */
  121574. private _onchange;
  121575. /**
  121576. * The value of the path cursor
  121577. */
  121578. value: number;
  121579. /**
  121580. * The animation array of the path cursor
  121581. */
  121582. animations: Animation[];
  121583. /**
  121584. * Initializes the path cursor
  121585. * @param path The path to track
  121586. */
  121587. constructor(path: Path2);
  121588. /**
  121589. * Gets the cursor point on the path
  121590. * @returns A point on the path cursor at the cursor location
  121591. */
  121592. getPoint(): Vector3;
  121593. /**
  121594. * Moves the cursor ahead by the step amount
  121595. * @param step The amount to move the cursor forward
  121596. * @returns This path cursor
  121597. */
  121598. moveAhead(step?: number): PathCursor;
  121599. /**
  121600. * Moves the cursor behind by the step amount
  121601. * @param step The amount to move the cursor back
  121602. * @returns This path cursor
  121603. */
  121604. moveBack(step?: number): PathCursor;
  121605. /**
  121606. * Moves the cursor by the step amount
  121607. * If the step amount is greater than one, an exception is thrown
  121608. * @param step The amount to move the cursor
  121609. * @returns This path cursor
  121610. */
  121611. move(step: number): PathCursor;
  121612. /**
  121613. * Ensures that the value is limited between zero and one
  121614. * @returns This path cursor
  121615. */
  121616. private ensureLimits;
  121617. /**
  121618. * Runs onchange callbacks on change (used by the animation engine)
  121619. * @returns This path cursor
  121620. */
  121621. private raiseOnChange;
  121622. /**
  121623. * Executes a function on change
  121624. * @param f A path cursor onchange callback
  121625. * @returns This path cursor
  121626. */
  121627. onchange(f: (cursor: PathCursor) => void): PathCursor;
  121628. }
  121629. }
  121630. declare module BABYLON {
  121631. /** @hidden */
  121632. export var blurPixelShader: {
  121633. name: string;
  121634. shader: string;
  121635. };
  121636. }
  121637. declare module BABYLON {
  121638. /** @hidden */
  121639. export var bones300Declaration: {
  121640. name: string;
  121641. shader: string;
  121642. };
  121643. }
  121644. declare module BABYLON {
  121645. /** @hidden */
  121646. export var instances300Declaration: {
  121647. name: string;
  121648. shader: string;
  121649. };
  121650. }
  121651. declare module BABYLON {
  121652. /** @hidden */
  121653. export var pointCloudVertexDeclaration: {
  121654. name: string;
  121655. shader: string;
  121656. };
  121657. }
  121658. // Mixins
  121659. interface Window {
  121660. mozIndexedDB: IDBFactory;
  121661. webkitIndexedDB: IDBFactory;
  121662. msIndexedDB: IDBFactory;
  121663. webkitURL: typeof URL;
  121664. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  121665. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  121666. WebGLRenderingContext: WebGLRenderingContext;
  121667. MSGesture: MSGesture;
  121668. CANNON: any;
  121669. AudioContext: AudioContext;
  121670. webkitAudioContext: AudioContext;
  121671. PointerEvent: any;
  121672. Math: Math;
  121673. Uint8Array: Uint8ArrayConstructor;
  121674. Float32Array: Float32ArrayConstructor;
  121675. mozURL: typeof URL;
  121676. msURL: typeof URL;
  121677. VRFrameData: any; // WebVR, from specs 1.1
  121678. DracoDecoderModule: any;
  121679. setImmediate(handler: (...args: any[]) => void): number;
  121680. }
  121681. interface HTMLCanvasElement {
  121682. requestPointerLock(): void;
  121683. msRequestPointerLock?(): void;
  121684. mozRequestPointerLock?(): void;
  121685. webkitRequestPointerLock?(): void;
  121686. /** Track wether a record is in progress */
  121687. isRecording: boolean;
  121688. /** Capture Stream method defined by some browsers */
  121689. captureStream(fps?: number): MediaStream;
  121690. }
  121691. interface CanvasRenderingContext2D {
  121692. msImageSmoothingEnabled: boolean;
  121693. }
  121694. interface MouseEvent {
  121695. mozMovementX: number;
  121696. mozMovementY: number;
  121697. webkitMovementX: number;
  121698. webkitMovementY: number;
  121699. msMovementX: number;
  121700. msMovementY: number;
  121701. }
  121702. interface Navigator {
  121703. mozGetVRDevices: (any: any) => any;
  121704. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121705. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121706. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121707. webkitGetGamepads(): Gamepad[];
  121708. msGetGamepads(): Gamepad[];
  121709. webkitGamepads(): Gamepad[];
  121710. }
  121711. interface HTMLVideoElement {
  121712. mozSrcObject: any;
  121713. }
  121714. interface Math {
  121715. fround(x: number): number;
  121716. imul(a: number, b: number): number;
  121717. }
  121718. interface WebGLRenderingContext {
  121719. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  121720. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  121721. vertexAttribDivisor(index: number, divisor: number): void;
  121722. createVertexArray(): any;
  121723. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  121724. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  121725. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  121726. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  121727. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  121728. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  121729. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  121730. // Queries
  121731. createQuery(): WebGLQuery;
  121732. deleteQuery(query: WebGLQuery): void;
  121733. beginQuery(target: number, query: WebGLQuery): void;
  121734. endQuery(target: number): void;
  121735. getQueryParameter(query: WebGLQuery, pname: number): any;
  121736. getQuery(target: number, pname: number): any;
  121737. MAX_SAMPLES: number;
  121738. RGBA8: number;
  121739. READ_FRAMEBUFFER: number;
  121740. DRAW_FRAMEBUFFER: number;
  121741. UNIFORM_BUFFER: number;
  121742. HALF_FLOAT_OES: number;
  121743. RGBA16F: number;
  121744. RGBA32F: number;
  121745. R32F: number;
  121746. RG32F: number;
  121747. RGB32F: number;
  121748. R16F: number;
  121749. RG16F: number;
  121750. RGB16F: number;
  121751. RED: number;
  121752. RG: number;
  121753. R8: number;
  121754. RG8: number;
  121755. UNSIGNED_INT_24_8: number;
  121756. DEPTH24_STENCIL8: number;
  121757. /* Multiple Render Targets */
  121758. drawBuffers(buffers: number[]): void;
  121759. readBuffer(src: number): void;
  121760. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  121761. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  121762. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  121763. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  121764. // Occlusion Query
  121765. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  121766. ANY_SAMPLES_PASSED: number;
  121767. QUERY_RESULT_AVAILABLE: number;
  121768. QUERY_RESULT: number;
  121769. }
  121770. interface WebGLProgram {
  121771. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  121772. }
  121773. interface EXT_disjoint_timer_query {
  121774. QUERY_COUNTER_BITS_EXT: number;
  121775. TIME_ELAPSED_EXT: number;
  121776. TIMESTAMP_EXT: number;
  121777. GPU_DISJOINT_EXT: number;
  121778. QUERY_RESULT_EXT: number;
  121779. QUERY_RESULT_AVAILABLE_EXT: number;
  121780. queryCounterEXT(query: WebGLQuery, target: number): void;
  121781. createQueryEXT(): WebGLQuery;
  121782. beginQueryEXT(target: number, query: WebGLQuery): void;
  121783. endQueryEXT(target: number): void;
  121784. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  121785. deleteQueryEXT(query: WebGLQuery): void;
  121786. }
  121787. interface WebGLUniformLocation {
  121788. _currentState: any;
  121789. }
  121790. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  121791. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  121792. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  121793. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  121794. interface WebGLRenderingContext {
  121795. readonly RASTERIZER_DISCARD: number;
  121796. readonly DEPTH_COMPONENT24: number;
  121797. readonly TEXTURE_3D: number;
  121798. readonly TEXTURE_2D_ARRAY: number;
  121799. readonly TEXTURE_COMPARE_FUNC: number;
  121800. readonly TEXTURE_COMPARE_MODE: number;
  121801. readonly COMPARE_REF_TO_TEXTURE: number;
  121802. readonly TEXTURE_WRAP_R: number;
  121803. readonly HALF_FLOAT: number;
  121804. readonly RGB8: number;
  121805. readonly RED_INTEGER: number;
  121806. readonly RG_INTEGER: number;
  121807. readonly RGB_INTEGER: number;
  121808. readonly RGBA_INTEGER: number;
  121809. readonly R8_SNORM: number;
  121810. readonly RG8_SNORM: number;
  121811. readonly RGB8_SNORM: number;
  121812. readonly RGBA8_SNORM: number;
  121813. readonly R8I: number;
  121814. readonly RG8I: number;
  121815. readonly RGB8I: number;
  121816. readonly RGBA8I: number;
  121817. readonly R8UI: number;
  121818. readonly RG8UI: number;
  121819. readonly RGB8UI: number;
  121820. readonly RGBA8UI: number;
  121821. readonly R16I: number;
  121822. readonly RG16I: number;
  121823. readonly RGB16I: number;
  121824. readonly RGBA16I: number;
  121825. readonly R16UI: number;
  121826. readonly RG16UI: number;
  121827. readonly RGB16UI: number;
  121828. readonly RGBA16UI: number;
  121829. readonly R32I: number;
  121830. readonly RG32I: number;
  121831. readonly RGB32I: number;
  121832. readonly RGBA32I: number;
  121833. readonly R32UI: number;
  121834. readonly RG32UI: number;
  121835. readonly RGB32UI: number;
  121836. readonly RGBA32UI: number;
  121837. readonly RGB10_A2UI: number;
  121838. readonly R11F_G11F_B10F: number;
  121839. readonly RGB9_E5: number;
  121840. readonly RGB10_A2: number;
  121841. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  121842. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  121843. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  121844. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121845. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  121846. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  121847. 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;
  121848. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  121849. readonly TRANSFORM_FEEDBACK: number;
  121850. readonly INTERLEAVED_ATTRIBS: number;
  121851. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  121852. createTransformFeedback(): WebGLTransformFeedback;
  121853. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  121854. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  121855. beginTransformFeedback(primitiveMode: number): void;
  121856. endTransformFeedback(): void;
  121857. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  121858. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121859. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121860. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121861. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  121862. }
  121863. interface ImageBitmap {
  121864. readonly width: number;
  121865. readonly height: number;
  121866. close(): void;
  121867. }
  121868. interface WebGLQuery extends WebGLObject {
  121869. }
  121870. declare var WebGLQuery: {
  121871. prototype: WebGLQuery;
  121872. new(): WebGLQuery;
  121873. };
  121874. interface WebGLSampler extends WebGLObject {
  121875. }
  121876. declare var WebGLSampler: {
  121877. prototype: WebGLSampler;
  121878. new(): WebGLSampler;
  121879. };
  121880. interface WebGLSync extends WebGLObject {
  121881. }
  121882. declare var WebGLSync: {
  121883. prototype: WebGLSync;
  121884. new(): WebGLSync;
  121885. };
  121886. interface WebGLTransformFeedback extends WebGLObject {
  121887. }
  121888. declare var WebGLTransformFeedback: {
  121889. prototype: WebGLTransformFeedback;
  121890. new(): WebGLTransformFeedback;
  121891. };
  121892. interface WebGLVertexArrayObject extends WebGLObject {
  121893. }
  121894. declare var WebGLVertexArrayObject: {
  121895. prototype: WebGLVertexArrayObject;
  121896. new(): WebGLVertexArrayObject;
  121897. };
  121898. // Type definitions for WebVR API
  121899. // Project: https://w3c.github.io/webvr/
  121900. // Definitions by: six a <https://github.com/lostfictions>
  121901. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  121902. interface VRDisplay extends EventTarget {
  121903. /**
  121904. * Dictionary of capabilities describing the VRDisplay.
  121905. */
  121906. readonly capabilities: VRDisplayCapabilities;
  121907. /**
  121908. * z-depth defining the far plane of the eye view frustum
  121909. * enables mapping of values in the render target depth
  121910. * attachment to scene coordinates. Initially set to 10000.0.
  121911. */
  121912. depthFar: number;
  121913. /**
  121914. * z-depth defining the near plane of the eye view frustum
  121915. * enables mapping of values in the render target depth
  121916. * attachment to scene coordinates. Initially set to 0.01.
  121917. */
  121918. depthNear: number;
  121919. /**
  121920. * An identifier for this distinct VRDisplay. Used as an
  121921. * association point in the Gamepad API.
  121922. */
  121923. readonly displayId: number;
  121924. /**
  121925. * A display name, a user-readable name identifying it.
  121926. */
  121927. readonly displayName: string;
  121928. readonly isConnected: boolean;
  121929. readonly isPresenting: boolean;
  121930. /**
  121931. * If this VRDisplay supports room-scale experiences, the optional
  121932. * stage attribute contains details on the room-scale parameters.
  121933. */
  121934. readonly stageParameters: VRStageParameters | null;
  121935. /**
  121936. * Passing the value returned by `requestAnimationFrame` to
  121937. * `cancelAnimationFrame` will unregister the callback.
  121938. * @param handle Define the hanle of the request to cancel
  121939. */
  121940. cancelAnimationFrame(handle: number): void;
  121941. /**
  121942. * Stops presenting to the VRDisplay.
  121943. * @returns a promise to know when it stopped
  121944. */
  121945. exitPresent(): Promise<void>;
  121946. /**
  121947. * Return the current VREyeParameters for the given eye.
  121948. * @param whichEye Define the eye we want the parameter for
  121949. * @returns the eye parameters
  121950. */
  121951. getEyeParameters(whichEye: string): VREyeParameters;
  121952. /**
  121953. * Populates the passed VRFrameData with the information required to render
  121954. * the current frame.
  121955. * @param frameData Define the data structure to populate
  121956. * @returns true if ok otherwise false
  121957. */
  121958. getFrameData(frameData: VRFrameData): boolean;
  121959. /**
  121960. * Get the layers currently being presented.
  121961. * @returns the list of VR layers
  121962. */
  121963. getLayers(): VRLayer[];
  121964. /**
  121965. * Return a VRPose containing the future predicted pose of the VRDisplay
  121966. * when the current frame will be presented. The value returned will not
  121967. * change until JavaScript has returned control to the browser.
  121968. *
  121969. * The VRPose will contain the position, orientation, velocity,
  121970. * and acceleration of each of these properties.
  121971. * @returns the pose object
  121972. */
  121973. getPose(): VRPose;
  121974. /**
  121975. * Return the current instantaneous pose of the VRDisplay, with no
  121976. * prediction applied.
  121977. * @returns the current instantaneous pose
  121978. */
  121979. getImmediatePose(): VRPose;
  121980. /**
  121981. * The callback passed to `requestAnimationFrame` will be called
  121982. * any time a new frame should be rendered. When the VRDisplay is
  121983. * presenting the callback will be called at the native refresh
  121984. * rate of the HMD. When not presenting this function acts
  121985. * identically to how window.requestAnimationFrame acts. Content should
  121986. * make no assumptions of frame rate or vsync behavior as the HMD runs
  121987. * asynchronously from other displays and at differing refresh rates.
  121988. * @param callback Define the eaction to run next frame
  121989. * @returns the request handle it
  121990. */
  121991. requestAnimationFrame(callback: FrameRequestCallback): number;
  121992. /**
  121993. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  121994. * Repeat calls while already presenting will update the VRLayers being displayed.
  121995. * @param layers Define the list of layer to present
  121996. * @returns a promise to know when the request has been fulfilled
  121997. */
  121998. requestPresent(layers: VRLayer[]): Promise<void>;
  121999. /**
  122000. * Reset the pose for this display, treating its current position and
  122001. * orientation as the "origin/zero" values. VRPose.position,
  122002. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  122003. * updated when calling resetPose(). This should be called in only
  122004. * sitting-space experiences.
  122005. */
  122006. resetPose(): void;
  122007. /**
  122008. * The VRLayer provided to the VRDisplay will be captured and presented
  122009. * in the HMD. Calling this function has the same effect on the source
  122010. * canvas as any other operation that uses its source image, and canvases
  122011. * created without preserveDrawingBuffer set to true will be cleared.
  122012. * @param pose Define the pose to submit
  122013. */
  122014. submitFrame(pose?: VRPose): void;
  122015. }
  122016. declare var VRDisplay: {
  122017. prototype: VRDisplay;
  122018. new(): VRDisplay;
  122019. };
  122020. interface VRLayer {
  122021. leftBounds?: number[] | Float32Array | null;
  122022. rightBounds?: number[] | Float32Array | null;
  122023. source?: HTMLCanvasElement | null;
  122024. }
  122025. interface VRDisplayCapabilities {
  122026. readonly canPresent: boolean;
  122027. readonly hasExternalDisplay: boolean;
  122028. readonly hasOrientation: boolean;
  122029. readonly hasPosition: boolean;
  122030. readonly maxLayers: number;
  122031. }
  122032. interface VREyeParameters {
  122033. /** @deprecated */
  122034. readonly fieldOfView: VRFieldOfView;
  122035. readonly offset: Float32Array;
  122036. readonly renderHeight: number;
  122037. readonly renderWidth: number;
  122038. }
  122039. interface VRFieldOfView {
  122040. readonly downDegrees: number;
  122041. readonly leftDegrees: number;
  122042. readonly rightDegrees: number;
  122043. readonly upDegrees: number;
  122044. }
  122045. interface VRFrameData {
  122046. readonly leftProjectionMatrix: Float32Array;
  122047. readonly leftViewMatrix: Float32Array;
  122048. readonly pose: VRPose;
  122049. readonly rightProjectionMatrix: Float32Array;
  122050. readonly rightViewMatrix: Float32Array;
  122051. readonly timestamp: number;
  122052. }
  122053. interface VRPose {
  122054. readonly angularAcceleration: Float32Array | null;
  122055. readonly angularVelocity: Float32Array | null;
  122056. readonly linearAcceleration: Float32Array | null;
  122057. readonly linearVelocity: Float32Array | null;
  122058. readonly orientation: Float32Array | null;
  122059. readonly position: Float32Array | null;
  122060. readonly timestamp: number;
  122061. }
  122062. interface VRStageParameters {
  122063. sittingToStandingTransform?: Float32Array;
  122064. sizeX?: number;
  122065. sizeY?: number;
  122066. }
  122067. interface Navigator {
  122068. getVRDisplays(): Promise<VRDisplay[]>;
  122069. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  122070. }
  122071. interface Window {
  122072. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  122073. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  122074. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  122075. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122076. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122077. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  122078. }
  122079. interface Gamepad {
  122080. readonly displayId: number;
  122081. }
  122082. interface XRDevice {
  122083. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  122084. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  122085. }
  122086. interface XRSession {
  122087. getInputSources(): Array<any>;
  122088. baseLayer: XRWebGLLayer;
  122089. requestFrameOfReference(type: string): Promise<void>;
  122090. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  122091. end(): Promise<void>;
  122092. requestAnimationFrame: Function;
  122093. addEventListener: Function;
  122094. }
  122095. interface XRSessionCreationOptions {
  122096. outputContext?: WebGLRenderingContext | null;
  122097. immersive?: boolean;
  122098. environmentIntegration?: boolean;
  122099. }
  122100. interface XRLayer {
  122101. getViewport: Function;
  122102. framebufferWidth: number;
  122103. framebufferHeight: number;
  122104. }
  122105. interface XRView {
  122106. projectionMatrix: Float32Array;
  122107. }
  122108. interface XRFrame {
  122109. getDevicePose: Function;
  122110. getInputPose: Function;
  122111. views: Array<XRView>;
  122112. baseLayer: XRLayer;
  122113. }
  122114. interface XRFrameOfReference {
  122115. }
  122116. interface XRWebGLLayer extends XRLayer {
  122117. framebuffer: WebGLFramebuffer;
  122118. }
  122119. declare var XRWebGLLayer: {
  122120. prototype: XRWebGLLayer;
  122121. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  122122. };